:root {
  --bg: #f7f3ea;
  --bg-2: #fffdf8;
  --ink: #1f1a14;
  --ink-2: #5b5248;
  --line: #e4dccc;
  --accent: #c9402a;
  --accent-ink: #fff;
  --gold: #d9a441;
  --ok: #2f7d4f;
  --bad: #b3261e;
  --zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f; --bg-2: #211d17; --ink: #f1ebe0; --ink-2: #b8ad9d; --line: #352f27;
    --accent: #e4553b; --gold: #e0b35a; --ok: #5fbf85; --bad: #ff7b6e;
  }
}
* { box-sizing: border-box; }
html { font-family: var(--sans); color: var(--ink); background: var(--bg); line-height: 1.55; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
[lang="zh-Hans"] { font-family: var(--zh); }
a { color: var(--accent); text-underline-offset: 2px; }
main { flex: 1; width: 100%; max-width: 72ch; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 2em 0 .5em; }
p, li { max-width: 70ch; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.eyebrow { margin: 0 0 .5em; color: var(--ink-2); font-size: .95rem; letter-spacing: .04em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; }
small { color: var(--ink-2); }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-family: var(--zh); font-size: 1.05rem; }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.site-header nav a[aria-current="page"], .site-header nav a:hover { background: var(--bg); color: var(--ink); }
.site-footer { border-top: 1px solid var(--line); padding: 20px 16px; color: var(--ink-2); font-size: .9rem; text-align: center; }
.site-footer p { margin: .3em auto; }
.crumbs { font-size: .9rem; color: var(--ink-2); margin-bottom: 12px; }
.crumbs a { color: inherit; }

.cards { list-style: none; padding: 0; margin: 1em 0; display: grid; gap: 12px; }
.cards li a { display: block; padding: 14px 16px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.cards li a:hover { border-color: var(--accent); }
.cards .count { color: var(--ink-2); font-size: .9rem; margin-left: 6px; }
ol.cards { counter-reset: none; }

.table-wrap { overflow-x: auto; margin: 1em -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: .85rem; position: sticky; top: 0; background: var(--bg); }
.words td:first-child { font-size: 1.25rem; white-space: nowrap; }
.py { color: var(--ink-2); white-space: nowrap; }
table.rules td, table.rules th { text-align: center; }
details { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); padding: 10px 14px; margin: 8px 0; }
summary { cursor: pointer; font-weight: 600; }
.notice { padding: 12px 14px; background: var(--bg-2); border: 1px dashed var(--line); border-radius: 10px; }
.next { margin-top: 2em; font-weight: 600; }

/* game */
.game-wrap { margin: 20px 0 8px; }
.game { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.05); }
.game-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .95rem; color: var(--ink-2); }
.game-top strong { color: var(--ink); font-size: 1.15rem; }
.level { display: inline-flex; gap: 4px; }
.level button { font: inherit; font-size: .85rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.level button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.word { text-align: center; margin: 22px 0 10px; }
.word .hanzi { font-family: var(--zh); font-size: clamp(2.6rem, 10vw, 4rem); line-height: 1.1; letter-spacing: .04em; }
.word .pinyin { color: var(--ink-2); font-size: 1.15rem; margin-top: 4px; }
.bets { display: flex; justify-content: center; gap: 8px; margin: 14px 0; }
.bets button { font: inherit; font-weight: 700; min-width: 64px; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.bets button[aria-pressed="true"] { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 18%, transparent); }
.bets button:disabled { opacity: .4; cursor: not-allowed; }
.options { display: grid; gap: 8px; grid-template-columns: 1fr; margin: 6px 0; }
@media (min-width: 560px) { .options { grid-template-columns: 1fr 1fr; } }
.options button { font: inherit; font-size: 1.02rem; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.options button:hover:not(:disabled) { border-color: var(--accent); }
.options button:disabled { cursor: default; }
.options button.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.options button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.result { margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.result.ok { border-color: var(--ok); }
.result.bad { border-color: var(--bad); }
.result .ex { margin-top: 6px; }
.result .ex [lang="zh-Hans"] { font-size: 1.1rem; }
.result .delta { font-weight: 700; }
.result.ok .delta { color: var(--ok); }
.result.bad .delta { color: var(--bad); }
.game-actions { display: flex; justify-content: center; margin-top: 12px; }
.game-actions button { font: inherit; font-weight: 700; padding: 10px 22px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; }

/* reserve space while the game boots (CLS) */
#game { min-height: 440px; }
