/* ─────────────────────────────────────────────
   Mobile 佈局（MOBILE-ADAPT-BRIEF 方案 A：雙佈局）
   app.js fit()：產品寬 < 1400 或高 < 810 重用緊湊版；非產品 QA 保留寬 < 900 或高 < 500 門檻。
   產品所有尺寸皆為滿版流式；只有非產品 desktop 保留 1440×810 等比參考。
   本檔只改「位置與尺寸」；色票、NP、卡 prefab、紙影語彙全部沿用。
   ───────────────────────────────────────────── */

/* 觸控裝置：hover 升起改以 :active／選中態為主 */
@media (hover: none) {
  .card[data-interactive]:hover:not([aria-pressed="true"]),
  .card[data-state="dim"][data-interactive]:hover { transform: none; filter: var(--lift-1); }
  .seat:hover, .room-row:hover, .menu-plaque:hover:not(:disabled) { transform: none; filter: var(--lift-1); }
  .pile--deck[data-drawable="true"] .pile__stack:hover .card:nth-child(3) { transform: none; }
  .card[data-interactive]:active { transform: translateY(-6px); }
}

body[data-layout="mobile"] {
  --gutter: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* 舞台：關掉固定 1440 縮放，改流式 */
body[data-layout="mobile"] .stage {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: none;
}
body[data-layout="mobile"] .screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + var(--gutter)) calc(var(--safe-b) + 16px) calc(var(--safe-l) + var(--gutter));
}

/* 共用角件 */
body[data-layout="mobile"] .room-corner { top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + var(--gutter)); height: 36px; padding: 0 10px 1px; font-size: 11px; }
body[data-layout="mobile"] .room-corner b { font-size: 14px; }
body[data-layout="mobile"] .corner-chrome { gap: 8px; top: calc(var(--safe-t) + 6px); right: calc(var(--safe-r) + var(--gutter)); }
body[data-layout="mobile"] .icon-btn { width: 44px; height: 44px; }
body[data-layout="mobile"] .icon-btn--sm { width: 40px; height: 40px; }
body[data-layout="mobile"] .tag { height: 30px; }
body[data-layout="mobile"] .btn { min-width: 0; }
body[data-layout="mobile"] .btn--sm { --btn-h: 44px; }

/* ═════════ 1. MainMenu：單欄紙牌堆疊；場景貓縮小降層 ═════════ */
body[data-layout="mobile"] .screen--menu { display: flex; flex-direction: column; gap: 14px; }
body[data-layout="mobile"] .menu__scene { inset: 0; background-position: 70% 30%; }
body[data-layout="mobile"] .menu__wash {
  background: linear-gradient(180deg, rgba(247, 241, 230, 0.55) 0, rgba(247, 241, 230, 0.78) 34%, rgba(247, 241, 230, 0.62) 70%, rgba(247, 241, 230, 0.2) 100%);
}
body[data-layout="mobile"] .menu__brand,
body[data-layout="mobile"] .menu__nav,
body[data-layout="mobile"] .menu__tagline,
body[data-layout="mobile"] .menu__profile { position: relative; left: auto; top: auto; bottom: auto; width: auto; z-index: 2; }
body[data-layout="mobile"] .menu__brand { margin: 44px 0 4px; padding: 18px 20px 14px; }
body[data-layout="mobile"] .menu__logo { font-size: 54px; }
body[data-layout="mobile"] .menu__subtitle { font-size: var(--fs-md); letter-spacing: 0.12em; }
body[data-layout="mobile"] .menu__nav { gap: 12px; }
body[data-layout="mobile"] .menu-plaque { --btn-h: 58px; font-size: 19px; }
body[data-layout="mobile"] .menu-plaque--lead { --btn-h: 64px; font-size: 20px; }
body[data-layout="mobile"] .menu__tagline { padding: 10px 14px; }
body[data-layout="mobile"] .menu__profile { align-self: flex-start; }
body[data-layout="mobile"] .menu__help { top: calc(var(--safe-t) + 8px); right: calc(var(--safe-r) + var(--gutter)); z-index: 3; }
body[data-layout="mobile"] .menu__foot { position: relative; right: auto; bottom: auto; align-self: flex-start; z-index: 2; font-size: 10px; }
body[data-layout="mobile"] .menu__cat { z-index: 1; }
body[data-layout="mobile"] .menu__cat--siamese { display: none; }
body[data-layout="mobile"] .menu__cat--sleeper { right: calc(var(--safe-r) + 6px); bottom: calc(var(--safe-b) + 22px); width: 132px; }

body[data-layout="mobile"][data-orient="landscape"] .screen--menu { padding-right: 44%; gap: 10px; }
body[data-layout="mobile"][data-orient="landscape"] .menu__brand { margin-top: 0; padding: 10px 16px 8px; }
body[data-layout="mobile"][data-orient="landscape"] .menu__logo { font-size: 40px; }
body[data-layout="mobile"][data-orient="landscape"] .menu-plaque,
body[data-layout="mobile"][data-orient="landscape"] .menu-plaque--lead { --btn-h: 48px; font-size: 17px; }
body[data-layout="mobile"][data-orient="landscape"] .menu__tagline { display: none; }
body[data-layout="mobile"][data-orient="landscape"] .menu__wash { background: linear-gradient(90deg, rgba(247, 241, 230, 0.9) 0, rgba(247, 241, 230, 0.6) 52%, rgba(247, 241, 230, 0) 70%); }
body[data-layout="mobile"][data-orient="landscape"] .menu__cat--siamese { display: block; right: 8%; top: 34%; width: 120px; }
body[data-layout="mobile"][data-orient="landscape"] .menu__cat--sleeper { right: 26%; bottom: calc(var(--safe-b) + 10px); width: 150px; }

/* ═════════ 2. Lobby：三欄改單欄捲動 ═════════ */
body[data-layout="mobile"] .screen--lobby { display: flex; flex-direction: column; gap: 14px; }
body[data-layout="mobile"] .screen-head { position: relative; top: auto; left: auto; right: auto; gap: 12px; }
body[data-layout="mobile"] .screen-head__title { font-size: var(--fs-xl); }
body[data-layout="mobile"] .lobby { position: relative; inset: auto; display: flex; flex-direction: column; gap: 14px; }
body[data-layout="mobile"] .lobby .panel { padding: 18px 16px 18px; }
body[data-layout="mobile"] .cat-preview .bust { --size: 84px !important; }
body[data-layout="mobile"] .cat-grid { gap: 8px 2px; }
body[data-layout="mobile"] .cat-opt { min-height: 44px; font-size: var(--fs-xs); }
body[data-layout="mobile"] .form-row { flex-wrap: wrap; }
body[data-layout="mobile"] .segmented button { height: 40px; }
body[data-layout="mobile"] .segmented[data-segment="max"] button { width: 38px; }
body[data-layout="mobile"] .room-row { height: auto; min-height: 64px; gap: 10px; padding: 8px 10px; grid-template-columns: auto 1fr auto; }
body[data-layout="mobile"] .room-row__count { grid-column: 2; grid-row: 2; }
body[data-layout="mobile"] .room-row .btn { grid-column: 3; grid-row: 1 / span 2; }
body[data-layout="mobile"] .room-row .bust { grid-row: 1 / span 2; }

/* ═════════ 3. Room：看板 → 你的狀態 → 席位 ═════════ */
body[data-layout="mobile"] .screen--room { display: flex; flex-direction: column; gap: 14px; padding-top: calc(var(--safe-t) + 60px); }
body[data-layout="mobile"] .screen--room .room-exit { top: calc(var(--safe-t) + 6px); left: calc(var(--safe-l) + var(--gutter)); height: 44px; }
body[data-layout="mobile"] .screen--room .room-corner { position: relative; top: auto; left: auto; align-self: flex-start; flex: none; margin-top: 2px; }
body[data-layout="mobile"] .room-board,
body[data-layout="mobile"] .room-friends,
body[data-layout="mobile"] .side-rail--room { position: relative; left: auto; right: auto; top: auto; width: auto; max-height: none; }
body[data-layout="mobile"] .room-board { order: 1; padding: 22px 20px 18px; }
body[data-layout="mobile"] .room-board__title { font-size: var(--fs-2xl); margin-bottom: var(--sp-4); }
body[data-layout="mobile"] .room-code-card { padding: 12px 14px; }
body[data-layout="mobile"] .room-code-card__code { font-size: 38px; letter-spacing: 0.24em; }
/* §BK 手機：中卡（含準備／開局）在上；席位次之；好友面板在下並限高捲動 */
body[data-layout="mobile"] .room-me { grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; }
body[data-layout="mobile"] .room-me > .bust { --size: 52px !important; }
body[data-layout="mobile"] .room-me__actions, body[data-layout="mobile"] .room-me__hint { grid-column: 1 / -1; }
body[data-layout="mobile"] .room-me__actions .btn { flex: 1 1 0; min-width: 0; min-height: 44px; }
body[data-layout="mobile"] .room-me__hint { text-align: center; }
body[data-layout="mobile"] .side-rail--room { order: 2; }
body[data-layout="mobile"] .room-friends { order: 3; }
body[data-layout="mobile"] .room-friends__list { max-height: 40vh; }
body[data-layout="mobile"] .side-rail--room .side-rail__list { overflow: visible; }

/* ═════════ 4. TableStage（§H 語意保留、位置改排） ═════════
   直式：上＝房碼角｜本地狀態｜齒輪；對手橫滑列；指令紙；L2 桌面；手牌橫滑；三 CTA 固定底欄。 */
body[data-layout="mobile"] .screen--table {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "me me gear"
    "rail rail rail"
    "command command command"
    "table table table"
    "hand hand hand";
  gap: 8px 8px;
  overflow: hidden;
  padding-bottom: 0;
}
body[data-layout="mobile"] .screen--table > .room-corner { grid-area: corner; position: relative; top: auto; left: auto; align-self: center; }
body[data-layout="mobile"] .screen--table > .corner-chrome { grid-area: gear; position: relative; top: auto; right: auto; align-self: center; }
body[data-layout="mobile"] .screen--table .side-rail { grid-area: rail; }
body[data-layout="mobile"] .screen--table .command { grid-area: command; }
body[data-layout="mobile"] .screen--table .tabletop { grid-area: table; }
body[data-layout="mobile"] .screen--table .hand { grid-area: hand; }
body[data-layout="mobile"] .screen--table .me-card { grid-area: me; }

/* 對手：頂部橫滑列（本地仍不進列） */
body[data-layout="mobile"] .side-rail {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  max-height: none;
  min-width: 0;
  padding: 6px;
  margin: 0 calc(-1 * var(--gutter));
  border-image: none;
  background: none;
}
body[data-layout="mobile"] .side-rail .side-rail__head, body[data-layout="mobile"] .side-rail__fade { display: none; }
body[data-layout="mobile"] .side-rail__list {
  flex-direction: row;
  gap: 8px;
  padding: 2px var(--gutter) 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
body[data-layout="mobile"] .side-rail__list::-webkit-scrollbar { display: none; }
body[data-layout="mobile"] .screen--table .seat {
  width: 138px;
  height: 62px;
  padding: 0 8px 0 7px;
  column-gap: 8px;
  scroll-snap-align: start;
}
body[data-layout="mobile"] .screen--table .seat .bust { --size: 40px !important; }
body[data-layout="mobile"] .screen--table .seat__name { font-size: 14px; }
body[data-layout="mobile"] .screen--table .seat__count { height: 20px; font-size: 12px; }
body[data-layout="mobile"] .screen--table .seat__turn,
body[data-layout="mobile"] .screen--table .seat__status { display: none !important; }
body[data-layout="mobile"] .screen--table .seat { width: 158px; height: 62px; row-gap: 3px; }
body[data-layout="mobile"] .seat__progress { gap: 4px; }
body[data-layout="mobile"] .pips--sm img { width: 11px; height: 11px; }
body[data-layout="mobile"] .seat__skip { padding: 1px 4px; font-size: 9.5px; }
body[data-layout="mobile"] .seat-peek--floating { left: 12px; transform: none; width: 176px; }
body[data-layout="mobile"] .seat-peek--floating[data-open="true"] { transform: none; }

/* 指令紙：一行；關閉後不佔位 */
body[data-layout="mobile"] .command {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  min-height: 46px;
  transform: none;
  padding: 4px 6px 4px 10px;
  gap: 8px;
}
body[data-layout="mobile"] .command[data-hidden="true"] { display: none; }
body[data-layout="mobile"] .command__icon { width: 28px; height: 28px; }
body[data-layout="mobile"] .command__text { font-size: var(--fs-md); line-height: 1.3; }
body[data-layout="mobile"] .command__timer { width: 34px; height: 34px; }

/* L2 共享對局：以 tabletop 為 size container，牌堆／刻度盤隨可用空間縮放 */
body[data-layout="mobile"] .tabletop {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  height: auto;
  min-height: 0;
  container-type: size;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  --pile-w: min(24cqw, 50cqh);
  --dial-w: min(40cqw, 78cqh);
}
/* §L-3 餐布：固定母圖比例（1760:760）、寬過螢幕往兩側出血，不再被拉成近圓的怪墊子 */
body[data-layout="mobile"] .tabletop__mat { inset: auto; left: 50%; top: 50%; width: 150%; height: auto; aspect-ratio: 1760 / 760; transform: translate(-50%, -50%); }
body[data-layout="mobile"] .tabletop::before { inset: auto; left: 50%; top: 50%; width: 146%; aspect-ratio: 1760 / 760; transform: translate(-50%, -44%); }
body[data-layout="mobile"] .pile { position: relative; left: auto; right: auto; top: auto; transform: none; flex-direction: column; gap: 6px; }
body[data-layout="mobile"] .pile--discard { flex-direction: column-reverse; }
body[data-layout="mobile"] .pile { isolation: isolate; }
body[data-layout="mobile"] .pile--deck .pile-preview { left: 0; right: auto; max-width: calc(100vw - 24px); transform: translateY(-4px); }
body[data-layout="mobile"] .pile--deck[data-preview-open="true"] .pile-preview,
body[data-layout="mobile"] .pile--deck:focus-within .pile-preview { transform: translateY(0); }
body[data-layout="mobile"] .pile--discard .pile-preview { left: auto; right: 0; max-width: calc(100vw - 24px); transform: translateY(-4px); }
body[data-layout="mobile"] .pile--discard[data-preview-open="true"] .pile-preview,
body[data-layout="mobile"] .pile--discard:focus-within .pile-preview { transform: translateY(0); }
body[data-layout="mobile"] .pile__stack { width: var(--pile-w); }
body[data-layout="mobile"] .pile__stack .card,
body[data-layout="mobile"] .pile__fan .card { --card-w: var(--pile-w) !important; }
body[data-layout="mobile"] .pile__fan { width: var(--pile-w); }
body[data-layout="mobile"] .pile__tag { height: 26px; padding: 0 9px; font-size: 12px; }
body[data-layout="mobile"] .dial { position: relative; left: auto; top: auto; transform: translateY(-4%); width: var(--dial-w); height: auto; aspect-ratio: 1; }
body[data-layout="mobile"] .dial__center { min-width: 0; height: calc(var(--dial-w) * 0.15); padding: 0 8px; gap: 4px; border-radius: 8px; }
body[data-layout="mobile"] .dial__value { font-size: calc(var(--dial-w) * 0.11); }
body[data-layout="mobile"] .dial__label { font-size: 9px; letter-spacing: 0.3em; }
body[data-layout="mobile"] .dial__dir { bottom: -24px; height: 24px; padding: 0 8px; font-size: 11px; white-space: nowrap; }

/* 本地狀態：頂列中間的緊湊紙條 */
body[data-layout="mobile"] .me-card {
  position: relative;
  right: auto;
  bottom: auto;
  width: auto;
  min-width: 0;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  filter: var(--lift-1);
}
body[data-layout="mobile"] .me-card__head { padding: 0; margin: 0; border: 0; }
body[data-layout="mobile"] .me-card__head { display: none; }
body[data-layout="mobile"] .me-card .stat-row { line-height: 1; gap: 2px; }
body[data-layout="mobile"] .me-card .stat-row > span:first-child { display: none; }
body[data-layout="mobile"] .me-card .pips { gap: 1px; }
body[data-layout="mobile"] .me-card .pips img { width: 15px; height: 15px; }
body[data-layout="mobile"] .me-card__skip { font-size: 11px; white-space: nowrap; }
body[data-layout="mobile"] .me-card__skip::before { content: "Skip "; color: var(--ink-3); font-weight: 400; }

/* 手牌：橫向滑動（拖曳打牌時由 app.js 暫停橫滑搶手） */
body[data-layout="mobile"] .hand {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  margin: 0 calc(-1 * var(--gutter));
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  /* HAND-VFX §A：直式三張微重疊扇吃掉桌面與手牌間空白；下緣是 home indicator → mobile 不出血 */
  --hand-w: min(140px, calc((100vw - 2 * var(--gutter)) / 2.6));
  --hand-bleed: 0;
}
body[data-layout="mobile"] .hand::-webkit-scrollbar { display: none; }
body[data-layout="mobile"] .hand__fan { width: max-content; min-width: 100%; padding: 20px calc(var(--gutter) + 12px) 4px; gap: 0; }
body[data-layout="mobile"] .hand__slot { margin: 0 -12px; transform: rotate(calc(var(--o) * 2deg)); scroll-snap-align: center; }
body[data-layout="mobile"] .hand__slot .card { --card-w: var(--hand-w); }
body[data-layout="mobile"] .hand__slot:hover .card[data-interactive]:not([aria-pressed="true"]) { transform: translateY(-8px); }
body[data-layout="mobile"] .hand .card[aria-pressed="true"] { transform: translateY(-14px) scale(1.03); }
body[data-layout="mobile"] .hand__empty { padding: 30px 20px; }

/* §I 三 CTA 已移除：手牌列直接貼底，避開 home indicator；Skip 小鈕在頂列本地狀態條 */
body[data-layout="mobile"] .screen--table .hand { padding-bottom: calc(var(--safe-b) + 8px); }
body[data-layout="mobile"] .me-card__skip-btn { --btn-h: 30px; width: auto; margin: 0; padding: 0 8px; font-size: 11px; gap: 4px; }
body[data-layout="mobile"] .me-card__skip-btn .ico { width: 12px; height: 12px; }
body[data-layout="mobile"] .me-card .stat-row:has(.me-card__skip) { display: none; }
body[data-layout="mobile"] .hand__pill { display: none !important; }

/* 橫式：左＝對手直列｜中＝指令＋桌面＋手牌｜右＝本地狀態（含 Skip 小鈕） */
body[data-layout="mobile"][data-orient="landscape"] .screen--table {
  grid-template-columns: 148px minmax(0, 1fr) 132px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "command command gear"
    "rail table me"
    "rail hand me";
  gap: 6px 10px;
  padding-top: calc(var(--safe-t) + 6px);
  padding-bottom: calc(var(--safe-b) + 6px);
}
body[data-layout="mobile"][data-orient="landscape"] .screen--table > .corner-chrome { justify-self: end; }
body[data-layout="mobile"][data-orient="landscape"] .side-rail { margin: 0; padding: 0; min-height: 0; }
body[data-layout="mobile"][data-orient="landscape"] .side-rail__list { flex-direction: column; height: 100%; padding: 2px 2px 6px; overflow-x: hidden; overflow-y: auto; }
body[data-layout="mobile"][data-orient="landscape"] .screen--table .seat { width: auto; height: 54px; }
body[data-layout="mobile"][data-orient="landscape"] .screen--table .seat .bust { --size: 34px !important; }
body[data-layout="mobile"][data-orient="landscape"] .command { min-height: 40px; }
body[data-layout="mobile"][data-orient="landscape"] .dial__label { display: none; }
body[data-layout="mobile"][data-orient="landscape"] .command__text small { display: none; }
body[data-layout="mobile"][data-orient="landscape"] .me-card { flex-direction: column; align-items: stretch; align-self: start; gap: 6px; padding: 8px 10px; }
body[data-layout="mobile"][data-orient="landscape"] .me-card .stat-row { justify-content: flex-start; }
body[data-layout="mobile"][data-orient="landscape"] .hand { margin: 0; --hand-w: 92px; }
body[data-layout="mobile"][data-orient="landscape"] .hand__tray { width: min(100%, clamp(320px, calc(5 * var(--hand-w) - 24px), 460px)); min-width: 0; margin-inline: auto; padding: 14px 8px 2px; }
body[data-layout="mobile"][data-orient="landscape"] .hand__fan { width: 100%; min-width: 0; padding: 14px 4px 2px; justify-content: center; }

/* ═════════ 疊層：全寬、可捲、可關 ═════════ */
body[data-layout="mobile"] .modal-scrim {
  place-items: start center;
  grid-template-columns: minmax(0, 1fr);
  overflow-y: auto;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 10px);
}
body[data-layout="mobile"] .modal {
  width: 100%;
  max-width: 560px;
  margin: auto 0;
  padding: 22px 18px 18px;
}
body[data-layout="mobile"] .modal__title { font-size: var(--fs-xl); }
body[data-layout="mobile"] .modal__foot { flex-wrap: wrap; }
body[data-layout="mobile"] .modal__foot .btn:not(.btn--sm) { --btn-h: 48px; }
body[data-layout="mobile"] .pending { padding: 28px 18px 24px; }
body[data-layout="mobile"] .pending__paws { margin-bottom: 14px; }

body[data-layout="mobile"] .peek__row { justify-content: flex-start; gap: 12px; padding: 14px 12px 6px; overflow-x: auto; }
body[data-layout="mobile"] .peek-slot .card { --card-w: min(132px, calc((100vw - 110px) / 3)) !important; }
body[data-layout="mobile"] .peek-slot__moves .icon-btn { width: 44px; height: 44px; }

body[data-layout="mobile"] .victory { padding: 22px 16px 18px; }
body[data-layout="mobile"] .victory__laurel { width: 44px; }
body[data-layout="mobile"] .victory__bust { --size: 84px !important; }
body[data-layout="mobile"] .victory__title { font-size: var(--fs-xl); }
body[data-layout="mobile"] .standing { grid-template-columns: 22px 32px minmax(0, 1fr) auto auto; gap: 8px; padding: 0 8px; }
body[data-layout="mobile"] .standing .bust { --size: 30px !important; }
body[data-layout="mobile"] .standing .pips img { width: 15px; height: 15px; }
body[data-layout="mobile"] .standing__skip { display: none; }
body[data-layout="mobile"] .rematch-busts { flex-wrap: wrap; }

body[data-layout="mobile"] .settings__body { grid-template-columns: 1fr; gap: 12px; min-height: 0; }
body[data-layout="mobile"] .settings .tabs-v { flex-direction: row; padding: 0 0 10px; border-right: 0; border-bottom: 1px dashed var(--line); overflow-x: auto; }
body[data-layout="mobile"] .settings .tabs-v button { flex: none; height: 44px; }
body[data-layout="mobile"] .settings .tabs-v button[aria-selected="true"]::before { left: 12px; right: 12px; top: auto; bottom: 4px; width: auto; height: 3px; }
body[data-layout="mobile"] .set-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
body[data-layout="mobile"] .account-pane { gap: 10px; }
body[data-layout="mobile"] .account-pane .btn { --btn-h: 46px; }
body[data-layout="mobile"] .account-avatar-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
body[data-layout="mobile"] .account-avatar-opt { min-height: 60px; font-size: 11px; }
body[data-layout="mobile"] .account-avatar-opt .bust { --size: 36px !important; }
body[data-layout="mobile"] .menu__profile { max-width: calc(100vw - 24px); }
body[data-layout="mobile"] .menu__account-btn { height: 40px; }
body[data-layout="mobile"] .set-row .slider { width: 100%; grid-column: 1 / -1; grid-row: 2; height: 32px; }
body[data-layout="mobile"] .set-row output { grid-row: 1; grid-column: 2; }
body[data-layout="mobile"] .set-row .segmented { flex-wrap: wrap; }
body[data-layout="mobile"] .switch { width: 52px; height: 30px; }
body[data-layout="mobile"] .switch span::after { width: 24px; height: 24px; }
body[data-layout="mobile"] .switch input:checked + span::after { transform: translateX(22px); }

body[data-layout="mobile"] .conn { padding: 28px 18px 20px; }

/* 說明書：手機改單頁直式（圖在上、文在下，整本可捲），色籤改頂部橫排 */
body[data-layout="mobile"] .book { width: 100%; max-width: 620px; height: calc(100dvh - var(--safe-t) - var(--safe-b) - 24px); padding: 0; grid-template-rows: auto minmax(0, 1fr) auto auto; }
body[data-layout="mobile"] .book__tabs { position: relative; top: auto; right: auto; z-index: 0; display: flex; gap: 4px; padding: 0 30px 0 6px; overflow-x: auto; scrollbar-width: none; }
body[data-layout="mobile"] .book__tab { flex: none; width: auto; height: 40px; padding: 0 12px; border-radius: 10px 10px 0 0; justify-content: center; transform: translateY(4px); }
body[data-layout="mobile"] .book__tab[aria-selected="true"] { transform: none; }
body[data-layout="mobile"] .book__spread { grid-template-columns: 1fr; overflow-y: auto; border-radius: 12px; background: var(--page); }
body[data-layout="mobile"] .book__page { padding: 22px 20px 18px; }
/* §N：手機書頁上下堆疊時列高跟內容走（大示意圖不被壓矮、圖說不疊到文頁標題） */
body[data-layout="mobile"] .book__spread { grid-auto-rows: max-content; align-content: start; }
body[data-layout="mobile"] .book__page { min-height: auto; }
body[data-layout="mobile"] .book__page--fig { padding-right: 20px; border-bottom: 1px dashed rgba(110, 92, 74, 0.28); }
body[data-layout="mobile"] .book__page--text { overflow: visible; padding-left: 20px; }
body[data-layout="mobile"] .book__page--fig .book__folio { display: none; }
body[data-layout="mobile"] .book__title { font-size: 24px; }
body[data-layout="mobile"] .book__foot { margin-top: 10px; gap: 14px; }
body[data-layout="mobile"] .book__colophon { margin-top: 4px; font-size: 10px; }
body[data-layout="mobile"] .book__close { top: -2px; right: 0; }
/* §N Ch.3 縮影：手機改排成手機 Table 的 IA（頂列狀態條→當前席置前橫列→桌布→手牌），不是縮放桌面圖 */
body[data-layout="mobile"] .hb-map { width: 100%; grid-template-columns: 1fr; grid-template-areas: "me" "seats" "table" "hand"; gap: 3cqw; padding: 3.5cqw; }
body[data-layout="mobile"] .hb-map__me { align-self: auto; justify-content: flex-start; padding: 2cqw 3cqw; }
body[data-layout="mobile"] .hb-map__me .bust { --size: 7cqw !important; }
body[data-layout="mobile"] .hb-map__me .pips img { width: 3.6cqw; height: 3.6cqw; }
body[data-layout="mobile"] .hb-map__skip { margin-left: auto; font-size: 3.2cqw; }
body[data-layout="mobile"] .hb-map__seats { flex-direction: row; gap: 2cqw; padding: 2cqw; }
body[data-layout="mobile"] .hb-seat { flex: none; width: 29.4cqw; }
body[data-layout="mobile"] .hb-seat:nth-child(4) { display: none; }
body[data-layout="mobile"] .hb-seat .bust { --size: 8cqw !important; }
body[data-layout="mobile"] .hb-seat b { font-size: 3.6cqw; }
body[data-layout="mobile"] .hb-seat i { font-size: 3cqw; }
body[data-layout="mobile"] .hb-map__table { margin: 2cqw -6cqw 0; aspect-ratio: 1760 / 900; }
body[data-layout="mobile"] .hb-map__deck .card, body[data-layout="mobile"] .hb-map__discard .card { --card-w: 17cqw !important; }
body[data-layout="mobile"] .hb-map__meter { width: 30cqw; }
body[data-layout="mobile"] .hb-map__meter b { font-size: 3.4cqw; }
body[data-layout="mobile"] .hb-map__note { font-size: 3.4cqw; }
body[data-layout="mobile"] .hb-map__cards .card { --card-w: 25cqw !important; }
body[data-layout="mobile"] .hb-caption--desktop { display: none; }
body[data-layout="mobile"] .hb-caption--mobile { display: block; }
/* §S／§Q／§R 直式書頁：demo 在上、等比縮小（卡寬隨 vw），步驟不合併 */
body[data-layout="mobile"] .hb-turn__stage { gap: 6px; }
body[data-layout="mobile"] .hb-turn__stage .bust { --size: min(46px, 12vw) !important; }
body[data-layout="mobile"] .hb-turn__pre .card, body[data-layout="mobile"] .hb-turn__draw .card { --card-w: min(54px, 14vw); }
body[data-layout="mobile"] .hb-turn__pre img { width: min(28px, 7.5vw); height: min(28px, 7.5vw); }
body[data-layout="mobile"] .hb-turn__arrow { width: min(30px, 7vw); }
body[data-layout="mobile"] .hb-dial { width: min(200px, 50vw); }
body[data-layout="mobile"] .hb-dial > b { font-size: 20px; }
body[data-layout="mobile"] .hb-bomb__card .card { --card-w: min(84px, 22vw); }
body[data-layout="mobile"] .hb-react__col .card { --card-w: min(84px, 23vw); }
body[data-layout="mobile"] .hb-window { width: min(300px, 80vw); }
/* §T 圖鑑：卡寬隨 vw；左頁內捲高度改以視窗計，詳情改直排 */
body[data-layout="mobile"] .hb-codex__scroll { max-height: min(420px, 52dvh); }
body[data-layout="mobile"] .hb-codex__grid { grid-template-columns: repeat(auto-fill, minmax(min(68px, 19vw), 1fr)); }
body[data-layout="mobile"] .hb-codex__item .card { --card-w: min(68px, 19vw); }
body[data-layout="mobile"] .hb-codex__detail { grid-template-columns: 1fr; justify-items: center; align-content: start; gap: 12px; overflow-y: auto; text-align: center; }
body[data-layout="mobile"] .hb-codex__big .card { --card-w: min(130px, 34vw); }
body[data-layout="mobile"] .hb-legend { grid-template-columns: 1fr; }
body[data-layout="mobile"] .toast { left: 50%; top: calc(var(--safe-t) + 112px); max-width: calc(100vw - 32px); text-align: center; }
body[data-layout="mobile"] .fx-chit { font-size: 18px; }
body[data-layout="mobile"] .fx-stamp { font-size: 26px; }

/* 審視導覽列（開發工具）：手機預設收合，展開鈕改為左緣小籤，不擋底欄 CTA */
body[data-layout="mobile"] .devbar-show { left: 0; bottom: auto; top: 46%; width: 24px; height: 34px; padding: 0 0 0 5px; overflow: hidden; white-space: nowrap; border-radius: 0 8px 8px 0; opacity: 0.4; font-size: 11px; }

/* 夜間打磨（2026-10-27）：倒數小籤改掛牌堆上方；Room 席位維持直列（不吃對局的橫滑列規則） */
body[data-layout="mobile"] .ptimer,
body[data-layout="mobile"] .pile--discard .ptimer { top: auto; bottom: calc(100% + 4px); left: 50%; height: 30px; padding: 0 8px 0 3px; gap: 5px; font-size: 11px; }
body[data-layout="mobile"] .ptimer__ring { width: 24px; height: 24px; }
body[data-layout="mobile"] .ptimer__ring b { font-size: 12px; }
body[data-layout="mobile"] .side-rail--room .side-rail__list { flex-direction: column; padding: 2px 4px 6px; overflow: visible; }
body[data-layout="mobile"] .side-rail--room { margin: 0; border-image: var(--np-src-rail) var(--np-m-rail) fill / calc(var(--np-m-rail) * 1px) stretch; padding: 10px 8px; }
body[data-layout="mobile"] .side-rail--room .side-rail__head { display: flex; }
body[data-layout="mobile"] .me-card__skip-btn { white-space: nowrap; }
body[data-layout="mobile"][data-orient="portrait"] .me-card__skip-verb { display: none; }

/* §L-1 手機：自己回合時頂列本地狀態條露出頭像（承載燃燒環）＋秒數 */
body[data-layout="mobile"] .screen--table[data-phase="local-turn"] .me-card__head { display: flex; gap: 4px; }
body[data-layout="mobile"] .me-card__head > div { display: none; }
body[data-layout="mobile"] .me-card__head .bust { --size: 26px !important; }
body[data-layout="mobile"] .me-card__clock { font-size: 12px; }
body[data-layout="mobile"] .bust[data-timer]::before { inset: -5px; }

/* §AR 緊湊產品：表單與房間可捲動，寬視窗保留並排步驟。 */
html[data-product="staging"] body[data-layout="mobile"] .screen--menu > :is(.menu__brand, .menu__nav, .menu__tagline, .menu__profile),
html[data-product="staging"] body[data-layout="mobile"] .screen--lobby > *,
html[data-product="staging"] body[data-layout="mobile"] .screen--room > * { flex-shrink: 0; }
html[data-product="staging"] body[data-layout="mobile"] .lobby__col { min-width: 0; }
html[data-product="staging"] body[data-layout="mobile"] .tabletop__mat,
html[data-product="staging"] body[data-layout="mobile"] .tabletop::before { max-width: 100vw; }
html[data-product="staging"] body[data-layout="mobile"][data-orient="landscape"] .tabletop__mat,
html[data-product="staging"] body[data-layout="mobile"][data-orient="landscape"] .tabletop::before { max-width: 100%; }
@media (min-width: 900px) {
  html[data-product="staging"] body[data-layout="mobile"] .lobby {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  html[data-product="staging"] body[data-layout="mobile"] .lobby__col--rooms { grid-column: 1 / -1; }
}
/* §AW 產品手機直式：暹羅仍遵守既有 hidden 語意；睡貓以安全區＋視窗比例貼近地板。 */
html[data-product="staging"] body[data-layout="mobile"][data-orient="portrait"] .menu__cat--sleeper {
  right: calc(var(--safe-r) + 4vw);
  bottom: calc(var(--safe-b) + 4vh);
  width: min(34vw, 160px);
  transform: translateY(12.14%);
}
/* §AW 橫式仍顯示暹羅，但把可見底緣錨回窗台（保留既有 landscape 顯示語意）。 */
html[data-product="staging"] body[data-layout="mobile"][data-orient="landscape"] .screen--menu {
  --menu-scene-w: max(100vw, 177.777778vh);
  --menu-scene-h: max(56.25vw, 100vh);
}
html[data-product="staging"] body[data-layout="mobile"][data-orient="landscape"] .menu__cat--siamese {
  /* 同一 source (1040, 528)，跟隨手機背景的 70% 30% 裁切。 */
  left: calc(70% - var(--menu-scene-w) * 0.05);
  right: auto;
  top: calc(30% + var(--menu-scene-h) * 0.286666667);
  width: min(20vw, 150px);
  transform: translate(-50%, -97.14%);
}
html[data-product="staging"] body[data-layout="mobile"][data-orient="landscape"] .menu__cat--sleeper {
  right: 26%;
  bottom: calc(var(--safe-b) + 5%);
  width: min(24vw, 180px);
  transform: translateY(12.14%);
}
