/* Dex Runs
   Direction: a speedrun timing instrument, not a toy Pokedex.
   The use scene is a player racing a clock at a desk at night with a stream
   running, scanning dense data at speed. That forces dark, tight and precise:
   the reference world is split timers and scoreboards, not pastel type cards.
   Colour strategy is Committed - one saturated signal colour carries the run
   state, everything else is a neutral tinted toward it. */

:root {
  /* Neutrals, all tinted toward the amber signal hue. Never pure black or white.
     Deepened for the night-route look: the ground darker, the lines firmer. */
  --bg:            oklch(15% 0.012 75);
  --surface:       oklch(20% 0.014 75);
  --surface-high:  oklch(24.5% 0.016 75);
  --line:          oklch(32% 0.02 75);
  --line-strong:   oklch(42% 0.024 75);

  --ink:           oklch(95% 0.008 75);
  --ink-2:         oklch(76% 0.012 75);
  --ink-3:         oklch(59% 0.014 75);

  /* Committed signal: the running clock. */
  --signal:        oklch(80% 0.155 78);
  --signal-dim:    oklch(64% 0.120 78);
  --signal-bg:     oklch(30% 0.055 78);

  --good:          oklch(78% 0.150 155);
  --good-bg:       oklch(30% 0.050 155);
  --warn:          oklch(72% 0.150 32);

  /* The Pokeball nod. Used ONLY for the wordmark dot and the board's rank-1
     medal ring. Never a second signal. */
  --red:           oklch(58% 0.19 28);

  /* Real depth: two elevation levels, soft offset+blur shadows. */
  --elev-1: 0 2px 10px oklch(8% 0.01 75 / 0.5);
  --elev-2: 0 6px 24px oklch(8% 0.01 75 / 0.55);

  --r:  14px;
  --r-s: 9px;

  /* Strong curves. The CSS built-ins are too weak to feel intentional. */
  --out:      cubic-bezier(0.23, 1, 0.32, 1);
  --in-out:   cubic-bezier(0.77, 0, 0.175, 1);

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  /* Display face: rounded and game-cabinet friendly, for headings, wordmark
     and verdicts. Measurements never wear it. */
  --display: 'Fredoka', var(--sans);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Every number in this UI is a measurement. Tabular figures stop the timer
   and hop counter from jittering as digits change. */
.num, .timer, .count {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Headings wear the display face with a slight positive tracking, not the
   negative tracking of the old look. Rounded forms need the air. */
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 500; letter-spacing: 0.005em; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.9375rem; }
p  { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.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;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

/* ---------- shell ---------- */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

/* Night meadow: a silhouetted row of classic sprites along the page's foot,
   behind everything, intercepting nothing. Filtered sprites, never a gradient. */
.meadow {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 0 3vw;
  pointer-events: none;
}

.meadow-mon {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  filter: brightness(0.28) saturate(0.35);
  flex: none;
}

/* Mobile: clutter. Stream mode: broadcast cleanliness. Both go without. */
@media (max-width: 720px) { .meadow { display: none; } }
[data-stream="on"] .meadow { display: none; }

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--display);
  letter-spacing: 0.005em;
  font-size: 1.5rem;
  font-weight: 500;
}

/* The Pokeball dot: the only red on the page besides rank-1's medal ring. */
.ball-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid oklch(30% 0.02 75);
  margin-right: 8px;
}

.wordmark span {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.masthead nav { display: flex; gap: 6px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  transition: background 160ms var(--out), border-color 160ms var(--out), transform 160ms var(--out);
}

.btn:hover { background: var(--surface-high); border-color: var(--ink-3); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: oklch(22% 0.05 78);
  font-weight: 500;
  box-shadow: var(--elev-1);
}

.btn-primary:hover { background: oklch(85% 0.155 78); border-color: oklch(85% 0.155 78); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface); color: var(--ink); }

.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- home ---------- */

.lede {
  max-width: 62ch;
  margin-bottom: 40px;
  color: var(--ink-2);
}

.lede strong { color: var(--ink); font-weight: 500; }

/* align-items: start, not stretch. Stretching made the daily panel match the
   height of the two stacked panels beside it, leaving 136px of empty colour
   under the countdown. The panel should be the size of its contents. */
.start-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: start;
  gap: 20px;
  margin-bottom: 44px;
}

@media (max-width: 720px) { .start-grid { grid-template-columns: 1fr; } }

/* The daily panel is the page's one committed surface. Everything else stays
   quiet so this reads as the primary action without a badge telling you so. */
.panel-daily {
  padding: 26px 28px;
  border: 2px solid var(--signal-dim);
  border-radius: var(--r);
  background: var(--signal-bg);
  box-shadow: var(--elev-2);
}

.panel-daily h2 { color: var(--ink); }

.panel-daily .matchup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0 22px;
}

.panel-side {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel {
  padding: 22px 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--elev-1);
}

.panel h3 { margin-bottom: 6px; }
.panel p { color: var(--ink-2); font-size: 0.875rem; margin-bottom: 16px; }

/* Stays a sentence: the ticker writes textContent. Tabular digits keep the
   interpolated countdown from jittering as it counts. */
.countdown {
  font-size: 0.75rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* ---------- species tokens ---------- */

.sprite {
  width: 72px; height: 72px;
  image-rendering: pixelated;
  flex: none;
}

.sprite-lg { width: 80px; height: 80px; }
.sprite-sm { width: 44px; height: 44px; }
.sprite-xs { width: 30px; height: 30px; }

/* The daily marquee: official artwork at hero size, smooth via .avatar-art. */
.sprite-hero { width: 88px; height: 88px; }

.mon {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mon-name { font-weight: 500; letter-spacing: -0.01em; }
.mon-dex  { font-size: 0.75rem; color: var(--ink-3); }

.arrow { color: var(--ink-3); flex: none; }

/* Type chips carry information (this Pokemon's typing), so they earn colour.
   They are never used decoratively elsewhere. */
.chips { display: flex; gap: 5px; flex-wrap: wrap; }

.chip {
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid currentColor;
  background: color-mix(in oklch, currentColor 18%, transparent);
  opacity: 0.9;
}

.tier {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--surface-high);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

/* ---------- run header ---------- */

.runbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 16px;
  margin-bottom: 26px;
}

.runbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.route {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.readout { display: flex; align-items: center; gap: 26px; }

.stat { text-align: right; }

.stat-label {
  display: block;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1px;
}

.timer { font-size: 1.5rem; line-height: 1.1; color: var(--signal); }
.count { font-size: 1.5rem; line-height: 1.1; }
.count.over { color: var(--warn); }

/* ---------- breadcrumb trail ---------- */

.trail {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 0 0;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.trail-step { display: flex; align-items: center; gap: 6px; }
.trail-via  { color: var(--ink-3); font-size: 0.75rem; }
.trail-now  { color: var(--ink); font-weight: 500; }

/* ---------- species page ---------- */

.mon-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 8px;
}

.mon-head .sprite { width: 96px; height: 96px; }
.mon-head h1 { font-size: 1.75rem; }

.mon-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 34px 0 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 { font-size: 0.9375rem; }
.section-head .hint { font-size: 0.8125rem; color: var(--ink-3); }

.head-actions { display: flex; align-items: center; gap: 12px; }

/* The only undo, so it carries a real border rather than the quiet treatment.
   It lives beside the trait heading, where the eye already is. */
.back-inline {
  padding: 7px 13px;
  font-size: 0.8125rem;
  border-color: var(--line-strong);
  color: var(--ink);
  white-space: nowrap;
}

.back-inline:hover { border-color: var(--ink-3); background: var(--surface-high); }

/* Disabled means "not yet", not "gone". Kept visible so its position is
   learnable, dimmed enough to read as unavailable. */
.back-inline[disabled] {
  opacity: 0.4;
  pointer-events: none;
  border-style: dashed;
}

/* Above the attribute heading, this is the first thing in the reading order,
   so it sits left and gets air beneath it. */
.view > .back-inline { margin-bottom: 16px; }

[data-stream="on"] .back-inline { font-size: 1rem; padding: 9px 16px; border-width: 2px; }

.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  text-align: left;
  transition: background 150ms var(--out), border-color 150ms var(--out), transform 150ms var(--out), box-shadow 150ms var(--out);
}

.link:hover { background: var(--surface-high); border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--elev-1); }
.link:active { transform: scale(0.985); }

/* The same glyph language as the emoji share trail: category, not trait. */
.link-emoji { font-size: 1.05rem; flex: none; }

.link-label { font-size: 0.875rem; min-width: 0; flex: 1; }
.link-cat {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.link-n {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  color: var(--ink-3);
  flex: none;
}

/* Dead links stay visible. Seeing "Water - 154 Pokemon, too broad" teaches the
   rule far better than hiding the attribute would. */
.link-dead {
  cursor: not-allowed;
  background: transparent;
  border-style: dashed;
  border-color: var(--line);
  color: var(--ink-3);
}

.link-dead:hover { background: transparent; border-color: var(--line); transform: none; box-shadow: none; }
.link-dead:active { transform: none; }

/* ---------- member grid ---------- */

.members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 8px;
}

.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  text-align: left;
  transition: background 150ms var(--out), border-color 150ms var(--out), transform 150ms var(--out);
}

.member:hover { background: var(--surface-high); border-color: var(--line-strong); }
.member:active { transform: scale(0.98); }

.member.is-goal { border-color: var(--good); background: var(--good-bg); }
.member.is-current { opacity: 0.4; pointer-events: none; }

.member-name { font-size: 0.875rem; }

/* ---------- result ---------- */

.verdict { max-width: 62ch; }

/* The podium moment wears the display face. */
.verdict-mark {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  margin-bottom: 6px;
}

.scoreline {
  display: flex;
  gap: 40px;
  margin: 26px 0 30px;
  padding: 20px 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--elev-1);
  flex-wrap: wrap;
}

.score-val { font-size: 1.75rem; line-height: 1.1; }
.score-val.perfect { color: var(--good); }

.route-list { display: grid; gap: 7px; margin-top: 12px; }

.route-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 0.875rem;
}

.route-row .via { color: var(--ink-3); font-size: 0.8125rem; }
.route-idx {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  width: 18px;
  flex: none;
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } }

/* ---------- preset picker ---------- */

.presets { display: grid; gap: 8px; }

.preset {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--elev-1);
  text-align: left;
  transition: background 150ms var(--out), border-color 150ms var(--out);
}

.preset:hover { background: var(--surface-high); }
.preset[aria-pressed="true"] { border-color: var(--signal-dim); background: var(--signal-bg); }

.preset-name { font-family: var(--display); font-size: 0.9375rem; font-weight: 500; letter-spacing: 0.005em; }
.preset-desc { font-size: 0.8125rem; color: var(--ink-2); margin-top: 2px; }
.preset-fig  { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); margin-top: 5px; }

/* A rule change, not a statistic, so it gets the warning colour rather than
   sitting in the grey figures line where it would be skimmed past. */
.preset-warn {
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--warn);
}

.no-undo {
  font-size: 0.8125rem;
  color: var(--warn);
  white-space: nowrap;
}

[data-stream="on"] .no-undo,
[data-stream="on"] .preset-warn { font-size: 1rem; }

/* ---------- misc ---------- */

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  color: var(--ink-2);
  text-align: center;
}

.foot {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.7;
}

.foot a { color: var(--ink-2); }

.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 12px;
  padding: 9px 16px;
  border-radius: var(--r-s);
  background: var(--surface-high);
  border: 1px solid var(--line-strong);
  font-size: 0.875rem;
  z-index: 20;
}

/* The one authored motion moment: arriving on a new page after a hop.
   Starts at 0.97 rather than 0 - nothing in the real world appears from
   nothing - and runs on a strong ease-out well under 300ms. */
.view { animation: arrive 190ms var(--out) both; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(6px) scale(0.995); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view { animation: fade 140ms var(--out) both; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .btn, .link, .member, .preset { transition-duration: 1ms; }
  .btn:active, .link:active, .member:active { transform: none; }
  .btn:hover, .link:hover { transform: none; }
}

/* Touch devices fire hover on tap, which makes every press look like a hover. */
@media (hover: none) {
  .link:hover, .member:hover, .btn:hover, .preset:hover { background: var(--surface); }
  .btn:hover, .link:hover { transform: none; }
  .link:hover { box-shadow: none; }
}

/* ==========================================================================
   Stream mode
   --------------------------------------------------------------------------
   A different medium, not a bigger version of the same one. Stream encoding
   destroys exactly what the default look is built from: bitrate compression
   mushes hairline borders into nothing, low-chroma greys turn to blocky noise,
   and a viewer on a phone is reading a 1440px layout scaled to their palm with
   a facecam over one corner.

   So this raises the floor rather than adding decoration. Borders thicken past
   what compression can eat, secondary text climbs toward primary, and the run
   state - clock, hops against par, and where you are heading - becomes the
   largest thing on screen so nobody needs the streamer to narrate it.
   ========================================================================== */

[data-stream="on"] {
  /* Every neutral moves up. --line-strong at 40% lightness survives a 6000kbps
     encode; the 31% default does not. */
  --line:        oklch(42% 0.016 75);
  --line-strong: oklch(55% 0.020 75);
  --ink-2:       oklch(88% 0.010 75);
  --ink-3:       oklch(74% 0.012 75);
  --signal:      oklch(84% 0.170 78);
}

[data-stream="on"] body { font-size: 19px; }

[data-stream="on"] .shell { max-width: 1240px; padding: 22px 30px 90px; }

/* The run state band. This is the part a viewer actually reads. */
[data-stream="on"] .runbar {
  padding: 18px 0 20px;
  border-bottom-width: 2px;
}

[data-stream="on"] .timer,
[data-stream="on"] .count {
  font-size: 3.25rem;
  letter-spacing: -0.03em;
}

[data-stream="on"] .stat-label {
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  margin-bottom: 3px;
}

[data-stream="on"] .readout { gap: 40px; }

/* Where you started and where you are going, legible at a glance. */
[data-stream="on"] .route .mon-name { font-size: 1.375rem; }
[data-stream="on"] .route .mon-dex  { font-size: 0.9375rem; }
[data-stream="on"] .route .sprite-xs { width: 62px; height: 62px; }
[data-stream="on"] .arrow { font-size: 1.75rem; }

/* The goal is the single most important fact on screen. Label it, so a viewer
   arriving mid-run knows which of the two Pokemon is the target. */
[data-stream="on"] .route .mon:last-of-type {
  padding: 6px 14px 6px 8px;
  border: 2px solid var(--signal-dim);
  border-radius: var(--r);
  background: var(--signal-bg);
}

[data-stream="on"] .route .mon:last-of-type .mon-dex::after {
  content: " · goal";
  color: var(--signal);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

[data-stream="on"] .trail { font-size: 1rem; padding-top: 14px; }

/* Cards and links: thicker edges, larger targets, fewer per row so the text
   never shrinks below what a phone viewer can read. */
[data-stream="on"] .link,
[data-stream="on"] .member,
[data-stream="on"] .preset,
[data-stream="on"] .route-row,
[data-stream="on"] .panel,
[data-stream="on"] .scoreline { border-width: 2px; }

[data-stream="on"] .panel-daily { border-width: 3px; }

[data-stream="on"] .links { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
[data-stream="on"] .members { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

[data-stream="on"] .link { padding: 15px 18px; }
[data-stream="on"] .link-label { font-size: 1.0625rem; }
[data-stream="on"] .link-cat { font-size: 0.8125rem; color: var(--ink-3); }
[data-stream="on"] .link-n { font-size: 1rem; color: var(--ink-2); }

[data-stream="on"] .member { padding: 11px 14px; }
[data-stream="on"] .member-name { font-size: 1.0625rem; }
[data-stream="on"] .member .sprite-xs { width: 42px; height: 42px; }

/* The species you are standing on. */
[data-stream="on"] .mon-head .sprite { width: 132px; height: 132px; }
[data-stream="on"] .mon-head h1 { font-size: 2.5rem; }
[data-stream="on"] .chip, [data-stream="on"] .tier { font-size: 0.8125rem; padding: 3px 10px; border-width: 2px; }

[data-stream="on"] .section-head { margin: 40px 0 16px; border-bottom-width: 2px; }
[data-stream="on"] .section-head h2 { font-size: 1.25rem; }
[data-stream="on"] .section-head .hint { font-size: 1rem; }

/* Result screen: the score is the payoff, so it carries the size. */
[data-stream="on"] .verdict-mark { font-size: 3rem; }
[data-stream="on"] .score-val { font-size: 3rem; }
[data-stream="on"] .scoreline { gap: 56px; padding: 26px 30px; }

[data-stream="on"] .btn { padding: 12px 20px; font-size: 1rem; border-width: 2px; }

/* Dead links stay legible rather than fading out. Dashed at 2px reads as
   "unavailable" on camera; the 31%-grey version just read as nothing. */
[data-stream="on"] .link-dead { border-width: 2px; color: var(--ink-3); }

/* Facecam usually sits bottom-right. Nothing load-bearing lives there anyway,
   but the extra bottom padding above keeps the last row of links clear of it. */

@media (max-width: 720px) {
  [data-stream="on"] .timer,
  [data-stream="on"] .count { font-size: 2.5rem; }
  [data-stream="on"] .readout { gap: 24px; }
}

/* ==========================================================================
   Leaderboard
   -------------------------------------------------------------------------- */

.attempt-note {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.lb-home { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--signal-dim); }

.lb-home-head {
  font-family: var(--display);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.lb-submit { margin-top: 30px; }

.lb-form { display: flex; gap: 8px; flex-wrap: wrap; }

.lb-form input {
  flex: 1;
  min-width: 200px;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  padding: 9px 13px;
}

.lb-form input:focus { outline: 2px solid var(--signal); outline-offset: 1px; }
.lb-form input::placeholder { color: var(--ink-3); }

.lb-note { font-size: 0.8125rem; color: var(--ink-3); margin-top: 9px; }
.lb-err  { color: var(--warn); }

.lb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }

.lb-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 0.875rem;
  transition: box-shadow 150ms var(--out);
}

.lb-row:hover { box-shadow: var(--elev-1); }

.lb-rank { color: var(--ink-3); min-width: 1.6em; text-align: right; }

/* Medals for the podium rows. Rank stays a measurement: mono, never the
   display face. Rank one alone earns the Pokeball-red ring. */
.lb-list li:nth-child(1) .lb-rank,
.lb-list li:nth-child(2) .lb-rank,
.lb-list li:nth-child(3) .lb-rank {
  font-size: 1.05rem;
  font-weight: 600;
}

.lb-list li:nth-child(1) .lb-rank {
  color: var(--signal);
  border: 2px solid var(--red);
  border-radius: 999px;
  min-width: 1.5em;
  text-align: center;
  padding: 0 5px;
  line-height: 1.35;
}

.lb-list li:nth-child(2) .lb-rank { color: oklch(80% 0.01 75); }
.lb-list li:nth-child(3) .lb-rank { color: oklch(70% 0.08 60); }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { margin-left: auto; color: var(--ink-2); }

/* Your own row is the one you scan for. */
.lb-you { border-color: var(--signal-dim); background: var(--signal-bg); }
.lb-you .lb-rank { color: var(--signal); }

.lb-tail { margin-top: 8px; }

.lb-slot { margin-top: 12px; }

[data-stream="on"] .lb-row { font-size: 1.0625rem; border-width: 2px; padding: 10px 14px; }
[data-stream="on"] .lb-home-head { font-size: 0.8125rem; }

/* ==========================================================================
   Accounts, welcome, daily stats
   --------------------------------------------------------------------------
   All of it borrows the leaderboard's quiet vocabulary: these are supporting
   surfaces around the run, never the run itself. */

.auth-slot { display: inline-flex; align-items: center; gap: 2px; }
.auth-strip { display: inline-flex; align-items: center; gap: 2px; }

.auth-panel { margin-bottom: 28px; }
.auth-panel .lb-form { margin-top: 12px; }
.auth-panel .lb-form input { flex: 0 1 220px; }

.welcome { margin-bottom: 28px; }

/* Pure decoration: the three classic starters greeting a first visit. */
.welcome-trio { display: flex; gap: 12px; margin-top: 12px; }

.welcome-trio img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  flex: none;
}

.welcome ol {
  margin: 10px 0 18px;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 0.875rem;
  display: grid;
  gap: 7px;
}

.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Ranked / unranked / demo, in the run bar. The .tier chip already reads as
   metadata; only the alignment is new. */
.run-tag { align-self: center; flex: none; }

/* The claimed name where the input used to be: same footprint, not editable. */
.lb-poster {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 0.9375rem;
}

/* ---------- account avatars ---------- */

/* Pixel sources (classic sprites, PMD's 40px portraits) keep hard pixels;
   official artwork is smooth and opts out via .avatar-art. Sizes: 28px in
   board rows (default), 22px in the masthead button, 34px beside the poster
   name in the submit block. */
/* Smooth scaling, deliberately NOT pixelated: avatars display at or below
   native size (40px portraits, 96px sprites), and nearest-neighbour
   downscaling deletes pixel rows outright. Pixelated is for enlarging pixel
   art; shrinking it needs averaging.

   Sized 36px in rows because PMD portrait framing is per-artist: some are
   face-filling busts, some (Mimikyu) are full-body scenes where the face is
   a quarter of the frame. Cropping cannot be automated across both, so the
   slot stays close to the portrait's native 40px, where every framing reads. */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-s);
  image-rendering: auto;
  object-fit: contain;
  flex: none;
}

.avatar-art  { image-rendering: auto; }
/* A face needs a floor: below ~28px even a smooth-scaled 40px portrait stops
   reading as a specific Pokémon. The submit-poster slot sits at native 40. */
.avatar-mast { width: 28px; height: 28px; }
.avatar-sub  { width: 40px; height: 40px; }

/* Board rows align text on the baseline; an image has none worth using. */
.lb-row .avatar { align-self: center; }

/* ---------- avatar picker ---------- */

.avatar-styles { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.style-chip[aria-pressed="true"] {
  border-color: var(--signal-dim);
  background: var(--signal-bg);
  color: var(--ink);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.avatar-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  transition: background 150ms var(--out), border-color 150ms var(--out), transform 150ms var(--out);
}

.avatar-pick:hover { background: var(--surface-high); border-color: var(--line-strong); }
.avatar-pick:active { transform: scale(0.96); }
.avatar-pick[aria-pressed="true"] { border-color: var(--signal-dim); background: var(--signal-bg); }

.avatar-pick .avatar { width: 40px; height: 40px; }

[data-stream="on"] .lb-row .avatar { width: 44px; height: 44px; }

/* Inline choice inside a note (retry / play unranked): a link-shaped button,
   because a full .btn inside one line of small print would shout. */
.note-act {
  padding: 0;
  font-size: inherit;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.note-act:hover { color: var(--signal); }

.lb-stats { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }

.lb-dist { display: grid; gap: 4px; margin-top: 10px; }

.lb-dist-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.lb-dist-label { min-width: 5.5em; }
.lb-dist-bar { letter-spacing: 2px; color: var(--line-strong); }

/* Your own row, same treatment as .lb-you: the one you scan for. */
.lb-dist-you { color: var(--ink); }
.lb-dist-you .lb-dist-bar { color: var(--signal); }

[data-stream="on"] .lb-dist-row { font-size: 1rem; }

/* ==========================================================================
   Stats page (the dedicated leaderboard view)
   --------------------------------------------------------------------------
   Built almost entirely from the .lb-* and .panel vocabulary above; only the
   parts with no existing shape get rules of their own. */

/* Day picker: chips for the near days, a select for the older tail. The
   select is dressed like the inputs so the row reads as one control. */
.day-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 24px;
}

.day-select {
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  padding: 8px 12px;
}

/* The stats page reuses the daily matchup row inside a plain panel, where the
   .panel-daily-scoped rule above cannot reach it. */
.panel .matchup { display: flex; align-items: center; gap: 14px; margin: 14px 0 12px; }

.lb-figures { display: grid; gap: 4px; margin-bottom: 14px; }
.lb-figures .lb-note { margin-top: 0; }

.lb-waypoints:not(:empty) { margin-top: 18px; }

.lb-waypoint {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.8125rem;
  color: var(--ink-2);
  margin-top: 6px;
}

/* Rooms: one row per room - the picker chip, then its quiet actions. The
   sub-headings need their own air because they stack inside one section. */
.lb-rooms .lb-home-head { margin-top: 22px; }
.room-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

[data-stream="on"] .day-picker .btn { font-size: 1rem; }
[data-stream="on"] .lb-waypoint,
[data-stream="on"] .lb-figures .lb-note { font-size: 1rem; }

/* ==========================================================================
   Moments
   --------------------------------------------------------------------------
   UI animation is capped at 300ms because a viewer meets it hundreds of times
   a day. A finished run is not that: it happens once, it is the payoff, and it
   is the thing that gets clipped. That earns a longer, staged sequence.

   Everything here is built from transform, opacity, clip-path and blur - no
   gradients, no glow, no glass. Nothing enters from scale(0): things that
   appear out of nothing read as fake.
   ========================================================================== */

/* --- the verdict stamp --- */

.verdict-mark {
  animation: stamp 460ms var(--out) both;
}

@keyframes stamp {
  0%   { opacity: 0; transform: scale(1.14); filter: blur(9px); }
  55%  { opacity: 1; filter: blur(0); }
  70%  { transform: scale(0.985); }
  100% { transform: scale(1); }
}

/* Par gets a second beat the near-misses do not: a rule that draws itself
   underneath the word. clip-path keeps it on the compositor. */
.verdict-mark.is-par { position: relative; color: var(--good); }

.verdict-mark.is-par::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  height: 3px;
  width: 100%;
  background: var(--good);
  border-radius: 2px;
  animation: draw 520ms var(--out) 340ms both;
}

@keyframes draw {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

.verdict-line { animation: rise 380ms var(--out) 140ms both; }

.scoreline { animation: rise 420ms var(--out) 220ms both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* --- the route replays itself --- */

/* Each hop lands in turn rather than the list appearing at once. 55ms apart:
   inside Emil's 30-80ms band, so it reads as cascade rather than delay. */
.route-row {
  animation: hop-in 300ms var(--out) both;
  animation-delay: calc(var(--i, 0) * 55ms + 300ms);
}

@keyframes hop-in {
  from { opacity: 0; transform: translateX(-10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* --- personal best --- */

.record {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 5px 12px;
  border: 2px solid var(--signal);
  border-radius: var(--r-s);
  color: var(--signal);
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  animation: stamp 460ms var(--out) 620ms both;
}

/* --- the goal is on this page --- */

/* A run is won or lost on noticing the target in a list of twelve. One firm
   pull on arrival, then it holds - a looping pulse would nag for the whole
   time the list is open. */
.member.is-goal {
  border-width: 2px;
  animation: spotted 620ms var(--out) both;
}

@keyframes spotted {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}

.member.is-goal .member-name { font-weight: 500; color: var(--good); }

.member.is-goal::after {
  content: "goal";
  margin-left: auto;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--good);
}

/* --- hop feedback --- */

/* 140ms, well inside the UI budget: this fires on every hop, so it confirms
   the click without ever feeling like a wait. */
.count.tick { animation: tick 140ms var(--out) both; }

@keyframes tick {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.13); }
  100% { transform: scale(1); }
}

/* --- stream mode turns it up --- */

[data-stream="on"] .verdict-mark { font-size: 4rem; }
[data-stream="on"] .verdict-mark.is-par::after { height: 5px; bottom: -9px; }
[data-stream="on"] .record { font-size: 1rem; padding: 8px 16px; }
[data-stream="on"] .member.is-goal::after { font-size: 0.8125rem; }
[data-stream="on"] .count.tick { animation-duration: 170ms; }

@keyframes tick-loud {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

[data-stream="on"] .count.tick { animation-name: tick-loud; }

/* --- reduced motion --- */

/* Reduced motion means gentler, not absent: opacity and colour stay because
   they carry meaning, movement and scale go. */
@media (prefers-reduced-motion: reduce) {
  .verdict-mark,
  .verdict-line,
  .scoreline,
  .route-row,
  .record { animation: fade 200ms var(--out) both; }

  .verdict-mark.is-par::after { animation: fade 200ms var(--out) 160ms both; }

  .member.is-goal,
  .count.tick { animation: none; }
}
