/* ============================================================
   7鬼523 横屏原型 · 基础样式（V2 返修版）
   目标：明亮蓝绿桌面 + 高清牌面 + 金色主操作按钮；
        · 640×360 与 844×390 一屏完成创建/准备/牌桌/设置/退出；
        · 一字不换行：按钮、昵称、标签都不许逐字竖排；
        · 竖屏不硬塞牌桌，只保留"横屏玩 / 离开 + 核心状态"的简洁页。
   横竖屏与尺寸分档只认 html[data-*] 标记（见 layout.js）。
   高度预算（360）：顶栏 44 + 状态条 22 + 牌桌 122 + 操作区 56 + 手牌 116
   高度预算（390）：顶栏 46 + 状态条 22 + 牌桌 140 + 操作区 58 + 手牌 124
   ============================================================ */

:root {
  --view-w: 100vw;
  --view-h: 100vh;
  --gold: #f7c33d;
  --gold-d: #dda318;
  --gold-ink: #3b2a05;
  --felt-top: #1a8f80;
  --felt-mid: #12766f;
  --felt-deep: #0b5757;
  --bg-deep: #06333a;
  --ink: #08302f;
  --paper: #f6fbfa;
  --line: rgba(255, 255, 255, 0.16);
  --text: #eafaf6;
  --text-dim: #a9cfc9;
  --danger: #ff6b62;
  --ok: #4fd39a;
  --info: #6fc4ff;
  --radius: 12px;
  --tap: 44px;

  /* 高度预算（可被 data-hband 覆盖） */
  --topbar-h: 44px;
  --notice-h: 22px;
  --action-h: 56px;
  --hand-h: 116px;

  /* 手牌：牌高 ≥100（640×360）/ ≥108（844×390），露出宽度 ≥44 */
  --card-w: 74px;
  --card-h: 108px;
  --card-overlap: 22px;
  --card-lift: 12px;

  /* 出牌区（贴在各家附近）：640 档 42×60、844 档 46×66 */
  --play-card-w: 42px;
  --play-card-h: 60px;
  --play-card-overlap: 24px;
  /* 自己的已出牌在操作栏里：36×52，保留点数与花色 */
  --my-play-card-w: 36px;
  --my-play-card-h: 52px;
  --my-play-card-overlap: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #04262c;
}

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 旋转舞台：模拟横屏时整体旋转 90°（本地坐标 → 屏幕坐标 见 layout.js / scroll-bridge.js） */
#rot {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--view-w);
  height: var(--view-h);
  transform-origin: 0 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -12%, #4ad3bd 0%, #22a795 34%, #14837c 62%, #0b6266 100%),
    var(--bg-deep);
}
#rot::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(closest-side at 50% 118%, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 70%),
    repeating-radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.045) 0 1px, rgba(255, 255, 255, 0) 1px 46px);
  opacity: 0.55;
}

html[data-rotated="true"] #rot {
  transform: translateX(var(--physical-w)) rotate(90deg);
}

#app {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 旋转回退下由 scroll-bridge.js 接管手势，必须关掉原生触摸滚动 */
html[data-rotated="true"] .proto-scroll { touch-action: none; }

.proto-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* ------------------------------------------------------------ 顶栏 */

.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  background: linear-gradient(180deg, rgba(4, 40, 44, 0.92), rgba(4, 40, 44, 0.6));
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.topbar .tb-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
}

.topbar .tb-spacer { flex: 1 1 auto; min-width: 4px; }

.tb-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34%;
}

.tb-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}

.tb-tag.demo { background: rgba(247, 195, 61, 0.18); color: #ffe6a8; border-color: rgba(247, 195, 61, 0.5); }

/* ------------------------------------------------------------ 牌桌顶栏：固定个人信息
  《房间管理与对局体验完善任务书V4》§5.1：本局已得分 / 整场累计 / 第 R 局 · 第 K 轮
  必须一直可见，不新增行高——分数挤进原有 44px（xs）/ 46px（short）顶栏里排成两行。
   我的分数 25
   累计 60 分     第 2/5 局 · 第 8 轮          [管理][上一轮][离开][历史][设置][规则][横屏] */

.table-topbar .tb-scores {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.14;
  min-width: 0;
}
.table-topbar .tb-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
}
/* [hidden] 必须真的隐藏：作者样式会盖掉浏览器默认的 [hidden]{display:none} */
.table-topbar .tb-pill[hidden] { display: none; }
.table-topbar .tb-pill.score-mine {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffe6a8;
  background: rgba(247, 195, 61, 0.2);
  border-color: rgba(247, 195, 61, 0.5);
}
.table-topbar .tb-pill.score-total {
  font-size: 11.5px;
  color: #cdeee8;
  background: transparent;
  border-color: transparent;
}
.table-topbar .tb-pill.progress {
  font-size: 11.5px;
  color: #dcf2ff;
  background: rgba(111, 196, 255, 0.14);
  border-color: rgba(111, 196, 255, 0.36);
  padding: 2px 7px;
}
.table-topbar .tb-pill.spectate-badge {
  font-size: 12px;
  font-weight: 700;
  color: #ffe6a8;
  background: rgba(247, 195, 61, 0.18);
  border-color: rgba(247, 195, 61, 0.5);
  padding: 2px 8px;
}
/* 顶栏里的紧凑入口（上一轮 / 管理）：宽度按内容，但可点范围仍按 44×44 的触摸规范 */
.table-topbar .btn.tb-compact {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 8px;
  font-size: 12.5px;
}
.table-topbar .tb-meta { max-width: 150px; }
/* 640×360：次要房间信息收进固定提示条，保证比分与局/轮一定有位置 */
html[data-hband="xs"] .table-topbar { gap: 3px; padding: 0 5px; }
html[data-hband="xs"] .table-topbar .tb-pill { padding: 0 5px; }
html[data-hband="xs"] .table-topbar .tb-meta { display: none; }

/* 固定提示条里的连接状态：断线时写明时长，绝不无提示地换成 AI */
.ns-conn { flex: 0 0 auto; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ns-conn::before { content: '●'; margin-right: 3px; font-size: 10px; }
.ns-conn[data-state="on"] { color: #9ff0d2; }
.ns-conn[data-state="off"] { color: #ffbdb8; }

/* ------------------------------------------------------------ 按钮 */

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;      /* 按钮文案绝不逐字换行 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, #ffd75e, var(--gold) 55%, var(--gold-d));
  border-color: #ffe9a8;
  color: var(--gold-ink);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}
.btn.ghost { background: rgba(255, 255, 255, 0.04); }
.btn.danger { background: rgba(255, 107, 98, 0.16); border-color: rgba(255, 107, 98, 0.5); color: #ffd9d6; }
.btn[disabled], .btn:disabled { opacity: 0.42; box-shadow: none; }
/* [hidden] 必须真的隐藏：.btn 的 display:inline-flex 是作者样式，
   会盖掉浏览器默认的 [hidden]{display:none}——不写这条，"AI 代出本手"这种
   只在超时时才该出现的按钮会一直占着操作栏的位置 */
.btn[hidden] { display: none; }
.btn.busy { opacity: 0.75; }
.btn.sm { min-height: var(--tap); padding: 0 10px; font-size: 13px; }
.btn.icon-btn { padding: 0 8px; min-width: var(--tap); font-size: 13.5px; }
.btn.wide { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; padding: 0 22px; }

/* ------------------------------------------------------------ 固定提示条 */

.notice-strip {
  flex: 0 0 auto;
  min-height: var(--notice-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px;
  font-size: 12.5px;
  line-height: 1.25;
  background: rgba(3, 28, 32, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}
.notice-strip .ns-main {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notice-strip .ns-side { flex: 0 0 auto; color: var(--text-dim); white-space: nowrap; font-size: 12px; }
.notice-strip[data-level="error"] { background: rgba(120, 24, 24, 0.75); color: #ffd9d6; }
.notice-strip[data-level="warn"] { background: rgba(120, 84, 12, 0.7); color: #ffe9b8; }
.notice-strip[data-level="ok"] { background: rgba(16, 96, 74, 0.7); color: #d6fff0; }
.notice-strip[data-level="info"] { background: rgba(16, 76, 104, 0.6); color: #dcf2ff; }

/* ------------------------------------------------------------ 通用布局 */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.action-bar {
  flex: 0 0 auto;
  min-height: var(--action-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: linear-gradient(180deg, rgba(3, 30, 34, 0.55), rgba(3, 30, 34, 0.9));
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.action-bar .ab-spacer { flex: 1 1 auto; min-width: 4px; }

.panel {
  background: rgba(3, 34, 38, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.panel h3 {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.hint-line { font-size: 12px; color: var(--text-dim); }
.hint-line.warn { color: #ffd9a1; }
.hint-line.err { color: #ffbdb8; }

/* 分段选择 */
.segment { display: inline-flex; gap: 4px; background: rgba(0, 0, 0, 0.2); padding: 3px; border-radius: 12px; }
.segment button {
  min-height: var(--tap);
  min-width: 48px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
}
.segment button[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffd75e, var(--gold));
  color: var(--gold-ink);
  border-color: #ffe9a8;
}

/* 表单：两列紧凑字段 */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; align-content: start; }
.field { display: flex; align-items: center; gap: 6px; min-height: var(--tap); }
.field > label { flex: 0 0 auto; font-size: 12.5px; color: var(--text-dim); min-width: 46px; white-space: nowrap; }
.field .ctl { flex: 1 1 auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
input.ctl-input {
  min-height: var(--tap);
  width: 100%;
  min-width: 0;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-size: 16px; /* 16px 以下 iOS 会自动放大页面 */
  font-family: inherit;
}
input.ctl-input:focus { outline: 2px solid rgba(247, 195, 61, 0.7); outline-offset: 0; }

.readonly-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(247, 195, 61, 0.14);
  border: 1px solid rgba(247, 195, 61, 0.4);
  color: #ffe6a8;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 一行放不下就换行显示的"信息入口"行 */
.info-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 固定可见的一行说明：永远整行显示，绝不露出半行被底栏盖住 */
.reason-row {
  flex: 0 0 auto;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 12px;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(3, 28, 32, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.reason-row .status-main { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reason-row .status-main.warn { color: #ffd9a1; }

/* 竖屏专用入口（横屏时隐藏，避免和顶栏重复） */
.portrait-only { display: none; }
html[data-viewport="portrait"] .portrait-only { display: flex; }

/* ------------------------------------------------------------ 座位卡（等待房间） */

.seats-row {
  flex: 1 1 auto;
  display: grid;
  gap: 8px;
  min-height: 0;
  align-content: start;
}
.seats-row[data-seats="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seats-row[data-seats="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seats-row[data-seats="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.seat-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(3, 34, 38, 0.6);
  border: 1px solid var(--line);
  min-width: 0;
}
.seat-card[data-you="1"] { border-color: rgba(247, 195, 61, 0.6); background: rgba(247, 195, 61, 0.1); }
/* 3～4 人时座位卡竖排：昵称与"左家 · AI 补位"这类说明才不会只露一个字 */
.seats-row[data-seats="3"] .seat-card,
.seats-row[data-seats="4"] .seat-card {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 6px 4px;
}
.seat-card .seat-main { min-width: 0; flex: 1 1 auto; width: 100%; }
.seat-card .nm { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-card .sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-card .state { font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); white-space: nowrap; }
.seat-card .state.ready { background: rgba(79, 211, 154, 0.22); color: #b9ffe2; }
.seat-card .state.waiting { background: rgba(255, 255, 255, 0.12); color: var(--text-dim); }

/* ------------------------------------------------------------ 头像（原创 SVG 素材） */

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(150deg, hsl(var(--seat-hue) 70% 62%), hsl(var(--seat-hue) 65% 40%));
  border: 2px solid rgba(255, 255, 255, 0.55);
  color: #04231f;
  font-weight: 800;
  font-size: 15px;
}
.avatar .av-img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar .av-init { line-height: 1; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; border-width: 2px; }
.avatar.xs { width: 26px; height: 26px; font-size: 12px; border-width: 1.5px; }
.avatar.md { width: 38px; height: 38px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* 座位叫法（左家/对家/右家）：放在头像外面，绝不压在小圆里 */
.role-chip {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1.35;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: #cdeee8;
  white-space: nowrap;
}
.role-chip[data-you="1"] { background: rgba(247, 195, 61, 0.25); color: #ffe6a8; }

/* ------------------------------------------------------------ 牌面 */

.pc {
  position: relative;
  flex: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.pc .pc-art { display: block; width: 100%; height: 100%; object-fit: cover; }
.pc .pc-pts {
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 10px;
  font-weight: 800;
  color: #b8860b;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 6px;
  padding: 0 3px;
}
.pc .pc-joker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  color: #fff;
  background: rgba(180, 20, 20, 0.86);
}
.pc .pc-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  font-weight: 800;
  color: #14231f;
}
.pc .pc-fallback.red { color: #c02626; }
.pc.selectable { cursor: pointer; }
.pc.selected { transform: translateY(calc(-1 * var(--card-lift))); box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(0, 0, 0, 0.4); }
.pc.dim { filter: grayscale(0.35) brightness(0.85); }
.pc.xs { --card-w: 26px; --card-h: 38px; width: 26px; height: 38px; border-radius: 4px; }
.pc.xs .pc-pts, .pc.sm .pc-pts { font-size: 8px; }
.pc.sm { --card-w: 34px; --card-h: 49px; width: 34px; height: 49px; border-radius: 5px; }
.pc.mini { width: 22px; height: 32px; border-radius: 3px; }
/* 比较阶段的大牌：必须能看清点数与花色 */
.pc.cmp { --card-w: 46px; --card-h: 66px; width: 46px; height: 66px; border-radius: 6px; }
.pc.cmp .pc-pts { font-size: 11px; }

/* ------------------------------------------------------------ 手牌（点击 + 左右滑动连选） */

.hand {
  flex: 0 0 auto;
  height: var(--hand-h);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 10px 2px;
  gap: 0;
  overflow: visible;
  touch-action: none;
}
.hand .pc + .pc { margin-left: calc(-1 * var(--card-overlap)); }
/* 手牌只按 DOM 顺序叠放：选中的牌绝不允许盖住后一张露出的那条可点区域，
   否则"沿手牌滑动连选"会在第二张就断掉，被压住的那张也点不回来 */
.hand .pc { z-index: auto; }
.hand-empty { font-size: 13px; color: var(--text-dim); align-self: center; }
/* 滑动连选的可视提示：手指按住第一张后沿手牌拖动 */
.hand.swiping .pc { transition: none; }

/* ------------------------------------------------------------ 弹层 */

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(2, 18, 22, 0.62);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px;
  z-index: 30;
}
.sheet {
  width: min(100%, 560px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, #0d4a4d, #073438);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 14.5px; white-space: nowrap; }
.sheet-hint { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-spacer { flex: 1 1 auto; }
/* 弹层正文必须是可伸缩的滚动区，否则最后一项会被底部操作栏盖住 */
.sheet-body { flex: 1 1 auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.sheet-actions { border-top: 1px solid var(--line); background: rgba(3, 26, 30, 0.92); }

.rule-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.6; color: #dcf3ef; }
.rule-list li { margin-bottom: 6px; }
.rule-note { font-size: 12.5px; color: #ffd9a1; background: rgba(120, 84, 12, 0.32); padding: 6px 8px; border-radius: 8px; }

.history-round { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: rgba(0, 0, 0, 0.18); }
.history-round h4 { margin: 0 0 4px; font-size: 12.5px; color: #ffe6a8; }
.history-line { font-size: 12.5px; color: #dcf3ef; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.history-cards { display: flex; gap: 2px; flex-wrap: wrap; }
.history-seat { font-size: 12px; font-weight: 700; color: #0b2b28; background: #cdeee8; border-radius: 6px; padding: 0 4px; }

.demo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: var(--tap); padding: 7px 9px; text-align: left;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600;
}
.demo-item .dv-note {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  /* 演示台条目多，说明最多两行，否则列表长得要滚好几屏 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.demo-item[aria-pressed="true"] { border-color: var(--gold); background: rgba(247, 195, 61, 0.18); }

.badge-demo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 3px 7px; border-radius: 999px;
  background: rgba(247, 195, 61, 0.18); border: 1px solid rgba(247, 195, 61, 0.5); color: #ffe6a8;
}

.portrait-hint { font-size: 12.5px; color: #ffe6a8; }

/* ------------------------------------------------------------ 竖屏回退页（不塞牌桌） */

.portrait-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 14px 12px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  overflow: hidden;
}
.portrait-panel .pp-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}
.portrait-panel h2 { margin: 0; font-size: 20px; }
.portrait-panel .pp-text { margin: 0; font-size: 13.5px; color: #d6f4ef; line-height: 1.5; max-width: 22em; }
.portrait-panel .pp-status {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(3, 34, 38, 0.62);
  border: 1px solid var(--line);
  font-size: 13.5px;
  text-align: left;
}
.portrait-panel .pp-status .pp-line { display: flex; justify-content: space-between; gap: 8px; }
.portrait-panel .pp-status .pp-k { color: var(--text-dim); font-size: 12.5px; flex: 0 0 auto; }
.portrait-panel .pp-status .pp-v { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portrait-panel .pp-tools {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: auto;
}
.portrait-panel .pp-tools .btn { width: 100%; }

/* 竖屏时：只有竖屏回退页显示，牌桌/手牌/牌桌操作区一律不参与布局 */
html[data-viewport="portrait"] .table-screen .stage,
html[data-viewport="portrait"] .table-screen .hand,
html[data-viewport="portrait"] .table-screen .table-actions { display: none; }
html[data-viewport="portrait"] .table-screen .portrait-panel { display: flex; }
/* 竖屏顶栏只留"离开 + 横屏玩"，其余入口搬到竖屏页里，绝不把按钮挤出屏外 */
html[data-viewport="portrait"] .topbar .tb-secondary { display: none; }
html[data-viewport="portrait"] .topbar .tb-meta { display: none; }
/* 上一轮 / 房间管理只在横屏牌桌上有意义：竖屏时收起，别把比分与局/轮挤出屏外 */
html[data-viewport="portrait"] .table-screen .tb-table-only { display: none; }
/* 竖屏观战标识与竖屏状态页里的"观战中"重复，顶栏让位给比分与局/轮 */
html[data-viewport="portrait"] .topbar .spectate-badge { display: none; }
