/* The Wiki Grand Prix — black and white race broadcast around a Wikipedia reader.
   Built for phones first. Red is reserved for the start lights and a few accents. */

:root {
  --red: #e10600;
  --link: #cc0a00;       /* article links: race red, a touch deeper for reading */
  --link-line: rgba(204, 10, 0, 0.45);
  --link-press: rgba(204, 10, 0, 0.12);
  --tower: #0d0d0f;      /* timing-tower black, the same in both themes */
  --tower-ink: #ffffff;
  --tower-muted: #9aa0a6;
  --tower-line: #2a2c30;
  --bg: #ffffff;
  --ink: #202122;
  --strong: #000000;
  --muted: #54595d;
  --faint: #72777d;
  --rule: #a2a9b1;
  --line: #c8ccd1;
  --hair: #eaecf0;
  --subtle: #f8f9fa;
  --press: #eaecf0;
  --scrim: rgba(0, 0, 0, 0.45);

  --display: 'Barlow Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --serif: 'Linux Libertine', 'Libertinus Serif', Georgia, 'Times New Roman', Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --measure: 46rem;      /* article reading width */
  --page: 46rem;         /* everything else; wider on desktop */
  --gutter: 16px;

  /* Wikipedia's design tokens, which the article template styles read. */
  --background-color-base: var(--bg);
  --background-color-neutral: var(--hair);
  --background-color-neutral-subtle: var(--subtle);
  --background-color-interactive: var(--hair);
  --background-color-interactive-subtle: var(--subtle);
  --background-color-disabled-subtle: var(--hair);
  --color-base: var(--ink);
  --color-emphasized: var(--strong);
  --color-subtle: var(--muted);
  --color-placeholder: var(--faint);
  --color-progressive: var(--strong);
  --color-visited: var(--strong);
  --border-color-base: var(--rule);
  --border-color-subtle: var(--line);
  --border-color-muted: var(--hair);
  --border-color-divider: var(--rule);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --ink: #e4e6ea;
    --strong: #ffffff;
    --muted: #a2a9b1;
    --faint: #878d94;
    --rule: #54595d;
    --line: #3d4146;
    --hair: #24282c;
    --subtle: #181c20;
    --press: #2b2f34;
    --scrim: rgba(0, 0, 0, 0.6);
    --red: #ff2a1a;
    --link: #ff5a4d;
    --link-line: rgba(255, 90, 77, 0.5);
    --link-press: rgba(255, 90, 77, 0.16);
    --tower: #050506;
    --tower-line: #24262a;
    color-scheme: dark;
  }
}

@media (min-width: 720px) {
  :root { --gutter: 24px; }
}
@media (min-width: 960px) {
  :root { --page: 70rem; --gutter: 32px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: var(--strong); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap {
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Masthead ---------- */

.masthead { border-bottom: 1px solid var(--rule); }
.masthead-inner {
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--strong);
  min-width: 0;
}
.brand-mark {
  flex: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--strong);
  background: conic-gradient(var(--strong) 25%, transparent 0 50%, var(--strong) 0 75%, transparent 0) 0 0 / 50% 50%;
  transform: skewX(-10deg);
}
.brand-name {
  font-family: var(--display);
  font-style: italic;
  font-weight: 800;
  font-size: 25px;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}
.mast-nav { display: flex; gap: 22px; }
.mast-nav a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  padding: 8px 0;
  white-space: nowrap;
}
.mast-nav a:hover { color: var(--strong); box-shadow: inset 0 -2px 0 var(--red); }
.nav-short { display: none; }
@media (max-width: 480px) {
  .nav-today { display: none; }
  .brand-name { font-size: 22px; }
}
@media (max-width: 400px) {
  .masthead-inner { gap: 10px; }
  .brand { gap: 8px; }
  .brand-mark { width: 19px; height: 19px; }
  .brand-name { font-size: 20px; }
  .mast-nav a { font-size: 15px; letter-spacing: 0.04em; }
}
@media (max-width: 360px) {
  .nav-long { display: none; }
  .nav-short { display: inline; }
}

.site-foot {
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 56px auto 0;
  padding: 16px var(--gutter) max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--hair);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.site-foot a { color: var(--muted); }

body.racing .masthead,
body.racing .site-foot { display: none; }

/* ---------- Shared pieces ---------- */

.eyebrow,
.route-label,
.field label,
.sheet-label,
.score span,
.path .tag {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow { margin: 0 0 6px; }
.fine { color: var(--muted); font-size: 15px; }

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 1.5px solid var(--strong);
  border-radius: 2px;
  background: var(--bg);
  color: var(--strong);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.06s;
}
.btn:hover { background: var(--subtle); }
.btn:active { transform: translateY(1px); background: var(--press); }
.btn-primary { background: var(--strong); color: var(--bg); }
.btn-primary:hover { background: var(--ink); }
.btn-primary:active { background: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 0; }
.actions .btn { flex: 1 1 200px; }

.checker {
  height: 14px;
  margin: 28px 0 22px;
  background: conic-gradient(var(--strong) 25%, var(--bg) 0 50%, var(--strong) 0 75%, var(--bg) 0) 0 0 / 14px 14px;
}
.results .checker { animation: flag 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 1; }
@keyframes flag { from { background-position: -196px 0; } }

/* Start → Finish */
.route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin: 6px 0 22px;
}
.route-label { display: block; }
.route-title {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(32px, 8.6vw, 42px);
  line-height: 0.98;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: var(--strong);
  overflow-wrap: anywhere;
  margin-top: 4px;
}
.route-desc {
  display: block;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  margin-top: 8px;
}
.route-desc:empty { display: none; }
.route-arrow {
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  padding-top: 26px;
  color: var(--red);
}
@media (max-width: 560px) {
  .route { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .route-arrow { padding: 0; transform: rotate(90deg); width: max-content; }
}

/* Today's race card: a broadcast-style header strip */
.box { border: 1px solid var(--rule); margin: 24px 0; }
.box-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px 9px 16px;
  background: var(--tower);
  color: var(--tower-ink);
  box-shadow: inset 5px 0 0 var(--red);
  font-family: var(--display);
  font-style: italic;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.day-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 18px 0 0;
}
.day-links a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--strong);
  padding: 6px 0;
}
.day-links a:hover { box-shadow: inset 0 -2px 0 var(--red); }

/* Past races */
.past { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.past-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'date result' 'route route';
  gap: 2px 16px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.past-item:hover { background: var(--subtle); }
.past-item:active { background: var(--press); }
.past-date { grid-area: date; color: var(--muted); font-size: 14px; }
.past-route {
  grid-area: route;
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--strong);
  overflow-wrap: anywhere;
}
.past-route .to { color: var(--red); padding: 0 0.3em; }
.past-result {
  grid-area: result;
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}
.past-result.done { color: var(--strong); }
.box-body { padding: 16px 14px 20px; }
.date { margin: 0 0 14px; color: var(--muted); font-size: 15px; }

.section-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--strong);
  margin: 36px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}

/* Today's result summary on the home page */
.today-result { margin-top: 4px; }
.today-line {
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.1;
  color: var(--strong);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.today-line .sep { color: var(--red); padding: 0 8px; }
.next { color: var(--muted); font-size: 15px; margin: 16px 0 0; font-variant-numeric: tabular-nums; }

details.route-details { margin-top: 16px; border-top: 1px solid var(--hair); padding-top: 10px; }
details.route-details summary { cursor: pointer; color: var(--ink); font-size: 15px; padding: 6px 0; }

/* ---------- Path list ---------- */

.path { list-style: none; margin: 8px 0 0; padding: 0; }
.path li {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr);
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--hair);
}
.path li:last-child { border-bottom: 0; }
.path .n {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.path a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  color: var(--strong);
  text-decoration-color: var(--line);
  text-underline-offset: 0.15em;
  overflow-wrap: anywhere;
}
.path .tag { display: inline-block; margin-left: 10px; font-size: 13px; }
.path li:last-child .tag { color: var(--red); }

/* ---------- Results ---------- */

.results h1,
.page-heading {
  font-family: var(--display);
  font-style: italic;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--strong);
}
.results h1 { font-size: clamp(48px, 14vw, 64px); margin: 0 0 8px; }
.results .route-mini {
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
  color: var(--ink);
}
.score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--tower);
  color: var(--tower-ink);
  box-shadow: inset 0 -3px 0 var(--red);
  margin: 20px 0;
}
.score > div { padding: 14px 16px 16px; }
.score > div + div { border-left: 1px solid var(--tower-line); }
.score b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 12vw, 54px);
  line-height: 1;
  color: var(--tower-ink);
  font-variant-numeric: tabular-nums;
}
.score span { color: var(--tower-muted); }
.verdict {
  border-left: 4px solid var(--red);
  padding: 4px 0 4px 14px;
  margin: 0 0 20px;
}
.verdict strong {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  text-transform: uppercase;
  color: var(--strong);
}
.verdict .pos {
  display: inline-block;
  margin-right: 10px;
  padding: 0 8px;
  background: var(--strong);
  color: var(--bg);
  font-style: italic;
}
.verdict .pos.p1 { background: var(--red); color: #fff; }
.verdict > span { color: var(--muted); font-size: 15px; }

.field { position: relative; margin: 0 0 18px; }
.field label { display: block; margin-bottom: 6px; }
.field input {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  font-size: 19px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--bg);
  color: var(--strong);
}
.field input::placeholder { color: var(--faint); }
.field input:focus { outline: none; border-color: var(--strong); box-shadow: 0 0 0 1px var(--strong); }
.field.small input { font-size: 17px; }

/* ---------- Build a race ---------- */

.page-heading { font-size: clamp(40px, 11vw, 52px); margin: 28px 0 8px; }
.lede { color: var(--muted); margin: 0 0 24px; }

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 15;
  background: var(--bg);
  border: 1px solid var(--strong);
  border-top: 0;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.sg {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border: 0;
  border-top: 1px solid var(--hair);
  background: none;
  text-align: left;
  cursor: pointer;
}
.sg:first-child { border-top: 0; }
.sg[aria-selected='true'], .sg:hover { background: var(--subtle); }
.sg img, .sg-ph {
  flex: none;
  width: 40px;
  height: 40px;
  object-fit: cover;
  background: var(--hair);
}
.sg-text { min-width: 0; display: flex; flex-direction: column; }
.sg-title { font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1.15; color: var(--strong); }
.sg-desc {
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.made { margin-top: 8px; }
.link-field {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--subtle);
  color: var(--ink);
}

.notice {
  border: 1px solid var(--rule);
  background: var(--subtle);
  padding: 14px 16px;
  margin: 0 0 20px;
}
.notice p { margin: 0 0 12px; }
.notice .btn { min-height: 42px; }

.challenge {
  border-left: 3px solid var(--strong);
  padding: 4px 0 4px 14px;
  margin: 0 0 24px;
  font-size: 17px;
}
.challenge p { margin: 0; }
.challenge b { font-variant-numeric: tabular-nums; }

/* ---------- Race HUD: a timing tower over the article ---------- */

.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--tower);
  color: var(--tower-ink);
  box-shadow: inset 0 -3px 0 var(--red), 0 2px 10px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.hud-row {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) var(--gutter) 11px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.hud-target {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 2px 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hud-label {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tower-muted);
}
.hud-target .hud-label::after { content: ' · tap for summary'; letter-spacing: 0.04em; text-transform: none; }
.hud-title {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--tower-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-stat { flex: none; text-align: right; }
.hud-num {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.05;
  color: var(--tower-ink);
  font-variant-numeric: tabular-nums;
}
.hud-stat-time { min-width: 4.2em; }
.hud-stat-time .hud-num { font-weight: 600; }
.loading .hud-stat-time .hud-num { color: var(--tower-muted); }
.hud-quit {
  flex: none;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--tower-line);
  border-radius: 2px;
  background: transparent;
  color: var(--tower-ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.hud-quit:hover { border-color: var(--tower-muted); }
.hud-quit:active { background: var(--tower-line); }
.hud-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 30%;
  background: var(--tower-ink);
  opacity: 0;
  transform: translateX(-100%);
}
.loading .hud-bar { opacity: 1; animation: slide 0.9s linear infinite; }
@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}
.hud-quit-x { display: none; }

/* Phones: the finish name gets the room. It can wrap to two lines,
   and Give up shrinks to an ✕ (it still asks before quitting). */
@media (max-width: 560px) {
  .hud-row { gap: 12px; }
  .hud-target .hud-label::after { content: none; }
  .hud-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 20px;
    line-height: 1.02;
  }
  .hud-num { font-size: 23px; }
  .hud-quit { width: 38px; min-height: 38px; padding: 0; }
  .hud-quit-text { display: none; }
  .hud-quit-x { display: inline; font-family: var(--sans); font-size: 16px; line-height: 1; }
}
@media (max-width: 360px) {
  .hud-row { gap: 9px; }
  .hud-title { font-size: 18px; }
  .hud-num { font-size: 21px; }
}

/* ---------- The article ---------- */

.page {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 4px var(--gutter) 96px;
  transition: opacity 0.15s;
  overflow-x: clip;
  /* Keep anything an article positions (maps, overlays) beneath the race bar. */
  position: relative;
  z-index: 0;
  isolation: isolate;
}
.loading .page { opacity: 0.35; pointer-events: none; }
.page-head { margin: 18px 0 10px; }
.page-title {
  font-family: var(--serif);
  font-weight: normal;
  font-size: clamp(30px, 7.5vw, 38px);
  line-height: 1.2;
  color: var(--strong);
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}
.page-from { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.page-error { padding: 32px 0; }

/* Tappable links are race red so they stand out from the text. */
.race-link {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.17em;
  cursor: pointer;
  border-radius: 2px;
  -webkit-tap-highlight-color: transparent;
}
.race-link:hover { text-decoration-color: var(--link); text-decoration-thickness: 2px; }
.race-link:active { background: var(--link-press); }
.race-link:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

.mw-parser-output {
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: break-word;
  color: var(--ink);
}
.mw-parser-output p { margin: 0.5em 0 1em; }
.mw-parser-output h2,
.mw-parser-output h3,
.mw-parser-output h4,
.mw-parser-output h5,
.mw-parser-output h6 { color: var(--strong); clear: both; }
.mw-parser-output h2 {
  font-family: var(--serif);
  font-weight: normal;
  font-size: 1.6em;
  line-height: 1.3;
  margin: 1.3em 0 0.45em;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--rule);
  clear: none;
}
.mw-parser-output h3 { font-size: 1.2em; font-weight: 700; line-height: 1.4; margin: 1.1em 0 0.3em; clear: none; }
.mw-parser-output h4,
.mw-parser-output h5,
.mw-parser-output h6 { font-size: 1em; font-weight: 700; margin: 1em 0 0.3em; clear: none; }
.mw-parser-output ul { margin: 0.3em 0 0.9em 1.6em; padding: 0; list-style: disc; }
.mw-parser-output ol { margin: 0.3em 0 0.9em 2em; padding: 0; }
.mw-parser-output li { margin-bottom: 0.2em; }
.mw-parser-output dl { margin: 0.3em 0 0.6em; }
.mw-parser-output dt { font-weight: 700; }
.mw-parser-output dd { margin: 0 0 0.2em 1.6em; }
.mw-parser-output blockquote { margin: 1em 0; padding: 0 0 0 1.2em; border-left: 3px solid var(--hair); }
.mw-parser-output hr { border: 0; border-top: 1px solid var(--rule); }
.mw-parser-output img { max-width: 100%; height: auto; vertical-align: middle; }
.mw-parser-output sup,
.mw-parser-output sub { line-height: 1; }
.mw-parser-output pre,
.mw-parser-output code { font-family: var(--mono); font-size: 0.9em; background: var(--subtle); }
.mw-parser-output pre { padding: 12px; border: 1px solid var(--hair); overflow-x: auto; white-space: pre; }
.mw-parser-output .nowrap { white-space: nowrap; }
.mw-parser-output .center { text-align: center; width: 100%; }
.mw-parser-output .center > * { margin-left: auto; margin-right: auto; }
.mw-parser-output .hatnote {
  font-style: italic;
  padding-left: 1.6em;
  margin-bottom: 0.6em;
  color: var(--muted);
}
.mw-parser-output .mw-collapsible-toggle,
.mw-parser-output .mw-collapsible-toggle-placeholder { display: none; }

/* Figures and thumbnails */
.mw-parser-output figure[typeof^='mw:File'] { display: table; margin: 0.5em 0 1.3em; border-collapse: collapse; }
.mw-parser-output figure[typeof^='mw:File'] > * > img,
.mw-parser-output figure[typeof^='mw:File'] > img { display: block; }
.mw-parser-output figure[typeof~='mw:File/Thumb'],
.mw-parser-output figure[typeof~='mw:File/Frame'] {
  border: 1px solid var(--line);
  background: var(--subtle);
  padding: 3px;
}
.mw-parser-output figure[typeof~='mw:File/Thumb'] > figcaption,
.mw-parser-output figure[typeof~='mw:File/Frame'] > figcaption {
  display: table-caption;
  caption-side: bottom;
  padding: 6px 8px 8px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--subtle);
  font-size: 14px;
  line-height: 1.45;
}
.mw-parser-output figure[typeof^='mw:File'] > figcaption:empty { display: none; }
.mw-parser-output figure:not([typeof~='mw:File/Thumb']):not([typeof~='mw:File/Frame']) > figcaption { display: none; }
.mw-parser-output .mw-halign-center { margin-left: auto; margin-right: auto; }
.mw-parser-output .thumbinner {
  border: 1px solid var(--line);
  background: var(--subtle);
  padding: 3px;
  max-width: 100%;
  font-size: 14px;
  line-height: 1.45;
}
.mw-parser-output .thumbcaption { padding: 4px 4px 2px; }

@media (min-width: 720px) {
  .mw-parser-output figure[typeof~='mw:File/Thumb']:not(.mw-halign-left):not(.mw-halign-center):not(.mw-halign-none),
  .mw-parser-output figure[typeof~='mw:File/Frame'].mw-halign-right,
  .mw-parser-output figure.mw-halign-right,
  .mw-parser-output .tright,
  .mw-parser-output .floatright {
    float: right;
    clear: right;
    margin: 0.4em 0 1.2em 1.4em;
  }
  .mw-parser-output figure.mw-halign-left,
  .mw-parser-output .tleft,
  .mw-parser-output .floatleft {
    float: left;
    clear: left;
    margin: 0.4em 1.4em 1.2em 0;
  }
  .mw-parser-output .infobox {
    float: right;
    clear: right;
    margin: 0.4em 0 1.2em 1.4em;
    max-width: 24em;
  }
}

/* On phones nothing floats: images and infoboxes take the full column. */
@media (max-width: 719px) {
  .mw-parser-output figure[typeof^='mw:File'] { margin: 1em auto 1.4em; float: none; }
  .mw-parser-output .infobox,
  .mw-parser-output table[style*='float'],
  .mw-parser-output div[style*='float'],
  .mw-parser-output .tright,
  .mw-parser-output .floatright,
  .mw-parser-output .tleft,
  .mw-parser-output .floatleft {
    float: none !important;
    clear: both;
    margin: 1em auto !important;
    max-width: 100% !important;
  }
  .mw-parser-output .infobox,
  .mw-parser-output table[style*='float'] { width: 100% !important; }
  .mw-parser-output .thumbinner { margin: 0 auto; }
}

/* Infobox fallback (Wikipedia's template styles usually take over) */
.mw-parser-output .infobox {
  border: 1px solid var(--rule);
  background: var(--subtle);
  color: var(--ink);
  padding: 0.2em;
  font-size: 88%;
  line-height: 1.5;
  border-spacing: 3px;
}
.mw-parser-output .infobox th { text-align: left; vertical-align: top; padding-right: 0.6em; }
.mw-parser-output .infobox td { vertical-align: top; }
.mw-parser-output .infobox-above,
.mw-parser-output .infobox-title { font-size: 125%; font-weight: 700; text-align: center; }
.mw-parser-output .infobox-image,
.mw-parser-output .infobox-caption { text-align: center; }

/* Tables */
.table-scroll { overflow-x: auto; max-width: 100%; margin: 1em 0; -webkit-overflow-scrolling: touch; }
.table-scroll > table { margin-top: 0 !important; margin-bottom: 0 !important; }
.mw-parser-output .wikitable {
  background: var(--subtle);
  color: var(--ink);
  margin: 1em 0;
  border: 1px solid var(--rule);
  border-collapse: collapse;
}
.mw-parser-output .wikitable > * > tr > th,
.mw-parser-output .wikitable > * > tr > td,
.mw-parser-output .wikitable > tr > th,
.mw-parser-output .wikitable > tr > td {
  border: 1px solid var(--rule);
  padding: 0.25em 0.5em;
}
.mw-parser-output .wikitable > * > tr > th,
.mw-parser-output .wikitable > tr > th { background: var(--hair); text-align: center; }
.mw-parser-output caption { font-weight: 700; padding: 0.3em; }

/* Galleries */
.mw-parser-output ul.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0.6em 0 1em;
  padding: 0;
}
.mw-parser-output li.gallerybox { margin: 0; max-width: 100%; }
.mw-parser-output li.gallerybox .thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--subtle);
  border: 1px solid var(--hair);
  max-width: 100%;
}
.mw-parser-output li.gallerybox .thumb > * { margin: 0 !important; }
.mw-parser-output .gallerytext { font-size: 14px; line-height: 1.4; padding: 4px 2px; }
.mw-parser-output li.gallerycaption { width: 100%; font-weight: 700; text-align: center; }

/* Math */
.mw-parser-output .mwe-math-fallback-image-inline { display: inline-block; vertical-align: middle; }
.mw-parser-output .mwe-math-fallback-image-display { display: block; margin: 0.5em auto; }

@media (prefers-color-scheme: dark) {
  .mw-parser-output img { background: #fff; }
  .mw-parser-output .mwe-math-fallback-image-inline,
  .mw-parser-output .mwe-math-fallback-image-display { filter: invert(1); background: transparent; }
}

/* ---------- Start lights: five red pods, then lights out ---------- */

.lights {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: radial-gradient(ellipse at 50% 40%, #1b1c20 0%, #08080a 70%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 24px;
  transition: opacity 0.35s ease;
}
.lights.out { opacity: 0; pointer-events: none; }
.lights-route {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 7.5vw, 38px);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-align: center;
  margin: 0;
  max-width: 22ch;
}
.lights-route .to { color: #ff2a1a; padding: 0 0.25em; }
.gantry {
  display: flex;
  gap: clamp(6px, 2.2vw, 14px);
  padding: clamp(10px, 3vw, 16px);
  background: #141416;
  border: 1px solid #2a2b2f;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.pod {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 2vw, 10px);
  padding: clamp(6px, 2vw, 9px);
  background: #050506;
  border-radius: 999px;
}
.lamp {
  width: clamp(36px, 11.5vw, 58px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #3b1513, #190605 72%);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.85);
  transition: background 0.04s, box-shadow 0.04s;
}
.pod.on .lamp {
  background: radial-gradient(circle at 36% 30%, #ff9a90 0%, #ff2a1a 42%, #c80800 78%);
  box-shadow: 0 0 16px 4px rgba(255, 34, 20, 0.7), 0 0 44px 12px rgba(255, 34, 20, 0.28);
}
.lights-text {
  margin: 0;
  min-height: 1.3em;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8f949a;
}
.lights.go .lights-text {
  color: #fff;
  font-style: italic;
  font-size: clamp(30px, 9vw, 44px);
  letter-spacing: 0.06em;
}

/* ---------- Sheets and toasts ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.15s ease-out;
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg);
  border-top: 1px solid var(--strong);
  padding: 22px var(--gutter) max(22px, env(safe-area-inset-bottom));
  animation: rise 0.2s ease-out;
}
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border: 1px solid var(--strong); padding: 26px 28px; }
}
.sheet-label { margin: 0 0 4px; }
.sheet-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--strong);
  margin: 0 0 8px;
}
.sheet-desc { color: var(--muted); margin: 0 0 14px; }
.sheet-img { display: block; max-width: 100%; max-height: 240px; margin: 0 0 14px; }
.sheet-extract { margin: 0 0 20px; }
.sheet p { overflow-wrap: break-word; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  background: var(--strong);
  color: var(--bg);
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- Desktop: the wider page gets bigger type, not more stuff ---------- */

@media (min-width: 960px) {
  .masthead-inner { padding-top: 20px; padding-bottom: 16px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name { font-size: 30px; }
  .mast-nav { gap: 28px; }
  .mast-nav a { font-size: 18px; }

  .box { margin: 44px 0 0; }
  .box-head { font-size: 26px; padding: 14px 24px 13px 28px; box-shadow: inset 6px 0 0 var(--red); }
  .box-body { padding: 28px 28px 32px; }
  .date { font-size: 17px; margin-bottom: 20px; }

  .route { gap: 40px; margin: 8px 0 34px; }
  .route-label { font-size: 17px; }
  .route-title { font-size: clamp(48px, 4.8vw, 68px); margin-top: 6px; }
  .route-desc { font-size: 18px; margin-top: 10px; }
  .route-arrow { font-size: 60px; padding-top: 30px; }

  .box .btn-block { min-height: 64px; font-size: 23px; }
  .today-line { font-size: 48px; }
  .today-result .actions .btn { min-height: 58px; font-size: 20px; }
  .next, details.route-details summary { font-size: 17px; }
  .day-links { margin-top: 22px; }
  .day-links a { font-size: 20px; }

  .page-heading { font-size: 64px; margin-top: 44px; }
  .lede { font-size: 18px; }
  .build-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .past-route { font-size: 30px; }
  .past-date { font-size: 15px; }
  .past-result { font-size: 17px; }
  .results h1 { font-size: 80px; }
  .results .route-mini { font-size: 26px; }
  .score b { font-size: 64px; }
  .site-foot { margin-top: 72px; }
}

/* ---------- Your stats ---------- */

.tiles,
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--tower);
  color: var(--tower-ink);
  margin: 16px 0;
}
.tiles { box-shadow: inset 0 -3px 0 var(--red); }
.tiles > div,
.mini-stats > div { padding: 14px 16px 16px; border-left: 1px solid var(--tower-line); border-top: 1px solid var(--tower-line); }
.tiles > div:nth-child(odd) { border-left: 0; }
.tiles > div:nth-child(-n + 2) { border-top: 0; }
.tiles b,
.mini-stats b {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(34px, 10vw, 46px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tiles span,
.mini-stats span {
  display: block;
  margin-top: 6px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tower-muted);
}
.tiles-light { background: transparent; color: var(--strong); border: 1px solid var(--rule); box-shadow: none; }
.tiles-light > div { border-color: var(--hair); }
.tiles-light span { color: var(--muted); }

.mini-stats { grid-template-columns: repeat(3, 1fr); margin: 0 0 6px; }
.mini-stats > div { border-top: 0; }
.mini-stats > div:first-child { border-left: 0; }
.mini-stats b { font-size: clamp(28px, 8vw, 38px); }
.stats-link { margin: 0 0 8px; justify-content: flex-end; }

.dist { list-style: none; margin: 10px 0 18px; padding: 0; }
.dist li {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.dist-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dist-track { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.dist-bar { display: block; height: 28px; background: var(--strong); }
.dist-n {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--strong);
  font-variant-numeric: tabular-nums;
}
.dist li.is-today .dist-bar { background: var(--red); }
.dist li.is-today .dist-label { color: var(--red); }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tiles > div { border-top: 0; }
  .tiles > div:nth-child(odd) { border-left: 1px solid var(--tower-line); }
  .tiles-light > div:nth-child(odd) { border-left-color: var(--hair); }
  .tiles > div:first-child { border-left: 0; }
}
@media (min-width: 960px) {
  .tiles b { font-size: 60px; }
  .tiles span { font-size: 16px; }
  .tiles > div { padding: 20px 22px 22px; }
  .dist-label, .dist-n { font-size: 21px; }
  .dist-bar, .dist-track { height: 34px; min-height: 34px; }
}
