/* ============================================================================
   SHUI001 · base.css —— Midnight Ledger 设计系统（frontend-shell）
   ----------------------------------------------------------------------------
   方向：克制、精密、可长期使用的专业扑克产品；深墨底 + 玻璃材质 + 黄铜价值色 + 钴蓝交互。
   规则：全站禁止绿色；系统字体；零外部依赖；所有页面共享本文件的 tokens 与组件类。
   归属：frontend-shell 所有；table.css / pages.css 直接引用本文件 :root 令牌。
   ============================================================================ */

/* ============================================================================
 * 1. 设计令牌（REDESIGN_BRIEF §1；table.css / pages.css 直接引用）
 * ==========================================================================*/
:root {
  /* Ink & surfaces */
  --ink: #08090c;
  --bg: #0a0c10;
  --bg-soft: #0e1116;
  --surface: #12151a;
  --panel: #171b22;
  --panel-2: #1d222a;
  --hairline: rgba(242, 238, 230, .08);
  --hairline-strong: rgba(242, 238, 230, .14);

  /* Text */
  --text: #f2eee6;
  --text-bright: #fbf8f2;
  --text-dim: #a6a29a;
  --text-faint: #6c6862;

  /* Accents */
  --cobalt: #6e8dff;
  --cobalt-hi: #9bb0ff;
  --cobalt-dim: rgba(110, 141, 255, .16);
  --brass: #d8b26b;
  --brass-hi: #eac98d;
  --brass-dim: rgba(216, 178, 107, .14);
  --crimson: #e06f6f;
  --crimson-dim: rgba(224, 111, 111, .14);

  /* Semantic（无绿色） */
  --win: var(--brass);
  --lose: var(--crimson);
  --warn: var(--brass);
  --focus-ring: var(--cobalt-hi);

  /* Shape & elevation */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-float: 0 24px 80px rgba(0, 0, 0, .55), 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-dock: 0 -24px 70px rgba(0, 0, 0, .52);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .18);

  /* Motion */
  --ease-spring: cubic-bezier(.22, .9, .28, 1);
  --ease-out: cubic-bezier(.2, .7, .3, 1);
  --dur-fast: .14s;
  --dur-base: .24s;
  --dur-slow: .42s;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, monospace;
  --track-display: -.035em;
  --track-title: -.02em;
  --track-body: .005em;
  --track-micro: .14em;

  /* Table themes 默认（table.css 用 #table-root[data-felt] 覆盖；此处提供兜底） */
  --felt: #0d1a2b;
  --felt-deep: #08111e;
  --felt-line: rgba(216, 178, 107, .22);
  --rail: #d8b26b;

  /* Layout */
  --page-max: 1280px;
  --gutter: 32px;
  --header-h: 64px;
  --tabbar-h: 64px;
  --control-h: 52px;

  /* —— 旧版兼容别名（table.css / 旧组件过渡期直接可用；值全部映射到 Midight Ledger） —— */
  --surface-2: var(--panel-2);
  --border: var(--hairline-strong);
  --border-soft: var(--hairline);
  --accent: var(--cobalt);
  --accent-strong: var(--cobalt-hi);
  --accent-dim: var(--cobalt-dim);
  --accent-quiet: var(--cobalt-dim);
  --accent-glow: rgba(110, 141, 255, .32);
  --danger: var(--crimson);
  --danger-dim: var(--crimson-dim);
  --radius: 10px;
  --radius-sm: 10px;
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --radius-card: 16px;
  --shadow: var(--shadow-float);
  --felt-2: var(--felt-deep);
  --material: rgba(18, 21, 26, .72);
  --material-strong: rgba(10, 12, 16, .86);
  --material-hairline: var(--hairline);
  --material-highlight: rgba(242, 238, 230, .04);
  --tracking-title: var(--track-title);
  --tracking-body: var(--track-body);
}

/* 牌桌主题兜底（B 的 table.css 也会在 #table-root[data-felt] 上覆盖） */
:root[data-felt="navy"],
#table-root[data-felt="navy"] {
  --felt: #0d1a2b;
  --felt-deep: #08111e;
  --rail: #d8b26b;
  --felt-line: rgba(216, 178, 107, .22);
}
:root[data-felt="oxblood"],
#table-root[data-felt="oxblood"] {
  --felt: #2a1216;
  --felt-deep: #1a090c;
  --rail: #e0bb7d;
  --felt-line: rgba(224, 187, 125, .22);
}
:root[data-felt="graphite"],
#table-root[data-felt="graphite"] {
  --felt: #121417;
  --felt-deep: #0a0c0f;
  --rail: #c9cdd6;
  --felt-line: rgba(201, 205, 214, .2);
}

/* ============================================================================
 * 2. Reset / 基础排版
 * ==========================================================================*/
*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

html,
body { margin: 0; padding: 0; min-height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: var(--track-body);
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

#app { min-height: 100vh; min-height: 100dvh; }

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: var(--track-title);
  line-height: 1.2;
  color: var(--text-bright);
}
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { touch-action: manipulation; }
a { color: var(--cobalt-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
::selection { background: var(--cobalt-dim); color: var(--text-bright); }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 数字等宽：金额/倒计时/统计永不跳动 */
.num,
.hist-pnl,
.settings-value,
.info-value,
.seat-score,
.room-meta,
.online-sub,
.lobby-stats b,
.stack-num { font-variant-numeric: tabular-nums; }
.font-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* 图片加载失败降级（img[data-fallback-hide] 由全局 error 监听加 .img-failed） */
.img-failed { display: none !important; }

/* ============================================================================
 * 3. 屏幕切换
 * ==========================================================================*/
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: screen-in .22s var(--ease-out) backwards;
}
#screen-table { background: var(--ink); }
#screen-table.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  animation: none;
}
#table-root {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
  width: 100%;
}
body[data-screen="table"] { overflow: hidden; }

/* ============================================================================
 * 4. 布局 / 工具类（shell、tutorial、history、table 共用）
 * ==========================================================================*/
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: calc(var(--header-h) * .6 + 16px) var(--gutter) calc(72px + env(safe-area-inset-bottom));
  min-width: 0;
}
.page-narrow { max-width: 920px; }
.page-index {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--text-faint);
}
.page-index::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--hairline-strong);
  flex: 0 0 auto;
}
.page-title {
  font-size: clamp(30px, 3.4vw, 38px);
  font-weight: 700;
  letter-spacing: var(--track-display);
  line-height: 1.08;
  color: var(--text-bright);
}
.page-sub { margin-top: 10px; color: var(--text-dim); font-size: 14px; max-width: 640px; }
.section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: var(--track-title);
  line-height: 1.15;
}
.card-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.micro {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  color: var(--text-faint);
  line-height: 1.2;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; line-height: 1.5; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; overflow-wrap: anywhere; }
.divider {
  height: 1px;
  width: 100%;
  border: 0;
  background: var(--hairline);
  margin: 16px 0;
}
.divider:first-child { margin-top: 0; }
.divider:last-child { margin-bottom: 0; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
 * 5. 按钮 / 图标按钮
 * ==========================================================================*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: .005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out),
    transform .12s var(--ease-spring);
  will-change: transform;
}
.btn:hover:not(:disabled) { background: #242a33; border-color: var(--hairline-strong); }
.btn:active:not(:disabled),
.btn.is-pressed:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn.primary {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: #080a10;
  font-weight: 650;
}
.btn.primary:hover:not(:disabled) { background: var(--cobalt-hi); border-color: var(--cobalt-hi); }
.btn.brass {
  background: transparent;
  border-color: rgba(216, 178, 107, .5);
  color: var(--brass);
}
.btn.brass:hover:not(:disabled) { background: var(--brass-dim); border-color: var(--brass); }
.btn.ghost {
  background: transparent;
  border-color: var(--hairline-strong);
  color: var(--text-dim);
}
.btn.ghost:hover:not(:disabled) { background: rgba(242, 238, 230, .05); color: var(--text); }
.btn.danger {
  background: transparent;
  border-color: rgba(224, 111, 111, .42);
  color: var(--crimson);
}
.btn.danger:hover:not(:disabled) { background: var(--crimson-dim); border-color: var(--crimson); }
.btn.quiet {
  background: rgba(242, 238, 230, .04);
  border-color: var(--hairline);
  color: var(--text-dim);
}
.btn.quiet:hover:not(:disabled) { background: rgba(242, 238, 230, .07); color: var(--text); }
.btn.sm { min-height: 38px; padding: 8px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn.xs { min-height: 32px; padding: 6px 12px; font-size: 12.5px; border-radius: 999px; }
.btn.block { width: 100%; }
.btn.pill { border-radius: 999px; }
.btn.link {
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--cobalt-hi);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.link:hover:not(:disabled) { background: transparent; color: var(--cobalt); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.icon-btn:hover { background: rgba(242, 238, 230, .06); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }

/* ============================================================================
 * 6. 表单
 * ==========================================================================*/
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-label {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-dim);
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.field-hint { font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 13px 15px;
  background: rgba(8, 9, 12, .42);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.4;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-faint); }
.input:hover:not(:disabled),
.select:hover:not(:disabled) { border-color: rgba(242, 238, 230, .22); }
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--cobalt);
  background: rgba(8, 9, 12, .56);
  box-shadow: 0 0 0 4px var(--cobalt-dim);
}
.input:disabled,
.select:disabled { opacity: .5; cursor: not-allowed; }
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; font-variant-numeric: tabular-nums; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select-wrap { position: relative; display: block; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-error {
  color: var(--crimson);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}
.form-error:not(.hidden) { display: block; }
.hint { font-size: 12px; line-height: 1.65; color: var(--text-faint); margin: 0; }
.hint-warn { color: var(--brass); }
.hint-error { color: var(--crimson); }

/* 开关 */
.switch {
  position: relative;
  width: 46px;
  height: 28px;
  min-width: 46px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--panel-2);
  cursor: pointer;
  padding: 0;
  transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform var(--dur-base) var(--ease-spring), background-color var(--dur-base) var(--ease-out);
}
.switch[aria-checked="true"] { background: var(--cobalt); border-color: var(--cobalt); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: #080a10; }

/* ============================================================================
 * 7. 面板 / 徽标 / 头像 / 分段控件
 * ==========================================================================*/
.panel-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 22px;
  min-width: 0;
  box-shadow: var(--shadow-card);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head-copy { min-width: 0; }
.panel-head .section-title { font-size: 20px; }
.panel-head .hint { margin-top: 5px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(242, 238, 230, .04);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge.cobalt { color: var(--cobalt-hi); border-color: rgba(110, 141, 255, .34); background: var(--cobalt-dim); }
.badge.brass { color: var(--brass); border-color: rgba(216, 178, 107, .32); background: var(--brass-dim); }
.badge.crimson { color: var(--crimson); border-color: rgba(224, 111, 111, .32); background: var(--crimson-dim); }
.badge.dim { color: var(--text-faint); }
/* 旧类名兼容（table.js 等仍可能使用；一律映射到无绿配色） */
.badge.grey { color: var(--text-dim); }
.badge.red { color: var(--crimson); border-color: rgba(224, 111, 111, .32); background: var(--crimson-dim); }
.badge.warn { color: var(--brass); border-color: rgba(216, 178, 107, .32); background: var(--brass-dim); }
.badge.cobalt::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cobalt);
  flex: 0 0 auto;
}
.badge.brass::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brass);
  flex: 0 0 auto;
}
.badge.no-dot::before { display: none; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--hairline-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--cobalt-hi);
  flex: 0 0 auto;
  user-select: none;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar.ai { color: var(--brass); }

.version-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(242, 238, 230, .03);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1em;
  line-height: 1.8;
  white-space: nowrap;
  user-select: none;
}

/* 分段控件：内凹底 + 滑动 pill（.is-register 控制登录/注册） */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(8, 9, 12, .42);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
  max-width: 100%;
}
.seg-btn {
  min-height: 38px;
  padding: 7px 16px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.seg-btn:hover { color: var(--text); }
.seg-btn:active { transform: scale(.97); }
.seg-btn.active {
  background: var(--panel-2);
  color: var(--text-bright);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(242, 238, 230, .04);
}

/* 空状态 */
.empty-state {
  padding: 26px 16px 22px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.7;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-md);
  background: rgba(8, 9, 12, .18);
}
.empty-state .empty-art {
  display: block;
  width: min(180px, 52%);
  margin: 0 auto 14px;
  opacity: .55;
  pointer-events: none;
}
.empty-state .empty-title { color: var(--text-dim); font-size: 13.5px; font-weight: 500; }
.empty-state p { margin: 0; }
.online-grid > .empty-state,
.room-list > .empty-state,
.stack > .empty-state { grid-column: 1 / -1; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 状态点 */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(242, 238, 230, .035);
}
.status-dot.status-lobby { background: var(--cobalt); }
.status-dot.status-in_room { background: var(--text-dim); }
.status-dot.status-playing { background: var(--brass); }
.status-dot.status-watching { background: var(--crimson); }

/* ============================================================================
 * 8. 桌面顶栏 / 移动 TabBar / 用户菜单
 * ==========================================================================*/
#app-chrome {
  position: sticky;
  top: 0;
  z-index: 60;
}
#app-chrome[hidden] { display: none; }
body.has-conn-bar #app-chrome { top: calc(32px + env(safe-area-inset-top)); }

.shell-topbar {
  position: relative;
  z-index: 50;
  background: rgba(10, 12, 16, .72);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border-bottom: 1px solid var(--hairline);
  transition: background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
body.is-scrolled .shell-topbar {
  background: rgba(10, 12, 16, .9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
body.has-conn-bar #app { padding-top: calc(32px + env(safe-area-inset-top)); }

.shell-topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}
.shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-align: left;
}
.brand-crest { width: 20px; height: 26px; display: block; object-fit: contain; flex: 0 0 auto; }
.shell-brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-bright);
  line-height: 1;
}
.shell-brand-sub {
  display: block;
  margin-top: 4px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: var(--track-micro);
  color: var(--text-faint);
  text-transform: uppercase;
  line-height: 1;
}
.shell-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.nav-item {
  min-height: 36px;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.nav-item:hover { color: var(--text); background: rgba(242, 238, 230, .05); }
.nav-item:active { transform: scale(.97); }
.nav-item.active { color: var(--text-bright); background: rgba(242, 238, 230, .07); }
.shell-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
  min-width: 0;
}
.conn-dot-mini {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 3px rgba(242, 238, 230, .04);
  flex: 0 0 auto;
}
.conn-dot-mini.open { background: var(--cobalt); }
.conn-dot-mini.warn { background: var(--brass); }
.conn-dot-mini.down { background: var(--crimson); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(242, 238, 230, .03);
  color: var(--text-dim);
  cursor: pointer;
  min-width: 0;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.user-chip:hover { background: rgba(242, 238, 230, .06); border-color: var(--hairline-strong); color: var(--text); }
.user-chip:active { transform: scale(.98); }
.user-chip-name {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.user-chip .caret { width: 14px; height: 14px; color: var(--text-faint); flex: 0 0 auto; }
.user-menu { position: relative; }
.user-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 80;
  width: 230px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  animation: menu-in .18s var(--ease-spring) both;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.user-pop[hidden] { display: none; }
.user-pop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 6px;
  min-width: 0;
}
.user-pop-head-copy { min-width: 0; }
.user-pop-head .name { font-size: 13.5px; font-weight: 600; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-head .handle { font-size: 11.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.user-pop-item:hover { background: rgba(242, 238, 230, .06); color: var(--text); }
.user-pop-item.danger { color: var(--crimson); }
.user-pop-item.danger:hover { background: var(--crimson-dim); }
.user-pop-item svg { width: 17px; height: 17px; opacity: .8; flex: 0 0 auto; }
.user-pop-foot {
  margin-top: 6px;
  padding: 10px 12px 4px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10, 12, 16, .84);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border-top: 1px solid var(--hairline);
}
.mobile-tabbar[hidden] { display: none; }
.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  min-width: 0;
  padding: 6px 2px;
  transition: color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.tabbar-item svg { width: 20px; height: 20px; }
.tabbar-item:active { transform: scale(.94); }
.tabbar-item.active { color: var(--cobalt-hi); }
.tabbar-item span { line-height: 1; }

/* 响应式：移动端用 TabBar，隐藏桌面顶栏 */
@media (max-width: 600px) {
  .shell-topbar { display: none; }
  .mobile-tabbar:not([hidden]) { display: grid; }
}

/* ============================================================================
 * 9. 连接状态条
 * ==========================================================================*/
.conn-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 32px;
  padding: 4px 12px;
  padding-top: calc(4px + env(safe-area-inset-top));
  background: rgba(10, 12, 16, .9);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  font-size: 12px;
  text-align: center;
}
.conn-bar[hidden] { display: none; }
.conn-bar .conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass);
  animation: conn-pulse 1.4s ease-in-out infinite;
  flex: 0 0 auto;
}
.conn-bar .btn.sm { min-height: 24px; padding: 2px 10px; font-size: 12px; border-radius: 999px; }
@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

/* ============================================================================
 * 10. Toast
 * ==========================================================================*/
#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 460px;
  pointer-events: none;
}
.toast {
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  padding: 12px 16px;
  background: rgba(10, 12, 16, .92);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  color: var(--text-bright);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: .004em;
  text-align: left;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring);
}
.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--cobalt);
  flex: 0 0 auto;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-info::before { background: var(--cobalt); }
.toast-warn::before { background: var(--brass); }
.toast-error::before { background: var(--crimson); }
.toast-warn { border-color: rgba(216, 178, 107, .24); }
.toast-error { border-color: rgba(224, 111, 111, .26); }

/* ============================================================================
 * 11. 模态层：桌面 scale+blur / 手机底部 sheet
 * ==========================================================================*/
body.modal-open { overflow: hidden; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(24px); filter: blur(6px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes sheet-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(24px); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 5, 7, .62);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
  animation: backdrop-in .2s var(--ease-out) both;
}
.modal {
  position: relative;
  width: min(580px, 100%);
  max-height: min(86vh, 860px);
  max-height: min(86dvh, 860px);
  display: flex;
  flex-direction: column;
  background: rgba(17, 20, 26, .94);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  backdrop-filter: blur(26px) saturate(1.2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  outline: none;
  animation: modal-in var(--dur-base) var(--ease-spring) both;
}
.modal-wide { width: min(800px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
  flex: 0 0 auto;
}
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -.015em; min-width: 0; overflow-wrap: anywhere; color: var(--text-bright); }
.modal-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.modal-close:hover { background: rgba(242, 238, 230, .06); color: var(--text); }
.modal-close:active { transform: scale(.94); }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; min-height: 0; flex: 1 1 auto; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--hairline);
  background: rgba(8, 9, 12, .24);
  flex: 0 0 auto;
}
.modal-footer .btn { border-radius: 999px; }
.modal-text { color: var(--text-dim); font-size: 14px; line-height: 1.7; margin: 0 0 10px; }
.modal-text:last-child { margin-bottom: 0; }
.modal-backdrop.closing { animation: backdrop-out .16s var(--ease-out) both; }
.modal-backdrop.closing .modal { animation: modal-out .16s var(--ease-out) both; }

/* ============================================================================
 * 12. Auth 分屏
 * ==========================================================================*/
.auth-layout {
  display: grid;
  grid-template-columns: 52fr 48fr;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}
.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 24px;
  padding: 48px;
  overflow: hidden;
  border-right: 1px solid var(--hairline);
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
}
.auth-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .72;
  z-index: 0;
  pointer-events: none;
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(8, 9, 12, .18) 0%, rgba(8, 9, 12, .5) 56%, rgba(8, 9, 12, .94) 100%);
  pointer-events: none;
}
.auth-hero-copy,
.auth-hero-foot { position: relative; z-index: 2; }
.auth-hero-copy .crest { width: 56px; height: 70px; object-fit: contain; margin-bottom: 22px; display: block; }
.auth-display {
  font-size: clamp(50px, 6vw, 72px);
  font-weight: 700;
  letter-spacing: var(--track-display);
  line-height: 1.02;
  color: var(--text-bright);
  margin: 0 0 12px;
}
.auth-tagline {
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 0;
}
.auth-hero-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--text-faint);
}
.auth-hero-foot .micro { color: var(--text-faint); }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 40px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}
.auth-form-wrap {
  width: min(408px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.auth-form-head { margin-bottom: 22px; }
.auth-form-head .section-title { font-size: 26px; }
.auth-form-head .hint { margin-top: 8px; }
.auth-brand-mobile { display: none; }

.tabs {
  position: relative;
  display: flex;
  gap: 0;
  padding: 3px;
  margin: 0 0 22px;
  background: rgba(8, 9, 12, .5);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
  isolation: isolate;
}
.tabs::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 11px;
  background: var(--panel-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(242, 238, 230, .05);
  transform: translateX(0);
  transition: transform var(--dur-base) var(--ease-spring);
  will-change: transform;
}
.tabs.is-register::before { transform: translateX(100%); }
.tab {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.tab:hover { color: var(--text); }
.tab:active { transform: scale(.98); }
.tab.active { color: var(--text-bright); font-weight: 600; }

#auth-form { display: flex; flex-direction: column; gap: 16px; }
#auth-submit { min-height: 52px; margin-top: 4px; border-radius: var(--r-md); font-size: 15px; }
.auth-hint { margin-top: 18px; color: var(--text-faint); font-size: 12px; line-height: 1.65; text-align: center; }
.auth-foot {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.auth-busy { color: var(--text-faint); font-size: 12px; text-align: center; }

/* ============================================================================
 * 13. Lobby
 * ==========================================================================*/
.lobby-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.lobby-head-main { min-width: 0; }
.lobby-title {
  font-size: clamp(32px, 3.8vw, 40px);
  font-weight: 700;
  letter-spacing: var(--track-display);
  line-height: 1.06;
  color: var(--text-bright);
}
.lobby-sub { margin-top: 10px; color: var(--text-dim); font-size: 14px; }
.lobby-stats {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 18px;
  background: rgba(242, 238, 230, .03);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  flex: 0 0 auto;
}
.lobby-stat { display: flex; flex-direction: column; gap: 2px; min-width: 62px; }
.lobby-stat b { font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: var(--text-bright); font-variant-numeric: tabular-nums; }
.lobby-stat span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }

.current-room-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid rgba(216, 178, 107, .28);
  border-radius: var(--r-md);
}
.current-room-banner .grow { min-width: 200px; }
.current-room-banner .name { font-size: 14.5px; font-weight: 600; color: var(--text-bright); }
.current-room-banner .meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 20px;
  align-items: start;
}
.lobby-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.rooms-list { display: flex; flex-direction: column; gap: 10px; }
.room-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: rgba(8, 9, 12, .24);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  min-width: 0;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.room-row:hover { background: var(--panel-2); border-color: var(--hairline-strong); }
.room-row-main { flex: 1 1 240px; min-width: 0; }
.room-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--text-bright);
  overflow-wrap: anywhere;
}
.room-row-meta {
  display: flex;
  align-items: center;
  gap: 4px 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
}
.room-row-meta b { color: var(--text); font-weight: 550; font-variant-numeric: tabular-nums; }
.room-row-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; }

.solo-config { display: flex; flex-direction: column; gap: 16px; }
.quick-seats { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-seats .btn { min-height: 36px; padding: 7px 14px; border-radius: 999px; font-size: 12.5px; }
.blind-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.solo-hint { margin-top: 2px; }

.global-tip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  margin-bottom: 20px;
  background: var(--cobalt-dim);
  border: 1px solid rgba(110, 141, 255, .26);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}
.global-tip .tip-icon { color: var(--cobalt-hi); font-size: 16px; flex: 0 0 auto; }
.global-tip .btn { border-radius: 999px; }

.online-strip {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  min-width: 0;
}
.online-strip-head { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.online-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}
.online-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 6px;
  background: rgba(8, 9, 12, .3);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  min-width: 0;
  max-width: 100%;
}
.online-main { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.online-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); min-width: 0; }
.online-name .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-sub { font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
 * 14. Room
 * ==========================================================================*/
.page-room { padding-bottom: calc(250px + env(safe-area-inset-bottom)); }
.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.room-head-main { min-width: 0; }
.room-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: var(--track-display);
  line-height: 1.1;
  color: var(--text-bright);
  overflow-wrap: anywhere;
}
.room-subline { margin-top: 8px; color: var(--text-faint); font-size: 12.5px; overflow-wrap: anywhere; }
.room-stats {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.info-chip {
  padding: 10px 14px;
  background: rgba(8, 9, 12, .28);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  min-width: 104px;
}
.info-chip .micro { color: var(--text-faint); }
.info-chip b {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
}

.seat-list { display: flex; flex-direction: column; }
.seat-row {
  display: grid;
  grid-template-columns: 34px 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--hairline);
  min-width: 0;
}
.seat-row:last-child { border-bottom: 0; }
.seat-row.empty { opacity: .8; border-bottom-style: dashed; }
.seat-row.self { background: linear-gradient(90deg, rgba(110, 141, 255, .07), transparent 60%); border-radius: var(--r-sm); }
.seat-num {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .06em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.seat-main { min-width: 0; }
.seat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--text-bright);
  min-width: 0;
}
.seat-name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.seat-tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.seat-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.seat-status .status-dot { box-shadow: none; }
.seat-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.seat-empty-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 13px;
}
.seat-empty-label .dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px dashed var(--hairline-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: var(--text-faint);
}

/* 房间底部固定 dock */
.room-dock {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 45;
  width: min(820px, calc(100% - 32px));
  padding: 14px 16px;
  background: rgba(14, 17, 22, .82);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  backdrop-filter: blur(26px) saturate(1.2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-dock), inset 0 1px 0 rgba(242, 238, 230, .05);
}
.room-dock-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-dock .grow { min-width: 160px; }
.room-dock .hint { margin-top: 2px; }
.room-dock-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.ai-add-row .select-wrap { flex: 0 1 190px; min-width: 150px; }
.room-note {
  padding: 12px 16px;
  background: rgba(8, 9, 12, .28);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}
.room-note.playing { border-color: rgba(110, 141, 255, .3); color: var(--text); }

/* ============================================================================
 * 15. Settings
 * ==========================================================================*/
.settings-layout { display: flex; flex-direction: column; gap: 20px; }
.settings-block { padding: 24px; }
.settings-block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.settings-block-head .section-title { font-size: 20px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.settings-row:first-of-type { padding-top: 0; }
.settings-row:last-child { border-bottom: 0; padding-bottom: 0; }
.settings-row-copy { min-width: 0; flex: 1 1 240px; }
.settings-row-copy .label { font-size: 14px; font-weight: 550; color: var(--text); }
.settings-row-copy .desc { margin-top: 3px; font-size: 12.5px; color: var(--text-faint); line-height: 1.55; }
.settings-value { font-size: 13.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.settings-row.is-block { display: block; }
.settings-row-copy.is-block-first { margin-bottom: 12px; }
.pw-form.row-top { margin-top: 10px; }
.row-end { justify-content: flex-end; margin-top: 10px; }
.room-dock-foot { margin-top: 2px; }
#displayname-input { width: 200px; max-width: 100%; }

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
.theme-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: rgba(8, 9, 12, .26);
  cursor: pointer;
  text-align: left;
  color: var(--text-dim);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.theme-option:hover { border-color: var(--hairline-strong); background: rgba(242, 238, 230, .04); }
.theme-option:active { transform: scale(.99); }
.theme-option[aria-pressed="true"] {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt-dim);
  color: var(--text);
}
.theme-preview {
  position: relative;
  height: 74px;
  border-radius: 10px;
  background: var(--sw-felt);
  border: 1px solid var(--sw-rail-line);
  overflow: hidden;
}
.theme-preview::before {
  content: "";
  position: absolute;
  inset: 13px 22px;
  border-radius: 50% / 42%;
  border: 1px solid var(--sw-rail-line);
  background: radial-gradient(120% 90% at 50% 30%, var(--sw-glow) 0%, transparent 62%);
}
.theme-preview::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--sw-rail);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .25);
}
.theme-option[data-theme="navy"] { --sw-felt: #0d1a2b; --sw-rail: #d8b26b; --sw-rail-line: rgba(216, 178, 107, .28); --sw-glow: rgba(216, 178, 107, .12); }
.theme-option[data-theme="oxblood"] { --sw-felt: #2a1216; --sw-rail: #e0bb7d; --sw-rail-line: rgba(224, 187, 125, .28); --sw-glow: rgba(224, 187, 125, .12); }
.theme-option[data-theme="graphite"] { --sw-felt: #121417; --sw-rail: #c9cdd6; --sw-rail-line: rgba(201, 205, 214, .24); --sw-glow: rgba(201, 205, 214, .1); }
.theme-option-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 550; color: var(--text); }
.theme-option-label .check { width: 16px; height: 16px; color: var(--cobalt-hi); opacity: 0; }
.theme-option[aria-pressed="true"] .check { opacity: 1; }
.theme-option .desc { font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }

.avatar-editor { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.avatar-editor .avatar-xl { border-color: var(--hairline-strong); }
.avatar-editor-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.avatar-editor-actions .hint { max-width: 320px; }

.pw-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; align-items: end; }
.pw-form .btn { min-height: var(--control-h); }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================================
 * 16. Profile / History 页面外壳（内容由 C 渲染；A 只提供容器与降级）
 * ==========================================================================*/
.page-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 64px 20px;
  text-align: center;
  color: var(--text-dim);
}
.page-fallback .empty-art { width: min(220px, 60%); opacity: .6; }
.page-fallback h2 { font-size: 22px; }
.page-fallback p { max-width: 420px; font-size: 13.5px; line-height: 1.6; color: var(--text-faint); margin: 0; }

/* ============================================================================
 * 17. 教程 / 历史手牌 / 免责声明（tutorial.js / history.js 复用）
 * ==========================================================================*/
.tutorial-body { min-height: 200px; }
.tut-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tut-title { font-size: 18px; font-weight: 600; letter-spacing: -.015em; color: var(--text-bright); }
.tut-content { color: var(--text-dim); font-size: 14px; line-height: 1.75; }
.tut-content p { margin: 0 0 10px; }
.tut-content p:last-child { margin-bottom: 0; }
.tut-list { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.tut-list li::marker { color: var(--cobalt-hi); }
.tut-content b { color: var(--text); }
.tut-note {
  margin-top: 10px;
  padding: 10px 13px;
  background: rgba(8, 9, 12, .3);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--brass);
  border-radius: var(--r-sm);
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.7;
}
.tut-formula {
  margin: 8px 0 12px;
  padding: 14px;
  background: rgba(8, 9, 12, .3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--brass);
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}
.tut-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.tut-dot {
  width: 10px; height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--hairline-strong);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.tut-dot:hover { background: var(--text-faint); }
.tut-dot.active { background: var(--cobalt); transform: scale(1.22); }
.tut-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; width: 100%; }
.hand-rank-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0 10px; }
.hand-rank-table th,
.hand-rank-table td { padding: 8px; border-bottom: 1px solid var(--hairline); text-align: left; vertical-align: top; }
.hand-rank-table th { color: var(--text); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.hand-rank-table td { overflow-wrap: anywhere; color: var(--text-dim); }
.hand-rank-table tr:last-child td { border-bottom: 0; }
.hand-rank-table td:first-child { white-space: nowrap; color: var(--brass); font-weight: 550; }

.hist-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  background: rgba(8, 9, 12, .28);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  min-width: 0;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.hist-item:hover { background: var(--panel-2); border-color: var(--hairline-strong); }
.hist-main { min-width: 0; flex: 1 1 auto; }
.hist-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.hist-room { font-size: 14px; font-weight: 600; letter-spacing: -.005em; overflow-wrap: anywhere; color: var(--text-bright); }
.hist-title .badge { font-size: 11px; padding: 1px 7px; }
.hist-meta { margin-top: 4px; display: flex; align-items: center; gap: 3px 10px; flex-wrap: wrap; color: var(--text-faint); font-size: 12px; line-height: 1.6; }
.hist-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.hist-pnl { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.hist-pnl.plus { color: var(--brass); }
.hist-pnl.minus { color: var(--crimson); }
.hist-side .btn { border-radius: 999px; }
.hist-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.8;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-md);
}
.hist-empty .empty-art { display: block; width: min(180px, 54%); margin: 0 auto 12px; opacity: .55; }
.hist-empty p { margin: 0; }

.disclaimer { display: flex; flex-direction: column; gap: 10px; }
.disclaimer p { color: var(--text-dim); font-size: 14px; line-height: 1.8; }
.announce-list {
  margin: 6px 0 12px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.65;
}
.announce-list li::marker { color: var(--brass); }
.announce-list b { color: var(--text); }

/* ============================================================================
 * 18. 牌桌加载占位（table.js 未就绪时）
 * ==========================================================================*/
.table-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
}
.table-placeholder p { max-width: 420px; font-size: 14px; line-height: 1.7; margin: 0; white-space: pre-line; }
.placeholder-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 15px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: rgba(242, 238, 230, .03);
  color: var(--brass);
  font-size: 13px;
  letter-spacing: .12em;
}

/* ============================================================================
 * 18b. P1：Hash 深链 / 邀请二维码 / 帮助侧栏 / 术语 tooltip / 返回牌桌
 * ==========================================================================*/
/* 术语：hover/focus/触屏点击显示统一 tooltip；.term 提供虚点下划线 */
[data-glossary] { cursor: help; }
.term,
.help-term-name {
  text-decoration: underline dotted rgba(242, 238, 230, .32);
  text-underline-offset: 3px;
}
.term:hover { color: var(--text-bright); text-decoration-color: var(--cobalt-hi); }
.glossary-tip {
  position: fixed;
  z-index: 400;
  max-width: 288px;
  padding: 10px 13px;
  background: rgba(10, 12, 16, .96);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-float);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.6;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .14s var(--ease-out), transform .14s var(--ease-out);
}
.glossary-tip[hidden] { display: none; }
.glossary-tip.show { opacity: 1; transform: translateY(0); }
.glossary-tip b {
  display: block;
  margin-bottom: 2px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-bright);
}
.glossary-tip span { display: block; }

/* 房间头部操作（邀请/帮助） */
.room-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.room-head-actions .btn svg { width: 16px; height: 16px; }

/* 邀请模态：链接 + 二维码 */
.invite-room-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(8, 9, 12, .3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-size: 13.5px;
}
.invite-room-line b { color: var(--text-bright); }
.invite-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.invite-link-row .input { flex: 1 1 260px; min-width: 0; font-size: 13px; }
.invite-link-row .btn { flex: 0 0 auto; }
.invite-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: rgba(8, 9, 12, .3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.invite-qr-wrap canvas {
  display: block;
  width: min(200px, 60vw);
  height: auto;
  border-radius: 8px;
  background: #fbf8f2;
  image-rendering: pixelated;
}
.invite-qr-fallback { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; text-align: center; }
.invite-note { margin-top: 12px; }
.invite-note code {
  font-family: var(--font-num);
  font-size: 11.5px;
  color: var(--brass);
  overflow-wrap: anywhere;
}

/* 返回牌桌悬浮按钮（从牌桌跳到战绩/设置后仍可一键回到进行中的牌局） */
.return-table-fab {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(110, 141, 255, .5);
  background: rgba(14, 17, 22, .9);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: var(--shadow-float);
  color: var(--text-bright);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), transform .12s var(--ease-spring);
}
.return-table-fab[hidden] { display: none; }
.return-table-fab:hover { background: var(--cobalt-dim); }
.return-table-fab:active { transform: scale(.97); }
.return-table-fab svg { width: 18px; height: 18px; color: var(--cobalt-hi); }
@media (max-width: 600px) {
  .return-table-fab { right: 14px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); min-height: 44px; padding: 10px 16px; }
}

/* 帮助侧栏 */
body.help-open { overflow: hidden; }
.help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(4, 5, 7, .52);
  -webkit-backdrop-filter: blur(6px) saturate(1.1);
  backdrop-filter: blur(6px) saturate(1.1);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
.help-backdrop[hidden] { display: none; }
.help-backdrop.open { opacity: 1; }
.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 220;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--hairline-strong);
  box-shadow: -24px 0 70px rgba(0, 0, 0, .5);
  transform: translateX(24px);
  opacity: 0;
  transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-base) var(--ease-out);
}
.help-panel[hidden] { display: none; }
.help-panel.open { transform: translateX(0); opacity: 1; }
.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--hairline);
}
.help-head .section-title { font-size: 21px; margin-top: 4px; }
.help-close { font-size: 22px; line-height: 1; }
.help-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  min-height: 0;
}
.help-section { padding: 0 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--hairline); }
.help-section:last-of-type { border-bottom: 0; }
.help-section h3 { margin: 4px 0 10px; font-size: 17px; letter-spacing: -.01em; }
.help-section p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.7; color: var(--text-dim); }
.help-section p:last-child { margin-bottom: 0; }
.help-terms { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 12px; }
.help-term { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.help-term-name { font-size: 13px; font-weight: 600; color: var(--text-bright); }
.help-term-desc { font-size: 12.5px; line-height: 1.6; color: var(--text-dim); }
.help-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.help-list kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-right: 4px;
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  background: rgba(8, 9, 12, .4);
  color: var(--text-bright);
  font-family: var(--font-num);
  font-size: 11px;
  text-align: center;
}
.help-rank-table { font-size: 12px; margin: 0 0 10px; }
.help-rank-table th, .help-rank-table td { padding: 6px 6px; }
.help-footer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
@media (max-width: 600px) {
  .help-panel { width: 100%; border-left: 0; transform: translateY(18px); }
  .help-panel.open { transform: translateY(0); }
  .help-head { padding: 18px 16px 12px; }
  .help-body { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .help-term { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* ============================================================================
 * 19. 桌面 hover 精致化（精确指针）
 * ==========================================================================*/
@media (hover: hover) and (pointer: fine) {
  .panel-card { transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring); }
  .panel-card:hover { border-color: var(--hairline-strong); }
  .lobby-col > .panel-card:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0, 0, 0, .22), 0 16px 40px rgba(0, 0, 0, .3); }
}

/* ============================================================================
 * 20. 响应式：≤1023（平板）
 * ==========================================================================*/
@media (max-width: 1023px) {
  :root { --gutter: 24px; }
  .lobby-layout { grid-template-columns: minmax(0, 1fr); }
  .lobby-stats { gap: 16px; padding: 10px 14px; }
  .auth-hero { padding: 36px; }
  .auth-panel { padding: 44px 28px; }
  .shell-topbar-inner { gap: 16px; }
  .nav-item { padding: 8px 12px; }
  .pw-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============================================================================
 * 21. 响应式：≤600（手机）
 * ==========================================================================*/
@media (max-width: 600px) {
  :root { --gutter: 16px; --header-h: 56px; --control-h: 50px; }
  body { font-size: 14px; }
  .page { padding-top: 22px; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  body[data-screen="lobby"],
  body[data-screen="room"],
  body[data-screen="profile"],
  body[data-screen="history"],
  body[data-screen="settings"] { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

  .page-title { font-size: 30px; }
  .page-index { margin-bottom: 10px; }
  .lobby-title { font-size: 32px; }
  .lobby-head { gap: 16px; margin-bottom: 20px; }
  .lobby-stats { width: 100%; justify-content: space-between; }
  .lobby-stat { min-width: 0; }
  .lobby-stat b { font-size: 16px; }
  .panel-card { padding: 16px 14px; border-radius: var(--r-md); }
  .panel-head { margin-bottom: 14px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .btn.sm { min-height: 44px; padding: 9px 14px; font-size: 13px; }
  .seg-btn { min-height: 44px; padding: 8px 14px; }
  .room-row { flex-direction: column; align-items: stretch; }
  .room-row-main { flex: 0 0 auto; }
  .room-row-actions { justify-content: flex-end; }
  .room-row-actions .btn { flex: 1 1 auto; }
  .quick-seats .btn { min-height: 44px; }

  /* auth：单列，顶部窄插画条 */
  .auth-layout { grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
  .auth-hero {
    min-height: 0;
    height: 208px;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
    justify-content: flex-end;
    gap: 12px;
  }
  .auth-hero-img { opacity: .6; }
  .auth-hero::after { background: linear-gradient(180deg, rgba(8, 9, 12, .12) 0%, rgba(8, 9, 12, .82) 100%); }
  .auth-hero-copy .crest { display: none; }
  .auth-display { font-size: 38px; margin-bottom: 4px; }
  .auth-tagline { font-size: 12.5px; }
  .auth-hero-foot { display: none; }
  .auth-panel { min-height: 0; padding: 24px 16px calc(28px + env(safe-area-inset-bottom)); align-items: flex-start; }
  .auth-form-wrap { width: 100%; }
  .auth-form-head .section-title { font-size: 23px; }

  /* room：dock 贴底全宽 */
  .room-dock {
    width: 100%;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    transform: none;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding: 14px 14px;
  }
  .page-room { padding-bottom: calc(340px + env(safe-area-inset-bottom)); }
  .room-head { gap: 14px; }
  .room-stats { gap: 6px; }
  .info-chip { flex: 1 1 calc(33.333% - 6px); min-width: 0; padding: 9px 12px; }
  .info-chip b { font-size: 15px; }
  .seat-row { grid-template-columns: 24px 40px minmax(0, 1fr); row-gap: 8px; padding: 12px 2px; }
  .seat-row .seat-status { grid-column: 2 / -1; }
  .seat-row .seat-actions { grid-column: 2 / -1; justify-content: flex-start; }
  .seat-row .avatar { justify-self: start; }
  .seat-num { text-align: left; }
  .room-dock .btn { flex: 1 1 auto; }
  .room-dock .ai-add-row .select-wrap { flex: 1 1 100%; }

  /* settings */
  .settings-block { padding: 18px 14px; }
  .theme-picker { grid-template-columns: minmax(0, 1fr); }
  .theme-preview { height: 64px; }
  .pw-form { grid-template-columns: minmax(0, 1fr); }
  .avatar-editor { gap: 14px; }
  .settings-row { align-items: flex-start; }
  .settings-row > .btn,
  .settings-row > .switch,
  .settings-row > .seg { margin-top: 2px; }

  .toast { border-radius: var(--r-lg); }
  #toast-root {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
    max-width: calc(100% - 24px);
  }
  body[data-screen="auth"] #toast-root,
  body[data-screen="table"] #toast-root { bottom: calc(20px + env(safe-area-inset-bottom)); }

  /* modal sheet */
  .modal-backdrop { align-items: flex-end; padding: 0; background: rgba(4, 5, 7, .56); }
  .modal,
  .modal-wide {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    box-shadow: var(--shadow-dock);
    animation: sheet-in var(--dur-base) var(--ease-spring) both;
  }
  .modal-backdrop.closing .modal { animation: sheet-out .16s var(--ease-out) both; }
  .modal::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: rgba(242, 238, 230, .16);
    pointer-events: none;
  }
  .modal-head { padding: 20px 16px 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1 1 auto; }
  .tut-footer { flex-direction: column-reverse; align-items: stretch; }
  .tut-footer .row { width: 100%; }
  .tut-footer .row .btn { flex: 1 1 0; }
  .tut-footer > .btn { width: 100%; }
  .hist-item { align-items: flex-start; }
  .hist-side { flex-direction: row; align-items: center; gap: 8px; }
  .hand-rank-table { font-size: 12px; }
  .hand-rank-table th, .hand-rank-table td { padding: 7px 5px; }
  .hand-rank-table td:first-child { white-space: normal; }
  .user-pop { position: fixed; right: 12px; top: 64px; }
}

/* ============================================================================
 * 22. 响应式：横屏 / 低高度
 * ==========================================================================*/
@media (max-height: 560px) and (orientation: landscape) {
  .page { padding-top: 16px; }
  .lobby-title { font-size: 30px; }
  .auth-hero { height: 100vh; min-height: 0; padding: 24px; }
  .auth-display { font-size: 40px; }
  .auth-panel { padding: 18px 24px; min-height: 0; }
  .auth-form-head .section-title { font-size: 22px; }
  .auth-hint { margin-top: 10px; }
  .modal { max-height: 94vh; max-height: 94dvh; }
}

/* ============================================================================
 * 23. 触摸目标
 * ==========================================================================*/
@media (pointer: coarse) {
  .btn,
  .btn.sm,
  .btn.xs { min-height: 44px; }
  .quick-seats .btn { min-height: 44px; }
  .seg-btn,
  .tab,
  .nav-item,
  .tabbar-item { min-height: 44px; }
  .seat-actions .btn { min-height: 44px; }
  .user-chip { height: 44px; }
  .shell-brand { min-height: 44px; }
  .theme-option { min-height: 44px; }
  /* 开关：视觉保持精致，但命中区域放大到 44px */
  .switch { width: 54px; height: 44px; }
  .switch::after { top: 9px; left: 4px; width: 26px; height: 26px; }
  .switch[aria-checked="true"]::after { transform: translateX(20px); }
}

/* ============================================================================
 * 24. 无障碍降级：动效 / 透明 / 对比
 * ==========================================================================*/
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .screen.active { animation: none; }
  .modal,
  .modal-wide { animation: backdrop-in .2s ease both !important; }
  .modal-backdrop { animation: none; }
  .modal-backdrop.closing { animation: backdrop-out .16s ease both; }
  .modal-backdrop.closing .modal { animation: backdrop-out .16s ease both; }
  .toast { transition: opacity .2s ease; transform: none; }
  .btn:active:not(:disabled),
  .btn.is-pressed:not(:disabled),
  .icon-btn:active,
  .nav-item:active,
  .tab:active,
  .tabbar-item:active,
  .seg-btn:active,
  .theme-option:active { transform: none; }
  .tabs::before { transition: none; }
  .conn-bar .conn-dot { animation: none; }
}
/* 用户在设置里选择“减少动效”（即时生效，无需重启） */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
:root[data-motion="reduced"] .screen.active { animation: none; }

@media (prefers-reduced-transparency: reduce) {
  .shell-topbar,
  .mobile-tabbar,
  .room-dock,
  .toast,
  .conn-bar,
  .modal,
  .auth-form-wrap {
    background: var(--bg-soft);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .modal-backdrop { background: rgba(4, 5, 7, .84); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  .panel-card,
  .room-row,
  .seat-row,
  .settings-row,
  .theme-option,
  .info-chip,
  .global-tip,
  .online-strip,
  .current-room-banner { border-color: var(--hairline-strong); }
  .shell-topbar,
  .mobile-tabbar,
  .room-dock,
  .modal { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--hairline-strong); }
  .muted,
  .hint,
  .online-sub,
  .hist-meta,
  .settings-row-copy .desc { color: var(--text-dim); }
}

@media print {
  #app-chrome,
  .mobile-tabbar,
  .conn-bar,
  #toast-root { display: none !important; }
}
