/**
 * 手机独立布局（html.mobile-layout）
 * 舞台 = 真机横屏像素、scale=1，不再沿用 PC 1280×720 缩小放大。
 * 目标：矮屏横持（约 844×390）可读可点，侧栏默认收起，行动区占底栏。
 */

html.mobile-layout {
  /* 可点但不臃肿：矮屏横持优先省高度 */
  --m-tap: 36px;
  --m-tap-sm: 32px;
  --m-gap: 0.3rem;
  --m-radius: 0.5rem;
  --m-font: 13px;
  --m-font-sm: 12px;
  --m-topbar-h: 40px;
  /* 底栏预算：旁观收小；轮到自己时由 my-turn 抬高 */
  --m-action-h: 152px;
  --m-hole-w: 2.45rem;
  --m-hole-h: 3.4rem;
  --m-hole-w-turn: clamp(2.95rem, 8.4vh, 3.8rem);
  --m-hole-h-turn: clamp(4.1rem, 11.6vh, 5.3rem);
}

html.mobile-layout #stage {
  /* 宽高由 JS 写成视口像素；这里只覆盖 PC 画布变量 */
  font-size: clamp(13px, 3.6vh, 16px);
  --topbar-h: var(--m-topbar-h);
  --action-h: var(--m-action-h);
  --card-w: clamp(2.6rem, 7.2vh, 3.4rem);
  --card-h: clamp(3.6rem, 10vh, 4.8rem);
  --hole-card-w: clamp(2.8rem, 8vh, 3.6rem);
  --hole-card-h: clamp(3.9rem, 11vh, 5rem);
  --seat-w: clamp(4.4rem, 12vh, 5.6rem);
  --seat-card-w: clamp(1.55rem, 4.8vh, 2rem);
  --seat-card-h: clamp(2.15rem, 6.6vh, 2.8rem);
  --side-gap: 0.25rem;
}

/* ========== 大厅 ========== */
html.mobile-layout #lobby {
  padding: 0.45rem 0.65rem 0.55rem;
  place-items: stretch;
}
html.mobile-layout .lobby-shell {
  width: 100%;
  max-width: none;
  gap: 0.5rem;
}
html.mobile-layout .lobby-hero {
  padding: 0.25rem 0.2rem 0;
  text-align: left;
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}
html.mobile-layout .brand {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
}
html.mobile-layout .lobby-tagline {
  font-size: var(--m-font-sm);
  margin: 0;
  opacity: 0.75;
}
html.mobile-layout .lobby-toolbar {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.45rem;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.2rem 0;
  background: linear-gradient(180deg, #16130f 70%, transparent);
}
html.mobile-layout .lobby-toolbar .btn {
  min-height: var(--m-tap);
  font-size: var(--m-font);
  padding: 0.4rem 0.35rem;
  width: 100%;
}
html.mobile-layout .room-list-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
html.mobile-layout .room-list {
  gap: 0.55rem;
  padding-bottom: 0.5rem;
}
html.mobile-layout .room-card,
html.mobile-layout .event-card {
  padding: 0.7rem 0.75rem;
  border-radius: var(--m-radius);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: center;
}
html.mobile-layout .room-card .btn,
html.mobile-layout .event-card .btn,
html.mobile-layout .room-actions .btn {
  min-height: var(--m-tap);
  min-width: 5.5rem;
  font-size: var(--m-font);
  padding: 0.55rem 0.85rem;
}
html.mobile-layout #lanHint {
  font-size: 0.72rem;
  opacity: 0.55;
}

/* ========== 顶栏：只留关键操作 ========== */
html.mobile-layout .topbar {
  height: auto;
  min-height: var(--m-topbar-h);
  padding: 0.3rem 0.45rem;
  gap: 0.3rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
html.mobile-layout .topbar::-webkit-scrollbar {
  display: none;
}
html.mobile-layout .topbar .btn,
html.mobile-layout .topbar .chip-badge-btn,
html.mobile-layout .topbar .auto-host-btn {
  min-height: var(--m-tap-sm);
  padding: 0.4rem 0.65rem;
  font-size: var(--m-font-sm);
  flex-shrink: 0;
}
html.mobile-layout .topbar .mode-badge,
html.mobile-layout .topbar .blind-badge,
html.mobile-layout .topbar .rise-badge,
html.mobile-layout .topbar .host-badge,
html.mobile-layout .topbar .god-badge,
html.mobile-layout .topbar .ledger-btn,
html.mobile-layout .topbar .prev-hand-btn {
  display: none !important;
}
html.mobile-layout .topbar .status {
  flex: 1;
  min-width: 4rem;
  font-size: var(--m-font-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.mobile-layout .topbar .room-badge {
  font-size: var(--m-font-sm);
  flex-shrink: 0;
}

/* ========== 侧栏：默认收起，不占桌面 ========== */
html.mobile-layout .hand-ranks-panel {
  display: none !important;
}
html.mobile-layout .chat-log-panel {
  max-width: min(42vw, 14rem);
  font-size: var(--m-font-sm);
}
html.mobile-layout .chat-log-panel.collapsed {
  width: auto;
}
html.mobile-layout .roster-panel {
  max-width: min(62vw, 18.5rem);
  /* 操作台浮层后，侧栏可用接近全高 */
  max-height: calc(100% - var(--m-topbar-h) - 0.6rem);
}
html.mobile-layout .roster-body {
  width: min(16.5rem, 58vw);
  min-width: 13.5rem;
  max-width: min(18.5rem, 62vw);
}
html.mobile-layout .roster-cols,
html.mobile-layout .roster-row {
  grid-template-columns: minmax(0, 1fr) 3.2rem 3.2rem;
  gap: 0.2rem 0.35rem;
}
html.mobile-layout .roster-panel.is-ranking .roster-cols,
html.mobile-layout .roster-panel.is-ranking .roster-row.is-rank-row {
  grid-template-columns: 1.6rem minmax(0, 1fr) 3.4rem;
}
html.mobile-layout .roster-name {
  overflow: hidden;
  font-size: 12px;
}
html.mobile-layout .roster-name-text {
  font-size: 12px;
}
html.mobile-layout .roster-chips,
html.mobile-layout .roster-profit {
  font-size: 12px;
}
html.mobile-layout .my-ledger-panel {
  max-width: min(48vw, 15rem);
}

/* ========== 牌桌台面：手机跑道形 ==========
 * 图层对齐 PC（低→高）：
 *   台面装饰(0) < 底池筹码(3) < 座位(5) < 公共牌(8) < 台面HUD(11) < 行动特效(16) < 底栏(30)
 * 关键：座位贴上下边，中间留空给公共牌，禁止几何重叠后再靠 z-index 互盖
 */
html.mobile-layout #table {
  /* 操作台改为浮层，不再用大 --action-h 去压缩台面 */
  --action-h: 48px;
  --card-w: clamp(2.2rem, 6.2vh, 2.9rem);
  --card-h: clamp(3.05rem, 8.6vh, 4rem);
}
html.mobile-layout .felt {
  padding: 0.2rem 0.45rem;
  /* 不给操作台预留高度：台面铺满，操作台绝对浮在上方 */
  padding-bottom: max(0.25rem, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  place-items: center;
}
html.mobile-layout #stage .felt-inner {
  width: 97% !important;
  height: 96% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-height: 0;
  aspect-ratio: auto;
}
html.mobile-layout #stage .felt-surface {
  inset: 1.2% 1.6%;
  border-radius: clamp(1.8rem, 10vh, 3.6rem);
  background:
    radial-gradient(ellipse 72% 58% at 50% 42%, #2a8a56 0%, var(--felt) 52%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 0 0 0.34rem var(--felt-rim),
    inset 0 0 0 0.52rem #5c3a1a,
    0 0.45rem 1.2rem rgba(0, 0, 0, 0.48);
  z-index: 0;
}
html.mobile-layout .seats {
  z-index: 5; /* 与 PC 一致 */
}
html.mobile-layout .pot-chips {
  z-index: 3;
  top: 38%;
}
html.mobile-layout .chip-legend {
  z-index: 2;
  bottom: 1.5%;
}
html.mobile-layout .table-hud {
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  width: min(22rem, 54%);
  max-height: 18%;
  gap: 0.08rem;
  z-index: 11; /* 与 PC 同级：高于公共牌文字信息，不盖座位框 */
  pointer-events: none;
}
/* 轮到自己操作：HUD/公共牌上移，给加注条+手牌腾空 */
html.mobile-layout:has(.action-bar.is-acting) .table-hud,
html.mobile-layout:has(.action-bar.my-turn-pulse) .table-hud {
  top: 14%;
  max-height: 14%;
}
html.mobile-layout:has(.action-bar.is-acting) .board,
html.mobile-layout:has(.action-bar.my-turn-pulse) .board {
  top: 34%;
}
html.mobile-layout:has(.action-bar.is-acting) .pot-chips,
html.mobile-layout:has(.action-bar.my-turn-pulse) .pot-chips {
  top: 26%;
}
html.mobile-layout .turn-broadcast {
  font-size: 11px;
  padding: 0.1rem 0.45rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.mobile-layout .pot-row {
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}
html.mobile-layout .pot-display,
html.mobile-layout .pot {
  font-size: clamp(0.78rem, 2.8vh, 0.95rem);
}
html.mobile-layout .to-call-banner {
  font-size: 11px;
  padding: 0.12rem 0.4rem;
}
html.mobile-layout .board {
  /* 与 PC 相同层级关系：居中、高于筹码、低于 HUD 播报区冲突时以几何分离为准 */
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 8;
  width: max-content;
  max-width: 70%;
  justify-content: center;
  gap: clamp(0.15rem, 0.6vh, 0.35rem);
  pointer-events: none;
}
html.mobile-layout .seat {
  width: auto;
  min-width: clamp(4.4rem, 12vw, 5.8rem);
  max-width: clamp(5.6rem, 15vw, 7.2rem);
  z-index: 3;
}
html.mobile-layout .seat.occupied {
  z-index: 4;
}
html.mobile-layout .seat-card {
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.22rem 0.32rem 0.24rem;
  border-radius: 0.45rem;
}
html.mobile-layout .seat-name {
  font-size: clamp(12px, 3.2vh, 14px);
  line-height: 1.2;
  font-weight: 800;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0;
}
html.mobile-layout .seat-row {
  margin-top: 0.08rem;
  gap: 0.28rem;
  font-size: clamp(11px, 2.8vh, 13px);
}
html.mobile-layout .seat-row .chip-stack {
  font-size: 1em;
}
html.mobile-layout .seat-profit {
  font-size: 0.95em;
}
html.mobile-layout .seat-badges {
  margin-top: 0.1rem;
  gap: 0.14rem;
  justify-content: center;
}
html.mobile-layout .seat-badges .badge {
  font-size: 10px;
  padding: 0.08rem 0.28rem;
  line-height: 1.15;
}
html.mobile-layout .seat-card.empty-seat {
  min-height: 2.2rem;
  font-size: 0.72rem;
  padding: 0.28rem 0.28rem;
}
html.mobile-layout .empty-title {
  font-size: 0.75rem;
}
html.mobile-layout .empty-hint {
  font-size: 0.62rem;
  opacity: 0.75;
}
/* 座位状态层级：与 PC 同思路，不把公共牌抬到盖住人名 */
html.mobile-layout .felt-inner.seat-layout-rect .seat.acting {
  z-index: 7;
}
html.mobile-layout .felt-inner.seat-layout-rect .seat.has-bubble {
  z-index: 10;
}
html.mobile-layout .felt-inner.seat-layout-rect .seat.you-bet-only {
  z-index: 6;
}
html.mobile-layout .felt-inner.seat-layout-rect .seat .seat-cards {
  margin-top: 0.14rem;
  gap: 0.18rem;
  justify-content: center;
}
html.mobile-layout .felt-inner.seat-layout-rect .seat .seat-cards .card {
  width: clamp(1.45rem, 4.4vh, 1.95rem);
  height: clamp(2rem, 6.1vh, 2.7rem);
  font-size: 0.62rem;
}
/* 「行动中」独占顶条，给名字让位，不再压在姓名上 */
html.mobile-layout .felt-inner.seat-layout-rect .seat.acting .seat-card {
  overflow: visible;
  padding-top: 1.05rem;
}
html.mobile-layout .felt-inner.seat-layout-rect .seat.acting .seat-card::before {
  top: 0.14rem;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  font-size: 0.58rem;
  padding: 0.06rem 0.4rem;
  letter-spacing: 0.04em;
  z-index: 2;
  max-width: calc(100% - 0.3rem);
  box-sizing: border-box;
}
/* 手机矩形桌不再沿用 PC crowded 的过小座位宽 */
html.mobile-layout .felt-inner.seat-layout-rect.crowded {
  --seat-w: clamp(4.6rem, 13vw, 6.4rem);
  --seat-card-w: clamp(1.45rem, 4.4vh, 1.95rem);
  --seat-card-h: clamp(2rem, 6.1vh, 2.7rem);
}
html.mobile-layout .felt-inner.seat-layout-rect.crowded .seat-name {
  font-size: clamp(12px, 3.2vh, 14px);
}
/* 账单默认收起，避免盖住台面 */
html.mobile-layout .my-ledger-panel:not(.collapsed) {
  max-width: min(52vw, 16rem);
  max-height: 55%;
}
html.mobile-layout .my-ledger-panel.collapsed {
  opacity: 0.92;
}

/* ========== 行动底栏：纵向堆叠；手牌旁观收小 / 轮到放大 ========== */
html.mobile-layout .action-bar {
  /* 浮层操作台：不占文档流、不压缩台面 */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  gap: 0.28rem;
  padding: 0.1rem 0.35rem calc(0.16rem + env(safe-area-inset-bottom, 0px));
  max-height: min(42%, 190px);
  min-height: 0 !important; /* 覆盖 PC 的 min-height: var(--action-h) */
  height: auto;
  background: transparent;
  box-shadow: none;
  /* 旁观可滚动；自己行动时改为 visible，禁止操作条盖住手牌 */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 40;
  justify-content: flex-end;
  pointer-events: none;
  transition: max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
html.mobile-layout .action-bar > * {
  pointer-events: auto;
}
html.mobile-layout .action-bar #waitText {
  position: relative;
  z-index: 1;
  background: rgba(10, 16, 14, 0.55);
  border-radius: 0.35rem;
  padding: 0.12rem 0.4rem;
}
/* 轮到自己：抬高上限 + 禁止裁切，保证加注条与手牌上下分立不互盖 */
html.mobile-layout .action-bar.my-turn-pulse,
html.mobile-layout .action-bar.is-acting {
  max-height: min(56%, 250px);
  overflow: visible;
  gap: 0.32rem;
}
/* 操作时收起筹码条，省出纵向给加注/按钮 */
html.mobile-layout .action-bar.is-acting .my-stack-bar {
  display: none;
}
html.mobile-layout .action-bar .controls-row {
  width: 100%;
  max-width: none;
  padding: 0;
  min-height: 0;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
  align-items: stretch;
  /* 必须低于手牌，避免 PC 默认 z-index:3 把手牌盖住 */
  position: relative;
  z-index: 1 !important;
}
/* 模块2：下注/行动区 */
html.mobile-layout .actions,
html.mobile-layout .idle-actions {
  width: auto;
  max-width: 100%;
  align-self: center;
  padding: 0.12rem 0.3rem;
  gap: 0.1rem;
  border-radius: var(--m-radius);
  background: rgba(8, 12, 10, 0.9);
  box-shadow: 0 0.12rem 0.45rem rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
}
html.mobile-layout .idle-actions {
  width: 100%;
  max-width: none;
}
html.mobile-layout .actions {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* 有下注滑条时再拉宽，纯按钮簇保持内容宽度 */
html.mobile-layout .actions:has(.bet-panel:not([hidden])) {
  width: min(100%, 22rem);
}
html.mobile-layout .action-info {
  display: none !important; /* 与台面 turnBroadcast 重复 */
}
html.mobile-layout .action-bar .hole-wrap {
  /* 手牌在操作钮下方，单独一层，绝不被加注条压住 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  width: auto;
  max-width: 100%;
  min-width: 0;
  margin-top: 0.05rem;
  padding: 0.16rem 4.1rem 0.18rem;
  border-radius: var(--m-radius);
  background: rgba(10, 16, 14, 0.88);
  box-shadow: 0 0.12rem 0.45rem rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: visible;
  position: relative;
  z-index: 6 !important;
  flex: 0 0 auto;
  --hole-card-w: var(--m-hole-w);
  --hole-card-h: var(--m-hole-h);
  transition:
    padding 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.38s ease,
    background 0.38s ease;
}
/* 轮到自己：手牌略放大；有加注条时用更克制尺寸 */
html.mobile-layout .action-bar .hole-wrap.my-turn-pulse {
  --hole-card-w: var(--m-hole-w-turn);
  --hole-card-h: var(--m-hole-h-turn);
  padding: 0.14rem 4.4rem 0.16rem;
  background: rgba(14, 20, 16, 0.9);
  box-shadow:
    0 0 0 0.08rem rgba(240, 200, 74, 0.35),
    0 0.18rem 0.55rem rgba(0, 0, 0, 0.35);
}
html.mobile-layout .action-bar.is-acting .hole-wrap.my-turn-pulse {
  --hole-card-w: clamp(2.55rem, 7vh, 3.3rem);
  --hole-card-h: clamp(3.55rem, 9.8vh, 4.55rem);
}
html.mobile-layout .action-bar .hole-wrap .hole .card {
  width: var(--hole-card-w);
  height: var(--hole-card-h);
  font-size: 0.78rem;
  transition:
    width 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    font-size 0.38s ease,
    box-shadow 0.38s ease;
  /* 禁止向上平移，避免牌面钻进上方操作条 */
  transform: none;
  transform-origin: center center;
}
html.mobile-layout .action-bar .hole-wrap.my-turn-pulse .hole .card {
  font-size: clamp(0.88rem, 2.6vh, 1.1rem);
  transform: none;
}
html.mobile-layout .action-bar .hole-wrap .hole {
  gap: 0.55rem;
  transition: gap 0.38s ease;
}
html.mobile-layout .action-bar .hole-wrap.my-turn-pulse .hole {
  gap: 0.75rem;
}
html.mobile-layout .hole-wrap > .hand-strength {
  margin: 0;
  font-size: 10px;
  padding: 0.08rem 0.4rem;
  transition: font-size 0.3s ease, padding 0.3s ease;
}
html.mobile-layout .hole-wrap.my-turn-pulse > .hand-strength {
  font-size: 11px;
  padding: 0.1rem 0.5rem;
}
html.mobile-layout .hole-wrap > .hole-peek-hint,
html.mobile-layout .hole-wrap > .hole-show-btn {
  display: none !important;
}
/* 翻牌/祈福：左右两侧，中间留空手牌（勿用 space-between 把中间钮压在牌上） */
html.mobile-layout .hole-wrap > .hole-peek-bar {
  position: absolute;
  left: 0.12rem;
  right: 0.12rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.18rem;
  margin: 0;
  padding: 0;
  z-index: 3;
  pointer-events: none;
  background: transparent;
  width: auto;
  max-width: none;
  min-height: 0;
}
html.mobile-layout .hole-wrap > .hole-peek-bar > * {
  pointer-events: auto;
  flex-shrink: 0;
}
html.mobile-layout .hole-wrap > .hole-peek-bar #peekAllBtn {
  margin-left: auto;
}
html.mobile-layout .hole-wrap > .hole-peek-bar .hole-peek-btn,
html.mobile-layout .hole-wrap > .hole-peek-bar .pray-fortune-btn {
  max-width: none;
  white-space: nowrap;
  line-height: 1.15;
  text-align: center;
  padding: 0.16rem 0.32rem;
  font-size: 10px;
}
/* 模块1：筹码/盈亏/底池 */
html.mobile-layout .my-stack-bar {
  width: auto;
  max-width: 100%;
  font-size: 11px;
  padding: 0.12rem 0.5rem;
  gap: 0.3rem 0.5rem;
  flex-wrap: nowrap;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(10, 16, 14, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.22);
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}
html.mobile-layout .my-stack-bar::-webkit-scrollbar {
  display: none;
}
html.mobile-layout .action-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.28rem;
  width: auto;
  max-width: 100%;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}
html.mobile-layout .action-main .btn {
  min-height: var(--m-tap);
  min-width: 3.4rem;
  max-width: none;
  flex: 0 0 auto;
  width: auto;
  font-size: var(--m-font);
  font-weight: 700;
  padding: 0.32rem 0.55rem;
  border-radius: 0.45rem;
  white-space: nowrap;
}
html.mobile-layout .action-main .call-btn:not([hidden]),
html.mobile-layout .action-main [data-action='raise']:not([hidden]),
html.mobile-layout .action-main [data-action='bet']:not([hidden]) {
  flex: 0 0 auto;
  min-width: 3.8rem;
  padding: 0.32rem 0.7rem;
}
html.mobile-layout .idle-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
}
html.mobile-layout .idle-actions #waitText {
  order: 3;
  font-size: var(--m-font-sm);
  text-align: center;
  max-width: none;
  margin: 0;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
}
html.mobile-layout .idle-actions #readyBtn,
html.mobile-layout .idle-actions #sitAgainBtn {
  order: 1;
  width: 100%;
  min-height: var(--m-tap);
  font-size: var(--m-font);
}
html.mobile-layout .idle-actions .btn,
html.mobile-layout .idle-actions .btn.primary {
  min-height: var(--m-tap);
  min-width: 0;
  font-size: var(--m-font);
  padding: 0.55rem 0.85rem;
}

/* 房主区：开始钮永远第一行全宽；设置默认折叠 */
html.mobile-layout .host-controls {
  order: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}
html.mobile-layout .host-controls #startBtnBottom,
html.mobile-layout .host-controls #newSessionBtn {
  order: -2;
  width: 100%;
  min-height: var(--m-tap);
  font-size: 1.05em;
  font-weight: 800;
  letter-spacing: 0.04em;
}
html.mobile-layout .host-controls #startBtnBottom.is-blocked,
html.mobile-layout .host-controls #startBtnBottom:disabled {
  opacity: 0.72;
  background: #3a3530;
  border-color: #5a5348;
  color: #e8e0d4;
}
html.mobile-layout .mobile-settings-toggle {
  order: -1;
  width: 100%;
  min-height: var(--m-tap-sm);
}
html.mobile-layout .settings-fields {
  order: 2;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  gap: 0.4rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.15rem 0;
}
html.mobile-layout .settings-fields.mobile-collapsed {
  display: none !important;
}
html.mobile-layout .settings-fields::-webkit-scrollbar {
  display: none;
}
html.mobile-layout .settings-fields .blind-edit {
  flex-shrink: 0;
  font-size: var(--m-font-sm);
}
html.mobile-layout .settings-fields input,
html.mobile-layout .settings-fields select {
  min-height: var(--m-tap-sm);
  font-size: 16px;
  padding: 0.35rem 0.45rem;
}
html.mobile-layout .settings-fields .rise-help-btn {
  display: none; /* 手机用顶栏/说明入口，避免占底栏 */
}

/* 局间房主待命：收起手牌槽，开始钮贴底可见 */
html.mobile-layout.mobile-idle-host .action-bar {
  max-height: min(48%, 200px);
  overflow-x: hidden;
  overflow-y: auto;
}
html.mobile-layout.mobile-idle-host .action-bar .hole-wrap {
  display: none !important;
}
html.mobile-layout.mobile-idle-host .my-stack-bar {
  display: none !important;
}

/* 下注条：与行动钮纵向分隔，禁止叠层 */
html.mobile-layout .bet-panel {
  max-width: 100%;
  width: min(100%, 20rem);
  gap: 0.06rem;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  padding-top: 0.04rem;
}
/* 非己方回合：操作区已隐藏，底栏只留手牌/筹码条 */
html.mobile-layout .action-bar:not(.is-acting) .controls-row {
  min-height: 0;
}
html.mobile-layout .bet-presets {
  gap: 0.2rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: center;
}
html.mobile-layout .bet-presets::-webkit-scrollbar {
  display: none;
}
html.mobile-layout .preset-btn {
  min-height: 26px;
  padding: 0.12rem 0.4rem;
  font-size: 10px;
  border-radius: 0.35rem;
  flex-shrink: 0;
}
html.mobile-layout .bet-slider-row {
  min-height: 28px;
  gap: 0.28rem;
  align-items: center;
}
html.mobile-layout .bet-hint {
  font-size: 10px;
}
html.mobile-layout .bet-amount-tip {
  display: none; /* 省一行高度 */
}
html.mobile-layout .bet-slider-row input[type='range'] {
  height: 28px;
  min-height: 28px;
}
html.mobile-layout .bet-slider-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold, #d4a017);
  border: 2px solid #fff6d8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
html.mobile-layout .bet-slider-row input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold, #d4a017);
  border: 2px solid #fff6d8;
}
html.mobile-layout .bet-amount-field {
  min-width: 3.4rem;
}
html.mobile-layout .bet-amount-field input[type='number'],
html.mobile-layout .bet-slider-row input[type='number'] {
  min-height: 28px;
  width: 3.4rem;
  font-size: 12px;
  padding: 0.12rem 0.25rem;
}
html.mobile-layout .hole-peek-bar {
  gap: 0.25rem;
  margin-top: 0.1rem;
}
html.mobile-layout .hole-peek-btn,
html.mobile-layout #peekAllBtn,
html.mobile-layout #peekOneBtn,
html.mobile-layout .pray-fortune-btn {
  min-height: 30px;
  min-width: 0;
  padding: 0.18rem 0.45rem;
  font-size: 12px;
  border-radius: 0.4rem;
}
/* 明牌：左右两侧常显小钮，不挡牌面 */
html.mobile-layout .hole {
  gap: 0.75rem;
  overflow: visible;
}
html.mobile-layout .hole-open-face-btn {
  min-height: 26px;
  min-width: 0;
  padding: 0.16rem 0.32rem;
  font-size: 11px;
  letter-spacing: 0.04em;
  border-radius: 999px;
  opacity: 0.98;
  pointer-events: auto;
}
html.mobile-layout .hole .card.my-hole-card[data-hole-index='0'] .hole-open-face-btn {
  transform: translate(-100%, -50%) translateX(-0.1rem);
}
html.mobile-layout .hole .card.my-hole-card[data-hole-index='1'] .hole-open-face-btn {
  transform: translate(100%, -50%) translateX(0.1rem);
}
/* 移动端搓牌：常显在手牌上方 */
html.mobile-layout .hole-rub-btn {
  min-height: 26px;
  padding: 0.16rem 0.36rem;
  font-size: 11px;
  opacity: 0.98;
  pointer-events: auto;
  transform: translate(-50%, calc(-100% - 0.2rem));
}
html.mobile-layout .hole.my-hole-card,
html.mobile-layout .hole {
  overflow: visible;
  padding-top: 0.15rem;
}
html.mobile-layout .hole-peek-hint {
  font-size: 11px;
  margin: 0.08rem 0 0;
  opacity: 0.78;
}

/* ========== 弹窗：接近半屏操作板 ========== */
html.mobile-layout .modal .modal-card,
html.mobile-layout #createRoomModal .modal-card,
html.mobile-layout #joinNameModal .modal-card {
  width: min(96vw, 36rem);
  max-height: 92vh;
  padding: 0.85rem 0.9rem 1rem;
  border-radius: 0.85rem;
}
html.mobile-layout .modal input,
html.mobile-layout .modal select,
html.mobile-layout #createRoomModal input,
html.mobile-layout #createRoomModal select,
html.mobile-layout #joinNameModal input {
  min-height: var(--m-tap);
  font-size: 16px; /* 防止 iOS 聚焦放大 */
  padding: 0.55rem 0.7rem;
}
html.mobile-layout .modal .btn,
html.mobile-layout .create-room-actions .btn,
html.mobile-layout .layer-actions .btn,
html.mobile-layout .dezhou-layer .btn,
html.mobile-layout #coachTeachModal .btn,
html.mobile-layout .coach-teach-modal .btn,
html.mobile-layout #sponsorSafeModal .btn,
html.mobile-layout #luckEventModal .btn,
html.mobile-layout #winnerEventModal .btn,
html.mobile-layout #handReportModal .btn {
  min-height: var(--m-tap);
  font-size: var(--m-font);
  padding: 0.6rem 1.1rem;
}
html.mobile-layout .create-room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
html.mobile-layout .create-room-actions .btn {
  width: 100%;
}

/* 聊天输入 */
html.mobile-layout .table-chat-form input,
html.mobile-layout #chatSendBtn {
  min-height: var(--m-tap-sm);
  font-size: 16px;
}
html.mobile-layout .throw-dock button,
html.mobile-layout .emoji-dock button {
  min-width: 40px;
  min-height: 40px;
  font-size: 1.15rem;
}

/* ========== Hub 模式选择 ========== */
html.mobile-layout .hub-screen {
  padding: 0.75rem 0.85rem 0.65rem;
  align-content: center;
}
html.mobile-layout .hub-shell {
  width: 100%;
  max-width: none;
  gap: 0.75rem;
}
html.mobile-layout .hub-logo {
  width: 3.2rem;
  height: 3.2rem;
  margin-bottom: 0.35rem;
}
html.mobile-layout .hub-brand {
  font-size: 1.55rem;
  letter-spacing: 0.12em;
}
html.mobile-layout .hub-sub {
  font-size: var(--m-font-sm);
  margin-top: 0.3rem;
}
html.mobile-layout .hub-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}
html.mobile-layout .hub-card {
  min-height: 5.8rem;
  padding: 0.75rem 0.8rem;
  border-radius: var(--m-radius);
}
html.mobile-layout .hub-card-name {
  font-size: 1.15rem;
}
html.mobile-layout .hub-card-desc {
  font-size: 0.78rem;
  line-height: 1.35;
}
html.mobile-layout .hub-note {
  font-size: 0.72rem;
}
html.mobile-layout .hub-note a {
  min-height: var(--m-tap-sm);
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
}

/* 统计 */
html.mobile-layout .stats-tabs button,
html.mobile-layout .stats-tab {
  min-height: var(--m-tap);
  padding: 0.5rem 0.85rem;
  font-size: var(--m-font);
}

/* 通用按钮兜底（未被上面覆盖的） */
html.mobile-layout .btn {
  min-height: var(--m-tap-sm);
  font-size: var(--m-font);
  padding: 0.5rem 0.85rem;
  touch-action: manipulation;
}
html.mobile-layout .btn.small {
  min-height: calc(var(--m-tap-sm) - 4px);
  font-size: var(--m-font-sm);
}

/* ========== 全局审查补丁 ========== */
/* 建房弹窗：矮屏可滚，避免底部确认钮被挡 */
html.mobile-layout #createRoomModal .modal-card,
html.mobile-layout .create-room-modal .modal-card {
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 100%);
  overflow: hidden;
}
html.mobile-layout #createRoomModal .modal-body,
html.mobile-layout #createRoomModal form,
html.mobile-layout .create-room-form {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  max-height: min(70vh, 28rem);
}
html.mobile-layout .create-room-actions {
  flex-shrink: 0;
  padding-top: 0.35rem;
}

/* 行动播报别占太高，且不要压公共牌 */
html.mobile-layout .action-broadcast {
  font-size: var(--m-font-sm);
  padding: 0.28rem 0.55rem;
  max-width: 90%;
  z-index: 12;
}
/* 行动字样/涟漪：字样改到公共牌两侧，涟漪仍跟座位 */
html.mobile-layout .action-fx-layer {
  z-index: 16; /* 高于公共牌，字样在两侧不压座位框 */
}
html.mobile-layout .action-stamp {
  font-size: 12px;
  padding: 0.18rem 0.48rem;
  letter-spacing: 0.04em;
  border-radius: 0.35rem;
}
html.mobile-layout .action-stamp.board-side {
  animation: action-stamp-side-pop 0.85s cubic-bezier(0.15, 0.9, 0.3, 1.1) forwards;
}
@keyframes action-stamp-side-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
}
html.mobile-layout .action-ripple {
  /* 涟漪缩小，减少扫到公共牌 */
  opacity: 0.85;
  animation-name: action-ripple-out-mobile;
}
@keyframes action-ripple-out-mobile {
  to {
    opacity: 0;
    width: 5.5rem;
    height: 5.5rem;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* 教练说明条：手机收成顶角小条，避免挡桌 */
html.mobile-layout .coach-panel,
html.mobile-layout #coachPanel {
  max-width: min(46vw, 14rem);
  font-size: var(--m-font-sm);
}
html.mobile-layout .coach-panel--dock,
html.mobile-layout #coachPanel.coach-panel--dock {
  top: calc(var(--m-topbar-h) + 0.25rem);
  right: 0.35rem;
  max-height: 42%;
  overflow: auto;
}

/* 祈福等次要入口缩小，避免和行动钮抢位 */
html.mobile-layout .pray-btn,
html.mobile-layout #prayBtn,
html.mobile-layout .hole-tools .btn {
  min-height: 30px;
  font-size: 12px;
  padding: 0.18rem 0.45rem;
}

/* ========== 战报：手机独立窗口（横持全幅工作台） ========== */
html.mobile-layout .hand-report-modal {
  padding: 0;
  place-items: stretch;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.58);
  z-index: 90;
}
html.mobile-layout .hand-report-card.hand-report-split {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 0.12rem solid rgba(240, 200, 100, 0.55);
  padding: 0.45rem 0.55rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  box-shadow: none;
  animation: none;
  background: linear-gradient(180deg, rgba(28, 22, 12, 0.98), rgba(10, 9, 7, 0.97));
}
html.mobile-layout .hand-report-eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.9;
}
html.mobile-layout .hand-report-title {
  margin: 0.05rem 0 0.25rem;
  font-size: 1rem;
  line-height: 1.2;
}
html.mobile-layout .hand-report-board-label {
  margin: 0 0 0.2rem;
  font-size: 10px;
}
html.mobile-layout .hand-report-board {
  margin: 0 0 0.35rem;
  min-height: 0;
  gap: 0.2rem;
}
html.mobile-layout .hand-report-board .card {
  width: 1.85rem;
  height: 2.55rem;
  font-size: 0.68rem;
}
html.mobile-layout .hand-report-board-empty {
  margin: 0 0 0.35rem;
  font-size: 11px;
}
/* 横持：左牌面 / 右快评，各自独立滚动 */
html.mobile-layout .hand-report-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 0.45rem;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}
html.mobile-layout .hand-report-left,
html.mobile-layout .hand-report-right {
  min-height: 0;
  max-height: none;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(240, 200, 100, 0.18);
  border-radius: 0.45rem;
  padding: 0.35rem 0.4rem;
}
html.mobile-layout .hand-report-col-title {
  margin: 0 0 0.28rem;
  font-size: 10px;
}
html.mobile-layout .hand-report-players {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  mask-image: none;
  padding-right: 0.15rem;
  gap: 0.28rem;
}
html.mobile-layout .hand-report-player {
  padding: 0.3rem 0.35rem;
}
html.mobile-layout .hand-report-player-name {
  font-size: 0.78rem;
}
html.mobile-layout .hand-report-player-meta {
  font-size: 0.68rem;
}
html.mobile-layout .hand-report-player-cards .card {
  width: 1.7rem;
  height: 2.35rem;
  font-size: 0.62rem;
}
html.mobile-layout .hand-report-comments {
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 0 0.3rem;
  gap: 0.25rem;
}
html.mobile-layout .hand-report-comments li {
  font-size: 0.72rem;
  padding: 0.28rem 0.35rem;
  line-height: 1.35;
}
html.mobile-layout .hand-report-stats,
html.mobile-layout .hand-report-list {
  max-height: min(28%, 6.5rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  gap: 0.2rem;
}
html.mobile-layout .hand-report-list li {
  font-size: 0.72rem;
  padding: 0.22rem 0.3rem;
}
html.mobile-layout .hand-report-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}
html.mobile-layout .hand-report-actions .btn,
html.mobile-layout #handReportModal .btn {
  width: 100%;
  min-height: var(--m-tap);
  margin: 0;
  font-size: var(--m-font);
}
html.mobile-layout .hand-report-split #handReportClose {
  display: block;
  width: 100%;
  margin: 0;
}
/* 极窄竖持兜底：单列 */
@media (max-width: 560px) {
  html.mobile-layout .hand-report-body {
    grid-template-columns: 1fr;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  html.mobile-layout .hand-report-left,
  html.mobile-layout .hand-report-right {
    overflow: visible;
    max-height: none;
  }
  html.mobile-layout .hand-report-players,
  html.mobile-layout .hand-report-comments {
    max-height: none;
    overflow: visible;
  }
}

/* 账单弹层：手机也改成全幅工作台，避免小窗裁切 */
html.mobile-layout .chip-ledger-modal {
  padding: 0;
  align-items: stretch;
}
html.mobile-layout .chip-ledger-card {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.55rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
}
html.mobile-layout .chip-ledger-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/*
 * 竖持 + 舞台横屏化：所有挂在 body 的全屏弹层/提示同步 rotate(90deg)，
 * 与牌桌同一套横屏坐标系（含赞助、搓牌、战报、建房等）。
 */
html.stage-portrait .create-room-modal,
html.stage-portrait .blind-rise-modal,
html.stage-portrait .chip-ledger-modal,
html.stage-portrait .hand-report-modal,
html.stage-portrait .pray-fortune-fx,
html.stage-portrait .luck-event-modal,
html.stage-portrait .winner-event-modal,
html.stage-portrait .rub-modal,
html.stage-portrait .sponsor-safe-modal {
  inset: auto;
  top: 50%;
  left: 50%;
  width: 100dvh;
  height: 100dvw;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
  padding: 0.55rem;
  box-sizing: border-box;
}

html.stage-portrait .rub-modal-card,
html.stage-portrait .sponsor-safe-card,
html.stage-portrait .luck-event-card,
html.stage-portrait .winner-event-card,
html.stage-portrait .create-room-card,
html.stage-portrait .blind-rise-card {
  width: min(92%, 28rem);
  max-width: min(92%, 28rem);
}

html.mobile-layout .rub-pick-suit-btn,
html.mobile-layout .rub-pick-rank-btn {
  min-height: 40px;
}
html.mobile-layout .rub-pick-rank-btn {
  min-width: 2.5rem;
}

html.stage-portrait .hand-report-card,
html.stage-portrait .chip-ledger-card {
  width: 100%;
  max-width: none;
  max-height: 100%;
}

/* 避免弹层卡片里仍按竖屏 vw 算宽 */
html.stage-portrait .hand-report-card {
  width: min(100%, 36rem);
}
