:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, .10);
  /* categorical slots 1-5 of the validated palette; colour follows the player, never the rank */
  --c-djokovic: #2a78d6; --c-nadal: #eb6834; --c-alcaraz: #1baf7a; --c-federer: #eda100; --c-sinner: #e87ba4;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
    --c-djokovic: #3987e5; --c-nadal: #d95926; --c-alcaraz: #199e70; --c-federer: #c98500; --c-sinner: #d55181;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 1040px; margin: 0 auto; padding: 32px 16px 48px; }
/* Display face: the DIN family of scoreboards and court signage, from fonts already on the device (no web fonts) */
h1, h2, .pace { font-family: Bahnschrift, "DIN Alternate", "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif; font-stretch: 78%; }

/* Hero: the five real Grand Slam curves run behind the title, all advancing at the same age. */
.hero { position: relative; overflow: hidden; padding: clamp(56px, 13vw, 150px) 0 clamp(10px, 2vw, 22px); margin-bottom: 14px; border-bottom: 1px solid var(--axis); }
.race { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; animation: sweep 5s linear both; }
.race path { fill: none; stroke-width: 4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.pace { position: absolute; z-index: 2; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--muted); animation: run 5s linear both; }
.pace span { position: absolute; top: 6px; right: 8px; white-space: nowrap; font-size: clamp(.95rem, 2vw, 1.3rem); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
h1 { position: relative; font-size: clamp(3.3rem, 17.5vw, 12.4rem); font-weight: 700; line-height: .8; letter-spacing: -.025em; margin: 0; white-space: nowrap; font-style: italic; }
@keyframes sweep { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes run { from { left: 0; opacity: 1; } 96% { opacity: 1; } to { left: 100%; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .race { animation: none; } .pace { display: none; } }
h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.lede { font-size: 1.1rem; margin: 0 0 20px; }
.sub { color: var(--ink-2); font-size: .875rem; margin: 2px 0 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; position: sticky; top: 0; z-index: 2; background: var(--page); padding: 8px 0; }
.legend button { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; font: inherit; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.legend button::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.legend button[aria-pressed="false"] { color: var(--muted); }
.legend button[aria-pressed="false"]::before { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.legend button:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 16px 12px; margin-bottom: 20px; }
.plot { position: relative; }
svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
svg text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .axis { stroke: var(--axis); stroke-width: 1; }
svg .axis-title { fill: var(--ink-2); }
svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
svg .dot { stroke: var(--surface); stroke-width: 1.5; }
svg .end-label { fill: var(--ink); font-size: 12.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
svg .dim { opacity: .18; }
svg .hot { stroke: var(--ink); stroke-width: 2; }

.tip { position: absolute; pointer-events: none; z-index: 3; min-width: 190px; padding: 8px 10px; font-size: .82rem; line-height: 1.4;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .14); }
.tip b { display: flex; align-items: center; gap: 6px; }
.tip b::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.tip span { color: var(--ink-2); display: block; }

details { margin-top: 4px; font-size: .875rem; }
summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; }
.table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; }
td.num, th.num { text-align: right; }
td i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 6px; }

footer { color: var(--ink-2); font-size: .85rem; }
footer p { margin: 0 0 8px; }
