:root {
  --paper: #eef1ee;
  --paper-deep: #dde2dc;
  --ink: #1d2621;
  --muted: #69706b;
  --line: #cbd1cc;
  --accent: #cc5d3b;
  --accent-deep: #9f3f29;
  --teal: #2e6963;
  --blue: #416b8b;
  --gold: #a47a2f;
  --success: #2d7655;
  --shadow: 0 18px 50px rgba(43, 36, 25, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.page-shell { min-height: 100vh; max-width: 1240px; margin: 0 auto; padding: 34px 34px 26px; }

.masthead { display: grid; grid-template-columns: 62px 1fr auto; gap: 18px; align-items: start; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid var(--ink); color: var(--paper); background: var(--ink); font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: 36px; }
.eyebrow { margin: 0 0 8px; color: var(--accent-deep); font-size: 11px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: 48px; line-height: 1.05; letter-spacing: 0; font-weight: 700; }
.lede { max-width: 590px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.dataset-note { display: flex; align-items: center; gap: 9px; margin-top: 11px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }

.mode-switcher { display: flex; gap: 6px; padding: 24px 0 14px; overflow-x: auto; scrollbar-width: thin; }
.mode-tab { border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; color: var(--muted); background: transparent; cursor: pointer; white-space: nowrap; transition: 160ms ease; }
.mode-tab:hover, .mode-tab:focus-visible { border-color: var(--teal); color: var(--teal); outline: none; }
.mode-tab.is-active { border-color: var(--ink); color: var(--paper); background: var(--ink); }

.score-strip { display: flex; align-items: center; gap: 34px; min-height: 62px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.score-strip > div { display: flex; align-items: baseline; gap: 10px; }
.status-label { color: var(--muted); font-size: 12px; }
.score-strip strong { font-size: 14px; }
.text-button { margin-left: auto; border: 0; padding: 7px 0; color: var(--accent-deep); background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr); gap: 22px; padding-top: 22px; }
.stage-panel, .control-panel { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.28); box-shadow: var(--shadow); }
.stage-panel { min-height: 580px; display: flex; flex-direction: column; padding: 24px; }
.control-panel { display: flex; flex-direction: column; padding: 25px; }
.stage-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
h2 { margin-bottom: 0; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: 36px; line-height: 1.15; font-weight: 700; }
.stage-tag { padding: 7px 9px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.stage { flex: 1; min-height: 400px; display: grid; place-items: center; margin-top: 14px; background: radial-gradient(circle at 50% 44%, rgba(255,255,255,0.8), rgba(235,228,214,0.42)); }
.stage svg { width: min(100%, 470px); height: min(100%, 470px); overflow: visible; }
.comparison { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: center; }
.glyph-box { min-width: 0; display: grid; place-items: center; gap: 8px; }
.glyph-box svg { width: min(100%, 290px); height: auto; aspect-ratio: 1; }
.glyph-label { color: var(--muted); font-size: 12px; }
.stage-caption { margin: 15px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.stroke-path { fill: var(--ink); transition: fill 180ms ease, opacity 180ms ease; }
.stroke-path.is-muted { fill: #b9b2a7; }
.stroke-path.is-highlight { fill: var(--accent); }
.stroke-path.is-reveal { fill: var(--teal); }
.stroke-path.piece-tone-0 { fill: var(--accent); }
.stroke-path.piece-tone-1 { fill: var(--teal); }
.stroke-path.piece-tone-2 { fill: var(--blue); }
.stroke-path.piece-tone-3 { fill: var(--gold); }
.stroke-path.piece-tone-4 { fill: var(--ink); }

.prompt-block { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.prompt { margin: 0; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: 28px; line-height: 1.35; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 22px 0; }
.choice { min-height: 74px; border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,0.38); cursor: pointer; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: 31px; transition: 160ms ease; }
.choice:hover, .choice:focus-visible { border-color: var(--teal); color: var(--teal); outline: none; transform: translateY(-1px); }
.choice.is-correct { border-color: var(--success); color: var(--success); background: rgba(45,118,85,0.1); }
.choice.is-wrong { border-color: var(--accent); color: var(--accent-deep); background: rgba(204,93,59,0.1); }
.feedback { min-height: 62px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.feedback.is-success { color: var(--success); }
.feedback.is-error { color: var(--accent-deep); }
.secondary-button { margin-top: 20px; border: 1px solid var(--teal); padding: 11px 14px; color: var(--teal); background: transparent; cursor: pointer; font-weight: 750; }
.secondary-button:hover, .secondary-button:focus-visible { color: white; background: var(--teal); outline: none; }
.primary-button { margin-top: auto; border: 0; padding: 13px 16px; color: white; background: var(--teal); cursor: pointer; font-weight: 750; transition: 160ms ease; }
.primary-button:hover:not(:disabled), .primary-button:focus-visible:not(:disabled) { background: #24534f; outline: none; }
.primary-button:disabled { cursor: not-allowed; opacity: 0.4; }

.footer-note { display: flex; justify-content: space-between; gap: 20px; padding-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 820px) {
  .page-shell { padding: 22px 16px 20px; }
  .masthead { grid-template-columns: 48px 1fr; gap: 14px; }
  .brand-mark { width: 48px; height: 48px; font-size: 28px; }
  .dataset-note { grid-column: 2; margin-top: -4px; }
  h1 { font-size: 34px; }
  h2 { font-size: 28px; }
  .score-strip { gap: 14px; flex-wrap: wrap; padding: 12px 0; }
  .score-strip > div { flex: 1 1 auto; }
  .text-button { margin-left: 0; }
  .game-layout { grid-template-columns: 1fr; }
  .stage-panel { min-height: 490px; }
  .stage { min-height: 310px; }
  .footer-note { flex-direction: column; gap: 4px; }
}

@media (max-width: 480px) {
  .stage-panel, .control-panel { padding: 18px; }
  .stage-header { flex-direction: column; gap: 10px; }
  .stage-tag { align-self: flex-start; }
  .prompt { font-size: 24px; }
  .comparison { gap: 8px; }
}
