/* ==========================================================================
   骷髅王 · 海盗船舱牌桌
   纯 CSS / 零外部资源。目录：
   1. 设计变量        2. 基础与木纹背景   3. 按钮与表单     4. 顶栏
   5. 纸牌            6. 入口（桌游盒封） 7. 房间（围坐牌桌）8. 游戏牌桌
   9. 弹窗（规则册）  10. 记分/结算/日志   11. Toast        12. 响应式 / 可访问性
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  --wood-0: #211711;
  --wood-1: #34231a;
  --wood-2: #4a3324;
  --felt-0: #123d32;
  --felt-1: #194e40;
  --brass: #c6a15a;
  --brass-hi: #e4c98b;
  --brass-lo: #8d6d31;
  --paper: #f2e5c9;
  --paper-2: #e6d4ac;
  --paper-3: #fbf3df;
  --ink: #2b1d12;
  --ink-soft: #6b5a43;
  --oxblood: #7a2a22;

  /* 在深色木/毡面上使用的文本变量（弹窗与纸面内会被局部覆盖） */
  --text: #f6eddc;
  --muted: #c4b69b;
  --gold: #e4c98b;
  --ok: #8fd6a2;
  --danger: #ef8a6c;

  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, "Times New Roman", serif;

  --card-w: 76px;
  --card-h: 108px;
  --tap: 44px;

  /* 复用的纹理层 */
  --grain:
    repeating-linear-gradient(90deg, rgba(0,0,0,.14) 0 2px, transparent 2px 9px, rgba(255,214,160,.035) 9px 11px, transparent 11px 23px),
    repeating-linear-gradient(88.6deg, rgba(0,0,0,.10) 0 1px, transparent 1px 31px),
    radial-gradient(ellipse 160px 34px at 18% 22%, rgba(0,0,0,.22), transparent 70%),
    radial-gradient(ellipse 220px 40px at 78% 68%, rgba(0,0,0,.20), transparent 70%);
  --felt-tex:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.06) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 42%, rgba(255,255,255,.10), transparent 62%),
    linear-gradient(160deg, var(--felt-1), var(--felt-0));
  --paper-tex:
    repeating-linear-gradient(0deg, rgba(120,84,30,.035) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(120,80,20,.22), transparent 55%),
    linear-gradient(180deg, var(--paper), #ead9b4);
  --card-back:
    repeating-linear-gradient(45deg, rgba(198,161,90,.34) 0 2px, transparent 2px 8px),
    repeating-linear-gradient(-45deg, rgba(198,161,90,.34) 0 2px, transparent 2px 8px),
    linear-gradient(160deg, #70222b, #3d1015);
  --rope: repeating-linear-gradient(135deg, #bf9f62 0 4px, #8d6d31 4px 8px);
  --compass: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23c6a15a' stroke-opacity='.42' stroke-width='1.4'%3E%3Ccircle cx='100' cy='100' r='94'/%3E%3Ccircle cx='100' cy='100' r='72' stroke-dasharray='2 6'/%3E%3Ccircle cx='100' cy='100' r='30'/%3E%3Cpath d='M100 6 L113 87 L194 100 L113 113 L100 194 L87 113 L6 100 L87 87 Z'/%3E%3Cpath d='M28 28 L172 172 M172 28 L28 172' stroke-opacity='.25'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- 2. 基础与木纹背景 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100%;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 38%, transparent 38%, rgba(0,0,0,.62) 100%),
    var(--grain),
    linear-gradient(180deg, #2b1d14, var(--wood-0));
  background-color: var(--wood-0);
}
#root { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); }
b, strong { font-weight: 700; }

/* ---------- 3. 按钮与表单 ---------- */
button {
  font-family: inherit; font-size: 15px; line-height: 1.2; cursor: pointer;
  min-height: var(--tap); padding: 8px 16px;
  color: #f6eddc;
  border: 1px solid #70502f; border-radius: 8px;
  background: linear-gradient(180deg, var(--wood-2), var(--wood-1));
  box-shadow: inset 0 1px 0 rgba(255,225,170,.18), 0 2px 0 #120b07, 0 4px 8px rgba(0,0,0,.35);
  transition: transform .08s, filter .15s;
}
button:hover:not(:disabled) { filter: brightness(1.18); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,225,170,.12), 0 1px 0 #120b07; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  color: #2a1b0c; font-weight: 800; border-color: #f0d9a0;
  background: linear-gradient(180deg, #f0d9a0, var(--brass) 55%, #a98539);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 2px 0 #5b4217, 0 5px 12px rgba(0,0,0,.4);
}
button.danger { background: linear-gradient(180deg, #9a3a2f, var(--oxblood)); border-color: #b9584a; }

input, select {
  font-family: inherit; font-size: 16px; min-height: var(--tap); padding: 8px 12px;
  color: var(--ink); background: var(--paper-3);
  border: 1px solid #a58b5b; border-radius: 8px; outline: none;
  box-shadow: inset 0 2px 4px rgba(90,60,20,.18);
}
input::placeholder { color: #8f7e60; }
input:focus { border-color: var(--brass-lo); }

:focus-visible {
  outline: 3px solid #ffd98a; outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--wood-0);
}
input:focus-visible, select:focus-visible { outline-offset: 1px; }

/* ---------- 4. 顶栏（船舷木条） ---------- */
.topbar {
  grid-row: 1; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--grain), linear-gradient(180deg, #3c2a1e, var(--wood-1));
  border-bottom: 3px solid var(--wood-0);
  box-shadow: 0 1px 0 var(--brass-lo), 0 6px 14px rgba(0,0,0,.45);
}
.topbar .brand { font-family: var(--serif); font-size: 22px; font-weight: 800; color: var(--brass-hi); letter-spacing: .12em; text-shadow: 0 2px 0 rgba(0,0,0,.6); }
.topbar .round-chip {
  font-family: var(--serif); font-weight: 700; font-size: 14px; color: var(--ink);
  padding: 5px 14px; border-radius: 6px; border: 1px solid #7d5f27;
  background: linear-gradient(180deg, #e8cf94, var(--brass) 60%, #a98539);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 1px 0 #3c2a10;
}
.topbar .phase-chip {
  font-size: 14px; font-weight: 600; color: var(--ink);
  padding: 5px 12px; border-radius: 4px; background: var(--paper); border: 1px solid #b59a68;
}
.topbar .spacer { flex: 1; }
.topbar button { min-height: 40px; padding: 6px 12px; font-size: 14px; }

/* ---------- 5. 纸牌（印刷质感） ---------- */
.card {
  --suit: #222;
  width: var(--card-w); height: var(--card-h); flex-shrink: 0;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 9px; border: 2px solid var(--suit); color: var(--suit);
  background: linear-gradient(180deg, #fbf3df, #eedfbc);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 3px 8px rgba(0,0,0,.5);
  font-family: var(--serif); user-select: none; text-align: center;
}
.card::before { /* 印刷内框 */
  content: ''; position: absolute; inset: 4px; border: 1px solid currentColor; opacity: .38;
  border-radius: 5px; pointer-events: none;
}
.card .suit { font-size: 20px; line-height: 1; margin-bottom: 3px; }
.card .big { font-size: 36px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.card .label { font-size: 12px; font-weight: 700; line-height: 1.2; margin-top: 4px; padding: 0 4px; }

/* 数字牌花色 */
.card.s-parrot { --suit: #17653a; background: linear-gradient(180deg, #e0eed6, #f3ecd2 60%); }
.card.s-chest  { --suit: #8a5a00; background: linear-gradient(180deg, #f3e2a8, #f6ebcb 60%); }
.card.s-map    { --suit: #5b3a9e; background: linear-gradient(180deg, #e6dcf5, #f3ecd8 60%); }
.card.s-jolly  { --suit: #e9dcc0; border-color: var(--brass); background: linear-gradient(160deg, #30323a, #131418); }
.card.s-jolly .big { color: #fff3d6; }

/* 特殊牌：满色底 + 奶油内框 */
.card.k-special { color: #fff; border-color: rgba(255,255,255,.55); }
.card.k-special .big { font-size: 34px; }
.card.k-escape  { color: #22303f; background: linear-gradient(160deg, #e3e6e6, #b9c3cb); border-color: #6b7a87; }
.card.k-pirate  { background: linear-gradient(160deg, #c8473e, #7f211c); }
.card.k-mary    { background: linear-gradient(160deg, #a35bd6, #6a2fa8); }
.card.k-mermaid { background: linear-gradient(160deg, #1f8f98, #0f5961); }
.card.k-sk      { background: linear-gradient(160deg, #262a31, #08090c); border-color: var(--brass); color: #fff3d6; }
.card.k-sk .big { color: var(--brass-hi); }
.card.k-kraken  { background: linear-gradient(160deg, #8e2437, #4d0f1c); }
.card.k-whale   { background: linear-gradient(160deg, #2f87a8, #165a76); }
.card.k-loot    { color: #2b1704; background: linear-gradient(160deg, #f0a64a, #c9701a); border-color: #7a4208; }

.card.back {
  background: var(--card-back); border: 3px solid var(--paper); color: var(--brass);
}
.card.back::before { inset: 3px; border-color: var(--brass); opacity: .7; }
.card.back::after { content: '☠'; font-size: 30px; line-height: 1; color: var(--brass-hi); text-shadow: 0 1px 2px rgba(0,0,0,.6); }

.card.small { --card-w: 44px; --card-h: 62px; border-radius: 6px; }
.card.small::before { inset: 3px; border-radius: 3px; }
.card.small .big { font-size: 19px; }
.card.small.k-special .big { font-size: 20px; }
.card.small .suit { font-size: 11px; margin-bottom: 2px; }
.card.small .label { font-size: 9px; margin-top: 2px; padding: 0 2px; }
.card.tiny { --card-w: 34px; --card-h: 48px; border-radius: 5px; border-width: 1.5px; }
.card.tiny::before { inset: 2px; border-radius: 3px; }
.card.tiny .big { font-size: 15px; }
.card.tiny.k-special .big { font-size: 16px; }
.card.tiny .suit { font-size: 8px; margin-bottom: 1px; }
.card.tiny .label { display: none; }
.card.tiny.back::after { font-size: 14px; }

/* ---------- 6. 入口：桌游盒封 + 入座登记表 ---------- */
.entry {
  position: relative; overflow: hidden; flex: 1;
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px;
  display: grid; align-content: center; align-items: center; gap: 0 36px;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 400px);
  grid-template-rows: 1fr auto auto auto 1fr;
}
/* 盒盖：墨绿底 + 罗盘 + 绳纹黄铜边 */
.entry::before {
  content: ''; grid-column: 1; grid-row: 1 / 6; align-self: stretch; min-height: 460px; z-index: 0;
  border: 9px solid transparent; border-radius: 14px;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.10), transparent 65%) padding-box,
    var(--compass) center 52% / 72% no-repeat padding-box,
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 3px) padding-box,
    linear-gradient(160deg, #17503f, var(--felt-0)) padding-box,
    var(--rope) border-box;
  box-shadow: 0 0 0 2px #120b07, 0 22px 50px rgba(0,0,0,.6), inset 0 0 70px rgba(0,0,0,.5);
}
.entry::after { /* 盒盖内细线框 */
  content: ''; grid-column: 1; grid-row: 1 / 6; align-self: stretch; margin: 22px; z-index: 0; pointer-events: none;
  border: 1px solid rgba(198,161,90,.55); border-radius: 8px;
  box-shadow: inset 0 0 0 4px rgba(18,61,50,.9), inset 0 0 0 5px rgba(198,161,90,.28);
}
.entry .logo, .entry h1, .entry .sub { position: relative; z-index: 1; grid-column: 1; text-align: center; }
.entry .logo {
  grid-row: 2; justify-self: center; display: grid; place-items: center;
  width: 116px; height: 116px; border-radius: 50%; font-size: 64px; line-height: 1;
  border: 3px double var(--brass);
  background: radial-gradient(circle at 50% 35%, #2b6a56, var(--felt-0) 75%);
  box-shadow: 0 0 0 5px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.5), inset 0 0 18px rgba(0,0,0,.5);
}
.entry h1 {
  grid-row: 3; margin-top: 18px; font-size: 58px; line-height: 1.15; font-weight: 900; letter-spacing: .08em;
  color: var(--brass-hi); text-shadow: 0 2px 0 #6b4f1f, 0 5px 14px rgba(0,0,0,.7);
}
.entry .sub { grid-row: 4; margin-top: 6px; font-size: 13px; letter-spacing: .22em; color: var(--muted); }

/* 散落卡背 */
.entry .logo::before, .entry .logo::after,
.entry h1::before, .entry h1::after,
.entry .sub::before, .entry .sub::after {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  width: 64px; height: 90px; border-radius: 8px; border: 3px solid var(--paper);
  background: var(--card-back); box-shadow: 0 6px 14px rgba(0,0,0,.55), inset 0 0 0 3px rgba(18,6,8,.35);
}
.entry .logo::before { left: -170px; top: -6px; transform: rotate(-16deg); }
.entry .logo::after  { right: -170px; top: 10px; transform: rotate(13deg); }
.entry h1::before { left: 5%; top: 60px; transform: rotate(9deg); }
.entry h1::after  { right: 5%; top: 66px; transform: rotate(-8deg); }
.entry .sub::before { left: 12%; top: 54px; transform: rotate(-6deg); }
.entry .sub::after  { right: 14%; top: 58px; transform: rotate(18deg); }

/* 入座登记表（羊皮纸） */
.entry form {
  grid-column: 2; grid-row: 1 / 6; align-self: center; position: relative; z-index: 2;
  --text: var(--ink); --muted: var(--ink-soft); --gold: #7a5410;
  display: flex; flex-direction: column; gap: 12px; padding: 26px 24px 22px;
  color: var(--ink); background: var(--paper-tex);
  border: 1px solid #a58b5b; border-radius: 6px;
  box-shadow: 0 0 0 4px var(--wood-1), 0 0 0 5px var(--brass-lo), 0 20px 44px rgba(0,0,0,.6);
}
.entry form::before {
  content: '入 座 登 记'; display: block; text-align: center; padding-bottom: 8px; margin-bottom: 2px;
  font-family: var(--serif); font-size: 20px; font-weight: 800; letter-spacing: .3em; color: var(--ink);
  border-bottom: 3px double #a58b5b;
}
.entry .row { display: flex; gap: 10px; align-items: stretch; }
.entry .row input { flex: 1; min-width: 0; }
.entry #name-input { font-size: 18px; min-height: 48px; }
#code-input { text-align: center; letter-spacing: .3em; font-family: var(--serif); font-weight: 800; font-size: 20px; padding-left: 14px; }
/* 层次：加入（次要，带虚线分隔）→ 创建（主按钮） */
.entry form > .row:nth-of-type(1) { flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px dashed #a58b5b; }
.entry form > .row:nth-of-type(1) button { min-width: 104px; }
.entry form > button.primary { min-height: 56px; font-size: 19px; letter-spacing: .12em; font-family: var(--serif); }
.entry form > .row:nth-of-type(2) { padding-top: 6px; gap: 8px; }
.entry form > .row:nth-of-type(2) button {
  flex: 1; font-size: 13px; min-height: var(--tap); color: var(--ink-soft);
  background: transparent; border: 1px solid #a58b5b; box-shadow: none;
}
.entry form > .row:nth-of-type(2) button:hover:not(:disabled) { filter: none; background: rgba(120,84,30,.12); }
.entry .hint { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.75; }

/* ---------- 7. 房间：围坐牌桌 ---------- */
.lobby2 {
  flex: 1; width: 100%; max-width: 1040px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding: 24px 16px 40px;
}
.lobby-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hero-skull { font-size: 40px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); }
.hero-title { font-family: var(--serif); font-size: 18px; font-weight: 800; letter-spacing: .5em; padding-left: .5em; color: var(--brass-hi); }

/* 黄铜房间码铭牌 */
.invite-card {
  position: relative; margin-top: 12px; min-width: min(420px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 44px 16px; border-radius: 10px; color: #2a1b0c;
  border: 1px solid #f0d9a0;
  background:
    radial-gradient(circle at 15px 15px, #5d4219 0 3px, rgba(255,255,255,.55) 3px 4.5px, transparent 5px),
    radial-gradient(circle at calc(100% - 15px) 15px, #5d4219 0 3px, rgba(255,255,255,.55) 3px 4.5px, transparent 5px),
    radial-gradient(circle at 15px calc(100% - 15px), #5d4219 0 3px, rgba(255,255,255,.55) 3px 4.5px, transparent 5px),
    radial-gradient(circle at calc(100% - 15px) calc(100% - 15px), #5d4219 0 3px, rgba(255,255,255,.55) 3px 4.5px, transparent 5px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, transparent 1px 4px),
    linear-gradient(145deg, #ecd49b, var(--brass) 45%, #94742f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), inset 0 -3px 6px rgba(70,45,10,.35), 0 0 0 3px var(--wood-0), 0 14px 30px rgba(0,0,0,.55);
}
.invite-label { font-size: 12px; font-weight: 700; color: #4a3410; letter-spacing: .25em; }
.invite-code {
  font-family: var(--serif); font-size: 56px; line-height: 1.1; font-weight: 900; font-variant-numeric: tabular-nums;
  letter-spacing: .22em; padding-left: .22em; color: #2a1b0c; text-shadow: 0 1px 0 rgba(255,238,200,.7), 0 -1px 0 rgba(60,40,10,.4);
}
.invite-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.invite-link { font-size: 13px; color: #3a2808; background: rgba(60,40,10,.16); border-radius: 6px; padding: 6px 10px; max-width: 100%; overflow-wrap: anywhere; box-shadow: inset 0 1px 3px rgba(60,40,10,.35); }

.lobby-main { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.panel { position: relative; border-radius: 14px; padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; font-family: var(--serif); font-weight: 800; font-size: 17px; }
.panel-count { font-family: var(--serif); font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); }
.panel-note { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }
.tag { font-family: var(--sans); font-size: 11px; font-weight: 400; color: var(--muted); border: 1px solid currentColor; padding: 2px 8px; border-radius: 999px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* 左：围桌场景（房间与游戏共用 .table-arena） */
.lobby-main > .panel:first-child:not(.table-arena) { padding: 0; background: none; box-shadow: none; border-radius: 0; }
.lobby-main > .panel:first-child .panel-head { justify-content: center; gap: 14px; color: var(--brass-hi); letter-spacing: .1em; }

/* ---- 共用围桌：椭圆毡面 + 木沿 + 黄铜边 + 罗盘 ---- */
.table-arena {
  --arena-h: 560px;
  --plate-w: 116px;
  --play-w: 56px; --play-h: 80px;
  --play-spread-x: 1; --play-spread-y: .94;
  position: relative; width: calc(100% - 40px); max-width: 1080px; height: var(--arena-h);
  margin: 22px auto; border-radius: 50%;
  background: var(--compass) center / min(46%, 420px) no-repeat, var(--felt-tex);
  box-shadow: 0 0 0 10px #3a2619, 0 0 0 12px var(--brass), 0 0 0 14px #120b07, 0 20px 44px 14px rgba(0,0,0,.5), inset 0 0 0 2px var(--brass), inset 0 0 90px rgba(0,0,0,.55);
}
.table-arena::before { /* 座位环细线 */
  content: ''; position: absolute; inset: 7%; border: 1px dashed rgba(198,161,90,.26); border-radius: 50%; pointer-events: none;
}
.lobby-main > .panel .table-arena { width: calc(100% - 40px); }

/* 玩家 / 空位：边缘座位 */
.table-place {
  position: absolute; z-index: 3;
  left: var(--seat-x, 50%); top: var(--seat-y, 50%); transform: translate(-50%, -50%);
  width: var(--plate-w); max-width: 100%;
  display: flex; flex-direction: column; align-items: center; min-width: 0;
}
.table-place:has(.active) { z-index: 5; }
.table-player { position: relative; width: 100%; min-width: 0; }
.table-front { position: static; display: contents; }
.table-front:empty { display: none; }

/* 桌前出牌槽：独立定位，朝桌心收拢 */
.table-play-slot {
  position: absolute; z-index: 2; pointer-events: none;
  left: calc(50% + (var(--play-x, 50%) - 50%) * var(--play-spread-x));
  top: calc(50% + (var(--play-y, 50%) - 50%) * var(--play-spread-y));
  transform: translate(-50%, -50%);
  width: var(--play-w); height: var(--play-h);
  display: flex; align-items: center; justify-content: center;
}
.table-play-slot:empty { border: 1px dashed rgba(198,161,90,.28); border-radius: 8px; background: rgba(0,0,0,.10); }

/* 桌心状态：简短，不压牌 */
.table-status {
  position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max-content; max-width: min(240px, 34%); text-align: center; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px; line-height: 1.4; color: var(--muted); text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.table-status .trick-banner { transform: none; padding: 5px 12px; font-size: 13px; text-shadow: none; animation: pop .25s; }
.table-status b { color: var(--brass-hi); font-family: var(--serif); }

/* 已赢墩：小叠牌 + 数量，贴名片外沿 */
.capture-pile {
  position: absolute; right: -8px; bottom: -6px; z-index: 2; pointer-events: none;
  display: flex; align-items: flex-end; gap: 2px;
  font-family: var(--serif); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
}
.capture-pile .card { --card-w: 16px; --card-h: 23px; border-width: 1px; border-radius: 3px; margin-left: -10px; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
.capture-pile .card:first-child { margin-left: 0; }
.capture-pile .card::before, .capture-pile .card::after { display: none; }
.capture-pile .n, .capture-pile .count, .capture-pile > span, .capture-pile > b {
  min-width: 20px; padding: 2px 5px; border-radius: 999px; text-align: center; font-size: 12px;
  color: #2a1b0c; background: linear-gradient(180deg, #f0d9a0, var(--brass)); border: 1px solid #7d5f27; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.capture-pile > .pile-stack { display: flex; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; min-width: 0; }
.capture-pile.bump { animation: pile-bump .45s ease-out; }
@keyframes pile-bump { 40% { transform: scale(1.3); } }

/* 房间名片（围坐版） */
.lobby-arena .player-card { width: 100%; }
.player-card { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; text-align: center; }
.player-card .avatar {
  width: 56px; height: 56px; flex: none; font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 3px solid var(--brass); background: radial-gradient(circle at 50% 30%, #5a3d28, var(--wood-0));
  box-shadow: 0 0 0 3px #120b07, 0 6px 12px rgba(0,0,0,.5), inset 0 0 12px rgba(0,0,0,.6);
}
.player-card .pc-info { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; margin-top: -10px; position: relative; }
.player-card .pc-name { /* 座牌 */
  display: block; max-width: 100%; padding: 2px 10px; border-radius: 4px;
  font-weight: 700; font-size: 14px; color: var(--ink); background: var(--paper); border: 1px solid #a58b5b;
  box-shadow: 0 3px 6px rgba(0,0,0,.45); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-card .pc-badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.pc-badge { font-size: 11px; padding: 0 8px; border-radius: 999px; background: rgba(0,0,0,.45); border: 1px solid rgba(198,161,90,.55); color: var(--muted); }
.pc-badge.captain { color: #2a1b0c; background: var(--brass); border-color: var(--brass-hi); font-weight: 800; }
.pc-badge.off { color: #ffb29c; border-color: var(--danger); }
.player-card.captain .avatar { border-color: var(--brass-hi); box-shadow: 0 0 0 3px #120b07, 0 0 0 5px var(--brass-lo), 0 0 20px rgba(228,201,139,.4), inset 0 0 12px rgba(0,0,0,.6); }
.player-card.ghost {
  justify-content: center; min-height: 72px; margin: 0; padding: 8px;
  border: 2px dashed rgba(198,161,90,.45); border-radius: 50px; background: rgba(0,0,0,.18);
  color: rgba(246,237,220,.65); font-size: 13px;
}

/* 右：纸质规则板 */
.lobby-main > .panel:last-child {
  --text: var(--ink); --muted: var(--ink-soft); --gold: #7a5410;
  color: var(--ink); background: var(--paper-tex); border: 1px solid #a58b5b; border-radius: 4px; padding: 22px 18px 14px;
  box-shadow: 0 0 0 3px var(--wood-1), 0 14px 30px rgba(0,0,0,.55);
}
.lobby-main > .panel:last-child::before { /* 黄铜夹板 */
  content: ''; position: absolute; top: -13px; left: 50%; width: 96px; height: 22px; transform: translateX(-50%);
  border-radius: 5px; border: 1px solid #f0d9a0; background: linear-gradient(180deg, #ecd49b, #94742f); box-shadow: 0 3px 6px rgba(0,0,0,.5);
}
.lobby-main > .panel:last-child .panel-head { color: var(--ink); border-bottom: 3px double #a58b5b; padding-bottom: 8px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; min-height: 56px; border-bottom: 1px dashed #b59a68; }
.setting-row:last-of-type { border-bottom: none; }
label.setting-row { cursor: pointer; }
.setting-row .setting-info { min-width: 0; }
.setting-row .setting-info b { display: block; font-size: 14px; }
.setting-row .setting-info span { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; line-height: 1.5; }
.setting-row select { flex: none; max-width: 48%; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: #8f7e60; box-shadow: inset 0 2px 4px rgba(0,0,0,.35); transition: background .2s; pointer-events: none; }
.switch .slider::before {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; top: 4px; left: 4px;
  background: var(--paper-3); box-shadow: 0 2px 3px rgba(0,0,0,.4); transition: transform .2s;
}
.switch input:checked + .slider { background: var(--felt-1); }
.switch input:checked + .slider::before { transform: translateX(22px); background: var(--brass-hi); }
.switch input:focus-visible + .slider { outline: 3px solid #ffd98a; outline-offset: 2px; }

/* 底部开局 */
.lobby-actions {
  display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  width: 100%; padding: 10px 0 0;
}
.start-btn {
  min-height: 60px; padding: 14px 52px; border-radius: 12px; border: 3px solid #f0d9a0;
  font-family: var(--serif); font-size: 22px; font-weight: 900; letter-spacing: .15em; color: #2a1b0c;
  background: linear-gradient(180deg, #f0d9a0, var(--brass) 55%, #a98539);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 0 0 3px var(--wood-0), 0 5px 0 #5b4217, 0 12px 24px rgba(0,0,0,.5);
}
.ghost-btn { background: rgba(0,0,0,.25); border: 1px solid rgba(198,161,90,.55); box-shadow: none; }
.ghost-btn.danger-text { color: #ffb29c; border-color: #8a4a3d; }
.wait-note { color: var(--muted); font-size: 14px; padding: 8px 12px; border-radius: 6px; background: rgba(0,0,0,.3); }

/* ---------- 8. 游戏牌桌 ---------- */
.game { flex: 1; position: relative; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; align-content: start; }
.game > * { grid-column: 1; min-width: 0; }
.game > .topbar { grid-row: 1; position: sticky; }
.game > .game-arena { grid-row: 2; }
.game > .me { grid-row: 3; }

.game-arena { margin-top: 28px; margin-bottom: 26px; }

/* 玩家名片（含自己）：压缩的铜牌 + 背牌 */
.seat {
  position: relative; width: 100%; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 6px 8px;
  border-radius: 12px; border: 2px solid #120b07;
  background: var(--grain), linear-gradient(180deg, #3f2c20, var(--wood-0));
  box-shadow: inset 0 1px 0 rgba(255,225,170,.14), 0 6px 14px rgba(0,0,0,.5);
  transition: border-color .2s, box-shadow .2s;
}
.seat .nm { /* 铜座牌 */
  display: block; max-width: 100%; padding: 1px 8px; border-radius: 4px;
  font-size: 14px; font-weight: 700; color: #2a1b0c; border: 1px solid #f0d9a0;
  background: linear-gradient(180deg, #ecd49b, #b08f45);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat .nm .dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #1f7a3a; border: 1px solid #0d3b1b; vertical-align: 1px; }
.seat .nm .dot.off { background: #b8402a; border-color: #5e180c; }
.seat .badges { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.badge {
  font-family: var(--serif); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.5;
  padding: 0 7px; border-radius: 999px; color: var(--muted); white-space: nowrap;
  background: rgba(0,0,0,.4); border: 1px solid rgba(198,161,90,.45);
}
.badge.bid { color: var(--brass-hi); }
.badge.turn { color: #2a1b0c; background: linear-gradient(180deg, #f0d9a0, var(--brass)); border-color: #f0d9a0; font-weight: 800; }
.seat .backs { display: flex; justify-content: center; min-height: 32px; margin-top: 1px; }
.seat .backs .card.tiny { --card-w: 24px; --card-h: 33px; margin-left: -14px; box-shadow: 0 2px 4px rgba(0,0,0,.55); }
.seat .backs .card.tiny:first-child { margin-left: 0; }
.seat .backs .card.tiny.back::after { font-size: 11px; }
.seat.active { border-color: var(--brass-hi); box-shadow: 0 0 0 2px var(--brass-lo), 0 0 26px rgba(228,201,139,.6), 0 6px 14px rgba(0,0,0,.5); animation: seatglow 1.6s ease-in-out infinite; }
.seat.winner { border-color: var(--ok); box-shadow: 0 0 0 2px #1f7a3a, 0 0 24px rgba(143,214,162,.6), 0 6px 14px rgba(0,0,0,.5); }
.seat.me-seat, .table-place.me .seat { border-color: var(--brass-lo); }
@keyframes seatglow { 50% { box-shadow: 0 0 0 2px var(--brass-lo), 0 0 38px rgba(228,201,139,.85), 0 6px 14px rgba(0,0,0,.5); } }

/* 桌前牌：正向读牌，不随座位旋转 */
.played-card { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.card.played-card { --card-w: var(--play-w); --card-h: var(--play-h); border-radius: 7px; box-shadow: 0 5px 10px rgba(0,0,0,.55); }
.played-card .big { font-size: 24px; }
.played-card.k-special .big { font-size: 24px; }
.played-card .suit { font-size: 13px; }
.played-card .label { font-size: 9px; margin-top: 2px; padding: 0 2px; }
.played-card .who { display: none; } /* 名字已由座位名片表达，避免占位 */
.card.played-card.winner { box-shadow: 0 0 0 3px var(--ok), 0 0 18px rgba(143,214,162,.7), 0 5px 10px rgba(0,0,0,.55); }
.played-card.winner .who { color: var(--ok); font-weight: 700; }

@keyframes card-land { from { opacity: 0; transform: scale(1.35) translateY(-10px); } to { opacity: 1; transform: none; } }

.last-strip {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px;
  padding: 2px 10px; border-radius: 999px; background: rgba(0,0,0,.32); color: var(--muted); font-size: 12px;
}
.trick-banner {
  max-width: 100%; padding: 8px 20px; border-radius: 4px; font-size: 14px; font-weight: 700; text-align: center;
  color: var(--ink); background: var(--paper); border: 1px solid #a58b5b;
  box-shadow: 0 0 0 3px rgba(0,0,0,.3), 0 6px 12px rgba(0,0,0,.45); animation: pop .25s;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { opacity: 1; } }

/* 我的席位：桌沿木盘 + 记分牌 + 手牌 */
.me {
  z-index: 2; width: calc(100% - 44px); max-width: 1080px; justify-self: center; margin: 0 auto 16px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0;
  border: 2px solid var(--brass-lo); border-radius: 14px;
  background: var(--grain), linear-gradient(180deg, #3e2b1f, var(--wood-0));
  box-shadow: inset 0 2px 0 rgba(255,225,170,.2), inset 0 0 0 4px rgba(0,0,0,.28), 0 -8px 22px rgba(0,0,0,.4), 0 12px 24px rgba(0,0,0,.5);
}
.me .mybadges { /* 记分牌 */
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; max-width: 100%;
  padding: 6px 12px; border-radius: 6px; background: var(--paper); border: 1px solid #a58b5b;
  box-shadow: 0 0 0 3px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.45);
}
.me .mybadges .badge { font-size: 15px; color: var(--ink); background: rgba(120,84,30,.12); border-color: #b59a68; padding: 1px 10px; max-width: 100%; overflow-wrap: anywhere; }
.me .mybadges .badge.bid { color: #7a3d00; }
.me .mybadges .badge.turn { color: #2a1b0c; background: linear-gradient(180deg, #f0d9a0, var(--brass)); border-color: var(--brass-lo); animation: turnpulse 1.4s ease-in-out infinite; }
@keyframes turnpulse { 50% { box-shadow: 0 0 0 4px rgba(198,161,90,.45); } }

/* 手牌：像握在手里的扇形，局部横向滚动 */
.hand {
  width: 100%; max-width: 100%; min-height: calc(var(--card-h) + 38px);
  display: flex; align-items: flex-end; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  padding: 26px 18px 12px; -webkit-overflow-scrolling: touch; scrollbar-color: var(--brass-lo) transparent;
}
.hand > .card:first-child { margin-left: auto; }
.hand > .card:last-child { margin-right: auto; }
.hand > .card + .card { margin-left: -14px; }
.hand .card { --lift: 0px; --rot: 0deg; transform: translateY(var(--lift)) rotate(var(--rot)); transform-origin: 50% 100%; transition: transform .12s, box-shadow .12s, filter .12s; cursor: default; }
.hand .card:nth-child(3n+1) { --rot: -1.2deg; }
.hand .card:nth-child(3n) { --rot: 1.2deg; }
.hand .card.legal { --lift: -12px; cursor: pointer; z-index: 2; box-shadow: 0 0 0 3px var(--brass-hi), 0 0 16px 3px rgba(228,201,139,.55), 0 4px 10px rgba(0,0,0,.5); }
.hand .card.legal:hover { --lift: -22px; z-index: 6; }
.hand.my-turn { background: radial-gradient(ellipse 60% 70% at 50% 100%, rgba(228,201,139,.20), transparent); }
.hand .card.dim { filter: brightness(.6) saturate(.75); }
.me .hint { min-height: 22px; font-size: 13px; color: var(--muted); text-align: center; }
.me .hint.hot { font-size: 14px; color: var(--brass-hi); font-weight: 700; }

/* 叫墩 / 装填：纸条面板（内嵌，不遮挡手牌） */
.bid-panel {
  --text: var(--ink); --muted: var(--ink-soft); --gold: #7a5410;
  width: min(720px, 100%); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; animation: pop .25s;
  color: var(--ink); background: var(--paper-tex); border: 1px solid #a58b5b; border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(0,0,0,.3), 0 8px 18px rgba(0,0,0,.45);
}
.bid-panel .bid-title { font-family: var(--serif); font-size: 15px; font-weight: 800; color: var(--ink); text-align: center; }
.bid-panel .bid-note { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.6; }
.bid-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0 2px; }
.bid-grid button { min-width: 56px; min-height: 56px; padding: 6px 10px; font-family: var(--serif); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; border-radius: 50%; }
.bid-grid button[style] { border-radius: 12px; min-width: 112px; font-size: 15px; font-family: var(--sans); }
.bid-grid button.sel { color: #2a1b0c; background: linear-gradient(180deg, #f0d9a0, var(--brass)); }

/* ---------- 9. 弹窗：规则册 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,12,7,.72), rgba(6,3,2,.9)); animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  --text: var(--ink); --muted: var(--ink-soft); --gold: #7a5410; --ok: #1f6b3d; --danger: #a3321d;
  position: relative; width: 100%; max-width: 640px; min-width: 0;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  color: var(--ink); font-size: 15px;
  border: 1px solid #3a2616; border-left: 16px solid #3a2616; border-radius: 4px 12px 12px 4px;
  background: var(--paper-tex);
  box-shadow: 0 0 0 2px #120b07, 0 28px 70px rgba(0,0,0,.7);
}
.modal h2 {
  position: sticky; top: 0; z-index: 3; padding: 16px 20px 10px; margin-bottom: 4px;
  font-size: 21px; font-weight: 900; letter-spacing: .1em; text-align: center; color: var(--ink);
  background: linear-gradient(180deg, #f2e5c9 80%, rgba(242,229,201,0));
  border-bottom: 3px double #a58b5b; overflow-wrap: anywhere;
}
.modal > :not(h2) { margin-left: 22px; margin-right: 22px; }
.modal > :not(h2):last-child { margin-bottom: 22px; }
.modal .close-x {
  float: right; min-width: var(--tap); min-height: var(--tap); margin: -8px -10px -8px 8px; padding: 0; font-size: 18px;
  color: var(--ink); background: transparent; border: 1px solid #a58b5b; box-shadow: none; border-radius: 50%;
}
.modal .desc { color: var(--ink-soft); font-size: 13px; text-align: center; line-height: 1.8; margin-top: 10px; }
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* 规则正文：支持 h3/h4/p/ul/ol/table/details */
.rules-body { font-size: 15px; line-height: 1.85; color: var(--ink); }
.rules-body h3 { margin: 18px 0 6px; padding-bottom: 3px; font-size: 17px; color: #5b3a0a; border-bottom: 1px dotted #a58b5b; }
.rules-body h3:first-child { margin-top: 6px; }
.rules-body h4 { margin: 12px 0 4px; font-family: var(--serif); font-size: 15px; color: #5b3a0a; }
.rules-body p { margin: 6px 0; }
.rules-body ul, .rules-body ol { padding-left: 22px; }
.rules-body li { margin-bottom: 4px; }
.rules-body .em { color: #7a3d00; font-weight: 700; }
.rules-body code, .rules-body kbd { font-family: ui-monospace, Menlo, monospace; font-size: .9em; padding: 0 5px; border-radius: 4px; background: rgba(120,84,30,.14); border: 1px solid #b59a68; }
.rules-body table, .modal table.rules-table {
  display: block; max-width: 100%; margin: 10px 0; overflow-x: auto; border-collapse: collapse; font-size: 14px;
}
.rules-body th, .rules-body td { padding: 7px 10px; text-align: left; vertical-align: top; border: 1px solid #b59a68; min-width: 64px; }
.rules-body th { font-family: var(--serif); color: var(--ink); background: rgba(120,84,30,.16); white-space: nowrap; }
.rules-body tr:nth-child(even) td { background: rgba(120,84,30,.06); }
.rules-body details { margin: 8px 0; border: 1px solid #b59a68; border-radius: 6px; background: rgba(251,243,223,.55); }
.rules-body summary {
  min-height: var(--tap); padding: 8px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 700; color: #5b3a0a; list-style: none;
}
.rules-body summary::-webkit-details-marker { display: none; }
.rules-body summary::before { content: '▸'; color: var(--brass-lo); transition: transform .15s; }
.rules-body details[open] > summary::before { transform: rotate(90deg); }
.rules-body details[open] > summary { border-bottom: 1px dashed #b59a68; }
.rules-body details > :not(summary) { margin-left: 12px; margin-right: 12px; }
.rules-body details > :last-child { margin-bottom: 10px; }

/* 卡牌一览 */
.gallery-row { display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.gallery-label { font-size: 13px; color: var(--ink-soft); margin-left: 4px; }
.gallery-item {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 10px 0; padding: 10px 14px;
  background: rgba(120,84,30,.10); border: 1px solid #b59a68; border-radius: 8px;
}
.gallery-item .gallery-cards { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery-item .card-desc { flex: 1; min-width: 160px; font-size: 13px; color: var(--ink-soft); line-height: 1.75; }
.gallery-item .card-desc b { color: var(--ink); font-size: 14px; }
.fan { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.fan .card { margin-left: -24px; transition: transform .12s; }
.fan .card:first-child { margin-left: 0; }
.fan .card:hover { transform: translateY(-8px); z-index: 5; }
.fan .card .label { display: none; }
.fan .gallery-label { width: 100%; order: 2; margin: 4px 0 0 2px; }
.fan .card.fan-num .suit { position: absolute; top: 2px; left: 5px; font-size: 10px; line-height: 1; margin: 0; }
.fan .card.fan-num .big { position: absolute; top: 19px; left: 5px; font-size: 13px; line-height: 1; }
.fan .card.fan-num:last-of-type .suit,
.fan .card.fan-num:hover .suit { position: static; font-size: 11px; margin-bottom: 2px; }
.fan .card.fan-num:last-of-type .big,
.fan .card.fan-num:hover .big { position: static; font-size: 19px; }

/* ---------- 10. 记分 / 结算 / 日志 ---------- */
.score-table { width: calc(100% - 44px); border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.score-table th, .score-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid #c4ab78; }
.score-table th { font-family: var(--serif); font-weight: 700; font-size: 12px; letter-spacing: .1em; color: var(--ink-soft); border-bottom: 2px solid #a58b5b; }
.score-table td { font-variant-numeric: tabular-nums; }
.score-table td.name { text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.score-table tr.me-row td { background: rgba(198,161,90,.28); }
.score-table .pts-pos { color: var(--ok); font-family: var(--serif); font-size: 16px; font-weight: 900; }
.score-table .pts-neg { color: var(--danger); font-family: var(--serif); font-size: 16px; font-weight: 900; }
.detail-lines { font-size: 12px; color: var(--ink-soft); line-height: 1.7; margin-top: 4px; }
.crown { font-size: 20px; }

.final-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; margin-bottom: 4px; }
.final-row {
  display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 16px; border-radius: 6px;
  background: rgba(251,243,223,.6); border: 1px solid #b59a68;
}
.final-row.first { border: 2px solid var(--brass-lo); background: linear-gradient(90deg, rgba(198,161,90,.5), rgba(251,243,223,.5)); }
.final-row .rank { width: 32px; flex: none; font-size: 20px; font-weight: 900; text-align: center; color: #7a3d00; }
.final-row .fname { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.final-row .fscore { font-family: var(--serif); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.continue-status { text-align: center; color: var(--ink-soft); font-size: 13px; margin-top: 10px; }
.countdown { color: #7a3d00; font-family: var(--serif); font-weight: 900; font-variant-numeric: tabular-nums; }

.log-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; max-height: 60vh; overflow-y: auto; margin-top: 12px; }
.log-list .log-item { color: var(--ink-soft); border-bottom: 1px dashed #b59a68; padding-bottom: 5px; overflow-wrap: anywhere; }
.log-list .log-item.hl { color: #7a3d00; font-weight: 700; }

/* ---------- 11. Toast（木牌） ---------- */
#toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; width: min(92vw, 520px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast-item {
  max-width: 100%; padding: 10px 22px; border-radius: 6px; font-size: 14px; color: var(--text); text-align: center; overflow-wrap: anywhere;
  background: linear-gradient(180deg, var(--wood-2), var(--wood-1)); border: 1px solid var(--brass);
  box-shadow: 0 0 0 2px #120b07, 0 10px 26px rgba(0,0,0,.6); animation: pop .2s;
}
.toast-item.err { border-color: var(--danger); color: #ffd0c2; }

/* ---------- 12. 响应式 / 可访问性 ---------- */
@media (max-width: 900px) {
  .entry { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; gap: 0; padding: 16px 14px 28px; align-content: start; }
  .entry::before, .entry::after { grid-row: 1 / 4; min-height: 0; }
  .entry::before { min-height: 250px; }
  .entry::after { margin: 18px; }
  .entry .logo { grid-row: 1; margin-top: 30px; width: 88px; height: 88px; font-size: 48px; }
  .entry h1 { grid-row: 2; margin-top: 10px; font-size: 40px; }
  .entry .sub { grid-row: 3; margin-bottom: 30px; font-size: 11px; letter-spacing: .14em; }
  .entry form { grid-column: 1; grid-row: 4; margin: 22px 6px 0; }
  .entry .logo::before { left: -96px; top: 4px; width: 46px; height: 64px; }
  .entry .logo::after { right: -96px; top: 12px; width: 46px; height: 64px; }
  .entry h1::before, .entry h1::after { display: none; }
  .entry .sub::before { left: 8%; top: -6px; width: 40px; height: 56px; }
  .entry .sub::after { right: 8%; top: -2px; width: 40px; height: 56px; }
  .lobby-main { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

@media (max-width: 900px) and (min-width: 641px) {
  .table-arena { --arena-h: 600px; --plate-w: 108px; }
  .table-arena[data-count="7"], .table-arena[data-count="8"] { --arena-h: 640px; }
}

@media (max-width: 760px) {
  .invite-card { padding: 12px 30px 14px; }
  .invite-code { font-size: 42px; }
  .lobby-actions { position: sticky; bottom: 0; z-index: 10; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); margin-top: 4px; background: linear-gradient(180deg, transparent, rgba(33,23,17,.96) 30%); }
  .start-btn { width: 100%; padding: 12px 20px; }
}

@media (max-width: 640px) {
  :root { --card-w: 62px; --card-h: 90px; }
  .card .big { font-size: 28px; }
  .card .suit { font-size: 17px; }
  .card.k-special .big { font-size: 28px; }

  .topbar { position: static; padding: 8px 10px; gap: 6px; }
  .topbar .brand { display: none; }
  .topbar .spacer { display: none; }
  .topbar button { flex: 1 1 auto; min-height: var(--tap); padding: 6px 8px; font-size: 13px; }

  .lobby2 { padding: 16px 10px 24px; gap: 16px; }
  .lobby-main > .panel:first-child:not(.table-arena) { margin: 0; padding: 0; }
  .player-card .avatar { width: 58px; height: 58px; font-size: 30px; }
  .setting-row select { max-width: 52%; }

  /* 围桌：窄屏加高、缩小名片与牌位，座位不换成网格 */
  .table-arena {
    --arena-h: 620px; --plate-w: 90px; --play-w: 46px; --play-h: 66px; --play-spread-x: .9; --play-spread-y: .94;
    width: calc(100% - 32px); margin: 20px auto;
    box-shadow: 0 0 0 7px #3a2619, 0 0 0 9px var(--brass), 0 0 0 11px #120b07, 0 14px 30px 10px rgba(0,0,0,.5), inset 0 0 0 2px var(--brass), inset 0 0 60px rgba(0,0,0,.55);
  }
  .table-arena[data-count="5"], .table-arena[data-count="6"] { --arena-h: 680px; }
  .table-arena[data-count="7"], .table-arena[data-count="8"] { --arena-h: 740px; }
  .game-arena[data-count="8"] { --play-w: 38px; --play-h: 58px; }
  .table-status { max-width: 112px; font-size: 12px; }
  .table-status .trick-banner { padding: 4px 8px; font-size: 12px; }
  .lobby-main > .panel .table-arena { width: calc(100% - 32px); }
  .player-card .avatar { width: 46px; height: 46px; font-size: 24px; border-width: 2px; }
  .player-card .pc-name { font-size: 12px; padding: 1px 6px; }
  .player-card.ghost { min-height: 60px; font-size: 12px; }
  .game-arena { margin-top: 18px; margin-bottom: 18px; }
  .seat { padding: 4px 3px 6px; gap: 2px; border-radius: 10px; }
  .seat .nm { font-size: 12px; padding: 0 5px; }
  .seat .nm .dot { width: 7px; height: 7px; margin-right: 3px; }
  .seat .badges { gap: 2px; }
  .badge { font-size: 11px; padding: 0 5px; }
  .seat .backs { min-height: 24px; }
  .seat .backs .card.tiny { --card-w: 18px; --card-h: 25px; margin-left: -11px; }
  .seat .backs .card.tiny.back::after { display: none; }
  .capture-pile { right: -4px; bottom: -8px; }
  .capture-pile .card { --card-w: 13px; --card-h: 19px; margin-left: -8px; }
  .played-card .big { font-size: 20px; }
  .played-card.k-special .big { font-size: 20px; }
  .played-card .label { font-size: 8px; }
  .played-card .suit { font-size: 11px; }

  .me { width: calc(100% - 20px); margin: 0 auto 10px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); border-radius: 12px; }
  .me .mybadges .badge { font-size: 13px; padding: 0 8px; }
  .hand { padding: 24px 10px 10px; min-height: calc(var(--card-h) + 36px); }
  .hand > .card + .card { margin-left: -12px; }
  .hand .card.legal { --lift: -10px; }
  .bid-grid button { min-width: 52px; min-height: 52px; }

  .overlay { padding: 8px; }
  .modal { border-left-width: 12px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); font-size: 14px; }
  .modal > :not(h2) { margin-left: 14px; margin-right: 14px; }
  .modal h2 { padding: 14px 12px 8px; font-size: 18px; letter-spacing: .04em; }
  .score-table { display: block; width: calc(100% - 28px); overflow-x: auto; font-size: 13px; }
  .score-table th, .score-table td { padding: 6px 5px; }
  .fan .card { margin-left: -27px; }
  .gallery-item { gap: 8px; }
  .toast-item { padding: 9px 16px; }
}

@media (max-width: 380px) {
  .entry h1 { font-size: 34px; }
  .table-arena { --plate-w: 84px; }
  .table-arena[data-count="2"], .table-arena[data-count="3"], .table-arena[data-count="4"] { --arena-h: 600px; }
  .invite-code { font-size: 36px; letter-spacing: .14em; }
  .hero-title { letter-spacing: .3em; }
}

@media (hover: none), (pointer: coarse) {
  .topbar button { min-height: var(--tap); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

.ghost-seat { border-color: #b5b2d0; }
.ghost-seat .nm { color: #e7e4ff; }

/* ---------- 固定视口：牌桌占用剩余高度，操作区始终可见 ---------- */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
#root { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.entry, .lobby2, .game { min-height: 0; flex: 1 1 0; }
.entry { padding-block: 16px; }
.entry::before { min-height: 0; }
.lobby2 { padding: 12px 16px; gap: 12px; }
.lobby-hero { flex: none; }
.hero-skull { display: none; }
.invite-card { margin: 0; padding: 8px 28px; }
.invite-code { font-size: 36px; }
.lobby-main { flex: 1; min-height: 0; align-items: stretch; }
.lobby-main > .panel:first-child { display: flex; flex-direction: column; min-height: 0; }
.lobby-main .panel-head { margin-bottom: 6px; flex: none; }
.lobby-main .panel-note { margin-top: 4px; flex: none; }
.lobby-main .lobby-arena { flex: 1; height: auto; min-height: 0; margin: 18px auto; }
.lobby-main > .panel:last-child { align-self: center; }
.lobby-actions { flex: none; position: static; padding: 4px 0; margin: 0; }
.start-btn { min-height: 46px; padding: 6px 28px; font-size: 18px; }
.game { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }
.game > .topbar { position: static; }
.game > .game-arena { height: auto; min-height: 0; margin: 18px auto; }
.me { margin-bottom: 8px; padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
.hand { min-height: 0; height: calc(var(--card-h) + 36px); overflow: hidden; padding: 24px 12px 12px; }
.hand > .card + .card { margin-left: min(-14px, calc((100cqw - 24px - var(--card-w) * var(--hand-count)) / max(1, var(--hand-count) - 1))); }
.hand { container-type: inline-size; }
.me .hint { min-height: 18px; }

@media (max-width: 900px) {
  .entry { align-content: center; padding: 12px; grid-template-rows: auto auto auto auto; }
  .entry::before, .entry::after { grid-row: 1 / 4; min-height: 0; }
  .entry .logo { margin-top: 12px; width: 58px; height: 58px; font-size: 34px; }
  .entry h1 { margin-top: 8px; font-size: 32px; }
  .entry .sub { margin: 4px 0 14px; }
  .entry form { margin: 12px auto 0; width: min(100%, 420px); padding: 14px 18px; gap: 8px; }
  .entry form::before { font-size: 16px; padding-bottom: 4px; }
  .entry form > button.primary { min-height: 46px; }
  .lobby-main { grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
  .lobby-main > .panel:last-child { padding: 12px; }
  .setting-row { min-height: 44px; padding: 6px 0; }
}
@media (max-width: 640px) {
  .lobby2 { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  .invite-card { padding: 6px 14px; min-width: 0; width: 100%; }
  .lobby-hero { width: 100%; }
  .invite-label { font-size: 10px; }
  .invite-code { font-size: 28px; }
  .invite-row { flex-wrap: nowrap; margin: 0; gap: 6px; }
  .invite-link { min-width: 0; font-size: 10px; padding: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #copy-link { font-size: 12px; min-height: 34px; padding: 4px 8px; flex: none; }
  .lobby-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .lobby-main > .panel:last-child { align-self: stretch; padding: 8px 12px; border-radius: 6px; }
  .lobby-main > .panel:last-child::before { display: none; }
  .lobby-main > .panel:last-child .panel-head { display: none; }
  .setting-row { min-height: 36px; padding: 2px 0; }
  .setting-row .setting-info span { display: none; }
  .setting-row select { min-height: 32px; font-size: 12px; padding: 2px 6px; }
  .setting-info b { font-size: 12px; }
  .lobby-actions { gap: 6px; flex-wrap: nowrap; background: none; }
  .lobby-actions .start-btn { width: auto; flex: 1; }
  .lobby-actions button { min-height: 40px; padding: 6px 10px; font-size: 12px; }
  .lobby-main .lobby-arena { margin: 12px auto; }
  .lobby-arena { --plate-w: 76px; }
  .player-card .avatar { width: 32px; height: 32px; font-size: 20px; }
  .player-card.ghost { min-height: 42px; }
  .player-card .pc-badges { font-size: 9px; }
  .game > .game-arena { margin: 12px auto; }
  .game-arena { --plate-w: 76px; --play-w: 36px; --play-h: 52px; }
  .game-arena[data-count="8"] { --play-w: 32px; --play-h: 46px; }
  .seat .backs { display: none; }
  .seat .nm { font-size: 11px; }
  .seat .badge { font-size: 10px; padding: 0 3px; }
  .game .topbar { padding: 5px 8px; gap: 4px; }
  .game .topbar button { min-height: 32px; padding: 4px 6px; font-size: 12px; }
  .game .topbar .round-chip, .game .topbar .phase-chip { font-size: 11px; padding: 3px 6px; }
  .me { padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 3px; }
  .me .mybadges { padding: 3px 6px; gap: 3px; }
  .me .mybadges .badge { font-size: 11px; padding: 0 5px; }
  .me .hint { font-size: 11px; }
}
@media (max-height: 560px) {
  :root { --card-w: 48px; --card-h: 68px; }
  .entry { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); grid-template-rows: 1fr auto auto auto 1fr; gap: 12px; }
  .entry::before, .entry::after { grid-column: 1; grid-row: 1 / 6; }
  .entry .logo { grid-row: 2; }
  .entry h1 { grid-row: 3; }
  .entry .sub { grid-row: 4; }
  .entry form { grid-column: 2; grid-row: 1 / 6; margin: 0; padding: 8px 14px; gap: 4px; }
  .entry form::before, .entry .hint { display: none; }
  .entry form > .row:nth-of-type(1) { padding-bottom: 4px; }
  .lobby-main { grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: minmax(0, 1fr); }
  .lobby2 { gap: 6px; }
  .invite-card { flex-direction: row; gap: 12px; }
  .invite-row { margin: 0; }
  .invite-code { font-size: 26px; }
  .lobby-main .panel-head, .lobby-main .panel-note { display: none; }
  .game .topbar { padding: 4px 8px; gap: 4px; }
  .game .topbar button { min-height: 30px; padding: 3px 6px; font-size: 12px; }
  .game-arena { --plate-w: 78px; --play-w: 32px; --play-h: 46px; }
  .seat .backs { display: none; }
  .me .mybadges { padding: 2px 6px; }
  .hand { height: calc(var(--card-h) + 28px); padding-top: 18px; padding-bottom: 10px; }
}

/* 游戏玩家卡：左上位次，左下猜墩，右下吃墩，中央名字与总分。 */
.game-arena .seat {
  display: flex; justify-content: center; gap: 3px;
  height: 112px; padding: 25px 6px 28px; border-radius: 10px;
  border: 1px solid #b79552;
  background: linear-gradient(145deg, rgba(246,223,171,.12), transparent 48%), var(--grain), linear-gradient(180deg, #443121, #20170f);
  box-shadow: inset 0 0 0 3px #24180f, inset 0 0 0 4px rgba(198,161,90,.24), 0 5px 12px #0008;
}
.game-arena .seat .seat-no {
  position: absolute; top: 5px; left: 6px; width: 21px; height: 21px;
  display: grid; place-items: center; border-radius: 50%;
  font: 800 13px/1 var(--serif); font-variant-numeric: tabular-nums;
  color: #2a1b0c; background: linear-gradient(#f2dfb4, #b18a3e); border: 1px solid #f0d9a0;
}
.game-arena .seat-presence { position: absolute; top: 6px; right: 7px; color: #a2d5af; font-size: 10px; line-height: 18px; }
.game-arena .seat-presence.off { color: #e6a18a; }
.game-arena .seat .nm {
  width: 100%; padding: 0; border: 0; background: none; border-radius: 0;
  color: var(--paper); font-size: 13px; line-height: 1.25; text-align: center;
}
.game-arena .seat-score { color: var(--brass-hi); font: 800 23px/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.game-arena .seat-score small { font: 400 10px/1 var(--sans); margin-left: 3px; color: var(--muted); }
.game-arena .seat-corner {
  position: absolute; bottom: 5px; display: flex; align-items: baseline; gap: 3px;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.game-arena .seat-corner small { font-size: 10px; color: var(--muted); }
.game-arena .seat-corner b { font: 800 18px/1 var(--serif); }
.game-arena .seat-corner.bid { left: 7px; color: var(--brass-hi); }
.game-arena .seat-corner.taken-badge { right: 7px; color: #b7dfc0; }
.game-arena .seat-load { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); font-size: 10px; }
.game-arena .ghost-seat .seat-score { font-size: 11px; font-weight: 400; color: var(--muted); }
.game-arena .seat.active { border-color: #ffe1a0; box-shadow: 0 0 0 2px #b69247, 0 0 24px #e4c98b80, inset 0 0 16px #e4c98b26; }
.game-arena .seat.winner { border-color: #9cdbad; box-shadow: 0 0 0 2px #4b9661, 0 0 22px #8fd6a280; }
@media (max-width: 640px), (max-height: 560px) {
  .game-arena .seat { height: 90px; padding: 22px 4px 24px; gap: 2px; }
  .game-arena .seat .nm { font-size: 11px; }
  .game-arena .seat-score { font-size: 19px; }
  .game-arena .seat .seat-no { width: 17px; height: 17px; font-size: 11px; top: 4px; left: 5px; }
  .game-arena .seat-presence { top: 3px; right: 5px; font-size: 9px; }
  .game-arena .seat-corner { bottom: 5px; gap: 2px; }
  .game-arena .seat-corner.bid { left: 5px; }
  .game-arena .seat-corner.taken-badge { right: 5px; }
  .game-arena .seat-corner b { font-size: 16px; }
  .game-arena .seat-corner small { font-size: 9px; }
}

/* 轮末结算表位于弹窗正文内，使用正文完整宽度，明细按分配宽度折行。 */
.modal .round-score-table {
  display: table; width: 100%; table-layout: fixed; overflow: visible;
}
.round-score-table .col-name { width: 16%; }
.round-score-table .col-count { width: 7%; }
.round-score-table .col-detail { width: 42%; }
.round-score-table .col-points { width: 14%; }
.round-score-table th, .round-score-table td { padding: 8px 4px; vertical-align: top; }
.round-score-table th { letter-spacing: 0; }
.round-score-table .round-detail {
  text-align: left; white-space: normal; overflow-wrap: anywhere; word-break: normal;
  font-size: 12px; line-height: 1.6;
}
@media (max-width: 640px) {
  .round-score-table th, .round-score-table td { padding: 6px 2px; }
  .round-score-table .pts-pos, .round-score-table .pts-neg { font-size: 14px; }
}

/* 顶部仅保留状态与菜单，操作列表浮在牌桌上方。 */
.game > .topbar { flex-wrap: nowrap; }
.game-menu-wrap { position: relative; margin-left: auto; flex: none; }
.game .topbar #btn-menu { flex: none; white-space: nowrap; }
.game-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  width: 172px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100dvh - 76px); overflow-y: auto;
  border: 1px solid var(--brass-lo); border-radius: 10px;
  background: var(--grain), linear-gradient(145deg, #443121, #20170f);
  box-shadow: 0 12px 32px #000b, inset 0 0 0 3px #20170f;
}
.game-menu[hidden] { display: none; }
.game .topbar .game-menu button { width: 100%; flex: none; min-height: 40px; text-align: left; padding: 8px 12px; font-size: 14px; }
@media (max-width: 640px) {
  .game .topbar .round-chip, .game .topbar .phase-chip { white-space: nowrap; }
  .game .topbar .round-chip { padding-inline: 4px; }
  .game .topbar .phase-chip { padding-inline: 4px; }
  .game .topbar #btn-menu { min-height: 34px; padding-inline: 8px; }
}
@media (max-width: 900px) { .game > .topbar .brand { display: none; } }
