/* The Bikote Scores headings' font, shared with the scorer guide (public/fonts).
   Only the page title and the round result use it; questions and answers
   stay in the system font, which reads better in long text. */
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/barlow-condensed-700-v1.woff2") format("woff2");
}

/* Colour tokens. Light is the default; dark applies when the device prefers
   it (unless the user picked Light) or when the user picked Dark. */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #1a1d22;
  --muted: #5e6672;
  --border: #dde2ea;
  --accent: #2f62b5;
  --accent-soft: #e1e9f7;
  --on-accent: #ffffff;
  --good: #2f7d4f;
  --good-soft: #dcefe3;
  --bad: #b5452f;
  --bad-soft: #f6e1db;
  --gold: #a8690c;
  --gold-bright: #f2b134;
  --gold-soft: #fcf0d2;
  --star-off: #868e9a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-lift: 0 12px 28px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161a;
    --surface: #1e2127;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --border: #343943;
    --accent: #79a8ec;
    --accent-soft: #1e2a3d;
    --on-accent: #0f1622;
    --good: #6cc391;
    --good-soft: #1f3528;
    --bad: #e0775f;
    --bad-soft: #3d2620;
    --gold: #f0c35a;
    --gold-bright: #f2b134;
    --gold-soft: #3a311c;
    --star-off: #757d89;
    --shadow: none;
    --shadow-lift: 0 12px 28px rgba(0, 0, 0, 0.55), 0 3px 8px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --surface: #1e2127;
  --text: #e8eaee;
  --muted: #9aa2ae;
  --border: #343943;
  --accent: #79a8ec;
  --accent-soft: #1e2a3d;
  --on-accent: #0f1622;
  --good: #6cc391;
  --good-soft: #1f3528;
  --bad: #e0775f;
  --bad-soft: #3d2620;
  --gold: #f0c35a;
  --gold-bright: #f2b134;
  --gold-soft: #3a311c;
  --star-off: #757d89;
  --shadow: none;
  --shadow-lift: 0 12px 28px rgba(0, 0, 0, 0.55), 0 3px 8px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  /* Also read by .study-header, which sits over this padding. */
  --main-top: 32px;
  max-width: 880px;
  margin: 0 auto;
  padding: var(--main-top) 16px 48px;
}

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

/* Home */

/* Title on the left, theme button pinned top right at every width. */
.home-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.home-top > div { min-width: 0; }
.home-header h1,
.summary h2 { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 700; letter-spacing: 0.01em; }
.home-header h1 { margin: 0; font-size: 2.5rem; line-height: 1.1; }
.subtitle { margin: 2px 0 20px; color: var(--muted); }

.segmented {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  margin-bottom: 24px;
}
.segmented .thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: 999px;
  background: var(--accent);
}
.segmented button {
  position: relative;
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] { color: var(--on-accent); }
/* Tap areas at least 44px tall without changing how controls look: an
   invisible layer that reaches past the visible shape. */
.segmented button::before,
.stepper button::before,
.theme-toggle::after {
  content: "";
  position: absolute;
  inset: -4px;
}
.segmented button::before { inset: -5px 0; }
.theme-toggle::after { inset: -5px; }
.segmented.animated .thumb {
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1), width 0.28s cubic-bezier(0.3, 0.7, 0.2, 1),
              background-color 0.2s;
}
.segmented.animated button { transition: color 0.2s; }

@media (prefers-reduced-motion: reduce) {
  .segmented.animated .thumb,
  .segmented.animated button { transition: none; }
}
.theme-toggle {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg {
  position: absolute;
  top: 9px;
  left: 9px;
  width: 20px;
  height: 20px;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.2, 1.2), opacity 0.25s;
}
/* Light mode shows the moon; dark mode spins it out and the sun in. */
.theme-toggle .sun { opacity: 0; transform: rotate(-90deg) scale(0.4); }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 0; transform: rotate(90deg) scale(0.4); }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg { transition: none; }
}

/* Mode switch, then questions per round */
.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  margin-bottom: 10px;
}
.options .segmented { margin-bottom: 0; }
.mode-note { margin: -2px 0 12px; max-width: 34rem; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.round-size {
  display: flex;
  align-items: center;
  gap: 10px;
  /* A little more room before the tiles than between the control rows. */
  margin-bottom: 16px;
  color: var(--muted);
  /* Line the label up with the mode switch's pill rather than its outline. */
  padding-left: 4px;
}
.round-size .segmented { margin-bottom: 0; font-size: 0.9rem; }
.round-size .segmented button { padding: 4px 14px; }
.round-size .segmented button::before { inset: -8px 0; }

/* Today: daily goal ring, streak and goal setting */

.today {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.today.met {
  border-color: var(--gold-bright);
  background: linear-gradient(135deg, var(--gold-soft), var(--surface) 70%);
}

.ring-wrap { position: relative; flex: none; width: 84px; height: 84px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--border); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; }
.ring-fill.empty { opacity: 0; }
.today.met .ring-fill { stroke: var(--gold-bright); }
.today.animate .ring-fill { animation: ring-fill 0.9s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
@keyframes ring-fill { from { stroke-dashoffset: var(--full); } }

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.ring-label strong { font-size: 1.35rem; }
.ring-label span { font-size: 0.75rem; color: var(--muted); }

.today-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.streak { font-size: 1.15rem; font-weight: 600; }
.streak strong { color: var(--accent); }
.today.met .streak strong { color: var(--gold); }
.today-sub { color: var(--muted); font-size: 0.9rem; }

.goal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}
.stepper button {
  position: relative;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1rem;
  line-height: 1;
}
.stepper button:hover { color: var(--accent); }
.stepper input {
  width: 3.2em;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline: 2px solid var(--accent); border-radius: 6px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s, transform 0.18s ease-out, box-shadow 0.18s ease-out;
}
/* Lift the tile off the page and thicken its outline. The extra 1px ring is
   a box-shadow rather than a wider border, so neighbouring tiles don't shift.
   Hover only applies with a mouse; on touch screens it would stick after a tap. */
@media (hover: hover) {
  .tile:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-lift);
    transform: translateY(-4px);
  }
}
.tile:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-lift);
  transform: translateY(-4px);
}
.tile:active { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  .tile, .tile:hover, .tile:focus-visible, .tile:active { transform: none; transition: none; }
}
/* The count, stars, bar and status sit at the bottom of the tile, so they
   line up across a row when one title wraps to two lines and the other doesn't. */
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.tile-title { font-weight: 600; font-size: 1.1rem; }
.tile-meta { font-size: 0.85rem; color: var(--muted); }
.tile-meta strong { color: var(--bad); font-weight: 600; }
/* Mixed draws from every topic, like the real test. */
.tile.mixed { border-style: dashed; grid-column: 1 / -1; }
/* A mode with one set of questions: its only tile, full width. */
.tile.single { grid-column: 1 / -1; }

/* Unlit stars at 3:1 against the tile, so the count reads at a glance; lit
   ones keep the bright gold with a darker gold edge for the same reason. */
.stars { font-size: 0.95rem; letter-spacing: 1px; color: var(--star-off); white-space: nowrap; }
.stars .on { color: var(--gold-bright); -webkit-text-stroke: 0.6px var(--gold); }

/* A fully mastered topic turns gold. */
.tile.complete {
  border-style: solid;
  border-color: var(--gold-bright);
  background: linear-gradient(160deg, var(--gold-soft), var(--surface) 75%);
}

/* Mastery bar: mastered, then known, then learning; the rest is unseen. */
.bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.bar .seg { display: block; height: 100%; }
.bar .mastered { background: var(--gold-bright); }
.bar .known { background: var(--good); }
.bar .learning { background: var(--accent); opacity: 0.55; }

.coming-soon {
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}
.coming-soon-icon { font-size: 2.4rem; }
.coming-soon h2 { margin: 8px 0 4px; font-size: 1.2rem; }
.coming-soon p { margin: 0; color: var(--muted); }

footer { margin-top: 32px; }
.disclaimer { margin: 12px 0 0; font-size: 0.8rem; color: var(--muted); }
.feedback { margin: 0; font-size: 0.9rem; }
.disclaimer + .feedback { margin-top: 4px; }
/* 44px tall tap areas; the padding replaces the gaps between the lines. */
.feedback a { display: inline-block; padding: 12px 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.feedback a:hover { color: var(--text); }
/* Reset all progress: last and quiet, below the links people use. */
.reset { margin: 8px 0 0; }
.reset .link { padding: 12px 0; font-size: 0.8rem; }

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
}
.link:hover { color: var(--text); }

/* Quiz */

/* Fixed at the top while a long question or explanation scrolls under it.
   It starts at the very top (pulled up over main's top padding), so it
   never moves at all; opaque and as wide as main's padding, so nothing
   shows through or beside it. */
.study-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: calc(-1 * var(--main-top)) -16px 16px;
  padding: 12px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}
/* A 44px tap area for the way out of a round, without moving the text. */
.study-header a { display: inline-block; margin: -12px -8px; padding: 12px 8px; color: inherit; white-space: nowrap; }
.study-header > span:last-child { white-space: nowrap; }
.study-header .title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

.combo {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.85rem;
  white-space: nowrap;
}
.combo.pop { animation: pop 0.35s ease-out; }
/* A leading space would be dropped inside the flex pill, so use a margin. */
.combo-text { margin-left: 0.3em; }

@keyframes pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.card {
  padding: 16px 20px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Level chip on the left, answer history on the right. Always the same
   height, so the question doesn't move once it has a history. */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  margin-bottom: 8px;
}
.level {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.level-learning { background: var(--accent-soft); color: var(--accent); }
.level-known { background: var(--good-soft); color: var(--good); }
.level-mastered { background: var(--gold-soft); color: var(--gold); }
.history { font-size: 0.8rem; color: var(--muted); }

.question { margin: 4px 0 18px; font-size: 1.2rem; font-weight: 400; line-height: 1.45; }
/* The setup reads as plain text; the question itself is bold, on its own line. */
.question .ask { font-weight: 650; }
.question .setup + .ask { display: block; margin-top: 8px; }

/* The question's setting, above it. */
.setting { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 1.3;
}
.tag svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tag-officiated { padding-left: 9px; background: var(--accent); box-shadow: none; color: var(--on-accent); }
.tag-non-officiated { padding-left: 9px; background: var(--gold-soft); box-shadow: inset 0 0 0 1.5px var(--gold); color: var(--gold); }
.tag-pro { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.missed .setting { margin: 0 0 4px; }
.missed .tag { padding: 2px 9px; font-size: 0.75rem; }
.missed .tag svg { width: 13px; height: 13px; }

.answers { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  line-height: 1.4;
  touch-action: manipulation;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s, opacity 0.2s;
}
@media (hover: hover) {
  .option:not(:disabled):hover { border-color: var(--accent); transform: translateY(-1px); }
}
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.option:disabled { cursor: default; }
.letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.option-text { flex: 1; padding-top: 1px; }
.mark { flex: none; font-weight: 700; padding-top: 1px; }

.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.correct .letter { border-color: var(--good); background: var(--good); color: var(--surface); }
.option.correct .mark { color: var(--good); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .letter { border-color: var(--bad); background: var(--bad); color: var(--surface); }
.option.wrong .mark { color: var(--bad); }
.option.dim { opacity: 0.5; }
.option.correct.picked { animation: pop 0.35s ease-out; }
.option.wrong.picked { animation: shake 0.4s ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.explain {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 4px solid;
  border-radius: 12px;
  animation: rise-in 0.3s ease-out both;
}
.explain.good { border-color: var(--good); background: var(--good-soft); }
.explain.bad { border-color: var(--bad); background: var(--bad-soft); }
.explain-head { margin-bottom: 4px; font-weight: 700; }
.explain.good .explain-head { color: var(--good); }
.explain.bad .explain-head { color: var(--bad); }
.explain p { margin: 0; }

/* Figures: inline SVG from scripts/usap_figures.py. Every colour comes from
   a token, so they follow the light/dark theme. */
.fig { margin: 0 0 18px; text-align: center; }
.explain .fig, .missed .fig { margin: 12px 0 0; }
.fig svg { display: block; max-width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.fig svg text { font-family: inherit; font-size: 12px; }
/* Signal photos: about the drawings' size, never wider than the card. */
.fig .photo {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}
.fig figcaption { margin-top: 6px; color: var(--muted); font-size: 0.85rem; }
.f-paper { fill: var(--surface); stroke: var(--border); }
.f-box { fill: none; stroke: var(--border); stroke-width: 1; }
.f-hl { fill: var(--gold-soft); }
.f-num { fill: var(--muted); font-size: 11px !important; }
.f-t { fill: var(--text); }
.f-label, .f-name { font-weight: 600; }
.f-muted { fill: var(--muted); }
.f-pen { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; fill: none; }
.f-so { stroke-width: 3; }
.f-arrowhead { fill: var(--accent); }
.f-pen-t { fill: var(--accent); font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.f-dash { stroke-dasharray: 6 4; }
.f-run { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.f-runhead { fill: var(--muted); }
.f-you { fill: var(--accent); }
.f-opp { fill: var(--gold); }
.f-air { fill: none; stroke-width: 1.6; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.f-air.f-you { stroke: var(--accent); }
.f-air.f-opp { stroke: var(--gold); }
.f-leader { stroke: var(--accent); stroke-width: 1.2; }
.f-leader-dot { fill: var(--accent); }
.f-crutch { stroke: var(--muted); stroke-width: 5; stroke-linecap: round; }
.f-link { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 4 3; }
.f-chair { fill: var(--surface); stroke: var(--muted); stroke-width: 1.4; }
.f-wheel { fill: var(--muted); opacity: 0.7; }
.f-wheel-o { fill: var(--gold); opacity: 0.8; }
.f-paddle { fill: var(--accent); }
.f-paddle-h { fill: var(--muted); }
.f-hat { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 1.5; }
.f-hat.f-air { fill: none; stroke: var(--gold); }
.f-dim { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.f-dim.f-dim-hi { stroke: var(--accent); stroke-width: 1.6; }
.f-crossbar { fill: var(--muted); opacity: 0.35; }
.f-tf { stroke: var(--surface); stroke-width: 3px; paint-order: stroke; font-size: 11px !important; }
.f-ink { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.f-rule { stroke: var(--border); stroke-width: 1.5; }
.f-clip { fill: var(--bad); }
.f-clip-card { fill: var(--surface); }
.f-clip-num { font-weight: 700; font-size: 15px !important; }
.f-court { fill: var(--accent-soft); }
.f-inplay { fill: var(--gold-soft); }
.f-target { fill: var(--gold-soft); }
/* Non-volley zones get their own colour on every court; their lines are a
   light grey so labels on them stay readable; an area that is the target but
   includes an NVZ is outlined instead of filled. */
.f-nvz { fill: var(--good-soft); }
.f-nvz-line { stroke: var(--muted); stroke-opacity: 0.45; stroke-width: 1.5; }
.f-target-edge { fill: none; stroke: var(--gold); stroke-width: 3; }
.f-line { stroke: var(--text); stroke-width: 2; }
.f-extra { stroke: var(--muted); stroke-dasharray: 5 4; }
.f-net { stroke: var(--muted); stroke-width: 3.5; stroke-linecap: round; }
.f-player { fill: var(--accent); }
.f-player-t { fill: var(--on-accent); font-weight: 700; }
.f-serve { stroke-dasharray: 6 4; }
.f-line-band { fill: var(--text); opacity: 0.8; }
.f-outside { fill: var(--bg); }
.f-on-band { fill: var(--surface); font-weight: 600; }
.f-ground { stroke: var(--muted); stroke-width: 1.5; }
.f-edge { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.f-ball { fill: var(--gold-bright); fill-opacity: 0.55; stroke: var(--gold); stroke-width: 2; }
.f-contact { fill: var(--bad); }
.f-head { fill: var(--muted); }
.f-body { stroke: var(--text); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.f-body-back { opacity: 0.45; }
.f-hand { fill: var(--accent-soft); stroke: var(--text); stroke-width: 2; }
.f-hand-top { fill: var(--surface); }
.f-knuckle { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.f-face { fill: var(--surface); stroke: var(--text); stroke-width: 2.5; }
.f-eye { fill: var(--text); }

.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
/* UPA-A explanations: the USAP rule the ruling differs from, set apart. */
.usap {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--gold-soft);
}
.usap p { margin: 0; }
.usap-head { font-weight: 700; color: var(--gold); }
.usap-same { border-left-color: var(--good); background: var(--good-soft); }
.usap-same .usap-head { color: var(--good); }
.usap .refs { margin-top: 8px; }
.summary .missed .usap { margin-top: 8px; font-size: 0.9rem; }
.ref {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
/* A Rulebook rule opens the online rulebook at its page (new tab). */
.ref-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
  text-decoration: none;
}
.ref-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ref-icon {
  flex: none;
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: hover) {
  .ref-link:hover { background: var(--accent-soft); }
}
/* Easier to tap on touch screens. */
@media (pointer: coarse) {
  .ref-link { padding: 6px 12px; }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.card-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.next { min-width: 200px; }

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

.btn {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: inherit;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { border-color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.summary { text-align: center; padding: 40px 0; }
.summary h2 { margin: 0 0 4px; font-size: 2rem; animation: pop 0.45s ease-out; }
.summary p { color: var(--muted); margin: 0 0 20px; }
.summary .summary-score { font-size: 1.1rem; }
.summary-score strong { color: var(--text); font-size: 1.5rem; }
.summary .summary-note { font-size: 0.85rem; margin-bottom: 24px; }
.summary .actions { max-width: 420px; margin: 0 auto; }

.highlights {
  max-width: 420px;
  margin: 0 auto 20px;
  padding: 0;
  list-style: none;
  text-align: left;
}
.highlights li {
  margin-bottom: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise-in 0.4s ease-out both;
  animation-delay: calc(var(--i) * 120ms + 200ms);
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
}

/* Missed questions, with their answers, folded away under the score. */
.missed {
  max-width: 560px;
  margin: 0 auto 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.missed summary { padding: 12px 16px; font-weight: 600; cursor: pointer; }
.missed ol { margin: 0; padding: 0 16px 4px 36px; }
.missed li { margin-bottom: 14px; }
.summary .missed p { margin: 0 0 2px; }
.summary .missed-q { color: var(--text); }
.summary .missed-said { color: var(--bad); }
.summary .missed-a { color: var(--good); font-weight: 600; }
.summary .missed-why { font-size: 0.9rem; }
.summary .missed .refs { margin-top: 6px; }

/* Toasts and confetti */

.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  font-weight: 600;
  text-align: center;
  animation: toast-in 0.35s cubic-bezier(0.3, 0.7, 0.2, 1.3) both;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.gold { border-color: var(--gold-bright); background: var(--gold-soft); }
.toast.leaving { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}
.confetti i { position: absolute; top: 0; display: block; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  .today.animate .ring-fill, .combo.pop, .summary h2, .highlights li, .toast,
  .option.correct.picked, .option.wrong.picked, .explain { animation: none; }
  .option { transition: none; }
}

@media (max-width: 480px) {
  main { --main-top: 20px; }
  /* Scales with the screen so the title stays on one line beside the theme
     button, even on 320px-wide phones; never larger than 1.8rem. */
  .home-header h1 { font-size: clamp(1.7rem, 8.5vw, 2.2rem); }
  .theme-toggle { width: 36px; height: 36px; }
  .theme-toggle svg { top: 7px; left: 7px; }
  .subtitle { font-size: 0.9rem; }
  .today { gap: 14px; padding: 14px; }
  .ring-wrap { width: 72px; height: 72px; }
  /* The line above already says how many questions are left. */
  .goal-unit { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { padding: 14px 12px; }
  .combo-text { display: none; }
  .card { padding: 14px 14px 16px; }
  .question { font-size: 1.1rem; }
  .next { width: 100%; }
}
