/* 财富流沙盘 · 网页版「账簿」视觉系统
 *
 * 色板沿用小程序那版（game2/app.wxss），一处改全都改：
 *   纸底 #F3EEE2   纸卡 #FBF7EC   表格线 #DFD4BE
 *   主墨 #17241F   次墨 #5E5A4E   弱墨 #918B7C
 *   印红 #A8322A   赭金 #A2762A
 *
 * 与小程序那版的两个差别：
 *   1. 单位用 px（1px ≈ 2rpx），网页不需要 rpx 那套缩放
 *   2. UI 是浮在 3D 画布上的，所以全部用半透明纸卡 + 细墨线，
 *      不做整块不透明面板 —— 挡住棋盘就看不见路了
 */

:root {
  --paper: #F3EEE2;
  --card: #FBF7EC;
  --line: #DFD4BE;
  --ink: #17241F;
  --ink-2: #5E5A4E;
  --ink-3: #918B7C;
  --seal: #A8322A;
  --gold: #A2762A;
  --shadow: 0 2px 10px rgba(80, 62, 36, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  /* 手机上滚动到底会带动整页（橡皮筋），全屏时表现为画面上下抖一下 */
  overscroll-behavior: none;
  /* 横屏时刘海会压到左边，靠 safe-area 让位而不是靠 body 留白 */
  -webkit-text-size-adjust: 100%;
}

/* 视口高度要用 dvh 而不是 vh。
 * vh 在手机上按「地址栏收起后」的高度算，于是地址栏在的时候，
 * 页面底部会被推到屏幕外面去 —— 表现为底部按钮看不见、要往下滑一下才有，
 * 而你又滑不动（overflow:hidden）。dvh 跟着可视高度实时变。 */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  background:
    repeating-linear-gradient(to bottom,
      rgba(23, 36, 31, .028) 0 1px, transparent 1px 40px),
    radial-gradient(120% 90% at 50% 42%, #F6F1E6 0%, #EFE8D8 62%, #DCD2BA 100%);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

#c {
  display: block;
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
}

/* 同上：地址栏在的时候 100vh 会把画布撑出屏幕，
   计算出来的宽高比跟着错，棋盘上下两圈就被裁掉了 */
@supports (height: 100dvh) {
  #c { height: 100dvh; }
}

/* 全屏 / 装到主屏之后浏览器不给任何 UI，画布正好铺满整块屏幕。
   这里不用再改尺寸，只把背景色对齐，避免退出全屏那一下闪白 */
:fullscreen, :webkit-full-screen {
  background: var(--paper);
}

/* ---------- 顶部 ---------- */
.hud {
  position: fixed;
  z-index: 10;
  left: 16px;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  background: rgba(251, 247, 236, .88);
  backdrop-filter: blur(8px);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  transition: opacity .28s ease;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.who-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--ink-3);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .7) inset;
}

.who-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
}

.who-role {
  font-size: 12px;
  color: var(--ink-3);
}

.ledger {
  display: flex;
  gap: 20px;
  flex: 1;
}

.acc { display: flex; flex-direction: column; gap: 1px; }

.acc .k {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: .5px;
}

.acc .v {
  font-size: 16px;
  font-weight: 600;
}

.turn {
  font-size: 12px;
  color: var(--ink-2);
  flex-shrink: 0;
}

.turn .sep { margin: 0 6px; color: var(--line); }

/* ---------- 日志 ---------- */
.logbox {
  position: fixed;
  z-index: 10;
  right: 16px;
  top: 86px;
  width: 250px;
  max-height: 44vh;
  display: flex;
  flex-direction: column;
  background: rgba(251, 247, 236, .82);
  backdrop-filter: blur(6px);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: opacity .28s ease;
}

.log-head {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--gold);
  padding: 8px 12px 6px;
  border-bottom: 1px dashed var(--line);
  flex-shrink: 0;
}

.log-body {
  overflow-y: auto;
  padding: 6px 12px 10px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
}

.log-row {
  padding: 3px 0;
  border-bottom: 1px dotted rgba(223, 212, 190, .7);
}

.log-row:last-child { border-bottom: 0; }

.log-row.good { color: #2F6B4F; }
.log-row.bad { color: var(--seal); }

/* ---------- 操作 ---------- */
.ops {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(251, 247, 236, .9);
  backdrop-filter: blur(8px);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  transition: opacity .28s ease;
}

.dice {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--card);
  font-variant-numeric: tabular-nums;
}

/* 骰子滚动的这段时间，面板跟着抖一下。
 * 不抖的话，屏幕上是一枚骰子在三维空间里翻，底部这个小方块却纹丝不动，
 * 眼睛会觉得「那两处不是同一个东西」。 */
.dice.rolling {
  border-color: var(--gold);
  color: var(--gold);
  animation: dice-jitter .14s linear infinite;
}

@keyframes dice-jitter {
  0%   { transform: translateY(0) rotate(-1.5deg); }
  50%  { transform: translateY(-1.5px) rotate(1.5deg); }
  100% { transform: translateY(0) rotate(-1.5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .dice.rolling { animation: none; }
}

.btn {
  font: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  padding: 11px 26px;
  border-radius: 5px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn.primary {
  background: var(--ink);
  color: #F7F2E6;
}

.btn.ghost {
  border-color: var(--line);
  color: var(--ink-2);
}

.btn:disabled {
  opacity: .38;
  cursor: default;
}

/* 文案在「掷骰 / 推进中 / 结算中」之间来回换，不定宽按钮会左右抽动 */
#btnRoll { min-width: 116px; }

/* ---------- AI 主持人 ----------
 * 回合不再由玩家点「结束」推进，节奏在它手里。所以它得一直看得见：
 * 一条常驻字幕，说明「现在是谁、正在发生什么」。
 * 没有这条，自动推进和界面卡死长得一模一样。
 */
.narration {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(760px, calc(100vw - 32px));
  padding: 7px 16px;
  background: rgba(23, 36, 31, .9);
  color: #F3EEDF;
  border-radius: 20px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(23, 36, 31, .18);
  pointer-events: none;
  transition: opacity .28s ease;
}

.narration .n-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #D8B45E;
  flex-shrink: 0;
  animation: n-pulse 1.6s ease-out infinite;
}

/* 停着等玩家决策时点不闪 —— 闪代表「正在推进」 */
.narration[data-busy="0"] .n-dot { animation: none; opacity: .5; }

@keyframes n-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(216, 180, 94, .5); }
  70%  { box-shadow: 0 0 0 7px rgba(216, 180, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(216, 180, 94, 0); }
}

.narration .n-who {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #D8B45E;
  flex-shrink: 0;
}

.narration .n-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 抽卡舞台 ----------
 * 落格要抽卡时全屏铺开。一个人抽卡，桌上其他人也得看清牌面，
 * 所以牌比任何 HUD 都大，而且翻面之前绝不露出内容。
 *
 * 两层 3D：
 *   .c3d     管「抽出来」这段位移（抬起、悬停）
 *   .flipper 管「翻面」这段旋转（preserve-3d，正反两面背靠背）
 * 拆开是因为两者时长不同、缓动也不同，揉成一个 transform 会互相打架。
 */
.stage {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
}

.stage.on { display: flex; }

.stage-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(52% 46% at 50% 45%, rgba(24, 38, 32, .82) 0%, rgba(11, 18, 15, .95) 76%),
    radial-gradient(30% 24% at 50% 44%, rgba(210, 172, 96, .14), transparent 70%);
  opacity: 0;
  transition: opacity .3s ease;
}

.stage.on .stage-veil { opacity: 1; }

.stage[data-phase="wait"] { cursor: pointer; }

/* 抽卡时把棋盘外的界面全部退场。
   牌要「所有人都看得见」，那就不能有 HUD 和按钮在旁边抢注意力，
   也不能让底部字幕和抽牌提示叠在一起 */
body.staging .hud,
body.staging .logbox,
body.staging .ops,
body.staging .sheet,
body.staging .ptags,
body.staging .narration {
  opacity: 0;
  pointer-events: none;
}

.stage-mid {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 牌堆：只是两张错位的牌背，不额外画纹理 —— 顶牌抽走后
 * 这两张留在原位，说明「牌堆还在」，比一整叠假牌省事也更像桌上真东西 */
.pile { position: relative; }

.pile-under {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(160deg, #1E3A31, #14251F 60%, #1B342B);
  border: 1px solid rgba(200, 164, 90, .38);
  box-shadow: 0 16px 30px rgba(8, 14, 12, .32);
}

/* 错位要够大才看得出是「一叠」。5px 那种只会在边缘露出头发丝宽的一条，
   远看像渲染毛边 */
.pile-under.u1 { transform: translate(11px, 15px) rotate(1.8deg); opacity: .95; }
.pile-under.u2 { transform: translate(21px, 29px) rotate(3.6deg); opacity: .7; }

.pile.no-stack .pile-under { display: none; }

.c3d {
  --cw: min(360px, 60vw, 50vh);
  --cardhue: var(--seal);
  --cardhue-soft: #F3E3DF;
  position: relative;
  width: var(--cw);
  /* 1.34 比扑克牌的 1.4 矮一点：我们的牌面常常只有两三行字，
     按扑克比例会空出小半张，看着像"没印完" */
  height: calc(var(--cw) * 1.34);
  perspective: 1500px;
  transform-style: preserve-3d;
}

/* 牌面配色按卡类走。同一套色板，只换那一根线和一个浅底色块 */
.c3d[data-tone="red"]   { --cardhue: #A8322A; --cardhue-soft: #F5E4E0; }
.c3d[data-tone="gold"]  { --cardhue: #A2762A; --cardhue-soft: #F5EBD7; }
.c3d[data-tone="green"] { --cardhue: #2F6B4F; --cardhue-soft: #E3EEE7; }
.c3d[data-tone="ink"]   { --cardhue: #33403A; --cardhue-soft: #E8E5DB; }

/* 光晕必须待在牌后面。
   它和牌面一样在 z=0，牌翻到位时两者共面，Chromium 会挑一半赢一半，
   于是牌面被劈成「左半亮右半暗」。translateZ 把它压到牌后面 6px，
   顺带去掉 filter —— filter 会让这个元素自己扁平化，z 排序更不可控。 */
.aura {
  position: absolute;
  inset: -16%;
  border-radius: 22%;
  background: radial-gradient(42% 42% at 50% 50%, rgba(214, 176, 98, .55), rgba(214, 176, 98, .12) 58%, rgba(214, 176, 98, 0) 78%);
  transform: translateZ(-6px);
  opacity: .22;
  transition: opacity .55s ease;
  pointer-events: none;
}

.c3d.lifted .aura,
.c3d.flipped .aura { opacity: 1; }

.flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
  backface-visibility: hidden;
  transition: transform .78s cubic-bezier(.32, .86, .26, 1);
}

.c3d.flipped .flipper { transform: rotateY(180deg); }

/* 这里不能写 overflow:hidden。
   它会让 Chromium 把这个面当成扁平层栅格化，两个面挤在同一 z 平面上，
   翻到中途就会出现「左半是正面、右半是背面」的硬接缝。
   裁剪交给各面自己的内边距和圆角去做。 */
.face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 22px 46px rgba(9, 15, 13, .45);
}

/* 牌背：深墨绿 + 细斜纹 + 金线双框 + 印章 */
.face-back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .04) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #1E3A31, #14251F 58%, #1B342B);
  border: 2px solid rgba(200, 164, 90, .55);
  display: grid;
  place-items: center;
}

.bk-frame {
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(200, 164, 90, .42);
  border-radius: 6px;
}

.bk-frame::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(200, 164, 90, .16);
  border-radius: 4px;
}

.bk-seal {
  width: 4.6em;
  height: 4.6em;
  display: grid;
  place-items: center;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: calc(var(--cw) * .062);
  color: #D8B45E;
  border: 2px solid rgba(216, 180, 94, .8);
  border-radius: 4px;
  letter-spacing: 0;
  box-shadow: 0 0 24px rgba(216, 180, 94, .18) inset;
}

.bk-word {
  position: absolute;
  bottom: 8%;
  font-size: calc(var(--cw) * .031);
  letter-spacing: .5em;
  color: rgba(216, 180, 94, .6);
  text-indent: .5em;
}

/* 牌面：纸底、顶部一根色条，标题用宋体拉出「牌」的分量 */
.face-front {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #FDFAF1 0%, #F5EDDC 100%);
  border: 1px solid #C9B791;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: calc(var(--cw) * .058) calc(var(--cw) * .055) 0;
}

.face-front::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: var(--cardhue);
  border-radius: 9px 9px 0 0;
}

.ff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: calc(var(--cw) * .028);
}

.ff-tag {
  font-size: calc(var(--cw) * .032);
  letter-spacing: .28em;
  color: var(--cardhue);
  border: 1px solid var(--cardhue);
  border-radius: 2px;
  padding: 2px 7px 2px 9px;
  flex-shrink: 0;
}

.ff-owner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: calc(var(--cw) * .03);
  color: var(--ink-3);
  min-width: 0;
}

.ff-owner i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8) inset;
}

.ff-title {
  margin: 0 0 calc(var(--cw) * .034);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: calc(var(--cw) * .072);
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: .02em;
}

/* 内容常常只有两三行，撑不满 1.4 比例的牌。
   靠上排，空白全留在下方 —— 牌面的留白应该像信纸，不该在标题和正文之间
   挖一个洞（垂直居中就是这个效果，试过，很怪）。 */
.ff-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.ff-desc {
  margin: 0 0 calc(var(--cw) * .036);
  font-size: calc(var(--cw) * .037);
  line-height: 1.85;
  color: var(--ink-2);
}

.ff-rule {
  margin: 0;
  padding: calc(var(--cw) * .032) calc(var(--cw) * .036);
  font-size: calc(var(--cw) * .035);
  line-height: 1.8;
  color: var(--ink-2);
  background: var(--cardhue-soft);
  border-left: 3px solid var(--cardhue);
  border-radius: 0 4px 4px 0;
}

.ff-rule:empty { display: none; }

.ff-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--cw) * .095);
  margin-top: calc(var(--cw) * .028);
  border-top: 1px dashed #DCCFB4;
  font-size: calc(var(--cw) * .027);
  letter-spacing: .16em;
  color: var(--ink-3);
}

/* 牌面水印。一张卡常常只有两三行字，1.4 比例的牌会空出大半张；
   竖排一个淡色类别字压在那儿，留白就成了「牌面纹样」而不是「没排满」 */
.ff-mark {
  position: absolute;
  right: calc(var(--cw) * .04);
  bottom: calc(var(--cw) * .035);
  z-index: 0;
  writing-mode: vertical-rl;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: calc(var(--cw) * .24);
  line-height: 1;
  letter-spacing: .1em;
  color: var(--cardhue);
  opacity: .07;
  pointer-events: none;
}

.ff-head,
.ff-title,
.ff-body,
.ff-foot { position: relative; z-index: 1; }

/* 抽牌：从牌堆里抬起来，带一点惯性，停住等翻面 */
.c3d.deal { animation: card-deal .54s cubic-bezier(.18, .9, .24, 1) both; }

@keyframes card-deal {
  0%   { transform: translateY(0) rotate(0deg) scale(.94); }
  38%  { transform: translateY(-32px) rotate(-4.2deg) scale(.99); }
  100% { transform: translateY(-22px) rotate(0deg) scale(1); }
}

/* 事件卡不走牌堆，直接从桌面上浮起来 */
.c3d.enter { animation: card-enter .44s cubic-bezier(.18, .9, .24, 1) both; }

@keyframes card-enter {
  0%   { transform: translateY(34px) scale(.93); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 收牌：牌沉回桌面。省略 from 帧，让它从「当前停在的位置」往下走，
   抽出来的牌和事件卡共用这一条，不用各写一份 */
.c3d.gone {
  animation: card-gone .26s ease forwards;
  pointer-events: none;
}

@keyframes card-gone {
  to { transform: translateY(22px) scale(.95); opacity: 0; }
}

/* 顶牌被抽走，底下那两张弹一下 —— 没有这一下，抽牌就只是「一张牌飞上去」 */
.pile.drawing { animation: pile-nudge .42s ease-out .1s both; }

@keyframes pile-nudge {
  0%   { transform: translateY(0); }
  35%  { transform: translateY(4px); }
  100% { transform: translateY(0); }
}

.stage-hint {
  position: absolute;
  left: 50%;
  top: calc(100% + 20px);
  transform: translateX(-50%);
  z-index: 3;
  padding: 7px 20px;
  font-size: 12px;
  letter-spacing: 2px;
  color: #EFE3C4;
  white-space: nowrap;
  border: 1px solid rgba(216, 180, 94, .42);
  border-radius: 18px;
  background: rgba(20, 32, 27, .55);
  opacity: 0;
  transition: opacity .25s ease;
}

.stage-hint.on { opacity: 1; animation: hint-breathe 2s ease-in-out infinite; }

@keyframes hint-breathe {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.035); }
}

.stage-choices {
  width: min(462px, 92vw);
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .34s ease, transform .34s cubic-bezier(.2, .9, .25, 1);
  pointer-events: none;
}

/* 只有一个选项时不要摊成一条 460px 的白条 —— 那是页脚，不是选项 */
.stage-choices[data-n="1"] {
  grid-template-columns: minmax(0, 300px);
  justify-content: center;
}

.stage-choices.on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* 奇数个选项时最后一个占满整行，否则右边空半格很难看 */
.stage-choices .choice:last-child:nth-child(odd) { grid-column: 1 / -1; }

.choice {
  text-align: left;
  font: inherit;
  padding: 10px 13px;
  border: 1.5px solid rgba(203, 185, 148, .6);
  border-radius: 5px;
  background: rgba(251, 247, 236, .95);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}

.choice:hover:not(:disabled) {
  border-color: #8C6A2A;
  background: #FFFDF6;
}

.choice:active:not(:disabled) { transform: translateY(1px); }

.choice:disabled { opacity: .42; cursor: default; }

.choice .ct {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .5px;
}

.choice .cd {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-3);
}

@media (max-width: 620px) {
  .stage-choices { grid-template-columns: 1fr; }
}

/* 720 高的笔记本是主力尺寸：牌 360×504 加上选项会贴到屏幕底边，
   这里整体缩一档，让上下都留出桌面 */
@media (max-height: 780px) {
  .c3d { --cw: min(320px, 60vw, 44vh); }
  .stage-choices { margin-top: 12px; }
  .choice { padding: 8px 12px; }
  .choice .ct { font-size: 12.5px; }
  .choice .cd { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .c3d.deal,
  .c3d.enter,
  .stage-hint.on,
  .narration .n-dot { animation: none; }
  .flipper { transition-duration: .2s; }
}

/* ---------- 小屏 ---------- */
@media (max-width: 820px) {
  .hud {
    left: 10px;
    right: 10px;
    top: 10px;
    padding: 8px 10px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .ledger { gap: 12px; }

  .acc .v { font-size: 14px; }

  .who-role { display: none; }

  .turn { font-size: 11px; }

  .logbox {
    right: 10px;
    top: auto;
    bottom: 88px;
    width: 190px;
    max-height: 30vh;
  }

  .ops {
    left: 10px;
    right: 10px;
    bottom: 10px;
    transform: none;
    justify-content: center;
  }

  /* 旁白跟着操作区一起落到窄屏位置，别压住日志 */
  .narration {
    bottom: 78px;
    max-width: calc(100vw - 20px);
    font-size: 12px;
  }

  .narration .n-who { display: none; }
}

/* ---------- 点格子看规则 ---------- */
.tilepop {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: 96px;
  width: 300px;
  display: none;
  padding: 12px 14px 14px;
  background: rgba(251, 247, 236, .95);
  border: 2px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.tilepop.on { display: block; }

.tp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tp-where {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--gold);
}

.tp-close {
  font: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border: 0;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}

.tp-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.tp-rule {
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-2);
}

@media (max-width: 820px) {
  .tilepop { left: 10px; right: 10px; width: auto; bottom: 150px; }
}

/* ============================================================
 * 账本：棋盘旁的损益表 / 资产负债表
 * ------------------------------------------------------------
 * 沙盘真正的决策信息不是骰子点数，是「被动收入离总支出还差多少」。
 * 这东西原本只在卡片里闪一下，玩家只能凭印象估。表摆在盘边、落格自动填数，
 * 才算把规则摊开给人看。
 * ============================================================ */

.sheet {
  position: fixed;
  z-index: 10;
  left: 16px;
  top: 86px;
  width: 268px;
  max-height: calc(100vh - 188px);
  display: flex;
  flex-direction: column;
  background: rgba(251, 247, 236, .93);
  backdrop-filter: blur(6px);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: opacity .28s ease;
}

.sh-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 11px;
  border-bottom: 1px dashed var(--line);
  flex-shrink: 0;
}

.sh-title {
  font-size: 10.5px;
  letter-spacing: 2.5px;
  color: var(--gold);
  flex-shrink: 0;
}

/* 六个页签挤在 268px 里：只放色点和名字，角色名放 title 里 */
.sh-tabs {
  display: flex;
  gap: 3px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.sh-tabs::-webkit-scrollbar { display: none; }

.sh-tab {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.sh-tab i {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  flex-shrink: 0;
}

.sh-tab:hover { background: #F3ECDA; }

.sh-tab.on {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}

/* 当前回合那位加条下划线 —— 和「我正在看谁」是两件事，不能混 */
.sh-tab.cur { box-shadow: inset 0 -2px 0 var(--seal); }

.sh-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}

.sh-btn:hover { border-color: var(--ink-3); color: var(--ink); }

.sh-body {
  overflow-y: auto;
  padding: 2px 11px 8px;
  font-size: 11.5px;
  line-height: 1.5;
  scrollbar-width: thin;
}

.sh-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 3px;
  font-size: 10.5px;
  color: var(--ink-3);
}

.sh-lv {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 4px;
  color: var(--ink-2);
}

.sh-turn { color: var(--seal); }

.sh-block { margin-bottom: 5px; }

.sh-bh {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0 3px;
  font-size: 10.5px;
  letter-spacing: 2px;
  color: var(--ink-2);
  border-bottom: 1.5px solid var(--ink);
}

.sh-x { letter-spacing: 0; font-size: 10.5px; color: var(--ink-3); }

.sh-grp {
  padding: 5px 0 1px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gold);
}

.sh-r {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted rgba(223, 212, 190, .8);
}

.sh-r .k {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sh-r .v { flex-shrink: 0; font-weight: 500; }

.sh-r.zero .k, .sh-r.zero .v { color: var(--ink-3); opacity: .62; }

.sh-r.sum {
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  padding: 3px 0;
}

.sh-r.key {
  margin: 4px -5px 0;
  padding: 4px 5px;
  border: 0;
  background: #F0E8D4;
  font-weight: 700;
}

.sh-r.key .v { color: #2F6B4F; }
.sh-r.key.neg .v { color: var(--seal); }

.sh-r.goal .k i { font-style: normal; margin-right: 5px; color: var(--ink-3); }
.sh-r.goal.done { color: #2F6B4F; }
.sh-r.goal.done .k { color: #2F6B4F; }
.sh-r.goal.done .k i { color: #2F6B4F; }

.sh-r.energy .k { font-size: 10px; color: var(--ink-3); }
.sh-r.energy .v { font-size: 15px; font-weight: 700; }

/* 数字变了闪一下金底。不闪的话，一局里几十次结算，玩家根本不知道
   刚才那一下改的是哪一行 —— 表就成了背景 */
.sh-r.chg { animation: sh-flash 1.5s ease-out; }

@keyframes sh-flash {
  0%   { background: rgba(216, 180, 94, .55); }
  35%  { background: rgba(216, 180, 94, .32); }
  100% { background: transparent; }
}

.sh-foot {
  flex-shrink: 0;
  padding: 5px 11px 6px;
  border-top: 1px dashed var(--line);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 收起：只留一条头。表挡路的时候（比如想拖棋盘）可以收掉 */
.sheet.folded .sh-body,
.sheet.folded .sh-foot { display: none; }
.sheet.folded .sh-tabs { display: none; }

/* ---------- 棋子头顶的名牌 ----------
 * z-index 压在 HUD 下面：它是跟着棋子跑的，不能让六个小气泡盖住顶栏。
 * 整层 pointer-events:none，只有名牌自己是 auto —— 否则整块画布都点不动。
 */
.ptags {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  transition: opacity .28s ease;
}

.ptag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px 0 4px;
  font: inherit;
  font-size: 10px;
  line-height: 15px;
  white-space: nowrap;
  color: var(--ink);
  background: rgba(251, 247, 236, .92);
  border: 1px solid rgba(23, 36, 31, .26);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(23, 36, 31, .14);
  pointer-events: auto;
  cursor: pointer;
  opacity: .7;
  will-change: transform;
}

.ptag i {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  flex-shrink: 0;
}

.ptag b { font-weight: 600; }

/* 现金只在当前回合那位的名牌上常显，其余收起来。
 * 六个「名字 + 金额」的小条并排在盘上就是一片糊 —— 名字才是用来认人的，
 * 钱要看就点开他的表，或者把鼠标停在名牌上。 */
.ptag em {
  display: none;
  font-style: normal;
  font-size: 10px;
  color: var(--ink-3);
}

.ptag:hover em { display: inline; }

/* 小尖角指向自己的棋子。只在没被往上抬的那一块上画 ——
   叠起来的名牌个个带角，会让人以为下面有两个棋子。 */
.ptag.anchor::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  background: inherit;
  border-right: 1px solid rgba(23, 36, 31, .26);
  border-bottom: 1px solid rgba(23, 36, 31, .26);
  transform: rotate(45deg);
}

.ptag:hover {
  opacity: 1;
  /* 内联样式里设了 z-index，hover 想压住邻居得用 !important */
  z-index: 9 !important;
}

/* 当前回合那位一直亮着，其余半透明 —— 一盘六个气泡，全亮就成了满天星 */
.ptag.cur {
  opacity: 1;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(162, 118, 42, .16), 0 2px 8px rgba(23, 36, 31, .18);
}

.ptag.cur em { color: var(--ink-2); }

.ptag.flow { border-color: #2F6B4F; }
.ptag.dead { opacity: .38; text-decoration: line-through; }

@media (prefers-reduced-motion: reduce) {
  .sh-r.chg { animation: none; }
}

/* ============================================================
 * 全屏大表
 * ------------------------------------------------------------
 * 和桌上那张纸质表一一对应：抬头、损益表、资产负债表、精力说明。
 * 侧栏是「够用」，这里是「完整」—— 想核账、想看清每一个科目时点开。
 * ============================================================ */

.sheetmodal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}

/* 抽卡舞台是 60，比它高：抽卡时牌要盖住一切 */
.sheetmodal.on { display: flex; }

.sm-veil {
  position: absolute;
  inset: 0;
  background: rgba(23, 36, 31, .56);
}

.sm-wrap {
  position: relative;
  width: min(880px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #FFFDF6;
  border-radius: 4px;
  box-shadow: 0 26px 64px rgba(16, 27, 22, .34);
  overflow: hidden;
}

.sm-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 10px 8px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.sm-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sm-name i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.sm-name span {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
  margin-left: 2px;
}

.sm-tabs { display: flex; gap: 5px; flex: 1; }

.sm-tab {
  font: inherit;
  font-size: 11.5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.sm-tab.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #F7F2E6;
}

.sm-tab:disabled {
  opacity: .4;
  cursor: default;
}

.sm-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}

.sm-close:hover { color: var(--seal); border-color: var(--seal); }

.sm-paper {
  overflow-y: auto;
  padding: 18px 24px 22px;
  overscroll-behavior: contain;
}

/* ---------- 纸面 ----------
 * 这套字用衬线。表格表单在印刷品里就是宋体，换成无襯线会立刻
 * 从「报表」变成「网页」—— 这张表要让人觉得能打印出来。
 */
.doc {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  color: #14100B;
  font-size: 12px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding-bottom: 7px;
  border-bottom: 2px solid #14100B;
  font-size: 11.5px;
}

.doc-meta span { color: #6B6151; }

.doc-meta b {
  margin-left: 6px;
  padding: 0 10px 0 8px;
  border-bottom: 1px solid #B9AC92;
  color: #14100B;
  font-weight: 700;
}

.doc-title {
  margin: 13px 0 7px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 7px;
}

.doc-cols {
  display: grid;
  grid-template-columns: 1fr 232px;
  gap: 14px;
  align-items: start;
}

.ftbl, .btbl, .fgoal, .bnote, .flow-top {
  border: 1.5px solid #14100B;
}

.ftr {
  display: grid;
  grid-template-columns: 84px 1fr 102px;
  min-height: 23px;
  align-items: stretch;
  border-bottom: 1px solid #D8CBB2;
  font-size: 11.5px;
}

.ftr:last-child { border-bottom: 0; }

.ftr > span {
  padding: 3px 7px;
  display: flex;
  align-items: center;
}

.ftr .c3 {
  justify-content: flex-end;
  border-left: 1px solid #D8CBB2;
  font-variant-numeric: tabular-nums;
}

.ftr .c1 {
  color: #3A3226;
  border-right: 1px solid #E8DECA;
  font-size: 10.5px;
  line-height: 1.3;
}

.ftr.fh {
  background: #EFE6D2;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
}

.fgrp {
  padding: 3px 8px;
  background: #14100B;
  color: #F7F2E6;
  font-size: 10.5px;
  letter-spacing: 5px;
}

.ftr.sum {
  background: #F5EEDC;
  font-weight: 700;
  border-top: 1.5px solid #14100B;
}

.ftr.key {
  background: #14100B;
  color: #F7F2E6;
  font-weight: 700;
  letter-spacing: 2px;
}

.ftr.key .c2 { letter-spacing: 3px; }

/* 右栏：第一阶段目标 + 四个汇总数 */
.fgoal { padding: 9px 11px 10px; }

.fg-t {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.fgoal p {
  margin: 3px 0 8px;
  font-size: 11px;
  line-height: 1.6;
  color: #6B6151;
}

.fg-bar {
  height: 7px;
  margin-bottom: 5px;
  background: #EDE4D0;
  border: 1px solid #C9BBA0;
  overflow: hidden;
}

.fg-bar i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.fg-gap {
  font-size: 10.5px;
  color: #6B6151;
  margin-bottom: 9px;
}

.fg-gap b { color: #14100B; }

.fgoal dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
}

.fgoal dt { font-size: 11.5px; color: #3A3226; }

.fgoal dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.fgoal dt.hl, .fgoal dd.hl { color: var(--seal); font-size: 13px; }

.fg-energy {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed #C9BBA0;
  font-size: 10.5px;
  color: #6B6151;
}

.fg-energy b {
  font-size: 15px;
  color: #14100B;
  margin-right: 8px;
}

.doc-cols2 {
  display: grid;
  grid-template-columns: 1fr 1fr 158px;
  gap: 12px;
  align-items: start;
}

.btr {
  display: grid;
  grid-template-columns: 1fr 88px;
  min-height: 23px;
  border-bottom: 1px solid #D8CBB2;
  font-size: 11.5px;
}

.btr:last-child { border-bottom: 0; }

.btr span {
  padding: 3px 7px;
  display: flex;
  align-items: center;
}

.btr span:last-child {
  justify-content: flex-end;
  border-left: 1px solid #D8CBB2;
  font-variant-numeric: tabular-nums;
}

.btr.sum {
  background: #F5EEDC;
  font-weight: 700;
  border-top: 1.5px solid #14100B;
}

.btr.dim { color: #9A8F7B; }

.bnote {
  padding: 8px 9px 9px;
  text-align: center;
}

.bn-t {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 2px;
}

.bn-big {
  margin: 3px 0 5px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.bn-big.neg { color: #A8322A; }

.bnote p {
  margin: 2px 0;
  font-size: 10px;
  line-height: 1.55;
  color: #6B6151;
}

.doc-note {
  margin-top: 9px;
  padding-top: 6px;
  border-top: 1px dashed #C9BBA0;
  font-size: 10px;
  color: #8B8069;
}

/* 顺流层那张纸：左边一个算式，右边精力框 */
.flow-top {
  display: grid;
  grid-template-columns: 1fr 148px;
  gap: 12px;
  padding: 10px 12px;
}

.lf-t {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 9px;
}

.lf-eq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
}

.lf-eq i { font-style: normal; color: #6B6151; font-weight: 400; }

.lf-eq span {
  padding: 2px 10px;
  border-bottom: 1.5px solid #14100B;
}

.lf-eq .hl { color: var(--seal); border-bottom-color: var(--seal); }

.rf {
  padding-left: 12px;
  border-left: 1px solid #C9BBA0;
  text-align: center;
}

.rf-t { font-size: 10.5px; color: #6B6151; letter-spacing: 1px; }

.rf-v {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.rf-n { font-size: 10.5px; color: #6B6151; }

.goalrow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0 2px;
}

.gitem {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border: 1.5px solid #14100B;
  font-size: 11.5px;
}

.gbox {
  width: 13px;
  height: 13px;
  display: grid;
  place-items: center;
  border: 1.5px solid #14100B;
  font-size: 9px;
  line-height: 1;
  margin-bottom: 2px;
}

.gitem b { font-weight: 700; letter-spacing: 1px; }

.gitem em {
  font-style: normal;
  font-size: 10px;
  color: #6B6151;
}

.gitem.done { background: #F1EAD8; }
.gitem.done .gbox { background: #14100B; color: #FFFDF6; }

/* ---------- 窄屏 ----------
 * 侧栏把左半块棋盘吃掉，小屏上直接收成一条，要看就点开大表 */
@media (max-width: 1180px) {
  .sheet { width: 232px; }
  .doc-cols { grid-template-columns: 1fr 200px; }
  .doc-cols2 { grid-template-columns: 1fr 1fr 140px; }
}

@media (max-width: 900px) {
  .sheet { left: 10px; top: 116px; width: 214px; max-height: calc(100vh - 240px); }
  .sheet.folded .sh-tabs { display: none; }
  .sm-paper { padding: 12px 12px 16px; }
  .doc-cols, .doc-cols2, .flow-top { grid-template-columns: 1fr; }
  .goalrow { grid-template-columns: 1fr; }
  .sm-wrap { width: 96vw; max-height: 94vh; }
  .doc-title { letter-spacing: 4px; font-size: 14px; }
}

@media (max-height: 780px) {
  .sheet { top: 86px; max-height: calc(100vh - 186px); }
  .sh-body { font-size: 11px; }
  .sm-paper { padding: 14px 18px 18px; }
}

@media (max-width: 820px) {
  .tilepop { left: 10px; right: 10px; width: auto; bottom: 150px; }
}

/* ============================================================
 * 开局大厅
 * ------------------------------------------------------------
 * 三层（房间列表 / 房间内 / 抽身份）共用一块全屏遮罩，用 data-state 切。
 * 视觉上要有「进了一间屋子」的感觉：深墨绿底 + 一束顶光 + 纸卡，
 * 和棋盘上的米色纸语言是一套，但更暗、更聚。
 * ============================================================ */

.lobby {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  overflow-y: auto;
  opacity: 1;
  transition: opacity .38s ease;
}

.lobby.hide { display: none; }
.lobby.gone { opacity: 0; }

.lb-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(46% 38% at 50% 20%, rgba(226, 200, 140, .22), transparent 74%),
    radial-gradient(96% 76% at 50% 112%, rgba(7, 13, 10, .9), transparent 62%),
    linear-gradient(168deg, #2A443A 0%, #1A2C24 55%, #122019 100%);
}

/* 桌面：大厅里那些卡是「摆在桌上」的，不是飘在空中 */
.lb-bg::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38%;
  background: linear-gradient(to top, rgba(6, 11, 9, .55), transparent);
}

.lb-pane {
  position: relative;
  z-index: 1;
  display: none;
  width: 100%;
  max-width: 1240px;
  margin: auto;
}

.lobby[data-state="home"] .lb-pane-home,
.lobby[data-state="create"] .lb-pane-create,
.lobby[data-state="join"] .lb-pane-join,
.lobby[data-state="room"] .lb-pane-room,
.lobby[data-state="draw"] .lb-pane-draw,
.lobby[data-state="rank"] .lb-pane-rank { display: block; }

/* ---------- 房间列表 ---------- */
.lb-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  color: #F2E8D2;
}

.lb-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-family: "Songti SC", "STSong", serif;
  font-size: 24px;
  color: #F2E8D2;
  border: 2px solid rgba(216, 180, 94, .62);
  border-radius: 4px;
  background: rgba(168, 50, 42, .88);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}

.lb-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
}

.lb-brand p {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 1.6px;
  color: rgba(232, 220, 192, .62);
}

/* ---------- 人数步进器 ---------- */
.lb-count {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 9px 14px;
  width: fit-content;
  background: rgba(251, 247, 236, .06);
  border: 1px solid rgba(216, 180, 94, .2);
  border-radius: 6px;
}

/* 房间内那一条和席位卡同一视觉重量，不要比房间标题还抢眼 */
.lb-count-in {
  margin-bottom: 14px;
  background: rgba(251, 247, 236, .04);
}

.lb-count-k {
  font-size: 11.5px;
  letter-spacing: 1.6px;
  color: rgba(232, 220, 192, .6);
}

.lb-count-v {
  min-width: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #F2E8D2;
  font-variant-numeric: tabular-nums;
}

.lb-step {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: #E8DCC0;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(216, 180, 94, .3);
  border-radius: 4px;
  cursor: pointer;
  transition: background .16s ease, opacity .16s ease;
}

.lb-step:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }

/* 到头了就淡掉，而不是藏起来 —— 按钮消失会让人以为坏了 */
.lb-step:disabled { opacity: .28; cursor: not-allowed; }

.lb-count-n {
  margin-left: 4px;
  font-size: 11px;
  color: rgba(232, 220, 192, .45);
}

.lb-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.lb-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px 18px 16px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: linear-gradient(170deg, #FDFAF1, #F4EEDF);
  border: 1px solid rgba(216, 180, 94, .38);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(4, 9, 7, .34);
  cursor: pointer;
  animation: lb-rise .42s cubic-bezier(.2, .9, .25, 1) both;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

@keyframes lb-rise {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

.lb-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 18px 38px rgba(4, 9, 7, .42);
}

.lb-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lb-card-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
}

.lb-badge {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--seal);
  border: 1px solid rgba(168, 50, 42, .42);
  border-radius: 10px;
  padding: 1px 7px;
}

.lb-card-meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 11.5px;
  color: var(--ink-2);
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line);
}

.lb-card-meta b { font-size: 16px; color: var(--ink); }
.lb-card-open { margin-left: auto; color: var(--ink-3); }

.lb-card-desc {
  margin: 0;
  min-height: 42px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
}

.lb-card-go {
  margin-top: auto;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--gold);
}

.lb-foot {
  margin: 22px 0 0;
  font-size: 11.5px;
  letter-spacing: .6px;
  color: rgba(232, 220, 192, .5);
}

/* ---------- 房间内 ---------- */
.lb-rhead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  color: #F2E8D2;
}

.lb-back {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  color: #E8DCC0;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(216, 180, 94, .3);
  border-radius: 4px;
  cursor: pointer;
}

.lb-back:hover { background: rgba(255, 255, 255, .12); }

.lb-rname b {
  display: block;
  font-size: 20px;
  letter-spacing: 3px;
}

.lb-rname span {
  font-size: 11.5px;
  color: rgba(232, 220, 192, .58);
}

.lb-code {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: rgba(232, 220, 192, .46);
  font-variant-numeric: tabular-nums;
}

.lb-seats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* 列数跟着人数走。8 个人固定三列会排成 3/3/2，最后一行永远缺一块；
   4 个人用三列则第二行只有一个，看着像掉了一个人。 */
.lb-seats[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.lb-seats[data-count="5"],
.lb-seats[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
.lb-seats[data-count="7"],
.lb-seats[data-count="8"] { grid-template-columns: repeat(4, 1fr); }

.lb-seat {
  display: grid;
  grid-template-columns: 26px 34px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  background: rgba(251, 247, 236, .07);
  border: 1px solid rgba(216, 180, 94, .16);
  border-radius: 6px;
  opacity: .35;
  transform: translateY(6px);
  transition: opacity .3s ease, transform .3s ease, border-color .3s ease, background .3s ease;
}

/* 自己那席先亮着，AI 陆续「进来」 */
.lb-seat.me,
.lb-seat.in {
  opacity: 1;
  transform: none;
}

.lb-seat.me {
  background: rgba(251, 247, 236, .12);
  border-color: rgba(216, 180, 94, .44);
}

.lb-seat.ready {
  border-color: rgba(108, 170, 132, .55);
  background: rgba(74, 122, 94, .16);
}

.lb-seat-no {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 11px;
  color: #E8DCC0;
  border: 1px solid rgba(216, 180, 94, .34);
  border-radius: 50%;
}

.lb-seat-ava {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: 10.5px;
  letter-spacing: .5px;
  color: #17241F;
  background: #E4D8BC;
  border-radius: 4px;
}

.lb-seat.me .lb-seat-ava { background: #D8B45E; }

.lb-seat-name {
  font-size: 13px;
  color: #F2E8D2;
  letter-spacing: 1px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-seat-task {
  display: block;
  margin-top: 1px;
  font-size: 9.5px;
  font-style: normal;
  letter-spacing: .3px;
  color: rgba(232, 220, 192, .42);
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-seat-st {
  font-size: 10.5px;
  color: rgba(232, 220, 192, .5);
}

.lb-seat.ready .lb-seat-st { color: #8FCFA8; }

.lb-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(216, 180, 94, .14);
}

.lb-host {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(232, 220, 192, .66);
}

.lb-hdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #D8B45E;
  box-shadow: 0 0 0 3px rgba(216, 180, 94, .16);
  animation: lb-pulse 1.8s ease-in-out infinite;
}

@keyframes lb-pulse {
  0%, 100% { opacity: .45; }
  50%      { opacity: 1; }
}

.lb-ready {
  margin-left: auto;
  min-width: 128px;
  color: #17241F;
  background: #E4D8BC;
  border-color: #D8B45E;
}

.lb-ready:hover:not(:disabled) { background: #EFE4C9; }

/* ---------- 抽身份 ---------- */
.lb-dhead {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

/* 牌堆：点它翻牌。抽完就淡出，免得人继续点 */
.lb-deck {
  position: relative;
  width: 58px;
  height: 82px;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity .3s ease, transform .2s ease;
}

.lb-deck:hover { transform: translateY(-2px); }
.lb-deck.spent { opacity: 0; pointer-events: none; }

.lb-deck::before,
.lb-deck::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(160deg, #24443A, #16281F);
  border: 1px solid rgba(216, 180, 94, .45);
}

.lb-deck::before { transform: translate(4px, 5px) rotate(2deg); opacity: .55; }
.lb-deck::after  { transform: translate(2px, 2px) rotate(1deg); opacity: .8; }

.lb-deck-b,
.lb-deck-t {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #E8D8B4;
  background: linear-gradient(160deg, #23423A, #172A23);
  border: 1px solid rgba(216, 180, 94, .55);
  border-radius: 4px;
}

.lb-deck-b {
  font-family: "Songti SC", "STSong", serif;
  font-size: 26px;
  opacity: .9;
}

.lb-deck-t {
  align-content: end;
  padding-bottom: 5px;
  font-size: 8.5px;
  letter-spacing: 3px;
  opacity: .5;
}

.lb-dtitle {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lb-tag {
  font-size: 10px;
  letter-spacing: 3px;
  color: #D8B45E;
}

.lb-dtitle span:last-child {
  font-size: 13px;
  color: rgba(242, 232, 210, .8);
}

.lb-cards {
  display: grid;
  grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr));
  gap: 12px;
}

.lb-cards[data-count="6"] { --n: 6; }
.lb-cards[data-count="4"] { --n: 4; max-width: 880px; }

/* 7–8 张不挤一行。一行八张时每张只有 140px 宽，牌面上的
   「＋¥12,000 / -¥3,000」会断成两行，金额读不出来 —— 那正是这张牌
   最需要读清的两行。改成两行四列，单张回到 200px 以上。 */
.lb-cards[data-count="7"],
.lb-cards[data-count="8"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 880px;
  margin-inline: auto;
}

/* 牌列收窄了，上面那行「牌堆 + 提示」要跟着收，
   否则标题留在 1240 的左边缘，和下面的牌差出小半个屏幕。 */
.lb-pane-draw[data-count="7"],
.lb-pane-draw[data-count="8"] {
  max-width: 920px;
}

/* 身份牌：竖版，1:1.42，和扑克一个比例 */
.idc {
  position: relative;
  /* 1.3 而不是扑克的 1.42：一张身份卡只有七行字，按扑克比例会空出
     下方三分之一，看着像没印完 */
  aspect-ratio: 1 / 1.24;
  perspective: 1200px;
}

.idc-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.3, .85, .25, 1);
}

.idc.on .idc-inner { transform: rotateY(180deg); }

.idc-face {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 26px rgba(4, 9, 7, .4);
}

/* 牌背 */
.idc-back {
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 40%, rgba(216, 180, 94, .16), transparent 70%),
    linear-gradient(160deg, #24443A, #14251F 62%, #1B342B);
  border: 1px solid rgba(216, 180, 94, .5);
}

.idc-back::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(216, 180, 94, .26);
  border-radius: 3px;
}

.idc-seal {
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(22px, 2.4vw, 34px);
  color: rgba(232, 216, 180, .88);
  border: 1px solid rgba(216, 180, 94, .5);
  border-radius: 3px;
  padding: 6px 9px;
  background: rgba(168, 50, 42, .22);
}

.idc-bw {
  position: absolute;
  bottom: 12px;
  font-size: 9px;
  letter-spacing: 5px;
  color: rgba(232, 216, 180, .42);
}

/* 牌面 */
.idc-front {
  display: flex;
  flex-direction: column;
  padding: 0 11px 9px;
  transform: rotateY(180deg);
  background: linear-gradient(172deg, #FFFDF6, #F6F0E1);
  border: 1px solid rgba(216, 180, 94, .5);
}

.idc-strip {
  height: 5px;
  margin: 0 -11px 8px;
}

.idc-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-bottom: 8px;
}

/* 职业色印：牌面太小，纯文字要靠读；一个色块加首字，扫一眼就知道是谁 */
.idc-mark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #FFFDF6;
  border-radius: 3px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}

.idc-role {
  font-size: clamp(14px, 1.35vw, 18px);
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}

.idc-who {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.idc-kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 6px;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
}

.idc-kv > div {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.idc-kv i {
  font-style: normal;
  font-size: 9.5px;
  color: var(--ink-3);
  letter-spacing: .3px;
}

.idc-kv b {
  font-size: clamp(12px, 1.1vw, 15px);
  font-variant-numeric: tabular-nums;
}

.idc-kv .hl b { color: #2F6B4F; }
.idc-kv .en b { color: var(--seal); }

.idc-life {
  margin-top: 7px;
  font-size: 9.5px;
  line-height: 1.62;
  color: var(--ink-2);
}

/* 「未触发不计支出」是这张牌最容易被误读的一行 ——
   做成小标签，而不是又一行灰色小字 */
.idc-life-t {
  margin-bottom: 2px;
}

.idc-life-t b {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--seal);
  border: 1px solid rgba(168, 50, 42, .34);
  border-radius: 2px;
  padding: 0 4px;
  line-height: 1.5;
}

.idc-life > div:not(.idc-life-t) {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.idc-life em {
  font-style: normal;
  color: var(--seal);
  white-space: nowrap;
}

.idc-note {
  margin: 6px 0 0;
  font-size: 10px;
  line-height: 1.55;
  color: var(--ink-2);
}

.idc-foot {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  font-size: 9.5px;
  letter-spacing: .3px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-dfoot {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

#lbEnter {
  min-width: 168px;
  color: #17241F;
  background: #E4D8BC;
  border-color: #D8B45E;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  .lb-list { grid-template-columns: 1fr; max-width: 520px; }
  .lb-seats { grid-template-columns: repeat(2, 1fr); }
  .lb-cards[data-count="6"] { --n: 3; }
  .lb-cards[data-count="4"] { --n: 2; }
  .lb-f { max-height: 70vh; overflow-y: auto; }
}

@media (max-width: 760px) {
  .lobby { padding: 18px 14px; }
  .lb-seats { grid-template-columns: 1fr; }
  .lb-cards[data-count="6"],
  .lb-cards[data-count="4"] { --n: 2; }
  .lb-brand h1 { font-size: 19px; }
  .lb-seat-task { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lb-card { animation: none; }
  .lb-hdot { animation: none; }
}

/* ============================================================
 * 联机大厅（创建 / 加入 / 房号 / 积分榜）
 * ------------------------------------------------------------
 * 这一层的任务只有一个：让人在 10 秒内坐到桌上。
 * 所以首屏只有两个按钮，剩下的全部收进二级页。
 * 视觉沿用大厅那一套：深墨绿底、米色纸、金色描边。
 * ============================================================ */

/* ---------- 首屏 ---------- */
.lb-pane-home {
  max-width: 880px;
  padding-bottom: 20px;
}

.lb-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 8px 0 26px;
}

.lb-big {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 30px 26px 28px;
  text-align: left;
  cursor: pointer;
  color: #17241F;
  background: linear-gradient(168deg, #F6EFDC 0%, #E6DBBF 100%);
  border: 1px solid #D8B45E;
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .18s ease, box-shadow .18s ease;
}

.lb-big::after {
  /* 左上角那道烫金压痕：两张卡并排时，它能让人一眼看出「这是卡片不是按钮」 */
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(168, 138, 66, .28);
  border-radius: 4px;
  pointer-events: none;
}

.lb-big b {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  font-family: "Songti SC", "STSong", serif;
}

.lb-big span {
  font-size: 12.5px;
  letter-spacing: .6px;
  color: rgba(23, 36, 31, .62);
}

.lb-big:hover { transform: translateY(-3px); }
.lb-big:active { transform: translateY(0); }

.lb-big-ghost {
  color: #F2E8D2;
  background: rgba(251, 247, 236, .05);
  border-color: rgba(216, 180, 94, .42);
  box-shadow: none;
}

.lb-big-ghost::after { border-color: rgba(216, 180, 94, .16); }
.lb-big-ghost span { color: rgba(242, 232, 210, .56); }

/* 主按钮被「回到房间 1234」占用时，换一桌的次级入口。
   字号按手机能看清来定，别做成一个小灰点 —— 这是唯一的另一条路。 */
.lb-switch {
  align-self: center;
  margin-top: 2px;
  padding: 9px 18px;
  font-size: 13px;
  letter-spacing: .8px;
  color: rgba(232, 220, 192, .82);
  background: none;
  border: 1px dashed rgba(216, 180, 94, .34);
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.lb-switch:hover,
.lb-switch:active {
  color: #F2E8D2;
  border-color: rgba(216, 180, 94, .62);
  background: rgba(216, 180, 94, .07);
}

.lb-switch[hidden] { display: none; }

.lb-home-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid rgba(216, 180, 94, .16);
}

.lb-link {
  padding: 6px 2px;
  font-size: 12.5px;
  letter-spacing: 1px;
  color: rgba(232, 220, 192, .78);
  background: none;
  border: 0;
  cursor: pointer;
}

.lb-link:hover { color: #E4D8BC; }

.lb-ainote {
  font-size: 11px;
  letter-spacing: .6px;
  color: rgba(158, 196, 172, .82);
}

.lb-ainote.off { color: rgba(232, 220, 192, .42); }

/* ---------- 表单页 ---------- */
.lb-pane-form {
  max-width: 460px;
}

.lb-fhead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.lb-ftitle b {
  display: block;
  font-size: 19px;
  letter-spacing: 2px;
  color: #F2E8D2;
  font-family: "Songti SC", "STSong", serif;
}

.lb-ftitle span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: .8px;
  color: rgba(232, 220, 192, .54);
}

.lb-form {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: rgba(11, 20, 16, .5);
  border: 1px solid rgba(216, 180, 94, .2);
  border-radius: 8px;
}

.lb-field > span {
  display: block;
  margin-bottom: 8px;
  font-size: 11.5px;
  letter-spacing: 1.4px;
  color: rgba(232, 220, 192, .58);
}

.lb-field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;          /* 16px 以下 iOS 会在聚焦时自动放大整页 */
  color: #F2E8D2;
  background: rgba(251, 247, 236, .06);
  border: 1px solid rgba(216, 180, 94, .26);
  border-radius: 6px;
  outline: none;
}

.lb-field input::placeholder { color: rgba(232, 220, 192, .28); }
.lb-field input:focus { border-color: rgba(216, 180, 94, .7); background: rgba(251, 247, 236, .1); }

.lb-codeinput {
  font-size: 30px !important;
  letter-spacing: 14px;
  text-align: center;
  padding: 10px 0 10px 14px !important;
}

.lb-stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: rgba(251, 247, 236, .05);
  border: 1px solid rgba(216, 180, 94, .22);
  border-radius: 6px;
}

.lb-stepper button {
  width: 34px;
  height: 34px;
  font-size: 18px;
  color: #F2E8D2;
  background: rgba(251, 247, 236, .08);
  border: 1px solid rgba(216, 180, 94, .26);
  border-radius: 5px;
  cursor: pointer;
}

.lb-stepper button:disabled { opacity: .3; cursor: default; }
.lb-stepper b { font-size: 20px; min-width: 26px; text-align: center; color: #E4D8BC; }
.lb-stepper em { font-size: 11px; font-style: normal; color: rgba(232, 220, 192, .44); }

.lb-chips { display: flex; gap: 10px; flex-wrap: wrap; }

.lb-chips button {
  flex: 1 1 160px;
  padding: 11px 12px;
  font-size: 13px;
  color: rgba(232, 220, 192, .7);
  background: rgba(251, 247, 236, .05);
  border: 1px solid rgba(216, 180, 94, .22);
  border-radius: 6px;
  cursor: pointer;
}

.lb-chips button.on {
  color: #17241F;
  background: #E4D8BC;
  border-color: #D8B45E;
  font-weight: 700;
}

.lb-go {
  margin-top: 4px;
  padding: 14px;
  font-size: 15px;
  letter-spacing: 3px;
}

.lb-err {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  color: #E58A7C;
  opacity: 0;
  transition: opacity .2s;
}

.lb-err.on { opacity: 1; }

/* ---------- 房号 ---------- */
.lb-roomcode {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-bottom: 18px;
  background: rgba(251, 247, 236, .05);
  border: 1px solid rgba(216, 180, 94, .24);
  border-radius: 8px;
}

.lb-rc-k {
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(232, 220, 192, .5);
}

.lb-roomcode b {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 10px;
  color: #E4D8BC;
  text-shadow: 0 2px 10px rgba(216, 180, 94, .26);
}

.lb-copy {
  padding: 8px 14px;
  font-size: 12px;
  color: #E4D8BC;
  background: rgba(216, 180, 94, .12);
  border: 1px solid rgba(216, 180, 94, .38);
  border-radius: 5px;
  cursor: pointer;
}

.lb-roomcode em {
  flex-basis: 100%;
  font-size: 11.5px;
  font-style: normal;
  color: rgba(232, 220, 192, .42);
}

/* 房主看「开局」、其他人看「准备」，同一个位置 */
.lb-start, .lb-ready { display: none; }
.lb-start.on, .lb-ready.on { display: inline-flex; }

/* ---------- 身份单卡 ---------- */
.idc.solo {
  grid-column: span 1;
  /* 单张时改成横版，像一张工牌而不是扑克。
     竖版 1:1.24 是给六张并排用的（按行对齐），单张竖着放时
     六行内容只占上半张纸，剩下四成空白怎么调字号都填不满。 */
  width: min(440px, 84vw);
  height: auto;
  aspect-ratio: 1 / 0.74;
  cursor: pointer;
}

.lb-cards[data-count="1"] {
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
}

/* 单张模式下把牌面内容撑开。
   六张并排时它只有 200px 宽，字号被 clamp 压到 14px 是对的；
   单张放到 380px 宽之后，上面挤成一小坨、下面空掉四成，像印废了。
   字号按单张的尺寸重设一遍，并用 margin-top:auto 把明细推到底 ——
   空白集中在中段一处，比整片空在底部像样。 */
.idc.solo .idc-front { padding: 0 16px 14px; }
.idc.solo .idc-strip { height: 6px; margin: 0 -16px 12px; }
.idc.solo .idc-head { margin-bottom: 12px; }
.idc.solo .idc-mark { width: 26px; height: 26px; font-size: 14px; }
.idc.solo .idc-role { font-size: 24px; }
.idc.solo .idc-who { font-size: 11px; }
.idc.solo .idc-kv { gap: 6px 8px; padding-bottom: 12px; }
.idc.solo .idc-kv i { font-size: 11px; }
.idc.solo .idc-kv b { font-size: 20px; }
.idc.solo .idc-life { margin-top: 12px; font-size: 12.5px; line-height: 1.85; }
.idc.solo .idc-note { font-size: 11.5px; line-height: 1.7; margin-top: 8px; }
.idc.solo .idc-foot { margin-top: auto; font-size: 11.5px; }

/* 单张模式：牌堆收到标题里，整页居中 */
.lb-pane-draw[data-solo="1"] {
  max-width: 560px;
  text-align: center;
}

.lb-pane-draw[data-solo="1"] .lb-dhead {
  display: block;
  margin-bottom: 22px;
  text-align: center;
}

.lb-pane-draw[data-solo="1"] .lb-deck { display: none; }

.lb-pane-draw[data-solo="1"] .lb-dtitle {
  align-items: center;
  gap: 7px;
}

.lb-pane-draw[data-solo="1"] .lb-dfoot { margin-top: 24px; }

/* ---------- 积分榜 ---------- */
.lb-pane-rank { max-width: 640px; }

.lb-rank {
  background: rgba(11, 20, 16, .5);
  border: 1px solid rgba(216, 180, 94, .2);
  border-radius: 8px;
  overflow: hidden;
}

.lb-rank-head,
.lb-rank-row {
  display: grid;
  grid-template-columns: 46px 1fr 76px 56px 76px;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 13px;
}

.lb-rank-head {
  font-size: 11px;
  letter-spacing: 1.4px;
  color: rgba(232, 220, 192, .46);
  border-bottom: 1px solid rgba(216, 180, 94, .16);
}

.lb-rank-row { color: rgba(242, 232, 210, .86); border-bottom: 1px solid rgba(216, 180, 94, .07); }
.lb-rank-row:last-child { border-bottom: 0; }
.lb-rank-row.top1 { background: rgba(216, 180, 94, .13); }
.lb-rank-row.top2 { background: rgba(216, 180, 94, .07); }
.lb-rank-row.top3 { background: rgba(216, 180, 94, .04); }

.rk-no { font-weight: 700; color: #D8B45E; text-align: center; }
.rk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-total { font-weight: 800; font-size: 15px; color: #E4D8BC; text-align: right; }
.rk-games, .rk-best { font-size: 12px; color: rgba(232, 220, 192, .5); text-align: right; }

.lb-rank-empty { padding: 40px 16px; text-align: center; font-size: 13px; color: rgba(232, 220, 192, .44); }

.lb-rank-foot {
  margin: 0;
  padding: 12px 16px;
  font-size: 11px;
  line-height: 1.7;
  color: rgba(232, 220, 192, .38);
  background: rgba(0, 0, 0, .16);
}

/* ============================================================
 * 终局复盘
 * ============================================================ */
.over {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 11, 9, .82);
  backdrop-filter: blur(6px);
}

.over.on { display: flex; }

.ov-card {
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(172deg, #F6EFDC, #E7DCC0);
  border: 1px solid #D8B45E;
  border-radius: 10px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  overflow: hidden;
}

.ov-head {
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(168, 138, 66, .22);
}

.ov-k {
  font-size: 10.5px;
  letter-spacing: 3px;
  color: rgba(23, 36, 31, .46);
}

.ov-head h2 {
  margin: 8px 0 0;
  font-size: 19px;
  line-height: 1.5;
  font-weight: 800;
  color: #17241F;
  font-family: "Songti SC", "STSong", serif;
}

.ov-head p {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: rgba(23, 36, 31, .6);
}

.ov-list { flex: 1; overflow-y: auto; padding: 8px 24px 16px; }

.ov-row {
  padding: 14px 0;
  border-bottom: 1px dashed rgba(168, 138, 66, .26);
}

.ov-row:last-child { border-bottom: 0; }
.ov-row.me .ov-name { color: #A8322A; }

.ov-top { display: flex; align-items: center; gap: 10px; }
.ov-name { font-size: 14px; font-weight: 700; color: #17241F; }

.ov-layer {
  padding: 2px 8px;
  font-size: 10.5px;
  border-radius: 20px;
  border: 1px solid rgba(23, 36, 31, .2);
  color: rgba(23, 36, 31, .6);
}

.ov-layer.l-flow { color: #1F6B4A; border-color: rgba(31, 107, 74, .4); background: rgba(31, 107, 74, .09); }
.ov-layer.l-adverse { color: #A8322A; border-color: rgba(168, 50, 42, .4); background: rgba(168, 50, 42, .07); }

.ov-points { margin-left: auto; font-size: 15px; font-weight: 800; }
.ov-points.up { color: #1F6B4A; }
.ov-points.down { color: #A8322A; }
.ov-break { margin-top: 5px; font-size: 11px; color: rgba(23, 36, 31, .46); }

.ov-line { margin: 8px 0 0; font-size: 13px; line-height: 1.7; color: rgba(23, 36, 31, .82); }

.ov-q {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: #7A5A18;
  font-style: italic;
}

.ov-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid rgba(168, 138, 66, .22);
  background: rgba(23, 36, 31, .04);
}

.ov-foot .btn:not(.primary) { color: #17241F; border-color: rgba(23, 36, 31, .26); }
/* 主按钮在深墨绿底上本来该是浅字，上面那条 color 会把它刷成黑字看不见 */
.ov-foot .btn.primary { color: #F6EFDC; }

/* ============================================================
 * 竖屏提示
 * ============================================================ */
.rot {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 11, 9, .94);
}

.rot.on { display: flex; }

.rot-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 34px 34px 26px;
  text-align: center;
  color: #F2E8D2;
  /* 底色不能只靠遮罩：0.94 的黑下面还能看见首屏的字，
     叠在一起像糊了两层内容，不如给它一张实实在在的卡 */
  background: #14201B;
  border: 1px solid rgba(216, 180, 94, .3);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}

.rot-icon {
  font-size: 46px;
  color: #D8B45E;
  animation: rotSpin 2.6s ease-in-out infinite;
}

@keyframes rotSpin {
  0%, 40% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(90deg); }
}

.rot-card b { font-size: 19px; letter-spacing: 3px; font-family: "Songti SC", "STSong", serif; }
.rot-card p { margin: 0; font-size: 12.5px; color: rgba(232, 220, 192, .56); }
.rot-card .btn { margin-top: 8px; min-width: 150px; }

/* ============================================================
 * 回合归属：不是我的回合，按钮就不该亮
 * ============================================================ */
body.waiting #btnRoll {
  opacity: .42;
  filter: saturate(.4);
}

body.myturn #btnRoll {
  box-shadow: 0 0 0 0 rgba(216, 180, 94, .55);
  animation: turnPulse 2.2s ease-out infinite;
}

@keyframes turnPulse {
  0% { box-shadow: 0 0 0 0 rgba(216, 180, 94, .5); }
  70% { box-shadow: 0 0 0 14px rgba(216, 180, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(216, 180, 94, 0); }
}

/* ============================================================
 * 手机：横屏优先，竖屏退化
 * ============================================================ */
/* 横屏手机上的翻牌页：竖着排会被裁掉半张牌（390 高放不下 471 高的卡）。
   改成「标题 | 卡 | 按钮」三栏，卡片用 zoom 等比缩到 78%，
   卡内字号跟着一起缩 —— 用 transform: scale 不改变占位，下面会叠到按钮上。 */
@media (max-height: 560px) and (pointer: coarse) {
  .lobby[data-state="draw"] .lb-pane-draw[data-solo="1"] {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    max-width: 100%;
  }

  .lb-pane-draw[data-solo="1"] .lb-dhead {
    justify-self: end;
    margin: 0;
    text-align: right;
    max-width: 200px;
  }

  .lb-pane-draw[data-solo="1"] .lb-dtitle { align-items: flex-end; }

  .lb-pane-draw[data-solo="1"] .lb-cards { justify-self: center; }

  .lb-pane-draw[data-solo="1"] .lb-dfoot {
    justify-self: start;
    margin: 0;
  }

  .idc.solo { zoom: .78; }
}

@media (max-height: 440px) and (pointer: coarse) {
  .idc.solo { zoom: .7; }
  .lb-pane-draw[data-solo="1"] .lb-dhead { max-width: 168px; }
}

@media (max-height: 520px) and (pointer: coarse) {
  /* 横屏手机：可视高度只剩三百多，所有留白都要压掉 */
  .lobby { padding: 12px 20px; }
  .lb-brand { margin-bottom: 12px; }
  .lb-mark { width: 36px; height: 36px; font-size: 19px; }
  .lb-brand h1 { font-size: 17px; letter-spacing: 2px; }
  .lb-brand p { font-size: 10px; }
  .lb-hero { gap: 12px; margin: 4px 0 14px; }
  .lb-big { padding: 18px 18px 16px; }
  .lb-big b { font-size: 20px; }
  .lb-big span { font-size: 11px; }
  .lb-form { padding: 14px; gap: 12px; }
  .lb-fhead { margin-bottom: 12px; }
  .lb-roomcode { padding: 10px 16px; margin-bottom: 10px; }
  .lb-roomcode b { font-size: 28px; letter-spacing: 6px; }
  .lb-seats { gap: 8px; }
  .lb-seat { padding: 8px 10px; }
  .lb-cards[data-count="1"] { grid-template-columns: minmax(0, 260px); }
  .idc.solo { width: min(260px, 60vw); }
  .ov-card { max-height: 94vh; }
  .ov-head { padding: 14px 18px 10px; }
  .ov-head h2 { font-size: 16px; }
  .ov-list { padding: 4px 18px 10px; }
  .ov-row { padding: 10px 0; }
}

@media (max-width: 760px) {
  .lb-hero { grid-template-columns: 1fr; gap: 12px; }
  .lb-big { padding: 22px 20px; }
  .lb-big b { font-size: 22px; }
  .lb-rank-head, .lb-rank-row { grid-template-columns: 34px 1fr 62px 44px 62px; padding: 10px 12px; font-size: 12px; }
  .lb-pane-form { max-width: 100%; }
  .lb-roomcode b { font-size: 32px; letter-spacing: 8px; }
}

/* 横屏窄高（667×375、844×390 这类）：
 * 宽度进了「单列」那条分支，可高度只有 375 —— 两张卡竖着排，
 * 底下「换个房间」和积分榜那行一定被切掉。这里强制并排，让它回到两行。 */
@media (orientation: landscape) and (max-height: 520px) {
  .lb-hero { grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 10px; }
  .lb-switch { grid-column: 1 / -1; margin-top: 0; }
  .lb-pane-home { padding-bottom: 6px; }
}

/* 刘海屏 / 手势条：底部按钮不能被吃掉 */
@supports (padding: max(0px)) {
  .ops, .lb-actions {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .hud { padding-top: max(8px, env(safe-area-inset-top)); }
  .lobby { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* ============================================================
 * 全屏与横屏：让界面真的铺满
 *
 * 这里只解决「布局配合」，能不能铺满取决于全屏成没成（见 src/screen.js）。
 * 两个必须分开看的东西：
 *   · 地址栏 —— 只有全屏/装到主屏能去掉，CSS 改不掉
 *   · 视口高度 —— 地址栏在的时候 vh 会算多，dvh 才是实时可视高度
 * ============================================================ */

/* 全屏开关：只在触摸设备出现。桌面按 F11 就行，占着 HUD 没意义 */
.hud-fs {
  display: none;
  margin-left: auto;
  flex: 0 0 auto;
  width: 32px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, .46);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, border-color .18s ease;
}

.hud-fs:active { background: rgba(216, 180, 94, .26); }

/* 已在全屏：图标换个方向，点一下是退出 */
body.fs .hud-fs-i { transform: rotate(0deg); }

@media (pointer: coarse) {
  .hud-fs { display: flex; }
}

/* 横屏时刘海在左边、手势条在右边 —— HUD 必须让开，
   否则「现金 / 月现金流」最左边那个数字会被切掉一半。
 
   ⚠️ 这里只动 .hud。.ops 和 .narration 是 left:50% + translateX(-50%) 居中的，
   给它们加 left/right 会顶掉居中：left 变成 10px，transform 还在，
   元素就整个左移半个宽度飞出屏幕（实测 x = -402px）。
   它们要让开安全区只能靠 max-width 扣减，见下面两条。 */
@supports (padding: max(0px)) {
  .hud {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
}

/* 居中元素让开安全区的唯一正确方式：把可用宽度算小，
   居中之后左右自然就落在安全区内，不用碰定位属性。
   这里用 20px 而不是 32px，是为了和窄屏那条 calc(100vw - 20px) 对齐 —— 
   否则竖屏下旁白会比原来窄一截。 */
@supports (width: calc(100vw - env(safe-area-inset-left))) {
  .narration {
    max-width: min(760px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }
}

/* 窄屏下 .ops 是 left/right 撑满的（transform 已经是 none），
   这时才需要让开安全区 */
@supports (padding: max(0px)) {
  @media (max-width: 820px) {
    .ops {
      left: max(10px, env(safe-area-inset-left));
      right: max(10px, env(safe-area-inset-right));
    }
  }
}

/* 竖屏提示里的失败原因：iOS 没有元素全屏、微信不给全屏、系统开了方向锁定，
   这三种情况得说不同的话，否则用户只会觉得「按钮点了没用」 */
.rot-hint {
  margin: 4px 0 0;
  max-width: 300px;
  font-size: 11.5px;
  line-height: 1.65;
  color: rgba(216, 180, 94, .7);
}

.rot-hint:empty { display: none; }

/* 全屏 / 独立窗口里，画布底下不该露出页面底色。
   退出全屏的那一瞬间浏览器会重绘，先垫一层同色免得起白边 */
body.fs,
body.fs .stage,
body.fs #c {
  background-color: #101A16;
}

/* 右侧日志、左侧账本、点格子浮窗：横屏时刘海和手势条正好压在它们身上。
   这三个都是单边定位（没有 translateX），所以可以直接改 left/right */
@supports (padding: max(0px)) {
  .logbox { right: max(16px, env(safe-area-inset-right)); }
  .tilepop { right: max(16px, env(safe-area-inset-right)); }
  .sheet { left: max(10px, env(safe-area-inset-left)); }
}

/* ============================================================
 * 横屏矮屏（手机横过来）：底部三层要重新排
 *
 * 基础样式是照桌面写的 —— 操作区 bottom:22px 高 70px（顶部在 92px 处），
 * 旁白 bottom:86px，两者差 6px，在 844×390 这种横屏上正好压住一行字。
 * 桌面高度 768 的时候看不出来，因为那时旁白离操作区很远。
 * ============================================================ */
@media (orientation: landscape) and (max-height: 520px) {
  .ops {
    bottom: 12px;
  }

  /* 让到操作区上方，留 16px 间隙 */
  .narration {
    bottom: 96px;
    font-size: 12px;
    padding: 6px 14px;
  }

  /* 日志框也跟着收一点，别顶到旁白 */
  .logbox {
    top: 74px;
    max-height: 38vh;
    width: 200px;
  }
}
