/* ==========================================================================
   Running Globe — single theme
   Colour: warm near-black neutrals + one ember hue that carries meaning.
           The pace ramp is a one-hue sequential ramp (dim = slow, bright = fast),
           computed in OKLCH with monotone lightness 0.42 → 0.92.
   Type:   Archivo (variable width). The width axis is the hierarchy — see DESIGN.md.
           Tabular figures everywhere a number can change.
   ========================================================================== */

:root {
  /* neutrals (OKLCH hue ~60, chroma ≤ 0.012) */
  --surface: #110f0d;
  --panel: #191714;
  --panel-2: #221f1c;
  --border: #312d2a;
  --faint: #413c38;
  --text: #efeae4;
  --muted: #9d9790;
  --dim: #8a847c; /* 5.2:1 on --surface: the faintest text that still passes AA */

  /* ember ramp (sequential, slow → fast) */
  --ember-1: #7a3525;
  --ember-2: #b64c1b;
  --ember-3: #e37725;
  --ember-4: #f8ab5e;
  --ember-5: #ffe0b0;
  --ramp: linear-gradient(90deg, var(--ember-1), var(--ember-2) 25%, var(--ember-3) 50%, var(--ember-4) 75%, var(--ember-5));
  --accent: var(--ember-4);
  --on-accent: #1d0f04;

  --font: "Archivo", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  /* Type system: Archivo's width axis is the hierarchy.
     condensed  -> values you read as numbers (date, stats, headlines)
     normal     -> names and sentences
     expanded   -> labels and units, in small tracked caps */
  --w-condensed: 72%;
  --w-display: 64%;
  --w-label: 118%;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --r: 6px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--surface); color: var(--text);
  font: 400 13px/1.45 var(--font); font-stretch: 100%;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
h2 { margin: 0; font: inherit; }
.city-marker [hidden] { display: none !important; } /* beats .label small { display: block } */
#map { position: absolute; inset: 0; background: var(--surface); }

/* One focus ring, in the palette: shown for keyboard focus only. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: var(--r); }
.maplibregl-canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--muted); }
.maplibregl-ctrl-attrib-button:focus-visible { outline: 2px solid var(--text) !important; }
#strip-wrap:focus-visible { outline-offset: 4px; }
.city-marker:focus-visible { outline: none; }
.city-marker:focus-visible .label .nm { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 2px; }

/* Vignette: darkens the corners where the interface sits, so text stays legible without boxes. */
body::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background:
    radial-gradient(ellipse 34% 42% at 0% 0%, rgba(17, 15, 13, 0.92), transparent 72%),
    radial-gradient(ellipse 26% 52% at 100% 0%, rgba(17, 15, 13, 0.9), transparent 72%),
    linear-gradient(to top, rgba(17, 15, 13, 0.96) 0, rgba(17, 15, 13, 0.7) 130px, transparent 210px);
}

/* Label tier: every caption, unit and axis label uses this one style. */
.eyebrow, .stats dt, .stats dd small, .legend-ends em, .list .km, .pop .g dt, .pop .g dd small, .toast .eyebrow,
.city-marker .label small, .w-race .k, .w-grid dt, .w-grid dd small, .w-yearbars .b span, .w-big small {
  font-size: 10.5px; font-weight: 500; font-stretch: var(--w-label); font-style: normal;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}

/* Units and inline metadata keep the label size and width but stay lowercase: km, h and /km are SI units. */
.stats dd small, .list .km, .w-big small, .city-marker .label small, .legend-ends em, .pop .g dd small, .w-grid dd small, #strip .unit {
  text-transform: none; letter-spacing: 0.03em;
}

/* Separator: a drawn dot centred on cap/digit height with equal space each side.
   (The "·" glyph sits on lowercase height and shrinks to a speck in small tracked caps.) */
.sep {
  display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6;
  margin: 0 0.55em; vertical-align: calc(0.36em - 1.5px);
}

/* ---------- HUD ---------- */
#hud { position: absolute; top: 24px; left: 28px; z-index: 5; width: 300px; }
.hud-date {
  font-size: 50px; font-weight: 600; font-stretch: var(--w-display); letter-spacing: -0.015em; line-height: 0.95;
  margin: 8px 0 22px;
}
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.stats div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stats dt { white-space: nowrap; }
.stats dd { margin: 0; font-size: 30px; font-weight: 500; font-stretch: var(--w-condensed); letter-spacing: -0.005em; line-height: 1; white-space: nowrap; }
.stats dd small { margin-left: 4px; letter-spacing: 0.05em; }

.legend { margin: 26px 0 0; }
.legend .eyebrow { margin-bottom: 8px; }
.legend .ramp { display: block; height: 4px; border-radius: 2px; background: var(--ramp); }
.legend-ends { display: flex; justify-content: space-between; margin-top: 7px; font-size: 15px; font-weight: 500; font-stretch: var(--w-condensed); }
.legend-ends em { margin: 0 5px; font-size: 9.5px; color: var(--dim); }

/* ---------- side ---------- */
#side { position: absolute; top: 24px; right: 28px; z-index: 5; width: 232px; display: flex; flex-direction: column; gap: 22px; }
#side .eyebrow { margin-bottom: 8px; }
.btn-primary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 0; border-radius: var(--r); padding: 11px 14px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; font-stretch: 95%; letter-spacing: 0.005em;
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
.btn-primary:active { transform: scale(0.98); }
@media (hover: hover) { .btn-primary:hover { background: var(--ember-5); } }

.list {
  list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border);
  max-height: calc(100vh - 440px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.list li { border-bottom: 1px solid var(--border); }
.list button {
  position: relative; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; gap: 10px;
  background: transparent; border: 0; border-radius: 0; padding: 8px 2px 8px 10px; cursor: pointer; text-align: left;
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
.list button::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; border-radius: 1px;
  background: var(--accent); transform: scaleY(0); transition: transform 200ms var(--ease-out);
}
.list button[aria-current="true"]::before { transform: scaleY(1); }
.list button:active { transform: scale(0.99); }
.list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.list .n { font-size: 16px; font-weight: 500; font-stretch: var(--w-condensed); color: var(--text); }
.list .km { color: var(--dim); min-width: 64px; text-align: right; }
@media (hover: hover) { .list button:hover { background: rgba(255, 255, 255, 0.03); } }

/* Segmented control: the selection is a sliding indicator behind the buttons. */
.seg {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 2px; border: 1px solid var(--faint); border-radius: var(--r); background: rgba(17, 15, 13, 0.6);
}
.seg-ind {
  position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / var(--n, 1)); border-radius: 4px;
  background: var(--faint); transform: translateX(calc(100% * var(--i, 0))); transition: transform 240ms var(--ease-out);
}
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; padding: 6px 0 5px; border-radius: 4px; cursor: pointer; color: var(--muted);
  font-size: 15px; font-weight: 500; font-stretch: var(--w-condensed); min-width: 0;
  transition: transform 120ms var(--ease-out), color 160ms var(--ease-out);
}
.seg button:active { transform: scale(0.96); }
.seg button[aria-checked="true"] { color: var(--text); }
@media (hover: hover) { .seg button[aria-checked="false"]:hover { color: var(--text); } }

.toggle { display: flex; gap: 8px; align-items: center; min-height: 32px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--ember-3); margin: 0; width: 15px; height: 15px; }

/* ---------- timeline ---------- */
#timeline { position: absolute; left: 28px; right: 28px; bottom: 28px; height: 104px; z-index: 5; display: flex; gap: 16px; align-items: stretch; }
.tl-controls { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; flex: none; }
.btn-play {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--text); color: var(--surface); transition: transform 120ms var(--ease-out);
}
.btn-play:active { transform: scale(0.94); }
.btn-play svg { overflow: visible; }
.btn-play path {
  fill: currentColor; transform-box: fill-box; transform-origin: center;
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.btn-play .i-pause, .btn-play.playing .i-play { opacity: 0; transform: scale(0.5); }
.btn-play.playing .i-pause { opacity: 1; transform: none; }
.btn-speed {
  min-width: 36px; min-height: 32px; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; font-weight: 500; font-stretch: var(--w-condensed); transition: transform 120ms var(--ease-out), color 120ms var(--ease-out);
}
.btn-speed:active { transform: scale(0.94); }
@media (hover: hover) { .btn-speed:hover { color: var(--text); } }

#strip-wrap { flex: 1; min-width: 0; position: relative; cursor: crosshair; touch-action: none; border-radius: 2px; }
#strip { width: 100%; height: 100%; display: block; overflow: visible; font-family: var(--font); }
#strip text { font-size: 10px; fill: var(--muted); font-stretch: var(--w-label); letter-spacing: 0.06em; }
#strip .lane-label { fill: var(--muted); font-size: 9.5px; font-weight: 500; letter-spacing: 0.08em; }
#strip .axis { fill: var(--dim); }
#strip .unit { fill: var(--muted); font-size: 10px; font-weight: 500; font-stretch: var(--w-label); }
#strip .grid { stroke: var(--border); }
#strip .base { stroke: var(--faint); }
#strip .wk { fill: var(--faint); }
#strip .wk-done { fill: var(--ember-3); }
#strip .mask { fill: var(--surface); fill-opacity: 0.7; }
#strip .pace-line { fill: none; stroke: var(--text); stroke-opacity: 0.75; stroke-width: 1.5; stroke-linejoin: round; }
#strip .tick { stroke: var(--dim); }
#strip .race { fill: var(--surface); stroke: var(--ember-4); stroke-width: 1.5; }
#strip .cursor { stroke: var(--text); stroke-width: 1.25; }
#strip .cursor-dot { fill: var(--text); }
#strip .hover-line { stroke: var(--muted); stroke-dasharray: 2 3; }
#strip .hover-tag rect { fill: var(--panel-2); stroke: var(--border); }
#strip .hover-tag .t-date { fill: var(--muted); }
#strip .hover-tag text { fill: var(--text); font-size: 13px; font-weight: 500; font-stretch: var(--w-condensed); letter-spacing: 0.01em; }

/* Map credit on its own line under the timeline, right-aligned to it. */
.maplibregl-ctrl-bottom-right { right: 22px; bottom: 2px; }
.maplibregl-ctrl-attrib { background: transparent !important; font: 10px var(--font); color: var(--dim); }
.maplibregl-ctrl-attrib a { color: var(--dim) !important; }

/* ---------- toasts ---------- */
#toasts { position: absolute; right: 28px; bottom: 150px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 6; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 9px 12px 10px; width: 232px;
  transform-origin: bottom right; animation: toast-in 220ms var(--ease-out);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.toast.race { box-shadow: inset 2px 0 0 var(--accent); }
.toast .eyebrow { margin-bottom: 3px; }
.toast.race .eyebrow { color: var(--accent); }
.toast b { display: block; font-weight: 600; font-size: 14px; font-stretch: 92%; overflow-wrap: anywhere; }
.toast span { color: var(--muted); font-size: 12px; }
.toast.out { opacity: 0; transform: translateY(-4px) scale(0.98); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- map markers & popup ---------- */
/* The marker element is a zero-size point; the dot centres on it and the label sits to one side. */
.city-marker { position: relative; width: 0; height: 0; cursor: pointer; --s: 8px; }
.city-marker .dot {
  position: absolute; left: calc(var(--s) / -2); top: calc(var(--s) / -2); width: var(--s); height: var(--s);
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 14px 2px rgba(248, 171, 94, 0.35);
  transition: scale 160ms var(--ease-out);
}
.city-marker .label {
  position: absolute; top: 0; left: calc(var(--s) / 2 + 8px); translate: 0 -50%;
  max-width: 190px; font-size: 15px; font-weight: 600; font-stretch: 82%; letter-spacing: 0.005em; line-height: 1.15; white-space: nowrap;
  text-shadow: 0 0 2px var(--surface), 0 0 6px var(--surface), 0 0 12px var(--surface);
}
.city-marker .label .nm { display: block; overflow: hidden; text-overflow: ellipsis; }
.city-marker.flip .label { left: auto; right: calc(var(--s) / 2 + 8px); text-align: right; }
.city-marker .label small { display: block; font-size: 9.5px; margin-top: 2px; }
@media (hover: hover) { .city-marker:hover .dot { scale: 1.25; } }

.race-pin-wrap { width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; }
.race-pin { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

.maplibregl-popup-content {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px 12px; font: 400 13px/1.4 var(--font); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: pop-in 200ms var(--ease-out); transform-origin: var(--po, 50% 100%);
}
/* A popover grows from the side it is anchored to. MapLibre owns .maplibregl-popup's own transform. */
.maplibregl-popup-anchor-top .maplibregl-popup-content { --po: 50% 0%; }
.maplibregl-popup-anchor-left .maplibregl-popup-content { --po: 0% 50%; }
.maplibregl-popup-anchor-right .maplibregl-popup-content { --po: 100% 50%; }
.maplibregl-popup-anchor-top-left .maplibregl-popup-content { --po: 0% 0%; }
.maplibregl-popup-anchor-top-right .maplibregl-popup-content { --po: 100% 0%; }
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content { --po: 0% 100%; }
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content { --po: 100% 100%; }
.maplibregl-popup.instant .maplibregl-popup-content { animation: none; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
.maplibregl-popup { z-index: 8; } /* above the HUD, side panel and vignette */
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button {
  width: 32px; height: 32px; right: 2px; top: 2px; border-radius: var(--r); color: var(--muted); font-size: 18px; line-height: 1;
}
@media (hover: hover) { .maplibregl-popup-close-button:hover { background: var(--panel-2); color: var(--text); } }
.pop h3 { margin: 0 26px 3px 0; font-size: 16px; font-weight: 600; font-stretch: 92%; overflow-wrap: anywhere; }
.pop .d { color: var(--muted); font-size: 12px; }
.pop .g { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.pop .g1 { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.pop .g2 { margin-top: 10px; }
.pop .g div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pop .g dt { font-size: 9.5px; }
.pop .g dd { margin: 0; font-weight: 500; font-stretch: var(--w-condensed); line-height: 1; white-space: nowrap; }
.pop .g1 dd { font-size: 24px; }
.pop .g2 dd { font-size: 16px; }
.pop .g dd small { margin-left: 3px; font-size: 9.5px; }
.pop .bar { margin-top: 14px; height: 4px; border-radius: 2px; background: var(--ramp); position: relative; }
.pop .bar i { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--text); border-radius: 1px; }
.pop .legend-ends { font-size: 13px; margin-top: 5px; }

/* ---------- Wrapped ---------- */
/* Opening: the explorer controls fade out quickly, then the overlay and card come in. */
#hud, #side, #timeline, #toasts, body::after { transition: opacity 240ms var(--ease-out); }
body.wrapped-on #hud, body.wrapped-on #side, body.wrapped-on #timeline, body.wrapped-on #toasts, body.wrapped-on::after {
  opacity: 0; pointer-events: none; transition-duration: 160ms;
}
body.wrapped-on .maplibregl-ctrl-bottom-right { opacity: 0; }
#wrapped {
  position: absolute; inset: 0; z-index: 20; opacity: 1;
  transition: opacity 240ms var(--ease-out), display 240ms allow-discrete;
}
#wrapped[hidden] { opacity: 0; transition-duration: 180ms; }
@starting-style { #wrapped { opacity: 0; } }
#wrapped::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(17, 15, 13, 0.97) 0%, rgba(17, 15, 13, 0.86) 40%, rgba(17, 15, 13, 0) 72%),
              linear-gradient(to bottom, rgba(17, 15, 13, 0.6), transparent 90px);
}
#wrapped .bars {
  position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 28px; right: 80px; display: flex; gap: 4px; z-index: 3;
}
#wrapped .bars i { flex: 1; height: 2px; border-radius: 1px; background: var(--faint); overflow: hidden; }
#wrapped .bars i b { display: block; height: 100%; width: 100%; background: var(--text); transform: scaleX(0); transform-origin: left; }
#wrapped .w-close {
  position: absolute; top: calc(-2px + env(safe-area-inset-top)); right: 18px; z-index: 4; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--text); border: 0; cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
#wrapped .w-close:active { transform: scale(0.94); }
@media (hover: hover) { #wrapped .w-close:hover { background: var(--panel-2); } }
#wrapped .tap { position: absolute; top: 0; bottom: 0; z-index: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#wrapped .tap.left { left: 0; width: 30%; }
#wrapped .tap.right { right: 0; width: 70%; }
#wrapped .card { position: absolute; left: 56px; bottom: 56px; width: min(680px, calc(100vw - 112px)); z-index: 2; pointer-events: none; }
#wrapped .card button { pointer-events: auto; }
.w-card-in > * { animation: w-in 360ms var(--ease-out) both; animation-delay: var(--w-delay, 0ms); }
.w-card-in > :nth-child(2) { animation-delay: calc(var(--w-delay, 0ms) + 50ms); }
.w-card-in > :nth-child(3) { animation-delay: calc(var(--w-delay, 0ms) + 100ms); }
.w-card-in > :nth-child(4) { animation-delay: calc(var(--w-delay, 0ms) + 150ms); }
.w-card-in > :nth-child(5) { animation-delay: calc(var(--w-delay, 0ms) + 200ms); }
@keyframes w-in { from { opacity: 0; transform: translateY(10px); } }

.w-big {
  font-size: clamp(96px, 15vw, 196px); font-weight: 600; font-stretch: 62%; letter-spacing: -0.025em; line-height: 0.82;
  margin: 10px 0 14px; color: var(--text);
}
.w-big small { font-size: 0.13em; margin-left: 12px; letter-spacing: 0.08em; vertical-align: 0.15em; }
.w-title {
  font-size: clamp(34px, 4.6vw, 56px); font-weight: 600; font-stretch: var(--w-condensed); letter-spacing: -0.012em; line-height: 0.98;
  margin: 8px 0 10px; overflow-wrap: anywhere; text-wrap: balance;
}
.w-title em { font-style: normal; color: var(--accent); }
.w-sub { font-size: 17px; line-height: 1.5; color: var(--muted); max-width: 46ch; text-wrap: pretty; }
.w-sub b { color: var(--text); font-weight: 600; }
.w-sub .nw { white-space: nowrap; }
.w-swatch { display: inline-block; width: 36px; height: 5px; border-radius: 3px; vertical-align: middle; background: var(--ramp); margin: 0 6px; }

.w-yearbars { display: flex; align-items: flex-end; gap: 14px; height: 190px; max-width: 420px; margin: 18px 0 8px; }
.w-yearbars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; height: 100%; min-width: 0; }
.w-yearbars .b i {
  display: block; border-radius: 4px 4px 0 0; background: var(--faint); transform-origin: bottom;
  animation: grow 360ms var(--ease-out) both; animation-delay: calc(var(--w-delay, 0ms) + var(--d, 0ms));
}
.w-yearbars .b:last-child i { background: var(--accent); }
/* Each value appears as its bar lands, so no number floats over an empty column. */
.w-yearbars .b b {
  font-size: 28px; font-weight: 500; font-stretch: var(--w-condensed);
  animation: fade 200ms var(--ease-out) both; animation-delay: calc(var(--w-delay, 0ms) + var(--d, 0ms) + 240ms);
}
@keyframes grow { from { transform: scaleY(0); } }
@keyframes fade { from { opacity: 0; } }

.w-races { margin: 16px 0 0; border-top: 1px solid var(--border); max-width: 600px; }
.w-race {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto auto; gap: 14px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.w-race .k { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-race .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.w-race .dt { color: var(--dim); font-size: 12px; white-space: nowrap; }
.w-race .t { font-size: 20px; font-weight: 500; font-stretch: var(--w-condensed); }
.w-race.pb .n, .w-race.pb .t { color: var(--accent); }
.w-race.more .k { grid-column: 1 / -1; overflow: visible; }

.w-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; margin: 20px 0 26px; max-width: 560px; }
.w-grid div { display: flex; flex-direction: column; gap: 6px; min-width: 0; border-top: 1px solid var(--border); padding-top: 10px; }
.w-grid dd { margin: 0; font-size: 48px; font-weight: 500; font-stretch: var(--w-display); letter-spacing: -0.01em; line-height: 1; white-space: nowrap; }
.w-grid dd small { margin-left: 5px; }
.w-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.w-actions button {
  border-radius: var(--r); padding: 10px 16px; font-weight: 600; cursor: pointer; border: 1px solid var(--faint); background: transparent;
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
.w-actions button:active { transform: scale(0.97); }
.w-actions button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
@media (hover: hover) {
  .w-actions button:not(.primary):hover { background: var(--panel-2); }
  .w-actions button.primary:hover { background: var(--ember-5); }
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  /* A solid band at the top for the HUD, the same fade at the bottom for the controls. */
  body::after {
    background:
      linear-gradient(to bottom, rgba(17, 15, 13, 0.94) 0, rgba(17, 15, 13, 0.7) 150px, transparent 230px),
      linear-gradient(to top, rgba(17, 15, 13, 0.96) 0, rgba(17, 15, 13, 0.7) 200px, transparent 290px);
  }
  #hud { left: 18px; right: 18px; width: auto; top: calc(16px + env(safe-area-inset-top)); }
  .hud-date { font-size: 32px; margin-bottom: 10px; }
  .stats { grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 8px; }
  .stats dd { font-size: 20px; }
  .stats dd small { margin-left: 2px; }
  .legend { display: none; }
  /* Phone: the year filter and Wrapped, in a column above the timeline. */
  #side { top: auto; bottom: 140px; left: 18px; right: 18px; width: auto; gap: 10px; }
  #side .places, #side .toggle, #side .years .eyebrow { display: none; }
  #side .years { order: -1; }
  #timeline { left: 18px; right: 18px; height: 92px; bottom: 28px; }
  #toasts { left: 18px; right: 18px; bottom: 244px; align-items: stretch; }
  .toast { width: auto; }
  .maplibregl-ctrl-bottom-right { right: 12px; }

  #wrapped .bars { left: 18px; right: 66px; }
  #wrapped .w-close { right: 10px; }
  /* Clear of Instagram's reply bar in a screen recording, and of the home indicator. */
  #wrapped .card { left: 20px; bottom: calc(max(72px, 9vh) + env(safe-area-inset-bottom)); width: calc(100vw - 40px); }
  .w-grid { gap: 14px 18px; }
  .w-grid dd { font-size: clamp(32px, 9.5vw, 48px); }
  .w-race { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .w-race .k { grid-column: 1 / -1; }
  .w-race .dt { grid-column: 1; grid-row: 3; }
  .w-race .t { grid-column: 2; grid-row: 2 / 4; align-self: center; }
}

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