:root {
  --bg: #0b1222;
  --bg2: #0f1a30;
  --panel: #131f38;
  --panel2: #1a2847;
  --line: rgba(255, 255, 255, .10);
  --text: #eef3ff;
  --muted: #9fb0d0;
  --gold: #ffd23f;
  --red: #e8343f;
  --green: #1fbf75;
  --felt: #177a4c;
  --radius: 14px;
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
h1, h2 { margin: 0; }

/* ---------- lobby ---------- */
.lobby { max-width: 980px; margin: 0 auto; padding: 28px 16px 56px; }
.hero { padding: 18px 0 8px; }
.kicker { margin: 0 0 10px; color: var(--gold); font-weight: 800; font-size: 14px; letter-spacing: .04em; }
.hero h1 { font-size: clamp(32px, 7vw, 56px); font-weight: 900; line-height: 1.1; letter-spacing: -.01em;
  text-shadow: 0 4px 0 #050914; }
.lede { max-width: 640px; margin: 14px 0 0; color: #cfdaf2; font-size: 16px; line-height: 1.75; }
.boot { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 14px; min-height: 22px; }
.boot .bar { width: 120px; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; flex: none; }
.boot .bar i { display: block; height: 100%; width: 4%; background: var(--gold); transition: width .4s ease; }
.boot.ok .bar { display: none; }
.boot.ok { color: var(--green); }
.boot.bad { color: #ff8a8a; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 26px 0 0; }
.mode { text-align: left; padding: 16px 16px 18px; min-height: 96px; border-radius: var(--radius); border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--panel2), var(--panel)); display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 4px 0 #060b17; transition: transform .12s ease, border-color .12s ease; }
.mode b { font-size: 21px; font-weight: 900; }
.mode small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.mode:hover { border-color: rgba(255, 210, 63, .5); transform: translateY(-2px); }
.mode[aria-pressed="true"] { border-color: var(--gold); background: linear-gradient(180deg, #2a2a1a, #1c2236); }

.byo-cta { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 12px; padding: 16px; min-height: 76px; text-align: left;
  border-radius: var(--radius); border: 2px dashed rgba(255, 210, 63, .45); background: rgba(255, 210, 63, .06); }
.byo-cta b { font-size: 19px; font-weight: 900; color: var(--gold); }
.byo-cta small { color: #cfdaf2; font-size: 13px; line-height: 1.6; }
.byo-cta[aria-pressed="true"] { border-style: solid; }
.byorow { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.codelabel { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 800; }
.code { width: 100%; min-height: 220px; resize: vertical; border-radius: 12px; border: 1px solid var(--line); background: #070c18; color: #d8e6ff;
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: 12px; }
.pickerfoot .muted { margin-right: auto; align-self: center; font-size: 13px; }
.picker { margin-top: 22px; padding: 18px; border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--line); }
.pickerhead { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.pickerhead h2 { font-size: 20px; font-weight: 900; }
.pickerhead p { margin: 0; font-size: 14px; }
.cast { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.ai { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; align-items: center; text-align: left;
  padding: 10px; min-height: 76px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); }
.ai img { grid-row: 1 / span 2; width: 44px; height: 66px; object-fit: contain; image-rendering: pixelated; }
.ai b { font-size: 16px; font-weight: 900; align-self: end; }
.ai small { color: var(--muted); font-size: 12px; line-height: 1.35; align-self: start; }
.ai .rank { position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--gold); font-weight: 800; }
.ai[aria-pressed="true"] { border-color: var(--gold); background: #222a1d; }
.ai[aria-pressed="true"]::after { content: "✓"; position: absolute; right: 8px; bottom: 6px; color: var(--gold); font-weight: 900; }
.pickerfoot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.primary, .ghost { min-height: 46px; padding: 0 22px; border-radius: 12px; font-weight: 900; font-size: 16px; }
.primary { border: 0; background: var(--gold); color: #1a1405; box-shadow: 0 4px 0 #8a6d0b; }
.primary:disabled { background: #4b4a3a; color: #8c8a78; box-shadow: none; }
.ghost { border: 2px solid var(--line); background: transparent; }

.notes { margin-top: 30px; color: #cfdaf2; font-size: 15px; line-height: 1.8; max-width: 760px; }
.notes h2 { font-size: 18px; margin-bottom: 6px; }
.notes p { margin: 8px 0; }

/* ---------- table ---------- */
.game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0c1424;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; flex: none; }
.iconbtn { min-height: 40px; min-width: 64px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 800; font-size: 14px; }
.iconbtn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.hud { flex: 1; text-align: center; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dock { flex: none; padding: 8px 10px 10px; background: linear-gradient(180deg, rgba(12, 20, 36, 0), #0a101d 22%); }
.me { display: flex; align-items: center; gap: 10px; max-width: 920px; margin: 0 auto 8px; min-height: 52px; }
.mycards { display: flex; gap: 4px; flex: none; }
.mycard { width: 38px; height: 52px; border-radius: 6px; background: #fbfbf7; color: #141a2a; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 900; line-height: 1; box-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.mycard.red { color: #e0303f; }
.mycard span { font-size: 18px; }
.mycard em { font-style: normal; font-size: 17px; margin-top: 2px; }
.myinfo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.myinfo b { font-size: 16px; font-weight: 900; color: var(--gold); }
.myinfo span { font-size: 12px; }
.status { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; }
.status.turn { color: var(--gold); font-weight: 900; font-size: 15px; }
.acts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-width: 920px; margin: 0 auto; }
.act { min-height: 50px; border-radius: 10px; border: 0; font-weight: 900; font-size: 15px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; background: var(--panel2); box-shadow: 0 3px 0 #050a15; padding: 4px 2px; }
.act i { font-style: normal; font-size: 12px; font-weight: 700; opacity: .85; }
.act.fold { background: #3a4458; }
.act.call { background: #1f8a58; }
.act.raise { background: #b77a12; }
.act.allin { background: var(--red); }
.act:disabled { opacity: .32; box-shadow: none; }
.act:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #050a15; }

.sheet { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 22px 20px 18px;
  width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.sheet::backdrop { background: rgba(3, 6, 14, .7); }
.sheet h2 { font-size: 24px; font-weight: 900; color: var(--gold); }
.sheet p { margin: 12px 0 18px; line-height: 1.7; color: #d6e0f5; font-size: 15px; white-space: pre-line; }
.sheetbtns { display: flex; flex-wrap: wrap; gap: 10px; }
.sheetbtns button { flex: 1 1 auto; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2a48; border: 1px solid var(--line);
  color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100vw - 32px); }
.noscript { padding: 24px; }

@media (max-width: 760px) {
  .modes { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mode { min-height: 84px; padding: 14px; }
  .mode b { font-size: 19px; }
  .cast { grid-template-columns: 1fr 1fr; }
  .lede { font-size: 15px; }
}
@media (max-width: 400px) {
  .act { font-size: 14px; min-height: 48px; }
  .acts { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 761px) {
  .acts { grid-template-columns: repeat(6, 1fr); }
  .act { min-height: 56px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Online AI tables and CSP-safe native loading indicator. */
.qq-home { color:#ffdc67; display:inline-block; margin-bottom:18px; }
.boot .bar progress { width:120px; height:8px; display:block; accent-color:#ffd23f; }
.local-title { margin-top:30px; }
#replay-hand { overflow-wrap:anywhere; }
#replay-hand li { padding:5px 0; }

.ai[data-slug="astra"] b { color:#1FC77E; }
.ai[data-slug="opus"] b { color:#FF9838; }
.ai[data-slug="grok"] b { color:#9BE23A; }
.ai[data-slug="gemini"] b { color:#A57BFF; }
.ai[data-slug="qwen"] b { color:#F05BC9; }
.ai[data-slug="deepseek"] b { color:#4567FF; }
.ai[data-slug="doubao"] b { color:#2FD3E6; }
.ai[data-slug="glm"] b { color:#FFDD3C; }
.ai[data-slug="minimax"] b { color:#FF4B4B; }
.ai[data-slug="kimi"] b { color:#F2F2F2; }