:root {
  color-scheme: light;
  --ink: #10374f;
  --navy: #064a72;
  --navy-dark: #083a5a;
  --deep-blue: #072b44;
  --red: #bc1831;
  --logo-red: #e60020;
  --gold: #e2ad31;
  --gold-light: #fae5a3;
  --gold-pale: #fff5d8;
  --paper: #fffdf8;
  --surface: #fff;
  --canvas: #fcf8ef;
  --sky: #e8f5fa;
  --sky-strong: #c7e9f4;
  --muted: #4f687c;
  --line: #dee5e7;
  --shadow: 0 2px 2px #12354b05, 0 12px 30px #1e4c6610;
  --radius: 24px;
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 87% 10%, #fff7df 0%, #fff7df00 47%), var(--canvas);
  font: 500 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2, h3, p, ul, ol, figure { margin: 0; }

img { display: block; max-inline-size: 100%; }

button, input { color: inherit; font: inherit; }

button { cursor: pointer; }

button:disabled, button[aria-disabled="true"] { cursor: default; }

button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--logo-red);
  outline-offset: 4px;
}

.sr-only, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-height: 50px;
  padding: .7rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
  line-height: 1.35;
  transition: background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.button:hover:not(:disabled, [aria-disabled="true"]) { background: var(--deep-blue); }
.button:active:not(:disabled, [aria-disabled="true"]) { transform: translateY(1px); }
.button:disabled, .button[aria-disabled="true"] { background: #e5edf1; color: #4f687c; }

.button.secondary {
  border-color: #b9ccd7;
  color: var(--navy-dark);
  background: var(--surface);
}

.button.secondary:hover:not(:disabled, [aria-disabled="true"]) { background: var(--sky); }

.eyebrow {
  color: var(--red);
  font-weight: 850;
  font-size: .78rem;
  letter-spacing: .12em;
}

.lab, .controls {
  min-inline-size: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.subject {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .78rem;
  border: 1px solid #edd780;
  border-radius: 99px;
  color: #674800;
  background: var(--gold-pale);
  font-size: .8rem;
  font-weight: 800;
  white-space: nowrap;
}

.subject > span:first-child {
  flex: 0 0 auto;
  width: .55em;
  height: .55em;
  background: #ad7c04;
  border-radius: 50%;
}

.subject-en {
  border-inline-start: 1px solid #d8bc62;
  padding-inline-start: .55rem;
  font: 750 .62rem/1.2 system-ui, sans-serif;
  letter-spacing: .13em;
}

.wrap {
  width: min(1160px, calc(100% - 3rem));
  margin-inline: auto;
}

.site-header {
  background: #ffffffb8;
  border-block-start: 4px solid var(--navy);
  border-block-end: 1px solid #e8e1d2;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  gap: 1rem;
  padding-block: .7rem;
}

.brand {
  width: clamp(220px, 31vw, 358px);
  height: auto;
  object-fit: contain;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding-block: clamp(1.55rem, 4vw, 2.9rem) clamp(1.25rem, 3vw, 2.1rem);
}

.hero h1 {
  color: var(--navy-dark);
  font-size: clamp(2.15rem, 5.7vw, 4.35rem);
  font-weight: 950;
  letter-spacing: -.045em;
  line-height: 1.05;
}

.hero h1 > span { color: var(--logo-red); margin-inline-start: .07em; }
.hero .eyebrow { margin-block-end: .45rem; }

.hero h1 + p {
  max-width: 42ch;
  margin-block-start: .62rem;
  color: var(--muted);
  font-size: clamp(.9rem, 1.7vw, 1.06rem);
  line-height: 1.55;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(355px, 1fr);
  gap: clamp(.9rem, 2.1vw, 1.5rem);
  align-items: stretch;
}

.journey {
  display: flex;
  align-items: center;
  gap: clamp(.35rem, 1vw, .7rem);
  margin-block-end: .23rem;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}

.journey li {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 850;
}

.journey li + li::before {
  content: "";
  width: clamp(.6rem, 2vw, 1.6rem);
  height: 1px;
  margin-inline-end: .08rem;
  background: #c9d3d9;
}

.journey li > span {
  display: grid;
  place-items: center;
  width: 1.75rem;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #c6d8e0;
  background: #fff;
  font: 850 .78rem/1 system-ui, sans-serif;
}

.journey li[aria-current="step"] { color: var(--navy-dark); }
.journey li[aria-current="step"] > span { background: var(--navy); border-color: var(--navy); color: white; }
.journey li[data-complete="true"] > span { background: var(--sky); border-color: #b9dbe9; color: var(--navy-dark); }

.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  transform: translateY(-200%);
  padding: .65rem .95rem;
  border-radius: .5rem;
  background: var(--deep-blue);
  color: #fff;
}

.skip-link:focus { transform: translateY(0); }

.lab {
  display: grid;
  overflow: hidden;
  padding: clamp(.8rem, 1.7vw, 1.15rem);
  background: var(--paper);
}

.lab-view, .result-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-content: center;
  gap: .85rem;
  min-inline-size: 0;
}

.lab-top, .lab-bottom, .lab-caption {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-inline-size: 0;
}

.lab-top, .lab-bottom {
  justify-content: space-between;
  padding-inline: .18rem;
  flex-wrap: wrap;
}

.lab-top { min-height: 29px; }
.lab-caption { font-weight: 900; color: var(--navy-dark); }

.lab-dot {
  width: .58rem;
  height: .58rem;
  border-radius: 50%;
  background: var(--logo-red);
  box-shadow: 0 0 0 4px #fee3e8;
  margin-inline: .14rem;
}

.lab-status {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: .22rem .55rem;
  color: #465e72;
  background: #edf1f3;
  border-radius: .4rem;
  font-size: .76rem;
  font-weight: 800;
}

.lab-status[data-running="true"] { color: var(--navy-dark); background: var(--sky-strong); }

.lab-body {
  display: flex;
  align-items: stretch;
  align-self: center;
  gap: clamp(.35rem, 1vw, .75rem);
  min-inline-size: 0;
}

.lab-body > .kitchen { flex: 1 1 0; min-inline-size: 0; align-self: center; }
.lab-bottom { min-height: 26px; }
.lab-bottom > p { color: var(--muted); font-size: .85rem; }
.lab-bottom strong { color: var(--ink); }

.plate-count { display: flex; align-items: center; gap: .34rem; }

.plate-count > span {
  display: block;
  width: 1.12rem;
  aspect-ratio: 1;
  border: 2px solid #c6d4dc;
  border-radius: 50%;
  background: #edf3f6;
  box-shadow: inset 0 0 0 2px #fff;
}

.plate-count > span[data-clean="true"] { background: #e8b843; border-color: #aa7602; }

.gauge {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: stretch;
  flex: 0 0 clamp(56px, 7.2vw, 83px);
  min-inline-size: 0;
  gap: .29rem;
  padding: .55rem .38rem;
  border: 1px solid #d9e9ef;
  border-radius: 15px;
  text-align: center;
  background: #f0f8fa;
}

.gauge-title { color: var(--navy-dark); font-size: .84rem; font-weight: 900; }
.gauge-unit { color: var(--muted); font-size: .73rem; font-weight: 750; }
.gauge-inner { display: grid; grid-template-columns: minmax(16px, 1fr) 1.6fr; padding: .3rem 3px; gap: .34rem; min-height: 0; }

.gauge-scale {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-block: -.5em;
  text-align: end;
  color: #456074;
  font: 700 .73rem/1 system-ui, sans-serif;
}

.gauge-tube, .chart-tank {
  overflow: visible;
  position: relative;
  isolation: isolate;
  background: #fff;
  border: 1px solid #a9cbd6;
  border-radius: .4rem;
}

.gauge-fill, .chart-water {
  position: absolute;
  inset: auto 0 0;
  border-radius: 0 0 .34rem .34rem;
  background: linear-gradient(180deg, #99e1f7, #5bbfe1);
}

.gauge-fill { transition: height .32s ease; }

.gauge-ticks, .chart-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to top, #346c7d40 0 1px, transparent 1px 10%);
  pointer-events: none;
}

.gauge-mark, .chart-mark {
  height: 0;
  position: absolute;
  z-index: 1;
  inset-inline: -.19rem;
  border-block-start: 3px solid #247649;
  transform: translateY(50%);
  pointer-events: none;
}

.gauge-mark[data-round="1"], .chart-column[data-round="1"] .chart-mark { border-block-start: 3px dashed #c32436; }

.controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.25rem, 2.7vw, 2.15rem);
  border-block-start: 4px solid var(--gold);
}

.controls h2, .result-board h2 {
  color: var(--navy-dark);
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  line-height: 1.18;
  letter-spacing: -.045em;
  font-weight: 950;
}

.controls h2 { margin-block-start: .39rem; }
.control-description { margin-block-start: .7rem; color: var(--muted); }
.stage-actions { display: grid; gap: .8rem; margin-block-start: 1.15rem; }
.stage-actions .button { width: 100%; }
.stage-actions .primary:not(:disabled, [aria-disabled="true"]) { box-shadow: 0 4px 0 #062c44; }
.stage-actions .primary:active:not(:disabled, [aria-disabled="true"]) { box-shadow: 0 2px 0 #062c44; }
.stage-actions .button > span { margin-inline-start: auto; }
.stage-actions .button:has(> span) { justify-content: flex-start; }

.choices {
  display: grid;
  gap: .55rem;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 61px;
  padding: .55rem .69rem;
  border: 1px solid #cddce3;
  border-radius: 12px;
  background: #fafcfd;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.choice:hover { background: #f0f8fc; border-color: #83b1c8; }
.choice:has(input:checked) { background: #e8f5fa; border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.choice input { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--navy); }
.choice strong, .choice small { display: block; }
.choice strong { color: var(--navy-dark); font-weight: 900; }
.choice small { color: var(--muted); font-size: .72rem; font-weight: 650; line-height: 1.35; }

.wash-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .33rem;
  padding: 0;
  list-style: none;
}

.wash-steps li {
  padding: .57rem .17rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  color: var(--muted);
  background: #f5f8fa;
  text-align: center;
  font-size: .81rem;
  font-weight: 790;
}

.wash-steps li[aria-current="step"] { color: var(--navy-dark); background: var(--gold-pale); border-color: #e3bd56; }
.wash-steps li[data-complete="true"] { color: #19593e; background: #edf6ef; border-color: #c4e0ce; }
.wash-steps li[data-complete="true"]::before { content: "✓ "; }

.mark-controls, .discussion, .prediction-note {
  padding: .72rem .8rem;
  border-radius: 11px;
  background: #f1f7fa;
}

.mark-label { display: flex; justify-content: space-between; gap: .5rem; color: var(--navy-dark); font-weight: 900; }
.mark-label output { font-variant-numeric: tabular-nums; }
.mark-controls input { display: block; width: 100%; min-height: 32px; margin: .15rem 0 0; accent-color: var(--navy); cursor: ew-resize; }
.feedback { color: #a32037; font-size: .88rem; font-weight: 750; }
.discussion { border-inline-start: 3px solid var(--gold); background: var(--gold-pale); }
.discussion strong { display: block; color: var(--navy-dark); }
.discussion p, .prediction-note { color: var(--muted); font-size: .88rem; }

.result-view { grid-template-rows: auto 1fr; }

.result-board {
  display: grid;
  align-content: center;
  gap: 1.25rem;
  min-inline-size: 0;
  padding: clamp(.8rem, 2.5vw, 1.8rem);
  border: 1px solid #d8eaf2;
  border-radius: 17px;
  background: #edf7fa;
  text-align: center;
}

.chart {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.4rem, 3.8vw, 2.2rem);
  width: min(100%, 440px);
  margin-inline: auto;
}

.chart-column { display: grid; justify-items: center; align-content: start; gap: .16rem; min-inline-size: 0; }
.chart-tank { width: min(83%, 112px); height: clamp(105px, 17vw, 175px); margin-block-end: .35rem; }
.chart-water { height: var(--result, 0%); }
.chart-mark { bottom: var(--result, 0%); }
.chart-value { color: var(--navy-dark); font-size: clamp(1.23rem, 2.5vw, 1.8rem); font-weight: 950; font-variant-numeric: tabular-nums; }
.chart-method { font-size: clamp(.78rem, 2.1vw, 1rem); color: var(--navy-dark); font-weight: 850; }
.chart-key { color: var(--muted); font-size: .74rem; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .3rem 1rem;
  flex-wrap: wrap;
  padding-block: 1rem 1.35rem;
  color: var(--muted);
  font-size: .77rem;
}

@media (max-width: 800px) {
  .wrap { width: min(620px, calc(100% - 2rem)); }
  .hero { align-items: start; flex-direction: column; }
  .game-grid { grid-template-columns: minmax(0, 1fr); }
  body[data-stage="predict"] .controls { order: -1; }
  .controls { justify-content: start; }
}

@media (max-width: 420px) {
  .wrap { width: calc(100% - 1.5rem); }
  .header-inner { min-height: 62px; }
  .brand { width: min(65vw, 245px); }
  .subject { padding: .28rem .46rem; font-size: .69rem; }
  .subject-en { display: none; }
  .gauge { border-radius: 11px; }
  .mark-controls input { min-height: 44px; }
}

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