:root {
  --paper: #f3f1eb;
  --paper-deep: #e8e4dc;
  --ink: #182422;
  --muted: #65716e;
  --teal: #087f78;
  --coral: #e85f42;
  --yellow: #f2bf3d;
  --line: rgba(24, 36, 34, 0.18);
  --focus: #006f68;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }

#math-scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.scene-wash { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg, rgba(243,241,235,.82) 0%, rgba(243,241,235,.48) 48%, rgba(243,241,235,.76) 100%); }
.app-shell { position: relative; z-index: 2; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: max(22px, env(safe-area-inset-top)) clamp(20px, 5vw, 72px) max(22px, env(safe-area-inset-bottom)); }
.topbar { min-height: 46px; display: grid; grid-template-columns: 1fr minmax(190px, 420px) 1fr; align-items: center; gap: 32px; }
.wordmark { justify-self: start; display: inline-flex; align-items: center; gap: 8px; font-weight: 760; font-size: 16px; letter-spacing: 0; }
.wordmark b { color: var(--teal); font-weight: 760; }
.wordmark-button { padding: 6px 0; border: 0; background: none; cursor: pointer; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 5px); gap: 2px; align-items: end; height: 17px; }
.brand-mark i { display: block; width: 5px; background: var(--ink); }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 17px; background: var(--coral); }
.brand-mark i:nth-child(3) { height: 12px; background: var(--teal); }
.run-status { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.run-status[hidden] { display: none; }
.run-status > span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.progress-track { overflow: hidden; height: 3px; background: rgba(24,36,34,.14); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--coral); transition: width 450ms ease; }
.rating-toggle { justify-self: end; min-width: 86px; height: 38px; display: inline-flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 6px 0 6px 12px; border: 0; background: transparent; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.rating-toggle[hidden] { display: none; }
.rating-toggle svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rating-toggle .eye-closed { display: none; }
.rating-toggle.is-hidden .eye-open, .rating-toggle.is-hidden span { display: none; }
.rating-toggle.is-hidden .eye-closed { display: block; }
.screen { display: none; min-height: 0; animation: screen-in 520ms cubic-bezier(.2,.75,.2,1) both; }
.screen.is-active { display: flex; }
.start-screen { width: min(1120px, 100%); margin: 0 auto; align-items: center; justify-content: space-between; gap: clamp(44px, 8vw, 120px); }
.start-copy { max-width: 540px; }
.eyebrow { margin: 0 0 22px; color: var(--coral); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .15em; }
.start-copy h1 { max-width: 520px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(48px, 6.5vw, 94px); line-height: .95; letter-spacing: 0; }
.lede { max-width: 430px; margin: 26px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.distance-list { width: min(430px, 100%); border-top: 1px solid var(--ink); }
.distance-choice { width: 100%; min-height: 96px; display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 16px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; text-align: left; cursor: pointer; transition: padding 180ms ease, color 180ms ease, background 180ms ease; }
.distance-choice:hover, .distance-choice:focus-visible { padding-left: 14px; padding-right: 14px; color: var(--teal); background: rgba(255,255,255,.38); outline: none; }
.distance-number { font-family: Georgia, "Times New Roman", serif; font-size: 38px; font-variant-numeric: tabular-nums; }
.distance-name { font-size: 15px; font-weight: 700; }
.distance-arrow { font-size: 25px; }
.question-screen { align-items: center; justify-content: center; }
.question-wrap { width: min(760px, 100%); text-align: center; transform: translateY(-2vh); }
.question-meta { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.meta-rule { width: 28px; height: 1px; background: var(--coral); }
.question-prompt { margin: 28px auto 8px; color: var(--muted); font-size: clamp(16px, 2vw, 20px); }
.question-expression { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(54px, 10vw, 116px); font-weight: 400; line-height: 1.08; letter-spacing: 0; }
.answer-choices { width: min(620px, 100%); margin: 38px auto 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.answer-choices button { position: relative; min-width: 0; min-height: 78px; padding: 12px 10px; border: 1px solid rgba(24,36,34,.42); border-radius: 6px; background: rgba(243,241,235,.72); color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(22px, 4vw, 32px); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; cursor: pointer; transition: transform 160ms ease, color 160ms ease, background 160ms ease, border-color 160ms ease; }
.answer-choices button:hover, .answer-choices button:focus-visible { transform: translateY(-3px); border-color: var(--teal); background: rgba(255,255,255,.72); color: var(--teal); outline: 3px solid rgba(8,127,120,.14); }
.answer-choices button:disabled { cursor: default; transform: none; }
.answer-choices button.is-muted { opacity: .36; }
.answer-choices button.is-correct { border-color: var(--teal); background: var(--teal); color: white; opacity: 1; }
.answer-choices button.is-wrong { border-color: var(--coral); background: var(--coral); color: white; opacity: 1; }
.choice-key { position: absolute; top: 7px; left: 9px; color: var(--muted); font-family: Inter, ui-sans-serif, sans-serif; font-size: 9px; font-weight: 800; }
.answer-choices button.is-correct .choice-key, .answer-choices button.is-wrong .choice-key { color: rgba(255,255,255,.72); }
.run-again svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.answer-feedback { position: absolute; left: 0; right: 0; margin-top: 16px; min-height: 30px; font-size: 14px; font-weight: 750; }
.answer-feedback.correct { color: var(--teal); }
.answer-feedback.wrong { color: var(--coral); }
.result-screen { align-items: center; justify-content: center; }
.result-wrap { width: min(680px, 100%); text-align: center; }
.result-kicker { margin: 0 0 8px; color: var(--muted); font-weight: 650; }
.result-wrap h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(82px, 16vw, 152px); font-weight: 400; line-height: .9; letter-spacing: 0; }
.result-wrap h1 small { display: block; margin-top: 18px; color: var(--muted); font-family: Inter, ui-sans-serif, sans-serif; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.result-stats { margin: 48px auto 38px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-stats div { padding: 18px 10px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border-right: 0; }
.result-stats strong, .result-stats span { display: block; }
.result-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.result-stats span { margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.run-again { display: inline-flex; align-items: center; gap: 28px; min-height: 52px; padding: 0 20px; border: 0; border-radius: 0; background: var(--ink); color: var(--paper); font-weight: 750; cursor: pointer; }
.run-again:hover, .run-again:focus-visible { background: var(--teal); outline: 3px solid rgba(8,127,120,.2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 16px; }
  .wordmark b { display: none; }
  .run-status { grid-template-columns: 1fr; gap: 6px; }
  .run-status > span { text-align: center; }
  .start-screen { flex-direction: column; justify-content: center; align-items: stretch; gap: 48px; padding: 36px 0 24px; }
  .start-copy h1 { font-size: clamp(48px, 15vw, 70px); }
  .lede { margin-top: 18px; font-size: 15px; }
  .distance-list { width: 100%; }
  .distance-choice { min-height: 76px; grid-template-columns: 64px 1fr auto; }
  .distance-number { font-size: 31px; }
  .question-wrap { transform: translateY(-4vh); }
  .question-expression { font-size: clamp(50px, 16vw, 82px); }
  .answer-choices { gap: 7px; margin-top: 30px; }
  .answer-choices button { min-height: 68px; padding-left: 7px; padding-right: 7px; }
  .result-stats { margin-top: 38px; }
}

@media (max-width: 420px) {
  .wordmark { font-size: 14px; }
  .rating-toggle { min-width: 48px; }
  .start-screen { gap: 34px; }
  .start-copy h1 { font-size: 48px; }
  .result-stats strong { font-size: 15px; }
}

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