:root {
  color-scheme: light;
  --ink: #172e31;
  --muted: #526767;
  --paper: #f6f2e8;
  --panel: #fffdf5;
  --line: #d8d6c9;
  --rust: #a33c24;
  --night: #102b32;
  --gold: #f0c37e;
  font: 16px/1.55 "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { border: 1px solid #99abaa; color: var(--ink); background: #fffdf6; border-radius: 9px; padding: .55rem .9rem; cursor: pointer; min-height: 43px; font-weight: 700; }
button:hover:not(:disabled) { background: #e5ede6; }
button:disabled { opacity: .5; cursor: default; }
button[aria-pressed="true"].choice, button[aria-current="step"] { border-color: #165f59; background: #d7eee6; color: #0b4740; }
.primary { background: var(--rust); color: white; border-color: var(--rust); }
.primary:hover:not(:disabled) { background: #7f2d1b; }
:focus-visible { outline: 3px solid #188a97; outline-offset: 3px; }
.top { background: var(--night); color: #fff9e4; }
.top-inner { max-width: 1090px; margin: auto; padding: 10px 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand, .top-actions { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--night); background: var(--gold); font-size: 24px; line-height: 1; }
.top-actions button { background: #1a3940; color: #fff9e4; border-color: #49646a; padding: .38rem .7rem; min-height: 38px; }
.top-actions button:hover:not(:disabled) { background: #34575c; }
main, footer { max-width: 1090px; margin: auto; padding: 0 22px; }
.heading { padding: 22px 0 13px; }
.subject { color: var(--rust); margin: 0; font-size: .83rem; font-weight: 800; letter-spacing: .11em; }
h1, h2, p { margin: 0; }
h1 { font-family: "Noto Serif CJK TC", Georgia, serif; font-size: clamp(2rem, 5.4vw, 3.5rem); line-height: 1.15; letter-spacing: .025em; margin: .15rem 0 .5rem; }
.heading > p:last-child { color: var(--muted); }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 13px; padding: 12px 17px; margin: 12px 0; }
#start-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
#start-form label { display: grid; gap: 4px; flex: 0 1 290px; }
label span { font-weight: 700; font-size: .86rem; }
input { min-height: 43px; border: 1px solid #99abaa; background: #fff; color: var(--ink); border-radius: 7px; padding: 6px 10px; width: 100%; }
.chart { background: var(--night); color: #fff9e4; border-radius: 17px; overflow: hidden; box-shadow: 0 9px 24px #102b3226; }
.chart-top { display: flex; padding: 11px 18px; justify-content: space-between; align-items: center; gap: 12px; }
.kicker { color: #f0c37e; font-size: .72rem; font-weight: 800; letter-spacing: .11em; }
.chart h2 { font-size: clamp(1rem, 3vw, 1.42rem); }
.stats { display: flex; flex-wrap: wrap; justify-content: end; align-items: center; gap: 5px 13px; font-size: .78rem; font-variant-numeric: tabular-nums; }
.map { position: relative; height: clamp(350px, 49vw, 470px); background: #2a666b; }
canvas { display: block; width: 100%; height: 100%; }
canvas[data-picking="true"] { cursor: crosshair; touch-action: manipulation; }
canvas:focus-visible { outline-offset: -4px; outline-color: #f0c37e; }
.map-tag { position: absolute; right: 10px; top: 10px; color: #fff8e5; background: #102b32e8; border: 1px solid #f0c37e75; border-radius: 6px; padding: 4px 8px; font-size: .74rem; pointer-events: none; }
.progress { display: flex; gap: 5px; padding: 9px 16px; }
.progress span { height: 5px; flex: 1; background: #3f565a; border-radius: 10px; }
.progress .past { background: #80c1ac; }
.progress .current { background: var(--gold); }
.activity h2 { font-size: 1.15rem; line-height: 1.45; }
.stations, .actions { display: flex; gap: 7px; flex-wrap: wrap; }
.stations { margin: 0 0 9px; }
.stations button { padding: .32rem .65rem; min-height: 34px; }
.actions { margin-top: 9px; }
#feedback { color: var(--muted); min-height: 1.55em; }
.formula { font-weight: 800; margin-top: 6px; padding: 7px 10px; border-radius: 6px; background: #dfeee5; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.pair { display: flex; gap: 8px; margin-top: 8px; }
.pair label { width: 96px; }
.error { background: #f9e2d8; color: #762710; border: 1px solid #c6775d; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.leaderboard summary { font-weight: 800; cursor: pointer; }
.leaderboard ol { margin: .5rem 0 0; }
.finished p { margin-top: 4px; }
footer { padding: 7px 22px 22px; display: flex; gap: 18px; color: var(--muted); font-size: .79rem; }
a { color: inherit; text-underline-offset: 3px; }
body.running .heading { padding: 12px 0 8px; }
body.running .heading .subject, body.running #summary { display: none; }
body.running h1 { font-size: clamp(1.35rem, 3vw, 2rem); margin: 0; }
@media (max-width: 580px) {
  main, footer, .top-inner { padding-left: 10px; padding-right: 10px; }
  .map { height: clamp(325px, 95vw, 430px); }
  .choices { grid-template-columns: 1fr; }
  .stats { gap: 2px 7px; }
  .chart-top { padding: 8px 11px; }
  .panel { padding: 11px; }
}
select { min-height: 43px; border: 1px solid #99abaa; border-radius: 7px; background: #fffdf5; color: var(--ink); padding: 6px 8px; font: inherit; }
@media (min-width: 581px) {
  body.running .map { height: clamp(337px, 49vh, 450px); }
}
@media (max-width: 580px) {
  .top-actions { gap: 6px; }
  .top-actions button { padding-inline: .5rem; font-size: .85rem; white-space: nowrap; }
  .brand { font-size: .88rem; }
}
