@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --page: #f6f7f3;
  --paper: #fff;
  --topbar: #fdfefa;
  --panel: #f5f8f2;
  --control-surface: #edf1e9;
  --control-hover: #e9f2e7;
  --ink: #14271f;
  --muted: #52655b;
  --border: #dce4da;
  --divider: #e7ece5;
  --brand: #14271f;
  --green: #277750;
  --green-dark: #1c4936;
  --lime: #caef72;
  --pitch-stripe-1: #203d32;
  --pitch-stripe-2: #254438;
  --pitch-shadow: #14281f80;
  --pitch-marking: #a0c49c59;
  --focus: #3d865d;
  --selected: #233f32;
  --selected-hover: #296348;
  --selected-text: #fff;
  --orange: #ae581e;
  --orange-text: #8a4719;
  --grid: #e2e9df;
  --axis: #becdc0;
  --split: #688573;
  --plot-marker: #839d8a;
  --plot-tag: #e9f0e7;
  --plot-fill-start: #b4ddbe;
  --plot-fill-end: #eff6e9;
  --line-winner: #6943a6;
  --line-bottler: #a43b73;
  --line-relegation: #9b4244;
  --line-made-top: #137488;
  --line-missed-top: #665d20;
  --band-survival: #d7a68d;
  --band-winner: #b58ccc;
  --band-top: #80bdbc;
  --band-mixed: #a4b5ad;
  --comparison-blue: #3854a0;
  --comparison-gold: #6a631a;
  --comparison-plum: #68364b;
  --comparison-teal: #196d60;
  --comparison-slate: #456579;
  --comparison-rust: #9f4521;
  --sans: Manrope, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c0c0d;
  --paper: #151517;
  --topbar: #111112;
  --panel: #1b1b1e;
  --control-surface: #202023;
  --control-hover: #2d2d32;
  --ink: #f0f0f2;
  --muted: #b9b9c1;
  --border: #3b3b40;
  --divider: #303035;
  --brand: #29292d;
  --green: #83d7a1;
  --green-dark: #dedee4;
  --pitch-stripe-1: #1c1c1f;
  --pitch-stripe-2: #242427;
  --pitch-shadow: #08080980;
  --pitch-marking: #a5a5af59;
  --focus: #c5c5ce;
  --selected: #dedee4;
  --selected-hover: #f0f0f4;
  --selected-text: #18181c;
  --orange: #f2a66c;
  --orange-text: #f4b586;
  --grid: #2c2c30;
  --axis: #616168;
  --split: #a7a7ad;
  --plot-marker: #96969e;
  --plot-tag: #303035;
  --plot-fill-start: #45454b;
  --plot-fill-end: #252528;
  --line-winner: #c8a7f3;
  --line-bottler: #f1a1ce;
  --line-relegation: #f29997;
  --line-made-top: #76cfe1;
  --line-missed-top: #dfcd79;
  --band-survival: #ab7058;
  --band-winner: #8867a7;
  --band-top: #4f8b88;
  --band-mixed: #777781;
  --comparison-blue: #9bb6ff;
  --comparison-gold: #ecc482;
  --comparison-plum: #e8a6ba;
  --comparison-teal: #6fd7bf;
  --comparison-slate: #a7c6d8;
  --comparison-rust: #f5a786;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font: 500 1rem/1.6 var(--sans); }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
.shell { width: min(100% - 80px, 1296px); margin-inline: auto; }
.topbar { background: var(--topbar); border-bottom: 1px solid var(--border); }
.topbar-inner { min-height: 71px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { display: inline-flex; gap: 10px; align-items: center; font-size: 1.05rem; font-weight: 800; text-decoration: none; letter-spacing: -.04em; line-height: 1.15; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); flex: none; }
.brand-mark i { width: 22px; height: 22px; background: var(--lime); clip-path: polygon(3% 80%, 30% 80%, 30% 55%, 54% 55%, 54% 29%, 82% 29%, 82% 17%, 98% 34%, 82% 51%, 82% 39%, 64% 39%, 64% 65%, 40% 65%, 40% 90%, 3% 90%); }
.header-actions { display: flex; align-self: stretch; align-items: center; gap: 22px; }
nav { display: flex; gap: 30px; align-items: stretch; align-self: stretch; }
nav a { display: grid; place-items: center; position: relative; text-decoration: none; font-size: .9rem; font-weight: 700; color: var(--muted); }
nav a:hover, nav a.nav-active { color: var(--green-dark); }
.nav-active::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--green); }
.theme-toggle { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--paper); color: var(--green-dark); font: 1.4rem/1 system-ui, sans-serif; }
.theme-toggle:hover { background: var(--control-hover); }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

.hero { min-height: 250px; padding-block: 39px 37px; display: flex; align-items: center; justify-content: space-between; gap: 36px; }
.hero-copy { min-width: 0; }
.eyebrow { font: 600 .79rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .09em; color: var(--green-dark); }
.eyebrow > span { display: inline-block; width: 7px; height: 7px; margin-right: 3px; background: #4d9e5d; border-radius: 2px; vertical-align: 1px; }
.hero h1 { margin: 8px 0 12px; font-size: clamp(2.85rem, 6.1vw, 5.15rem); line-height: 1.04; letter-spacing: -.076em; font-weight: 800; }
.hero h1 span { color: var(--green); }
.hero-copy > p:last-child { max-width: 58ch; color: var(--muted); }
.hero-art { flex: 0 1 365px; min-width: 230px; height: 161px; border-radius: 14px; position: relative; overflow: hidden; background: repeating-linear-gradient(90deg, var(--pitch-stripe-1) 0 12.5%, var(--pitch-stripe-2) 12.5% 25%); isolation: isolate; }
.hero-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(118deg, var(--pitch-shadow), transparent 70%); z-index: -1; }
.pitch { position: absolute; inset: 20px; border: 1px solid var(--pitch-marking); border-radius: 5px; }
.pitch::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--pitch-marking); }
.centre-circle { position: absolute; left: 50%; top: 50%; width: 58px; aspect-ratio: 1; translate: -50% -50%; border: 1px solid var(--pitch-marking); border-radius: 50%; }
.penalty { position: absolute; width: 40px; top: 22%; bottom: 22%; border: 1px solid var(--pitch-marking); }
.penalty-left { left: -1px; }
.penalty-right { right: -1px; }
.pitch-curve { position: absolute; inset: 28px 42px 31px; display: flex; align-items: flex-end; }
.pitch-curve i { position: relative; width: 20%; height: var(--level); border-top: 2px solid var(--lime); }
.pitch-curve i:not(:first-child) { border-left: 2px solid var(--lime); clip-path: inset(-6px -8px var(--trim) -5px); }
.pitch-curve i:first-child { --level: 15%; }
.pitch-curve i:nth-child(2) { --level: 31%; --trim: 48%; }
.pitch-curve i:nth-child(3) { --level: 46%; --trim: 67%; }
.pitch-curve i:nth-child(4) { --level: 68%; --trim: 67%; }
.pitch-curve i:nth-child(5) { --level: 93%; --trim: 73%; }
.pitch-curve i:last-child::after { content: ''; position: absolute; top: -5px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 5px #caef7229; }

#explorer, #methodology { scroll-margin-top: 18px; }
.filters { display: flex; align-items: end; gap: 25px; margin-bottom: 16px; }
.filter-field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.filter-field label[for], .filter-field legend { font: 600 .79rem/1.45 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filter-field legend { margin-bottom: 6px; padding: 0; }
.league-field { flex: 0 1 450px; max-width: 100%; }
.format-field { flex: 1 1 360px; max-width: 100%; }
.league-field select, .format-field select { width: 100%; text-overflow: ellipsis; }
.league-gaps { margin: -4px 0 16px; color: var(--muted); font: 500 .8rem/1.55 var(--mono); }
.filters:has(.format-field:not([hidden])) { flex-wrap: wrap; }
.filters:has(.format-field:not([hidden])) .benchmark-fields { order: 3; width: 100%; }
.benchmark-fields { display: flex; gap: 16px; align-items: end; }
.target-controls { display: flex; align-items: center; gap: 6px; }
select { height: 45px; appearance: none; padding: 0 37px 0 14px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%236b8273' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 13px center no-repeat; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; font-weight: 750; cursor: pointer; }
.segmented { display: flex; gap: 3px; align-items: stretch; border: 1px solid var(--border); background: var(--control-surface); border-radius: 8px; padding: 3px; min-height: 45px; }
.segmented label { position: relative; display: flex; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; border-radius: 5px; padding: 4px 14px; font-size: .86rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.segmented label:hover span { color: var(--ink); }
.segmented input:checked + span { background: var(--selected); color: var(--selected-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 3px; }
.compare-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; margin-left: auto; min-height: 45px; background: var(--paper); border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; font-size: .87rem; font-weight: 800; white-space: nowrap; }
.compare-toggle:hover, .compare-toggle[aria-expanded="true"] { background: var(--control-hover); }
.compare-icon { width: 14px; height: 14px; position: relative; }
.compare-icon::before, .compare-icon::after { content: ''; display: block; background: var(--green); position: absolute; width: 12px; height: 2px; top: 6px; left: 1px; border-radius: 1px; }
.compare-icon::after { rotate: 90deg; }
.compare-toggle[aria-expanded="true"] .compare-icon::after { display: none; }
.compare-controls { display: flex; align-items: end; gap: 16px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--control-surface); }
.compare-controls select { min-width: 145px; width: 100%; }
.compare-controls p { align-self: center; color: var(--muted); font-size: .875rem; padding-top: 18px; }
.add-comparison { min-height: 45px; padding: 0 13px; border: 1px solid var(--selected); border-radius: 8px; background: var(--selected); color: var(--selected-text); font-size: .87rem; font-weight: 800; white-space: nowrap; }
.add-comparison:hover:not(:disabled) { background: var(--selected-hover); }
.comparison-list { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0 0 16px; list-style: none; }
.comparison-tag { display: flex; align-items: center; gap: 7px; max-width: 100%; padding: 1px 2px 1px 11px; background: var(--paper); border: 1px solid var(--border); border-radius: 8px; font-size: .86rem; font-weight: 750; }
.comparison-name { overflow-wrap: anywhere; }
.comparison-swatch { flex: none; width: 14px; border-top: 3px solid var(--comparison-color); border-radius: 2px; }
.comparison-tag.is-dashed .comparison-swatch { border-top-style: dashed; }
.remove-comparison { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.remove-comparison:hover { background: var(--control-surface); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.chart-card { background: var(--paper); border: 1px solid var(--border); border-radius: 16px; padding: 26px; box-shadow: 0 4px 14px #15251b06; }
.chart-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; padding-bottom: 21px; border-bottom: 1px solid var(--divider); }
.chart-heading h2 { margin: 3px 0 3px; font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.18; letter-spacing: -.05em; font-weight: 800; }
.chart-heading p:not(.eyebrow) { color: var(--muted); font-size: .94rem; }
.coverage { max-width: 42%; text-align: right; color: var(--muted); font: 500 .8rem/1.45 var(--mono); padding-top: 2px; }
.coverage strong { display: block; color: var(--green-dark); font-weight: 600; }
.chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 269px; gap: 24px; padding-top: 19px; }
.plot-column { min-width: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 7px 18px; min-height: 30px; align-items: baseline; font-size: .82rem; font-weight: 700; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-item::before { content: ''; width: 20px; border-top: 3px solid var(--line-color, var(--green)); border-radius: 2px; }
.legend-holder::before { border-color: var(--orange); }
.plot { width: 100%; height: clamp(270px, 31vw, 365px); position: relative; touch-action: pan-y; border-radius: 5px; }
.plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.plot:focus-visible { outline-offset: 1px; }
.plot-help { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.plot-hint { color: var(--muted); font-size: .82rem; display: flex; align-items: baseline; gap: 7px; margin-top: 1px; }
.plot-action { background: none; border: 0; padding: 0; color: var(--green-dark); font-size: .82rem; font-weight: 800; text-decoration: underline; }
.chart-link-status { color: var(--muted); font-size: .82rem; }
.chart-link-status:empty { display: none; }
.chart-link { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--paper); color: var(--ink); font: .82rem var(--mono); }
.pointer-icon { width: 12px; height: 14px; margin-inline: 2px; background: var(--green); clip-path: polygon(0 0, 100% 55%, 60% 60%, 79% 100%, 53% 100%, 37% 66%, 6% 89%); flex: none; transform: translateY(3px); }
.axis-text { fill: var(--muted); font: 12px var(--mono); }
.axis-label { fill: var(--muted); font: 700 13px var(--sans); }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.phase-line { stroke: var(--split); stroke-width: 1.5; stroke-dasharray: 5 4; }
.axis-line { stroke: var(--axis); }
.match-card { align-self: start; min-width: 0; border: 1px solid var(--border); background: var(--panel); border-radius: 12px; padding: 15px 16px; }
.match-heading { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding-bottom: 11px; border-bottom: 1px solid var(--border); }
.match-heading h3 { font: 600 .82rem var(--mono); text-transform: uppercase; letter-spacing: .055em; color: var(--green-dark); }
.inspect-field { margin-top: 10px; }
.inspect-field select { width: 100%; font-size: .875rem; }
.match-nav { display: flex; gap: 5px; }
.match-nav button { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid var(--border); border-radius: 6px; background: var(--paper); }
.match-nav button:hover:not(:disabled) { background: var(--control-hover); }
.match-nav button span { width: 7px; height: 7px; rotate: 45deg; border-top: 1.5px solid var(--green-dark); border-right: 1.5px solid var(--green-dark); }
.match-nav button:first-child span { rotate: 225deg; }
.match-total { font-size: 2.9rem; line-height: 1.1; letter-spacing: -.07em; font-weight: 800; margin-top: 12px; }
.match-total small { font: 600 .9rem var(--mono); color: var(--muted); letter-spacing: 0; }
.match-total.text-total { font-size: 1.5rem; letter-spacing: -.045em; margin-top: 16px; }
.match-caption { color: var(--muted); font-size: .85rem; margin-top: 3px; }
#record-holder { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 13px; }
.holder-caption { color: var(--orange-text); font: 600 .75rem var(--mono); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1px; }
.team-name { overflow-wrap: anywhere; font-weight: 800; font-size: 1.08rem; letter-spacing: -.035em; line-height: 1.25; }
.team-season, .team-stats { color: var(--muted); font-size: .85rem; }
.team-stats { margin-top: 8px; }
.team-stats strong { color: var(--ink); }
.tie-field { margin-top: 10px; }
.tie-field select { width: 100%; min-height: 44px; font-size: .875rem; }
#comparison-results { display: grid; gap: 8px; border-top: 1px solid var(--border); margin: 12px 0 0; padding: 10px 0 0; list-style: none; }
.comparison-readout { padding-left: 7px; border-left: 3px solid var(--comparison-color); font-size: .83rem; }
.comparison-readout strong { display: block; overflow-wrap: anywhere; }
.comparison-readout span { color: var(--muted); }
.data-status { margin-top: 9px; font-size: .85rem; color: var(--muted); }
.data-status:empty { display: none; }

.methodology { margin: 36px 0 0; border-top: 1px solid var(--border); padding: 31px 0 33px; display: grid; grid-template-columns: minmax(245px, 1fr) 1.8fr; gap: 11px 30px; }
.methodology h2 { font-size: 1.65rem; line-height: 1.25; letter-spacing: -.05em; margin: 4px 0 9px; }
.methodology p:not(.eyebrow), .methodology dd { color: var(--muted); font-size: .91rem; }
.methodology dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 19px; margin: 0; }
.methodology dl div { border-left: 2px solid var(--axis); padding-left: 10px; }
.methodology dt { font-weight: 800; font-size: .92rem; }
.methodology dd { margin: 0; }
.methodology .method-note { grid-column: 1 / -1; padding-top: 8px; }
.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; border-top: 1px solid var(--border); padding: 17px 0 23px; }
.footer .brand-mark { scale: .86; }
.footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.footer-tip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: .84rem; }
.footer-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--paper); color: var(--green-dark); font-size: .84rem; font-weight: 800; text-decoration: none; }
.footer-link:hover { background: var(--control-hover); }

@media (max-width: 1180px) {
  .filters { flex-wrap: wrap; gap: 9px 10px; }
  .benchmark-fields { order: 3; width: 100%; flex-wrap: wrap; gap: 9px 12px; }
  .benchmark-fields > .filter-field { flex: 1 1 auto; max-width: 100%; }
  .segmented { flex-wrap: wrap; }
  .segmented label { flex: 1; justify-content: center; }
  .segmented span { width: 100%; }
  .target-controls .segmented { flex: 1; }
}
@media (max-width: 900px) {
  .shell { width: calc(100% - 46px); }
  .chart-card { padding: 20px; }
  .chart-layout { grid-template-columns: minmax(0,1fr) 226px; gap: 16px; }
  .hero { gap: 20px; }
}
@media (max-width: 690px) {
  .shell { width: calc(100% - 28px); }
  .topbar-inner { min-height: 60px; gap: 9px; }
  .header-actions { gap: 9px; }
  nav { gap: 13px; }
  nav a { font-size: .8rem; }
  .hero { padding-block: 28px 25px; min-height: 0; }
  .hero-art { display: none; }
  .league-field { flex: 1; }
  .format-field { order: 2; flex-basis: 100%; }
  .segmented label { min-height: 36px; }
  .segmented span { padding-inline: 5px; }
  .compare-toggle { padding-inline: 9px; }
  .compare-controls { flex-wrap: wrap; gap: 7px; }
  .compare-controls .filter-field { flex: 1; }
  .compare-controls select { min-width: 0; }
  .compare-controls p { flex-basis: 100%; padding: 0; }
  .chart-card { padding: 15px; }
  .chart-heading { flex-direction: column; gap: 9px; padding-bottom: 12px; }
  .coverage { max-width: none; text-align: left; }
  .coverage strong { display: inline; margin-right: 7px; }
  .chart-layout { grid-template-columns: 1fr; gap: 14px; padding-top: 12px; }
  .plot { height: 270px; }
  .methodology { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
  .topbar .wordmark { min-width: 0; gap: 6px; font-size: .95rem; }
  .topbar .brand-mark { width: 29px; height: 29px; }
  nav { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
