:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: #121417;
  --surface-soft: #181b20;
  --surface-glass: rgba(18, 20, 23, 0.72);
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  /* #71717a was only 4.1:1 contrast on --bg, below WCAG AA.
     #8d8d9a gives ~6.1:1 and passes at all font sizes used in the app. */
  --text-dim: #8d8d9a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --player-a: #facc15;
  --player-b: #3b82f6;
  --accent: #ef4444;
  --focus: #facc15;
  --radar-grid: rgba(255, 255, 255, 0.12);
  --radar-axis: rgba(255, 255, 255, 0.22);
  --warn-bg: rgba(239, 68, 68, 0.10);
  --warn-border: rgba(239, 68, 68, 0.42);
  --warn-text: #fecaca;
  --shadow-soft: 0 18px 60px rgba(0, 0, 0, 0.34);
  --radius-sm: 6px;
  --radius-md: 10px;
  /* Differential tooltip colours — WCAG AA against the dark tooltip surface */
  --tt-pos: #4ade80;   /* green-400  ~8:1 on tooltip bg */
  --tt-neg: #f87171;   /* red-400    ~6:1 on tooltip bg */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto Condensed", "Arial Narrow", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.38;
}

button,
input {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 0.5rem 1rem;
  background: var(--focus);
  color: #111;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.visually-hidden,
.sr-only {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: #08090b;
}

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.8rem 1.25rem 0.9rem;
  text-align: center;
}

.broadcast-kicker {
  margin: 0;
  color: var(--player-a);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3.7vw, 3.35rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.95;
}

.matchup-vs {
  margin: 0 0.38em;
  color: var(--accent);
  font-size: 0.54em;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.matchup-rule {
  width: min(460px, 64vw);
  height: 3px;
  margin: 0.48rem auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.matchup-rule__a,
.matchup-rule__b {
  display: block;
  border-radius: 999px;
}

.matchup-rule__a {
  background: var(--player-a);
}

.matchup-rule__b {
  background: var(--player-b);
}

.lede {
  margin: 0.2rem auto 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.load-status {
  margin: 0.1rem 0 0;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 600;
}

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 1.5rem;
}

.banner {
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.84rem;
}

.league-filter {
  margin: 0 auto 0.95rem;
  padding: 0.78rem 0;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  column-gap: 1.35rem;
  row-gap: 0.72rem;
  align-items: center;
  border-block: 1px solid var(--border);
  background: #08090b;
}

.filter-block {
  grid-column: 1 / -1;
  padding-top: 0.72rem;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  column-gap: 1.35rem;
  align-items: center;
  border-top: 1px solid var(--border);
}

.league-filter__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.12rem;
  min-height: 36px;
  text-align: left;
}

.league-filter h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.league-filter p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.league-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1.35rem;
  align-items: center;
  justify-content: flex-end;
}

.league-tab,
.position-tab,
.role-tab,
.filter-toggle,
.btn-secondary {
  min-height: 30px;
  padding: 0.2rem 0 0.38rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.96rem;
  font-weight: 750;
  cursor: pointer;
}

.filter-toggle,
.btn-secondary {
  padding: 0.32rem 0.58rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.84rem;
}

.league-tab:hover,
.position-tab:hover,
.role-tab:hover,
.filter-toggle:hover,
.btn-secondary:hover {
  color: var(--text);
}

.league-tab:focus,
.position-tab:focus,
.role-tab:focus,
.filter-toggle:focus,
.btn-secondary:focus,
.autocomplete input:focus,
.chart-axis-search:focus {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 3px;
}

.league-tab.is-active,
.position-tab.is-active,
.role-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--player-a);
  border-bottom-width: 3px;
}

.position-tab.is-active,
.role-tab.is-active {
  border-bottom-color: var(--player-b);
}

.filter-toggle.is-active {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
  background: var(--surface-soft);
}

.role-tab.is-active {
  border-bottom-color: var(--accent);
}

.role-filter-block[hidden] {
  display: none;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(245px, 295px) minmax(600px, 1fr) minmax(245px, 295px);
  gap: 1rem 2rem;
  align-items: start;
}

.player-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
}

.player-panel--a {
  --profile-accent: var(--player-a);
}

.player-panel--b {
  --profile-accent: var(--player-b);
}

.player-search {
  padding: 0;
}

.player-search label {
  display: block;
  margin-bottom: 0.38rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.autocomplete {
  position: relative;
}

.autocomplete input {
  width: 100%;
  padding: 0.58rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(18, 20, 23, 0.82);
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.autocomplete input::placeholder {
  color: var(--text-dim);
}

.autocomplete-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: rgba(18, 20, 23, 0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.autocomplete-list li {
  min-height: 54px;
  padding: 0.48rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.autocomplete-list li:hover,
.autocomplete-list li:focus {
  background: rgba(59, 130, 246, 0.12);
  outline: none;
}

.ac-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.ac-name {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 750;
}

.ac-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
}

.ac-flag {
  flex: 0 0 26px;
  width: 26px;
  height: 19px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.player-card {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.player-photo {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  border-radius: var(--radius-md);
  border: 6px solid var(--profile-accent);
  background: transparent;
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--profile-accent) 35%, transparent);
}

.player-text {
  padding-top: 0.1rem;
}

.player-name {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.35rem, 2.1vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.02;
}

.identity-row {
  margin-top: 0.48rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.identity-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.1;
}

.identity-flag {
  flex: 0 0 29px;
  width: 29px;
  height: 21px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background-color: var(--surface);
}

.identity-empty {
  display: inline-block;
}

.asset-missing {
  opacity: 0.25;
}

.club-logo {
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  padding: 2px;
  border: 1px solid var(--border);
}

.club-logo--empty {
  display: inline-block;
  background: var(--surface);
}

.player-meta {
  margin: 0.42rem 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.chart-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.chart-wrap {
  width: 100%;
  min-height: 620px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0;
  background: #08090b;
}

#radar-mount {
  width: min(100%, 700px);
  display: flex;
  justify-content: center;
}

#radar-mount svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.legend-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: opacity 200ms ease, border-color 200ms ease, background 200ms ease;
}

.legend-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.legend-item:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
}

/* Focused player: highlighted border */
.legend-item.is-locked {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 800;
}

.legend-item.legend-a.is-locked {
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.08);
}

.legend-item.legend-b.is-locked {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.08);
}

/* The other player fades out when one is focused */
.legend-item.is-dimmed {
  opacity: 0.38;
}

.radar-lock-hint {
  margin: 0.3rem 0 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.01em;
}

.swatch {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}

.legend-a .swatch {
  background: var(--player-a);
}

.legend-b .swatch {
  background: transparent;
  border-top: 3px dashed var(--player-b);
}

.chart-column > .btn-secondary {
  min-height: 28px;
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
}

/* ── INTRO SECTION ───────────────────────────────────────────────────────── */
/* Flex row on desktop, single column on narrow viewports */
.intro-section {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem 2rem;
  padding: 0.72rem 0 0.9rem;
  margin-bottom: 0.95rem;
  /* No border-bottom here — the league-filter's border-block top edge
     already provides the single dividing line below this section. */
  flex-wrap: wrap;
}

.intro-blurb {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.intro-heading {
  margin: 0;
  color: var(--player-a);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intro-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.58;
  max-width: 780px;
}

/* ── HOW-TO COLLAPSIBLE ──────────────────────────────────────────────────── */
/* Uses <details>/<summary> so keyboard focus and aria-expanded are free */
.how-to {
  flex: 0 0 auto;
  align-self: flex-start;
}

.how-to__toggle {
  list-style: none;          /* Firefox shows a default marker — remove it */
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 140ms ease, color 140ms ease;
}

/* Remove Safari/Chrome default triangle marker */
.how-to__toggle::-webkit-details-marker { display: none; }
.how-to__toggle::marker               { display: none; }

.how-to__toggle:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.how-to__toggle:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 3px;
}

.how-to__chevron {
  display: inline-block;
  font-size: 0.72rem;
  line-height: 1;
  transition: transform 200ms ease;
}

.how-to[open] .how-to__chevron {
  transform: rotate(180deg);
}

.how-to__list {
  margin: 0.55rem 0 0;
  padding: 0.62rem 0.85rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 300px;
  max-width: 430px;
}

.how-to__list li {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.48;
}

.how-to__list li strong {
  color: var(--text);
  font-weight: 750;
}

/* ── DATASET LINK ────────────────────────────────────────────────────────── */
/* #3b82f6 gives ~5.7:1 contrast on the dark footer — passes WCAG AA */
.dataset-cta {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.82rem;
}

.dataset-cta a {
  color: var(--player-b);
  font-weight: 700;
  text-decoration: underline;
}

.dataset-cta a:hover { color: #93c5fd; }
.dataset-cta a:focus-visible { outline: 2px solid rgba(250, 204, 21, 0.74); outline-offset: 2px; }

.footer-links {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.35rem 0;
}

.dataset-link,
.report-link {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.84rem;
  text-decoration: none;
  transition: background 150ms, color 150ms;
}

.dataset-link {
  color: var(--player-a);
  border: 1px solid rgba(250, 204, 21, 0.45);
}
.dataset-link:hover { background: rgba(250, 204, 21, 0.08); color: #fde68a; }

.report-link {
  color: var(--player-b);
  border: 1px solid rgba(59, 130, 246, 0.45);
}
.report-link:hover { background: rgba(59, 130, 246, 0.10); color: #93c5fd; }

.dataset-link:focus-visible,
.report-link:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
  border-radius: 2px;
}

.app-footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.25rem 1.25rem 1rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
}

.radar-tooltip {
  max-width: 300px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(14, 16, 19, 0.97);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  font-size: 0.84rem;
  line-height: 1.45;
  pointer-events: none;
}

.radar-tooltip .tt-stat-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 0.1rem;
}

.radar-tooltip .tt-player {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.radar-tooltip .tt-key {
  display: block;
  color: var(--player-a);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 0.05rem;
}

.radar-tooltip .tt-row {
  display: block;
  font-weight: 500;
}

.radar-tooltip .tt-section {
  margin-top: 0.3rem;
}

.radar-tooltip .tt-section--diff {
  margin-top: 0.45rem;
  padding-top: 0.42rem;
  border-top: 1px solid var(--border-strong);
}

.radar-tooltip .tt-range {
  margin-top: 0.42rem;
  padding-top: 0.38rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 600;
}

/* Both colours are ≥ 6:1 contrast against the dark tooltip background */
.radar-tooltip .tt-pos {
  color: var(--tt-pos);
}

.radar-tooltip .tt-neg {
  color: var(--tt-neg);
}

/* 11px is small — weight 800 keeps the axis label readable on the dark chart */
.axis-label {
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.axis-label-hit {
  fill: rgba(18, 20, 23, 0.88);
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.98;
}

.axis-label-control:hover .axis-label,
.axis-label-control:focus .axis-label {
  fill: var(--text);
}

.axis-label-control:hover .axis-label-hit,
.axis-label-control:focus .axis-label-hit {
  fill: rgba(59, 130, 246, 0.16);
  stroke: rgba(59, 130, 246, 0.55);
}

.axis-label-control:focus {
  outline: none;
}

.chart-axis-picker {
  position: fixed;
  z-index: 1200;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(18, 20, 23, 0.98);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  font: inherit;
  font-size: 0.82rem;
}

.chart-axis-search {
  width: 100%;
  margin: 0 0 0.4rem;
  padding: 0.48rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

.chart-axis-results {
  max-height: 310px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart-axis-option,
.chart-axis-empty {
  padding: 0.58rem 0.6rem;
  border-radius: var(--radius-sm);
}

.chart-axis-option {
  cursor: pointer;
}

.chart-axis-option:hover,
.chart-axis-option:focus,
.chart-axis-option[aria-selected="true"] {
  background: rgba(59, 130, 246, 0.13);
  outline: none;
}

.chart-axis-option__label,
.chart-axis-option__meta,
.chart-axis-option__desc {
  display: block;
}

.chart-axis-option__label {
  color: var(--text);
  font-weight: 800;
}

.chart-axis-option__meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

/* ── SCALE LABELS ────────────────────────────────────────────────────────── */
/*
 * Numeric ring labels (20 · 40 · 60 · 80 · 100).
 * paint-order: stroke fill creates a dark halo so the text stays readable
 * even when a polygon or axis line crosses it.
 */
.scale-label {
  font-size: 9.5px;
  font-weight: 750;
  fill: var(--text-muted);
  stroke: var(--bg);        /* halo colour matches the chart background */
  stroke-width: 3.5px;
  stroke-linejoin: round;
  paint-order: stroke fill; /* render halo behind the fill */
  pointer-events: none;
  user-select: none;
}

/* ── POSITION SEARCH FILTER ──────────────────────────────────────────────── */
.pos-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.42rem;
}

.pos-filter-btn {
  min-height: 24px;
  padding: 0.1rem 0.52rem 0.15rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  user-select: none;
}

.pos-filter-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

.pos-filter-btn:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
}

.pos-filter-btn.is-active {
  background: rgba(250, 204, 21, 0.10);
  color: var(--text);
  border-color: rgba(250, 204, 21, 0.55);
  font-weight: 800;
}

.rank-btn {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.rank-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.rank-btn:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
}

/* ── RANKING MODAL ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 1rem;
  overflow-y: auto; /* prevents layout shift when scrollbar disappears */
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: #181b20;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 2px solid var(--border-strong);
}

.modal-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
}

.modal-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms ease, color 140ms ease;
}

.modal-close:hover  { background: var(--surface-soft); color: var(--text); }
.modal-close:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
}

/* Sort toggle bar inside the ranking modal */
.modal-sort {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-sort-btn {
  padding: 0.22rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.modal-sort-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.modal-sort-btn.is-active {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--accent);
}

.modal-sort-btn:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.74);
  outline-offset: 2px;
}

/* Column header row above the ranking list */
.ranking-header {
  display: grid;
  grid-template-columns: 1fr 5rem 5rem;
  gap: 0 0.5rem;
  padding: 0.35rem 1rem 0.3rem;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-soft);
}

.rh-name {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rh-col {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: right;
}

.ranking-list {
  margin: 0;
  padding: 0.25rem 1rem 0.25rem;
  list-style: none;
}

.ranking-item {
  display: grid;
  grid-template-columns: 1fr 5rem 5rem;
  align-items: baseline;
  gap: 0 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.ranking-item:last-child { border-bottom: none; }

.rank-name {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

/* Score colour is set inline by JS to match the player's accent */
.rank-score {
  font-size: 1rem;
  font-weight: 900;
  text-align: right;
}

.rank-raw {
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.modal-pref {
  padding: 0.65rem 1rem 0.8rem;
  border-top: 1px solid var(--border);
}

.modal-pref-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.modal-pref-check {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: var(--player-a);
  cursor: pointer;
}

/* 0.72rem is small — weight 550 adds legibility without darkening the colour */
.chart-axis-option__desc {
  margin-top: 0.2rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 550;
  line-height: 1.28;
}

.chart-axis-empty {
  color: var(--text-muted);
}

@media (max-width: 1120px) {
  .compare-grid {
    grid-template-columns: minmax(205px, 240px) minmax(500px, 1fr) minmax(205px, 240px);
    gap: 0.85rem 1rem;
  }

  .chart-wrap {
    min-height: 560px;
  }
}

@media (max-width: 900px) {
  .league-tabs {
    gap: 0.75rem;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .chart-column {
    order: -1;
  }

  .chart-wrap {
    min-height: auto;
    padding: 0.75rem 0;
  }
}

@media (max-width: 600px) {
  /* Stack intro text and how-to vertically on small screens */
  .intro-section {
    flex-direction: column;
    gap: 0.65rem;
  }

  .how-to {
    align-self: stretch;
  }

  .how-to__toggle {
    width: 100%;
    justify-content: space-between;
  }

  .how-to__list {
    min-width: 0;
    max-width: 100%;
  }
}
