:root {
  --paper: #efe6d6;
  --ink: #1a1714;
  --card: #fffdf8;
  --line: #d9cebc;
  --muted: #5e574e;
  --red: #c4322a;
  --green: #1c6b42;
  --green-bg: #e4f5eb;
  --red-bg: #fde8e4;
  --blue: #1e4d7b;
  --shadow: 4px 4px 0 var(--ink);
  --sans: Outfit, "Segoe UI", sans-serif;
  --serif: Fraunces, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  background-color: var(--paper);
  background-image:
    linear-gradient(transparent 31px, rgba(26, 23, 20, 0.045) 32px),
    linear-gradient(90deg, transparent 31px, rgba(26, 23, 20, 0.045) 32px);
  background-size: 32px 32px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
.choice:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.shell {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}

.mark svg { color: var(--red); display: block; }

.ghost {
  background: transparent;
  border: 2px solid transparent;
  padding: 6px 10px;
  color: var(--muted);
}

.ghost:hover { color: var(--ink); }

.hero {
  margin-bottom: 22px;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-sign {
  color: var(--red);
  width: 64px;
  height: auto;
  flex: none;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(3.4rem, 9vw, 5.4rem);
  font-weight: 680;
  line-height: 0.85;
  letter-spacing: -0.045em;
  margin: 0;
}

h1.result-title {
  font-size: clamp(2.3rem, 6vw, 3.5rem);
  line-height: 0.95;
  margin-bottom: 8px;
}

.kicker {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
}

.lede {
  font-size: 1.12rem;
  max-width: 38rem;
  margin: 14px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  margin-top: 22px;
}

.primary {
  background: var(--ink);
  color: #fffdf8;
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--red);
  padding: 14px 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.primary:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--red); }

.primary:active { transform: translate(4px, 4px); box-shadow: none; }

.record-chip {
  border: 2px solid var(--ink);
  background: var(--card);
  padding: 8px 12px;
  font-weight: 600;
}

.record-chip span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 18px 18px 8px;
  margin-top: 28px;
}

.panel h2 {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}

.scoring {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.score-bit {
  border: 2px solid var(--ink);
  background: var(--card);
  padding: 12px;
}

.score-bit strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 680;
  letter-spacing: -0.03em;
}

.score-bit span { color: var(--muted); font-size: 0.92rem; }

.rule {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.rule h3 {
  margin: 0;
  font-size: 1rem;
}

.rule p { margin: 0; color: var(--ink); }

.example {
  font-family: var(--serif);
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.hud-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric {
  background: var(--card);
  border: 2px solid var(--ink);
  min-width: 92px;
  padding: 6px 10px 7px;
}

.metric span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric strong {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1;
}

.lives {
  display: flex;
  gap: 4px;
  align-items: center;
  background: var(--card);
  border: 2px solid var(--ink);
  padding: 8px 10px;
}

.lives svg { display: block; }

.heart-off { opacity: 0.28; }

.timer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.timer-track {
  height: 10px;
  border: 2px solid var(--ink);
  background: var(--card);
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--ink);
}

.timer-bar.is-urgent { background: var(--red); }

.timelabel {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 3.2rem;
  text-align: right;
}

.timelabel.is-urgent { color: var(--red); }

.dots {
  display: flex;
  gap: 5px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.dot {
  width: 18px;
  height: 8px;
  border: 2px solid var(--ink);
  background: transparent;
}

.dot.is-now { background: var(--ink); }
.dot.is-ok { background: var(--green); border-color: var(--green); }
.dot.is-bad { background: var(--red); border-color: var(--red); }

.card {
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 22px 22px 20px;
}

.pill {
  display: inline-block;
  margin: 0 0 12px;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eq {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(1.8rem, 4.6vw, 2.8rem);
  letter-spacing: -0.03em;
  text-align: center;
  margin: 0;
  line-height: 1.15;
}

.note {
  text-align: center;
  margin: 12px 0 0;
  font-size: 1.05rem;
}

.lead {
  text-align: center;
  font-weight: 700;
  font-size: 1.12rem;
  margin: 16px 0 0;
}

.stake {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 8px 0 0;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.choices.is-stack { grid-template-columns: 1fr; }

.choice {
  position: relative;
  min-height: 84px;
  padding: 26px 14px 14px;
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 650;
  font-size: 1.02rem;
}

.choice.is-math {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.choice.is-long { font-size: 1.15rem; }

.choice .key {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0;
}

.choice:hover:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.choice:disabled { cursor: default; }

.choice.is-right {
  background: var(--green-bg);
  box-shadow: 3px 3px 0 var(--green);
}

.choice.is-wrong {
  background: var(--red-bg);
  box-shadow: 3px 3px 0 var(--red);
}

.choice.is-dim { opacity: 0.45; }

.feedback {
  margin-top: 16px;
  padding: 14px 14px 12px;
  border: 2px solid var(--ink);
}

.feedback.is-ok { background: var(--green-bg); }
.feedback.is-bad { background: var(--red-bg); }

.feedback h3 {
  margin: 0;
  font-size: 1.05rem;
}

.feedback p { margin: 8px 0 0; }

.feedback .primary { margin-top: 14px; width: 100%; }

.play-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.result-score {
  font-family: var(--serif);
  font-size: clamp(4rem, 12vw, 6.2rem);
  font-weight: 680;
  letter-spacing: -0.05em;
  line-height: 0.85;
  margin: 8px 0;
}

.stamp {
  display: inline-block;
  border: 3px solid var(--red);
  color: var(--red);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 8px;
  transform: rotate(-8deg);
  background: #fffdf8;
}

.summary {
  font-size: 1.08rem;
  margin: 0 0 8px;
}

.prop-list { margin-top: 18px; }

.prop {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.meter {
  grid-column: 1 / -1;
  height: 8px;
  border: 2px solid var(--ink);
  background: transparent;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--ink);
}

.misses { margin-top: 22px; }

.miss {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.miss h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.miss .eq {
  font-size: 1.35rem;
  text-align: left;
}

.miss p { margin: 4px 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.pop { animation: pop 0.35s ease; }

@keyframes pop {
  from { transform: scale(1.18); }
  to { transform: scale(1); }
}

@media (min-width: 720px) {
  .rule {
    grid-template-columns: 168px 1.3fr 1fr;
    align-items: baseline;
  }
}

@media (max-width: 680px) {
  .hero-sign { width: 46px; }
  .scoring { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .shell { width: min(820px, calc(100% - 20px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
