/* Table Hockey H2H. Order: design tokens, then the component styles kept from
   the previous design (match table, typeahead, filters, playoff panels), then
   the redesigned layout and views, which override those where they overlap. */

/* Declared on body as well as :root so the aliases below resolve against the
   palette body actually has. The dark palette is set on body, and an alias
   resolved on :root would keep the light colours. */
:root,
body {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --sunk: #ECEAE4;
  --ink: #15181B;
  --ink-2: #4A525B;
  --ink-3: #6F757D;
  --line: #E2DFD8;
  --line-2: #CFCBC2;
  --a: #1D6A59;
  --a-tint: #DDEBE6;
  --b: #D4532A;
  --b-tint: #F7E0D6;
  /* Orange for small text: the bright orange is under 4.5:1 on white. */
  --b-text: #B4441F;
  --draw: #B6BABF;
  --shadow: 0 12px 32px rgba(21, 24, 27, 0.12);
  --sans: "Schibsted Grotesk", "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Cyrillic first for tournament names, which are often Russian. */
  --text-cyr: "Golos Text", "Schibsted Grotesk", system-ui, sans-serif;
  --num: "Barlow Condensed", "Schibsted Grotesk", "Golos Text", sans-serif;

  /* Aliases read by the legacy component styles below. */
  --text: var(--ink);
  --muted: var(--ink-2);
  --border: var(--line);
  --card: var(--surface);
  --card-bg: var(--surface);
  --card-border: var(--line);
  --bg-alt: var(--sunk);
  --teal: var(--a);
  --teal-text: var(--a);
  --teal-soft: var(--a-tint);
  --accent: var(--b);
  --accent-dark: var(--b-text);
  --accent-graphic: var(--b);
  --accent-soft: var(--b-tint);
  --ui: var(--ink);
  --ui-soft: rgba(21, 24, 27, 0.06);
  --focus-ring: var(--ink);
  --radius: 8px;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.75rem;
}

body[data-theme="dark"] {
  --bg: #0F1113;
  --surface: #171A1D;
  --sunk: #1E2226;
  --ink: #EEF0F2;
  --ink-2: #A9B0B8;
  --ink-3: #8A929B;
  --line: #262B30;
  --line-2: #343A40;
  --a: #4DBFA3;
  --a-tint: #183A33;
  --b: #F07A52;
  --b-tint: #40241B;
  --b-text: #F07A52;
  --draw: #59606A;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --ui-soft: rgba(238, 240, 242, 0.08);
}

/* Before the theme script runs, follow the system setting. */
@media (prefers-color-scheme: dark) {
  body:not([data-theme]) {
    --bg: #0F1113;
    --surface: #171A1D;
    --sunk: #1E2226;
    --ink: #EEF0F2;
    --ink-2: #A9B0B8;
    --ink-3: #8A929B;
    --line: #262B30;
    --line-2: #343A40;
    --a: #4DBFA3;
    --a-tint: #183A33;
    --b: #F07A52;
    --b-tint: #40241B;
    --b-text: #F07A52;
    --draw: #59606A;
  }
}

/* ── Components kept from the previous design ──────────────────────── */
.table-link {
  display: inline;
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.table-link:hover {
  color: var(--ui);
  text-decoration: underline;
}

.external-icon {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  vertical-align: -0.1em;
}

.table-link .external-icon {
  opacity: 0;
}

tr:hover .table-link .external-icon,
.table-link:focus-visible .external-icon {
  opacity: 0.6;
}

.table-link:hover .external-icon {
  opacity: 1;
}

button,
input,
select {
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

a {
  transition: color 0.15s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none !important;
  box-shadow: none !important;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
  flex: 0 0 auto;
  transition: background 0.16s ease, color 0.16s ease;
}

.icon-btn::after,
.info-btn::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
}

.info-btn::after {
  inset: -11px;
}

.icon-btn,
.info-btn {
  position: relative;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--ui-soft);
  color: var(--ui);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.clear-btn[hidden] {
  display: none;
}

.typeahead {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow: auto;
  display: none;
  z-index: 10;
  padding: 4px;
}

.typeahead.is-open {
  display: block;
}

.typeahead button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  border-radius: 6px;
  min-height: 44px;
}

.typeahead-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.typeahead-flag {
  width: 24px;
  flex: 0 0 24px;
  text-align: center;
  line-height: 1;
}

.typeahead-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typeahead-player--group .typeahead-name {
  font-weight: 700;
}

.typeahead-group-label {
  color: var(--teal);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.typeahead button:hover,
.typeahead button.is-active {
  background: var(--bg-alt);
}

.typeahead .game-count {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.typeahead .empty-message {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.input-loader {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--ui);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

.input-loader[hidden] {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.input-shell input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-shell input:disabled::placeholder {
  color: var(--muted);
  opacity: 0.6;
}
.swap-btn.is-spinning {
  animation: swap-spin 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes swap-spin {
  0% {
    transform: rotate(0deg) scale(1);
  }

  45% {
    transform: rotate(210deg) scale(1.12);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .swap-btn.is-spinning {
    animation: none;
  }

  .streak-chip {
    animation: none;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
:where(button, input, select, a, [role="button"], [role="option"]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.streak-chip {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 42px;
  height: clamp(22px, 2.6vw, 28px);
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--teal-text) 42%, transparent);
  background: var(--teal-soft);
  color: var(--teal-text);
  font-size: var(--fs-xs);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(24, 32, 37, 0);
  animation: streak-pop 0.18s ease-out;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.streak-chip.is-exceptional {
  min-width: 0;
  height: clamp(28px, 2.8vw, 32px);
  padding-inline: 9px;
  border-color: color-mix(in srgb, var(--teal-text) 70%, #a96700);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--teal-soft) 86%, var(--card)),
    color-mix(in srgb, #f4c34f 16%, var(--card))
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--teal-text) 13%, transparent),
    0 2px 8px color-mix(in srgb, var(--teal-text) 12%, transparent);
  color: var(--teal-text);
}

button.streak-chip {
  appearance: none;
  font-family: inherit;
  cursor: pointer;
}

button.streak-chip::before {
  content: "";
  position: absolute;
  inset: -8px -6px;
  border-radius: 999px;
}

.streak-chip.is-exceptional::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid color-mix(in srgb, #d79212 72%, var(--teal-text));
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
}

.streak-chip__flame,
.streak-chip__count,
.streak-chip__unit,
.streak-chip__honor,
.streak-chip__replay {
  display: inline-flex;
  align-items: center;
}

.streak-chip__count {
  margin-left: 1px;
  font-size: var(--fs-sm);
}

.streak-chip__unit {
  margin-left: -2px;
}

.streak-chip__honor {
  margin-left: 6px;
  padding-left: 7px;
  border-left: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  font-size: var(--fs-xs);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.streak-chip__replay {
  margin-left: 4px;
  font-size: var(--fs-md);
  line-height: 1;
  opacity: 0.72;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

button.streak-chip:hover {
  border-color: var(--teal-text);
  transform: translateY(-1px);
}

button.streak-chip:hover .streak-chip__replay {
  transform: rotate(-35deg);
  opacity: 1;
}

button.streak-chip:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.streak-chip.is-view-scoped {
  border-style: dashed;
}

@keyframes streak-pop {
  0% {
    opacity: 0;
    transform: translateY(2px);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.chart {
  min-height: 180px;
  display: grid;
  gap: 8px;
  align-content: start;
  color: var(--muted);
  position: relative;
}

.chart svg {
  width: 100%;
  height: auto;
  min-height: 180px;
  display: block;
  overflow: visible;
}

.chart svg:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.chart-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
  line-height: 1.35;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 2;
  width: max-content;
  min-width: 172px;
  max-width: 240px;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.chart-tooltip .tooltip-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
}

.chart-tooltip .tooltip-side,
.chart-tooltip .tooltip-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 1px 0;
}

.chart-tooltip .tooltip-side-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-tooltip .tooltip-side-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip .tooltip-side.is-winner .tooltip-side-label,
.chart-tooltip .tooltip-side.is-winner .tooltip-side-value {
  font-weight: 800;
}

.chart-tooltip .tooltip-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.chart-tooltip .tooltip-kv {
  color: var(--muted);
}

.chart-tooltip .tooltip-kv strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.legend-dot.a {
  background: var(--teal);
}

.legend-dot.b {
  background: var(--accent-graphic);
}

.chart-note {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.chart-big {
  margin-right: 4px;
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--teal-text);
}


/* ── Filters (bar, advanced panel, active chips) ──────────────────── */
.filter-bar {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.filter-bar-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar-search {
  position: relative;
  flex: 1 1 180px;
  min-width: 140px;
}

.filter-bar-search-icon {
  position: absolute;
  width: 16px;
  height: 16px;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.filter-bar-search input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  min-height: 44px;
}

.filter-bar-search input:focus {
  border-color: var(--focus-ring);
  box-shadow: none;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.filter-bar-period {
  position: relative;
  flex-shrink: 0;
}

.period-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
  min-height: 44px;
}

.period-toggle:hover {
  border-color: var(--muted);
}

.period-toggle[aria-expanded="true"],
.period-toggle.has-value {
  border-color: var(--ui);
  background: var(--ui-soft);
  color: var(--ui);
}

.period-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
}

.period-popover-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 8px;
}

.period-popover-row label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
}

.period-popover-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  min-height: 44px;
}

.filter-bar-tournament {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  flex: 1 1 160px;
  min-width: 120px;
  max-width: 280px;
  min-height: 44px;
}

.more-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  border-color: var(--border);
  min-height: 44px;
}

.more-filters-btn[aria-expanded="true"] {
  background: var(--ui-soft);
  border-color: var(--ui);
  color: var(--ui);
}

/* Advanced Filter Section */
.filter-bar-advanced {
  overflow: hidden;
}

.filter-bar-advanced-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.filter-bar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.filter-bar-group > label:first-child {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-bar-group select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  min-width: 120px;
  min-height: 44px;
}

.filter-bar-toggles {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-bar-toggles .toggle {
  min-height: 44px;
}

.multi-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip-toggle,
.best-of-toggle {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.filter-chip-toggle:has(input:checked),
.best-of-toggle:has(input:checked) {
  border-color: var(--ui);
  background: var(--ui-soft);
  color: var(--ui);
}

/* Active Filter Chips */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 0 0 10px;
  border-radius: 999px;
  background: var(--ui-soft);
  color: var(--ui);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--ui) 30%, transparent);
  white-space: nowrap;
  transition: background 0.16s ease;
}

.active-filter-chip:hover {
  background: color-mix(in srgb, var(--ui) 20%, transparent);
}

.active-filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.16s ease;
}

.active-filter-chip button:hover {
  opacity: 1;
}

.clear-all-filters-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 999px;
  transition: color 0.16s ease, background 0.16s ease;
  min-height: 44px;
}

.clear-all-filters-btn:hover {
  color: var(--text);
  background: var(--bg-alt);
}

/* ── Match list & table ───────────────────────────────────────────── */
/* Matches Header */
.matches-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.rows-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rows-selector label {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.rows-selector select {
  padding: 6px 12px;
  font-size: var(--fs-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  min-height: 44px;
}

.mobile-sort-control {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mobile-sort-control label {
  color: var(--muted);
  font-size: var(--fs-sm);
}

#mobile-sort {
  min-width: 0;
  min-height: 44px;
  flex: 1 1 auto;
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
}

#mobile-sort-direction {
  width: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0;
  justify-content: center;
  font-size: var(--fs-md);
}

/* Custom chevron for native selects */
.filter-bar select,
.rows-selector select,
#mobile-sort {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6770' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

body[data-theme="dark"] .filter-bar select,
body[data-theme="dark"] .rows-selector select,
body[data-theme="dark"] #mobile-sort {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a5b0bb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

@media (max-width: 600px) {
  .matches-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-sort-control {
    display: flex;
    flex: 1 1 100%;
    width: 100%;
  }

  #pagination-top {
    margin-left: auto;
  }
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* Switch-style checkboxes (Options group) */
.filter-bar-toggles .toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  margin: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.filter-bar-toggles .toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.filter-bar-toggles .toggle input[type="checkbox"]:checked {
  background: var(--ui);
  border-color: var(--ui);
}

.filter-bar-toggles .toggle input[type="checkbox"]:checked::before {
  transform: translateX(14px);
}

.filter-bar-toggles .toggle input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Filter chips: the pill carries the state, hide the native checkbox */
.filter-chip-toggle,
.best-of-toggle {
  position: relative;
}

.filter-chip-toggle input[type="checkbox"],
.best-of-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

.filter-chip-toggle:has(input:focus-visible),
.best-of-toggle:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.matches-card {
  display: grid;
  gap: 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

/* Desktop: scroll long match lists internally so the sticky header works */
@media (min-width: 601px) {
  .matches-card .table-wrap {
    max-height: 72vh;
    overflow: auto;
  }
}

#matches-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

body[data-comparison-mode="single"] #matches-table {
  min-width: 820px;
}

body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table {
  min-width: 900px;
}

#matches-table th,
#matches-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
}

#matches-table tbody tr:not(.detail-row) {
  transition: background 0.15s ease;
}

#matches-table tbody tr:not(.detail-row):hover {
  background: var(--bg-alt);
}

#matches-table th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
}

.expand-header {
  width: 36px;
}

.sort-header {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: color 0.16s ease;
}

#matches-table th:has(.sort-header) {
  padding-block: 0;
}

.sort-header:hover,
.sort-header:focus-visible {
  color: var(--ui);
}

.sort-header:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.sort-header.is-active {
  color: var(--text);
}

.sort-header.is-active:hover,
.sort-header.is-active:focus-visible {
  color: var(--ui);
}

.sort-indicator {
  width: 12px;
  height: 12px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: currentColor;
}

.sort-indicator::before {
  content: "↑";
  display: block;
  opacity: 0;
  font-size: var(--fs-xs);
  line-height: 1;
  transform-origin: center;
  transform: rotate(0deg) scale(0.92);
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sort-header:hover .sort-indicator::before,
.sort-header:focus-visible .sort-indicator::before {
  opacity: 0.45;
}

.sort-header.is-active .sort-indicator::before {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.sort-header.is-desc .sort-indicator::before {
  transform: rotate(180deg) scale(1);
}

/* Plain score: the winner's goals carry the weight and the player color. */
.match-score {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.match-score .goals {
  min-width: 1ch;
  text-align: center;
}

.match-score[data-result="A"] .goals--a {
  color: var(--teal-text);
  font-weight: 800;
}

.match-score[data-result="B"] .goals--b {
  color: var(--accent-dark);
  font-weight: 800;
}

.match-score[data-result="D"] .goals {
  color: var(--text);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(24, 32, 37, 0.08);
  font-size: var(--fs-xs);
  text-transform: uppercase;
}

.winner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: none;
  white-space: nowrap;
}

.winner::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.winner.a {
  color: var(--teal-text);
}

.winner.b {
  color: var(--accent-dark);
}

.winner.d {
  color: var(--muted);
}

.expand-btn {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  transition: background 0.15s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Invisible larger tap target (>=36px) without changing the visual size */
.expand-btn::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.expand-btn:hover {
  background: var(--bg-alt);
}

.expand-btn svg {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.expand-btn.is-open svg {
  transform: rotate(180deg);
}

.detail-row td {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}

@keyframes detail-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Expanded game: what the game meant, not its raw IDs. */
.match-detail-row td {
  background: var(--card);
}

.game-ctx {
  display: grid;
  gap: 12px;
  max-width: 560px;
  padding: 4px 0 2px;
  animation: detail-in 0.18s ease;
}

.game-ctx-head {
  display: grid;
  gap: 2px;
}

.game-ctx-title {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.game-ctx-note,
.game-ctx-meta {
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.game-ctx-label,
.game-ctx-stat-label,
.game-ctx-tile-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.game-ctx-label {
  margin-bottom: -6px;
}

.game-ctx-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 6px;
}

.game-ctx-tile {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 7px 4px 6px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: var(--sunk);
}

.game-ctx-tile-score {
  font: 600 1.15rem/1.1 var(--num);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.game-ctx-tile--a { background: var(--a-tint); }
.game-ctx-tile--a .game-ctx-tile-score { color: var(--a); }
.game-ctx-tile--b { background: var(--b-tint); }
.game-ctx-tile--b .game-ctx-tile-score { color: var(--b-text); }

.game-ctx-tile.is-current {
  border-color: var(--ink);
}

.game-ctx-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-ctx-stat {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--sunk);
}

.game-ctx-stat-value {
  font: 600 1.2rem/1.2 var(--num);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.game-ctx-stat-value small {
  margin-left: 5px;
  font: 500 var(--fs-xs) var(--sans);
  color: var(--ink-2);
}

.game-ctx-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.game-ctx-source {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.game-ctx-source .external-icon {
  opacity: 0.6;
}

.series-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  width: 100%;
  max-width: 100%;
  animation: detail-in 0.18s ease;
}

.series-detail-head {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.series-detail-caption {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.series-detail-players {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.series-detail-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  font-size: var(--fs-md);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.series-detail-player.b {
  justify-self: end;
}

.series-detail-player.a {
  color: var(--teal-text);
}

.series-detail-player.b {
  color: var(--accent-dark);
}

.series-detail-player-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.series-detail-score {
  font-size: var(--fs-lg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.series-detail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Shared side dot (tooltips, series panels) */
.side-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-block;
}

.side-dot.a {
  background: var(--teal);
}

.side-dot.b {
  background: var(--accent-graphic);
}

.series-games-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.series-game {
  flex: 0 0 auto;
  width: 132px;
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  min-width: 0;
}

.series-game--a {
  background: var(--teal-soft);
  border-color: rgba(42, 117, 100, 0.3);
}

.series-game--b {
  background: var(--accent-soft);
  border-color: rgba(239, 108, 68, 0.32);
}

.series-game-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.series-game-num {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.series-game-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.series-game-score {
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  font-weight: 800;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.series-game-ot {
  padding: 2px 5px;
  line-height: 1;
  font-size: var(--fs-xs);
  flex-shrink: 0;
  min-width: 24px;
}

.series-game-winner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-game-running {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination button.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 44px;
}

.page-info {
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
}

.muted {
  color: var(--muted);
}

@media (max-width: 600px) {
  .matches-header {
    align-items: flex-start;
  }

  /* Mobile-friendly table: card layout */
  #matches-table {
    min-width: 0;
    display: block;
  }

  #matches-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #matches-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #matches-table tr:not(.detail-row) {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  #matches-table tr:not(.detail-row).is-expanded {
    border-bottom-color: transparent;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  #matches-table td {
    border: none;
    padding: 2px 0;
    font-size: var(--fs-sm);
  }

  #matches-table td.date-cell {
    grid-column: 2;
    grid-row: 1;
    font-weight: 600;
    color: var(--muted);
  }

  #matches-table td:nth-child(6) {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
  }

  #matches-table td:nth-child(8) {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }

  #matches-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    font-size: var(--fs-xs);
    color: var(--muted);
    white-space: normal;
    line-height: 1.4;
  }

  #matches-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 3;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  #matches-table td:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
    text-align: right;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  #matches-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 4;
    color: var(--muted);
    font-size: var(--fs-xs);
  }

  #matches-table td.ot-cell.is-empty {
    display: none;
  }

  #matches-table td:first-child {
    display: flex;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-items: center;
  }

  #matches-table .expand-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--ui);
  }

  #matches-table tr.match-detail-row:not([hidden]) {
    display: block !important;
    margin-top: -12px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--card);
  }

  #matches-table tr.match-detail-row td {
    display: block;
    padding: 0 12px 12px;
    background: var(--card);
    border: none;
  }

  #matches-table tr.empty-table-row,
  #matches-table tr.loading-table-row {
    display: block;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  #matches-table tr.empty-table-row td:first-child,
  #matches-table tr.loading-table-row td:first-child {
    display: block;
    padding: 0;
    color: var(--muted);
  }

  body[data-comparison-mode="single"] #matches-table {
    min-width: 0;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table {
    min-width: 0;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td.date-cell {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text);
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(3)::before {
    content: "vs ";
    color: var(--muted);
    font-weight: 600;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(4) {
    grid-column: 2 / -1;
    grid-row: 3;
    font-size: var(--fs-xs);
    color: var(--muted);
    white-space: normal;
    line-height: 1.4;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(5) {
    grid-column: 2;
    grid-row: 4;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(6) {
    grid-column: 3;
    grid-row: 4;
    text-align: right;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(7) {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(8) {
    grid-column: 2;
    grid-row: 5;
    text-align: left;
  }

  body[data-comparison-mode="single"] #matches-table tr.single-match-row td:nth-child(9) {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row.is-expanded {
    border-bottom-color: transparent;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:first-child {
    display: flex;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-items: center;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row .expand-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--ui);
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td.date-cell {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(4) {
    grid-column: 2;
    grid-row: 3;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
    text-align: right;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(6) {
    grid-column: 3;
    grid-row: 1;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(7) {
    grid-column: 2 / -1;
    grid-row: 4;
    text-align: left;
    color: var(--muted);
    font-size: var(--fs-xs);
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(7)::before {
    content: "Goals ";
    font-weight: 700;
  }

  body[data-stats-mode="series"] #matches-table tr.series-row td:nth-child(8) {
    grid-column: 3;
    grid-row: 2;
  }

  body[data-stats-mode="series"] #matches-table tr.series-detail-row:not([hidden]) {
    display: block !important;
    margin-top: -12px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--card);
  }

  body[data-stats-mode="series"] #matches-table tr.series-detail-row td {
    display: block;
    padding: 0 12px 12px;
    background: var(--card);
    border: none;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td.date-cell {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text);
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(3)::before {
    content: "vs ";
    color: var(--muted);
    font-weight: 600;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(4) {
    grid-column: 2 / -1;
    grid-row: 3;
    font-size: var(--fs-xs);
    color: var(--muted);
    white-space: normal;
    line-height: 1.4;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(5) {
    grid-column: 2;
    grid-row: 4;
    text-align: left;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(6) {
    grid-column: 3;
    grid-row: 4;
    text-align: right;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(7) {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(7)::before {
    content: "";
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(8) {
    grid-column: 2 / -1;
    grid-row: 5;
    text-align: left;
    color: var(--muted);
    font-size: var(--fs-xs);
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(8)::before {
    content: "Goals ";
    font-weight: 700;
  }

  body[data-comparison-mode="single"][data-stats-mode="series"] #matches-table tr.series-row td:nth-child(9) {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }

  .winner {
    font-size: var(--fs-xs);
  }

  #matches-table tr.detail-row {
    min-width: 0;
  }

  .period-popover {
    left: auto;
    right: 0;
  }

  .series-detail-players {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
  }

  .series-detail-player {
    font-size: var(--fs-sm);
  }

  .series-detail-player.b {
    justify-self: center;
  }

}
/* Generational run: a fast, replayable celebration for genuine 10+ win streaks. */
.generational-lane {
  position: absolute;
  inset: 0;
  z-index: 4;
  min-width: 100%;
  overflow: visible;
  pointer-events: none;
}

.generational-lane__track {
  position: absolute;
  top: calc(var(--run-track-y, 28px) - 1px);
  left: var(--run-start-x, 0);
  width: var(--run-distance, 0);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--teal-text) 18%, transparent),
    var(--teal-text) 22%,
    #35a981 76%,
    #d79212
  );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card) 68%, transparent);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform, opacity;
}

.generational-lane__track::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -3px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: #d79212;
  box-shadow: 0 0 0 1px color-mix(in srgb, #a96700 70%, var(--teal-text));
}

.generational-lane.is-active .generational-lane__track {
  animation: generational-track-sweep 2.1s linear both;
}

.generational-runner {
  position: absolute;
  top: calc(var(--run-track-y, 28px) - 26px);
  left: calc(var(--run-start-x, 0) - 13px);
  width: 28px;
  height: 28px;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  will-change: transform, opacity;
}

.generational-lane.is-active .generational-runner {
  animation: generational-runner-sprint 2.1s linear both;
}

.generational-runner__trail {
  position: absolute;
  top: 13px;
  right: 18px;
  width: 36px;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--teal-text) 52%, transparent)
  );
  opacity: 0;
  transform: scaleX(0.7);
  transform-origin: right center;
}

.generational-lane.is-active .generational-runner__trail {
  animation: generational-trail-pulse 300ms ease-in-out 6 alternate 140ms;
}

.generational-runner__flame {
  position: absolute;
  top: 7px;
  left: -6px;
  z-index: 1;
  font-size: var(--fs-sm);
  line-height: 1;
  text-shadow: 0 0 7px rgba(215, 146, 18, 0.58);
  transform: rotate(-18deg) scale(0.9);
}

.generational-lane.is-active .generational-runner__flame {
  animation: generational-flame-flicker 240ms ease-in-out 8 alternate 80ms;
}

.generational-runner__figure {
  position: absolute;
  inset: 2px 0 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
  line-height: 1;
  text-shadow:
    -2px 0 0 color-mix(in srgb, var(--teal-text) 75%, transparent),
    -5px 0 6px color-mix(in srgb, var(--teal-text) 42%, transparent);
  transform: scaleX(-1);
  transform-origin: center;
}

.generational-lane.is-active .generational-runner__figure {
  animation: generational-runner-stride 260ms ease-in-out 7 alternate 90ms;
}

.generational-runner::before,
.generational-runner::after {
  content: "";
  position: absolute;
  top: 16px;
  left: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #d79212;
  opacity: 0;
}

.generational-runner::after {
  top: 10px;
  left: -9px;
  width: 3px;
  height: 3px;
  background: var(--teal-text);
}

.generational-lane.is-active .generational-runner::before {
  animation: generational-runner-spark 620ms ease-out 2 180ms;
}

.generational-lane.is-active .generational-runner::after {
  animation: generational-runner-spark 520ms ease-out 3 80ms;
}

.form-chips.is-generational-running .chip:hover {
  transform: none;
}

.chip.win.is-run-lit {
  animation: generational-win-ignite 520ms cubic-bezier(0.22, 0.9, 0.32, 1.28)
    var(--run-delay, 0ms) both;
}

.streak-chip.is-celebrating {
  animation: generational-streak-finale 700ms cubic-bezier(0.22, 0.9, 0.3, 1.35)
    1.8s both;
}

.streak-chip.is-celebrating::after {
  animation: generational-streak-ring 700ms cubic-bezier(0.2, 0.82, 0.26, 1)
    1.8s both;
}

.streak-chip.is-celebrating .streak-chip__flame {
  animation: generational-finale-flame 700ms cubic-bezier(0.22, 0.9, 0.3, 1.35)
    1.8s both;
}

.streak-chip.is-celebrating .streak-chip__replay {
  animation: generational-replay-spin 700ms ease-out 1.8s both;
}

body[data-theme="dark"] .streak-chip.is-exceptional {
  border-color: color-mix(in srgb, var(--teal-text) 70%, #f4c34f);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--teal-soft) 86%, var(--card)),
    color-mix(in srgb, #d79212 14%, var(--card))
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--teal-text) 16%, transparent),
    0 2px 10px rgba(0, 0, 0, 0.28);
}

@keyframes generational-track-sweep {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }

  8% {
    opacity: 0.86;
  }

  86% {
    opacity: 0.9;
    transform: scaleX(1);
  }

  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@keyframes generational-runner-sprint {
  0% {
    opacity: 0;
    transform: translate3d(0, 2px, 0);
  }

  7% {
    opacity: 1;
  }

  84% {
    opacity: 1;
    transform: translate3d(var(--run-distance, 0), 0, 0);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--run-distance, 0), -2px, 0) scale(0.86);
  }
}

@keyframes generational-runner-stride {
  from {
    transform: scaleX(-1) translateY(1px) rotate(-5deg);
  }

  to {
    transform: scaleX(-1.04) translateY(-2px) rotate(5deg);
  }
}

@keyframes generational-trail-pulse {
  from {
    opacity: 0.38;
    transform: scaleX(0.72);
  }

  to {
    opacity: 0.9;
    transform: scaleX(1);
  }
}

@keyframes generational-flame-flicker {
  from {
    opacity: 0.72;
    transform: rotate(-20deg) scale(0.82);
  }

  to {
    opacity: 1;
    transform: rotate(-10deg) scale(1.08);
  }
}

@keyframes generational-runner-spark {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.6);
  }

  30% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translate3d(-13px, -8px, 0) scale(0.2);
  }
}

@keyframes generational-win-ignite {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  42% {
    border-color: var(--teal-text);
    background: color-mix(in srgb, var(--teal-soft) 64%, #ffffff);
    box-shadow:
      0 0 0 4px color-mix(in srgb, var(--teal-text) 16%, transparent),
      0 5px 12px color-mix(in srgb, var(--teal-text) 24%, transparent);
    color: var(--teal-text);
    transform: translateY(-3px) scale(1.13);
  }
}

@keyframes generational-streak-finale {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  38% {
    border-color: #a96700;
    box-shadow:
      0 0 0 5px color-mix(in srgb, #d79212 18%, transparent),
      0 7px 18px color-mix(in srgb, var(--teal-text) 24%, transparent);
    transform: translateY(-2px) scale(1.12) rotate(-1deg);
  }

  66% {
    transform: translateY(1px) scale(0.98) rotate(0.5deg);
  }
}

@keyframes generational-streak-ring {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }

  28% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: scale(1.22);
  }
}

@keyframes generational-finale-flame {
  0%,
  100% {
    transform: translateY(0) scale(1) rotate(0);
  }

  42% {
    transform: translateY(-5px) scale(1.32) rotate(-8deg);
  }
}

@keyframes generational-replay-spin {
  from {
    transform: rotate(-90deg);
  }

  to {
    transform: rotate(0);
  }
}

@media (max-width: 800px) {
  .streak-chip__honor {
    display: none;
  }
}

@media (max-width: 600px) {
  .form-detail {
    grid-column: 1;
  }

  .generational-runner__figure {
    font-size: var(--fs-md);
  }

  .generational-runner__flame {
    font-size: var(--fs-xs);
  }
}

@media (max-width: 430px) {
  .form-chips {
    gap: 2px;
  }

  .streak-chip.is-exceptional {
    gap: 2px;
    padding-inline: 8px;
  }

  .streak-chip__unit {
    display: none;
  }

  .streak-chip__replay {
    margin-left: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .generational-lane {
    display: none !important;
  }

  .chip.win.is-run-lit,
  .streak-chip.is-celebrating,
  .streak-chip.is-celebrating::after,
  .streak-chip.is-celebrating .streak-chip__flame,
  .streak-chip.is-celebrating .streak-chip__replay {
    animation: none !important;
  }

  .streak-chip__replay {
    transition: none;
  }
}

@media (forced-colors: active) {
  .generational-lane,
  .streak-chip.is-exceptional::after {
    display: none !important;
  }

  .streak-chip.is-exceptional {
    border: 2px solid currentColor;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }
}

@media print {
  .generational-lane {
    display: none !important;
  }
}

.chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 180px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  padding: 24px;
  text-align: center;
  gap: 12px;
}

body[data-theme="light"] .chart-placeholder {
  background: rgba(0, 0, 0, 0.015);
}

.chart-placeholder svg {
  width: 32px;
  height: 32px;
  stroke: var(--muted);
  opacity: 0.6;
}

.chart-placeholder span {
  font-size: var(--fs-sm);
  font-weight: 500;
  max-width: 240px;
  line-height: 1.4;
}

#matches-table tr.empty-table-row td,
#matches-table tr.loading-table-row td {
  text-align: center !important;
  padding: 48px 24px !important;
  color: var(--muted);
  font-size: var(--fs-md);
  font-weight: 500;
  background: transparent;
}

/* ── Opponents Panel (single-player view) ─────────────────────────── */
.opponents-panel {
  display: grid;
  gap: 12px;
}

.opponents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.opponents-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.opponents-filter-label {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  min-width: 90px;
}

.opponents-filter-label span {
  font-weight: 700;
  color: var(--text);
  display: inline-block;
  min-width: 1.6em;
  text-align: right;
}

/* Range slider */
.opponents-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(var(--border), var(--border)) center / 100% 4px no-repeat;
  outline: none;
  cursor: pointer;
}

.opponents-slider:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.opponents-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.2);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.opponents-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.opponents-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg);
  cursor: pointer;
}

/* Table layout */
.opponents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.opponents-table-wrap {
  overflow-x: auto;
  border: 0;
  -webkit-overflow-scrolling: touch;
}

.opponents-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-alt);
}

.opponents-table thead th {
  padding: 8px 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.opponents-table thead th:has(.opponents-sort-btn) {
  padding: 0;
}

/* Sortable column headers */
.sortable-col {
  cursor: default;
  transition: color 0.15s ease;
}
.sortable-col:hover {
  color: var(--text);
}
.sortable-col.active-sort {
  color: var(--teal-text);
}

.opponents-sort-btn {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.opp-col-numeric .opponents-sort-btn {
  justify-content: flex-end;
  text-align: right;
}

.opponents-sort-btn:hover {
  color: var(--text);
  background: var(--card);
}

.opponents-sort-btn:focus-visible,
.opponent-select-btn:focus-visible {
  outline-offset: -4px;
}

.opponents-table .sort-indicator {
  font-size: var(--fs-xs);
  margin-left: 2px;
  opacity: 0.7;
}

/* Column alignments */
.opp-col-name { text-align: left; }
.opp-col-numeric { text-align: right; }
.opp-col-record { text-align: center; }

/* Cell styles */
.opp-cell-name {
  padding: 0 6px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.opponent-select-btn {
  width: 100%;
  min-height: 44px;
  display: block;
  padding: 8px 0;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.opponent-select-btn:hover {
  color: var(--teal-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.opp-cell-numeric {
  padding: 8px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.opp-cell-record {
  padding: 8px 6px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Row styles */
.top-opponents-row {
  cursor: default;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid var(--border);
}
.top-opponents-row:last-child {
  border-bottom: none;
}
.top-opponents-row:hover {
  background: var(--bg-alt) !important;
}
body[data-theme="dark"] .top-opponents-row:hover {
  background: var(--card) !important;
}

/* Count indicator */
.opponents-count {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-align: right;
  padding: 0 2px;
}

/* Responsive adjustments for mobile screens */
@media (max-width: 480px) {
  .opponents-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .opponents-filter {
    justify-content: space-between;
    width: 100%;
  }

  .opponents-slider {
    flex-grow: 1;
    max-width: 180px;
  }

  .opponents-table {
    font-size: var(--fs-sm);
  }

  .opponents-table thead th {
    padding: 6px 4px;
    font-size: var(--fs-xs);
  }

  .opp-cell-name,
  .opp-cell-numeric,
  .opp-cell-record {
    padding: 6px 4px;
  }

  .opp-cell-name {
    max-width: 100px;
  }
}
@media (max-width: 600px) {
  #matches-table .expand-btn,
  body[data-stats-mode="series"] #matches-table tr.series-row .expand-btn {
    color: var(--ui);
  }
}

/* ── Medium widths: fold OT into the score pill, drop Round/OT columns ── */
.ot-inline {
  display: none;
}

.match-score .ot-inline {
  align-self: flex-start;
  margin-left: 3px;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 0.625em;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@media (min-width: 601px) and (max-width: 800px) {
  body[data-stats-mode="games"] #matches-table {
    min-width: 0;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table th:nth-child(5),
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td:nth-child(5),
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table th:nth-child(7),
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td:nth-child(7),
  body[data-comparison-mode="single"][data-stats-mode="games"] #matches-table th:nth-child(6),
  body[data-comparison-mode="single"][data-stats-mode="games"] #matches-table td:nth-child(6),
  body[data-comparison-mode="single"][data-stats-mode="games"] #matches-table th:nth-child(8),
  body[data-comparison-mode="single"][data-stats-mode="games"] #matches-table td:nth-child(8) {
    display: none;
  }

  body[data-stats-mode="games"] .match-score .ot-inline {
    display: inline-flex;
  }
}

@media (forced-colors: active) {
  :where(button, input, select, a, [role="button"], [role="option"]):focus-visible {
    outline-color: Highlight;
  }

  .filter-chip-toggle input[type="checkbox"],
  .best-of-toggle input[type="checkbox"] {
    position: static;
    width: 18px;
    height: 18px;
    opacity: 1;
    pointer-events: auto;
  }

  .filter-bar-toggles .toggle input[type="checkbox"]:checked {
    background: Highlight;
    border-color: Highlight;
  }

  .score-fill {
    display: none;
  }

  .winner,
  .chip,
  .streak-chip,
  .badge {
    border: 1px solid currentColor;
  }
}

/* ── Print: scoreboard-first output ── */
@media print {
  .background,
  .header-actions,
  .selection-card,
  .controls-bar,
  .matches-card,
  .site-footer {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .container {
    padding-bottom: 0;
  }

  .card,
  .viz-block,
  .form-strip {
    box-shadow: none;
    backdrop-filter: none;
    border: 1px solid var(--border);
  }
}

/* ── Mobile match list: dense two-line rows instead of tall cards ─── */
@media (max-width: 600px) {
  #matches-table tbody {
    gap: 0;
  }

  #matches-table tr:not(.detail-row) {
    padding: 12px 4px;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }

  #matches-table tr:not(.detail-row).is-expanded {
    border-bottom-color: transparent;
    border-radius: 0;
  }

  #matches-table tr.match-detail-row:not([hidden]),
  body[data-stats-mode="series"] #matches-table tr.series-detail-row:not([hidden]) {
    margin-top: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: var(--bg-alt);
  }

  #matches-table tr.match-detail-row td {
    padding: 12px;
    background: transparent;
  }

  #matches-table tr.match-detail-row:not([hidden]) {
    background: var(--card);
  }

  #matches-table tr.match-detail-row td {
    padding: 0 16px 16px;
  }

  #matches-table .expand-btn {
    border: none;
    background: transparent;
    color: var(--muted);
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table tr:not(.detail-row) {
    grid-template-columns: 64px minmax(0, 1fr) auto auto 28px;
    gap: 2px 10px;
    align-items: center;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td {
    padding: 0;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.score-cell {
    grid-column: 1;
    grid-row: 1 / span 2;
    font-size: var(--fs-lg);
    text-align: left;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] .match-score .ot-inline {
    display: inline-flex;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td:nth-child(3) {
    grid-column: 2 / span 3;
    grid-row: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--fs-sm);
    color: var(--text);
    line-height: 1.35;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td:nth-child(3) .external-icon {
    display: none;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.date-cell,
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.stage-cell,
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.round-cell {
    grid-row: 2;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.date-cell {
    grid-column: 2;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.stage-cell {
    grid-column: 3;
    text-align: right;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.round-cell {
    grid-column: 4;
    text-align: right;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.ot-cell,
  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td.winner-cell {
    display: none;
  }

  body[data-comparison-mode="matchup"][data-stats-mode="games"] #matches-table td:first-child {
    grid-column: 5;
    grid-row: 1 / span 2;
    justify-content: center;
  }

  /* Controls: sort and rows share one line; pagination lives at the bottom. */
  .matches-card .header-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .matches-card .mobile-sort-control {
    flex: 1 1 0;
    width: auto;
  }

  .matches-card .rows-selector label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .matches-card #pagination-top {
    display: none;
  }
}

/* ── Home screen: headline, stats and featured rivalries ──────────── */
.home-only,

/* ── Redesign: base, layout and views ──────────────────────────────── */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 20px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
  padding-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

p {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

.wrap {
  width: 100%;
  max-width: 1248px;
  margin: 0 auto;
  padding: 0 24px;
}

.num,
.tab-count {
  font-variant-numeric: tabular-nums;
}

.only-m {
  display: none !important;
}

.eyebrow {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted {
  color: var(--ink-2);
}

.cyr {
  font-family: var(--text-cyr);
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn,
.select-btn,
.icon-button {
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn svg,
.select-btn svg,
.icon-button svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--ink-2);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.btn:hover:not(:disabled),
.select-btn:hover,
.icon-button:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.btn.primary:hover:not(:disabled) {
  color: var(--bg);
  opacity: 0.9;
}

.btn.is-done {
  border-color: var(--a);
  color: var(--a);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: inherit;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

:where(button, input, select, a, [role="button"], [role="option"]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: relative;
  z-index: 20;
}

.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
}

/* Norges Bordhockeyforbund crest. Dark mode puts it on a white tile, as puck.no does,
   so the navy lettering keeps its contrast. */
.mark {
  width: auto;
  height: 36px;
  flex: none;
  border-radius: 5px;
}

body[data-theme="dark"] .mark {
  background: #fff;
  padding: 2px;
}

.nav {
  display: flex;
  gap: 24px;
  font-size: 14px;
  font-weight: 500;
}

.nav a,
.mobile-menu a {
  color: var(--ink-2);
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"],
.mobile-menu a[aria-current="page"] {
  color: var(--ink);
}

.header-search {
  margin-left: auto;
  width: 320px;
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--ink-3);
  font-size: 14px;
  cursor: text;
  text-align: left;
}

.header-search svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.header-search-label {
  flex: 1;
}

.header-search kbd,
kbd {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 18px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 6px;
  color: var(--ink-3);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

body[data-home="true"] .header-search {
  display: none;
}

body[data-home="true"] .topbar-actions {
  margin-left: auto;
}

.mobile-menu {
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.mobile-menu .wrap {
  display: grid;
  padding-top: 4px;
  padding-bottom: 8px;
}

.mobile-menu a {
  display: block;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.mobile-menu a:last-child {
  border-bottom: 0;
}

/* ── Home / finder ─────────────────────────────────────────────────── */
.home-only {
  display: none !important;
}

body[data-home="true"] .home-only:not([hidden]) {
  display: block !important;
}

body[data-home="true"] .results-only {
  display: none !important;
}

.top-grid {
  position: relative;
  z-index: 12;
}

body[data-home="true"] .top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  column-gap: 64px;
  align-items: start;
  padding-top: 72px;
}

body[data-home="true"] .home-intro {
  grid-column: 1;
}

body[data-home="true"] .finder {
  grid-column: 1;
  margin-top: 32px;
}

body[data-home="true"] .feature {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.home-title {
  font-size: 56px;
  line-height: 60px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.home-sub {
  font-size: 18px;
  line-height: 28px;
  color: var(--ink-2);
  margin-top: 16px;
  max-width: 520px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* On result pages the finder is a panel that opens from the header search. */
.finder {
  padding: 20px;
  display: grid;
  gap: 16px;
}

body:not([data-home="true"]) .finder {
  display: none;
}

body.finder-open:not([data-home="true"]) .finder {
  display: grid;
  margin-top: 24px;
  box-shadow: var(--shadow);
}

.finder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.finder-title {
  font-size: 16px;
  font-weight: 700;
}

.selection-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.player-field {
  display: grid;
  gap: 8px;
  position: relative;
  min-width: 0;
}

.player-field label {
  font-size: 13px;
  font-weight: 600;
}

.label-note {
  font-weight: 400;
  color: var(--ink-3);
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 52px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-shell:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.input-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--ink-3);
}

.input-shell input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--ink);
  text-overflow: ellipsis;
}

.input-shell input::placeholder {
  color: var(--ink-3);
}

.input-shell input:focus-visible {
  outline: none;
}

.swap-btn {
  width: 40px;
  height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.swap-btn svg {
  width: 18px;
  height: 18px;
}

.swap-btn:hover:not(:disabled) {
  color: var(--ink);
  background: var(--sunk);
}

.swap-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.finder-foot {
  display: flex;
  align-items: center;
  gap: 16px;
}

.finder-hint {
  font-size: 13px;
  color: var(--ink-2);
}

.view-player-btn {
  flex: none;
}

.status:empty {
  display: none;
}

.status:empty + .view-player-btn {
  margin-left: auto;
}

.status {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-2);
}

.recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.recent.is-empty {
  display: none;
}

.recent-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.recent-list button {
  height: 32px;
  max-width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-list button:hover {
  border-color: var(--ink-3);
}

.recent-note {
  font-size: 13px;
}

/* Featured rivalry card */
.feature {
  padding: 24px;
}

.feature .names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  font-weight: 600;
  font-size: 15px;
}

.feature .names .r,
.feature .sc .r {
  text-align: right;
}

.feature .sc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 6px;
  font-family: var(--num);
  font-size: 48px;
  line-height: 48px;
  font-weight: 600;
}

.feature .sc .a {
  color: var(--a);
}

.feature .sc .b {
  color: var(--b);
}

.feature .mini-chart {
  margin-top: 16px;
}

.feature .mini-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.feature p {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 12px;
  line-height: 20px;
}

.feature .open {
  margin-top: 16px;
  border: 0;
  background: none;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.feature .open svg {
  width: 16px;
  height: 16px;
}

.feature .open:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Records */
#records {
  padding-top: 64px;
}

.records {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.record {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 20px 24px;
  color: inherit;
  font: inherit;
  text-align: left;
}

button.record {
  cursor: pointer;
}

button.record:hover,
.streak-row:hover {
  background: var(--sunk);
}

.record-num {
  font-family: var(--num);
  font-size: 44px;
  line-height: 44px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.record-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 8px;
  margin-top: 12px;
}

.record-unit {
  font-size: 14px;
  color: var(--ink-2);
}

.record-who {
  margin-top: 4px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
}

.record-when {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.record-visual {
  display: block;
  width: 100%;
  height: 64px;
  margin-top: 16px;
}

/* Streaks: one square per game */
.record--streaks {
  grid-column: 1 / -1;
  gap: 0;
  padding-bottom: 8px;
}

.streak-row {
  width: calc(100% + 48px);
  margin: 0 -24px;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.streak-row:last-child {
  border-bottom: 0;
}

.streak-head {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.streak-head .record-num {
  min-width: 72px;
  color: var(--a);
}

.streak-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  min-width: 0;
}

.streak-text .record-unit {
  flex-basis: 100%;
}

.streak-text .record-who {
  margin-top: 0;
}

.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.pips i,
.pip-legend i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--a);
}

.pips i.d,
.pip-legend i.d {
  background: var(--draw);
}

.pip-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}

.pip-legend i.d {
  margin-left: 6px;
}

/* Perfect record: a full bar and a zero */
.shutout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

.shutout-bar {
  display: flex;
  height: 14px;
  border-radius: 3px;
  background: var(--sunk);
  overflow: hidden;
}

.shutout-bar i {
  flex: 1;
  background: var(--a);
}

.shutout-labels,
.gap-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
}

.record--perfect .record-num {
  color: var(--a);
}

/* Rival streak: the lead climbing game by game */
.climb {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.climb svg {
  display: block;
  width: 100%;
  height: 40px;
}

.record--climb .record-num {
  color: var(--a);
}

/* Dead even: a bar split down the middle */
.balance {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

.balance-bar {
  display: flex;
  gap: 2px;
  height: 14px;
}

.balance-bar i {
  display: block;
  height: 14px;
}

.balance-bar i:first-child {
  border-radius: 3px 0 0 3px;
}

.balance-bar i:last-child {
  border-radius: 0 3px 3px 0;
}

.balance-mid {
  position: absolute;
  left: 50%;
  top: 8px;
  height: 30px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
}

/* Rematch: two dots and a long silence */
.gap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

.gap-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gap-line .dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--b);
}

.gap-line .dash {
  flex: 1;
  border-top: 2px dashed var(--line-2);
}

.record--gap .record-num {
  color: var(--b-text);
}

@media (max-width: 900px) {
  .records {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  #records {
    padding-top: 40px;
  }

  .records {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .record {
    padding: 16px;
  }

  .streak-row {
    width: calc(100% + 32px);
    margin: 0 -16px;
    padding: 14px 16px;
  }

  .streak-head {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .streak-head .record-num {
    min-width: 0;
  }

  .pip-legend {
    margin-left: 0;
    flex-basis: 100%;
  }

  .pips i {
    width: 8px;
    height: 8px;
  }

  .record-num {
    font-size: 36px;
    line-height: 36px;
  }

  .record-visual {
    height: 48px;
  }

  .climb svg {
    height: 32px;
  }
}

/* Biggest rivalries */
#rivalries {
  padding-top: 64px;
}

.rlist {
  overflow: hidden;
}

.rrow {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 280px 80px 110px 24px;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 0 24px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.rrow:last-child {
  border-bottom: 0;
}

button.rrow:hover {
  background: var(--sunk);
}

.rrow.head {
  min-height: 44px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: default;
}

.rrow .rank {
  font-family: var(--num);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-3);
}

.rrow .pair {
  font-weight: 600;
  min-width: 0;
}

.rrow .pair i {
  font-style: normal;
  color: var(--ink-3);
  font-weight: 400;
  margin: 0 6px;
}

.rrow .wr {
  font-family: var(--num);
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-3);
  margin-right: 5px;
}

.rrow .rec {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.mini-bar {
  flex: 1;
  display: flex;
  height: 8px;
  gap: 2px;
}

.mini-bar span {
  display: block;
  height: 8px;
}

.mini-bar span:first-child {
  border-radius: 2px 0 0 2px;
}

.mini-bar span:last-child {
  border-radius: 0 2px 2px 0;
}

.rrow .gn {
  text-align: right;
  font-family: var(--num);
  font-size: 20px;
  font-weight: 600;
}

.rrow.head .gn {
  font-family: var(--sans);
  font-size: 12px;
}

.rrow .mut {
  color: var(--ink-2);
  text-align: right;
}

.rrow .chev svg {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
}

.prow {
  grid-template-columns: 32px minmax(0, 1fr) 200px 80px 24px;
}

.prow .mut {
  text-align: left;
}

/* ── Sections and panels ──────────────────────────────────────────── */
.section {
  padding-top: 40px;
}

.sec-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 16px;
}

.sec-title {
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sec-sub {
  font-size: 14px;
  color: var(--ink-2);
}

.sec-head .right {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-2);
}

.cols {
  display: grid;
  gap: 24px;
  align-items: start;
}

.c-7-5 {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}

.chart-panel {
  padding: 24px 24px 20px;
  min-width: 0;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 12px;
}

.chart-title {
  font-size: 16px;
  line-height: 22px;
  font-weight: 700;
}

.chart-sub {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 2px;
}

.legend {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--ink-2);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  display: inline-block;
  flex: none;
}

.dot.a { background: var(--a); }
.dot.b { background: var(--b); }
.dot.d { background: var(--draw); }
.dot.band { background: var(--b); opacity: 0.3; }
.dot.faint { background: var(--draw); opacity: 0.6; }

.chart {
  position: relative;
  min-height: 0;
  display: block;
  color: var(--ink-3);
}

.chart svg {
  width: 100%;
  height: auto;
  min-height: 0;
  display: block;
  overflow: visible;
}

.chart svg text {
  font-family: var(--sans);
}

/* ── Matchup hero ─────────────────────────────────────────────────── */
.view-hero {
  padding-top: 40px;
}

.crumbs {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crumbs a {
  color: inherit;
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.crumbs .sep {
  color: var(--ink-3);
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 24px;
  margin-top: 24px;
}

.who {
  min-width: 0;
}

.who .name {
  display: block;
  font-size: 32px;
  line-height: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.who .meta {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 6px;
}

.who.b {
  text-align: right;
}

/* Matchup player switcher: the name opens a search of the other player's opponents. */
.who {
  position: relative;
}

.who .switch-trigger {
  display: inline-block;
  max-width: 100%;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-size: 32px;
  line-height: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: inherit;
  cursor: pointer;
}

.switch-name {
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.switch-chevron {
  display: inline-block;
  vertical-align: -3px;
  margin-left: 6px;
  width: 28px;
  height: 28px;
  padding: 4px;
  border-radius: 6px;
  color: var(--ink-2);
  background: var(--ui-soft);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.switch-trigger:hover .switch-name,
.switch-trigger[aria-expanded="true"] .switch-name {
  text-decoration-color: currentColor;
}

.switch-trigger:hover .switch-chevron {
  color: var(--ink);
  background: var(--line);
}

.switch-trigger[aria-expanded="true"] .switch-chevron {
  transform: rotate(180deg);
  color: var(--surface);
  background: var(--ink);
}

.switcher {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  width: min(340px, calc(100vw - 32px));
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.switcher[hidden] {
  display: none;
}

.switcher--b {
  left: auto;
  right: 0;
}

.switcher-head {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switcher-kept {
  font-weight: 600;
  color: var(--ink);
}

.switcher-search {
  height: 44px;
}

.switcher .switcher-list {
  position: static;
  display: block;
  max-height: min(300px, 45vh);
  margin: 8px -4px 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
}

.switcher-career {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: calc(100% + 24px);
  margin: 8px -12px -12px;
  padding: 0 14px;
  min-height: 48px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.switcher-career span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switcher-career svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--ink-3);
}

.switcher-career:hover {
  background: var(--sunk);
}

.tick {
  display: block;
  width: 32px;
  height: 4px;
  border-radius: 2px;
  margin-bottom: 14px;
}

.who.a .tick { background: var(--a); }
.who.b .tick { background: var(--b); margin-left: auto; }
.who.field .tick { background: var(--draw); margin-left: auto; }

.board .mid {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score {
  display: flex;
  align-items: baseline;
  gap: 20px;
  font-family: var(--num);
  font-weight: 600;
  font-size: 112px;
  line-height: 96px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.score .dash {
  color: var(--line-2);
  font-weight: 400;
  font-size: 80px;
}

.score .a { color: var(--a); }
.score .b { color: var(--b); }

.facts {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 14px;
  text-align: center;
}

.share {
  margin-top: 28px;
}

.share-bar {
  display: flex;
  height: 10px;
  gap: 2px;
}

.share-bar span {
  display: block;
  height: 10px;
}

.share-bar span:first-child { border-radius: 5px 0 0 5px; }
.share-bar span:last-child { border-radius: 0 5px 5px 0; }

.share-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.share-labels b {
  color: var(--ink);
  font-weight: 700;
}

.verdict {
  margin-top: 24px;
  font-size: 18px;
  line-height: 28px;
  max-width: 760px;
}

.verdict strong {
  font-weight: 700;
}

/* Last 10 games, newest first */
.form-strip {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.form-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.form-tally {
  font-size: 13px;
  color: var(--ink-2);
}

.form-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  min-width: 0;
}

.form-latest {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 4px;
}

.chip {
  width: 44px;
  height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  line-height: 14px;
  cursor: pointer;
}

.chip b {
  font-family: var(--num);
  font-size: 16px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.win { background: var(--a); color: #fff; }
.chip.loss { background: var(--b-tint); color: var(--b-text); }
.chip.draw { background: var(--sunk); color: var(--ink-2); }
body[data-theme="dark"] .chip.win { color: #0F1113; }

.chip.is-latest {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink);
}

.form-detail {
  flex-basis: 100%;
  font-size: 13px;
  color: var(--ink-2);
}

.form-strip .form-detail {
  margin-top: 0;
}

/* ── Controls ─────────────────────────────────────────────────────── */
.controls-bar {
  margin-top: 28px;
  position: relative;
  z-index: 11;
}

.controls-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.controls-bar {
  padding: 0;
}

.controls-inner {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stage-card {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  background: var(--sunk);
  border-radius: 8px;
  padding: 3px;
  border: 0;
}

.seg .tab,
.seg .mode-btn {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.seg .tab:hover,
.seg .mode-btn:hover {
  color: var(--ink);
}

.seg .is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.tab-count {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
}

.tab-count:empty {
  display: none;
}

.filter-card {
  flex: 1;
  min-width: 0;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
}

.filter-bar-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.filter-bar-period {
  position: relative;
}

.select-btn {
  gap: 24px;
  font-weight: 400;
}

.select-btn.has-value {
  border-color: var(--ink);
}

.filter-bar-tournament,
.filter-bar-group select,
.period-popover-row select {
  height: 40px;
  max-width: 260px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background-color: var(--surface);
  padding: 0 36px 0 12px;
  /* 1rem minimum: iOS Safari zooms into smaller form controls. */
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868C94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  text-overflow: ellipsis;
}

.filter-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
}

.more-filters-btn[aria-expanded="true"] {
  border-color: var(--ink);
}

.controls-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.filter-bar-advanced {
  flex-basis: 100%;
}

.active-filters {
  flex-basis: 100%;
}

.filter-bar-group--search {
  grid-column: 1 / -1;
}

/* Inside the column-direction group the old flex-basis became a 180px height. */
.filter-bar-group--search .filter-bar-search {
  flex: none;
}

.filter-bar-search input {
  font-size: 16px;
}

/* ── Lead chart ───────────────────────────────────────────────────── */
.lead-chart svg {
  overflow: visible;
}

.strip-block {
  margin-top: 14px;
}

.strip-label {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.strip-label > span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.strip-label > span:first-child {
  margin-right: auto;
  color: var(--ink-3);
}

.tournament-strip svg {
  display: block;
}

/* ── Tale of the tape (flat, centred share bars) ──────────────────── */
.tape {
  border-top: 1px solid var(--line-2);
}

.tape-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.tape-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 12px;
}

.tape-top .v {
  font-family: var(--num);
  font-size: 22px;
  line-height: 24px;
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.tape-top .v.r {
  text-align: right;
}

.tape-top .v.win {
  font-weight: 600;
}

.tape-top .v.win.a { color: var(--a); }
.tape-top .v.win.b { color: var(--b); }

.tape-top .k {
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
}

.tape-sub {
  display: block;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-3);
  font-weight: 400;
}

.tape-bar {
  position: relative;
  display: flex;
  height: 8px;
  margin-top: 12px;
  margin-bottom: 4px;
}

/* The two shares meet with no seam, so the only mark on the bar is the 50/50 tick. */
.tape-bar span {
  display: block;
  height: 8px;
}

.tape-bar span:first-of-type {
  border-radius: 2px 0 0 2px;
}

.tape-bar span:last-of-type {
  border-radius: 0 2px 2px 0;
}

/* 50/50 reference: an ink tick that pokes out above and below the bar. */
.tape-bar i {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 2px;
  margin-left: -1px;
  height: 16px;
  border-radius: 1px;
  background: var(--ink);
}

.tape-bar.is-empty {
  background: var(--sunk);
  border-radius: 2px;
}

/* ── Scorelines heatmap ──────────────────────────────────────────── */
.heat {
  padding: 24px;
}

.heat-chart svg {
  max-width: 420px;
  margin: 0 auto;
}

.heat-cap {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 12px;
  line-height: 20px;
}

.heat-cap b {
  color: var(--ink);
}

/* ── Season by season (diverging) ────────────────────────────────── */
.seasons {
  border-top: 1px solid var(--line-2);
}

.srow {
  display: grid;
  grid-template-columns: 72px 110px minmax(0, 1fr) 120px;
  gap: 16px;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.srow.head {
  min-height: 40px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.srow .yr {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 600;
}

.srow .yr small {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 12px;
  font-weight: 400;
  color: var(--ink-3);
}

.srow .rec {
  font-family: var(--num);
  font-size: 16px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.srow.head .rec {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-3);
}

.srow .div {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.srow .half {
  display: flex;
  height: 14px;
}

.srow .half.l {
  justify-content: flex-end;
  border-right: 1px solid var(--ink-3);
}

.srow .half > span {
  display: block;
  height: 14px;
}

.srow.head .half {
  height: auto;
}

.srow.head .half.l {
  border: 0;
  padding-right: 10px;
}

.srow.head .half.r {
  padding-left: 10px;
}

.srow .edge {
  text-align: right;
  font-weight: 600;
}

.srow .edge.a { color: var(--a); }
.srow .edge.b { color: var(--b-text); }
.srow .edge.d { color: var(--ink-2); }

/* ── Tournaments list ────────────────────────────────────────────── */
.tlist {
  overflow: hidden;
}

.titem {
  border-bottom: 1px solid var(--line);
}

.titem:last-of-type {
  border-bottom: 0;
}

.trow {
  width: 100%;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 150px 220px 24px;
  gap: 16px;
  align-items: center;
  min-height: 60px;
  padding: 10px 24px;
  border: 0;
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.trow:hover {
  background: var(--sunk);
}

.trow .date,
.trow .stage {
  color: var(--ink-2);
}

.trow .tname {
  font-family: var(--text-cyr);
  font-weight: 600;
  line-height: 20px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.trow .tsub {
  display: none;
}

.trow .res {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.trow .sc {
  font-family: var(--num);
  font-size: 20px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

.sc.a { color: var(--a); }
.sc.b { color: var(--b); }
.sc.d { color: var(--ink-2); }

.trow .chev svg {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  transition: transform 0.15s ease;
}

.trow[aria-expanded="true"] .chev svg {
  transform: rotate(180deg);
}

.pill {
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.pill.a { background: var(--a-tint); color: var(--a); }
.pill.b { background: var(--b-tint); color: var(--b-text); }
.pill.d { background: var(--sunk); color: var(--ink-2); }

.games {
  padding: 4px 24px 18px 136px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.g {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}

a.g:hover {
  border-color: var(--ink-3);
}

.g b {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.g .wa { color: var(--a); }
.g .wb { color: var(--b-text); }
.g small {
  font-size: 11px;
  color: var(--ink-3);
}

.tfoot {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

button.tfoot {
  cursor: pointer;
}

button.tfoot:hover {
  background: var(--sunk);
}

/* ── Player page ─────────────────────────────────────────────────── */
.p-top {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  margin-top: 12px;
}

.p-name {
  font-size: 44px;
  line-height: 50px;
  font-weight: 700;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.p-meta {
  font-size: 15px;
  color: var(--ink-2);
  margin-top: 8px;
}

.p-top .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.kpis {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 0.9fr 1.35fr 1fr 1.3fr 1.1fr;
}

.kpi {
  padding: 18px 24px;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.kpi:last-child {
  border-right: 0;
}

.kpi .v {
  font-family: var(--num);
  font-size: 36px;
  line-height: 40px;
  font-weight: 600;
  margin-top: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kpi .s {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 2px;
}

.callout {
  padding: 24px;
}

.callout .big {
  font-size: 22px;
  line-height: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.callout .big span {
  color: var(--a);
}

.split {
  display: flex;
  height: 12px;
  gap: 2px;
  margin-top: 20px;
}

.split span {
  display: block;
  height: 12px;
}

.split-legend {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.split-legend > div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 64px 44px;
  align-items: center;
  gap: 8px;
}

.split-legend .head {
  grid-template-columns: minmax(0, 1fr) 64px 44px;
  font-size: 12px;
  color: var(--ink-3);
}

.split-legend b {
  text-align: right;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.split-legend em {
  font-style: normal;
  text-align: right;
  color: var(--ink-2);
}

.split-legend .head b,
.split-legend .head em {
  color: var(--ink-3);
  font-weight: 400;
}

.split-legend .nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extremes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.extremes .xn {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-top: 6px;
}

.extremes .xs {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 2px;
}

.extremes .xs .a { color: var(--a); font-weight: 600; }
.extremes .xs .b { color: var(--b-text); font-weight: 600; }

.xfoot {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 12px;
}

/* Opponents table */
.opponents-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.opponents-panel {
  overflow: hidden;
}

.opponents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.opponents-table thead th {
  height: 44px;
  padding: 0 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  background: none;
  position: static;
}

.opponents-table thead {
  position: static;
  background: none;
}

.opponents-table thead th:has(.opponents-sort-btn) {
  padding: 0 12px;
}

.opponents-table .opponents-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.opponents-table .sort-indicator::before {
  content: none;
}

.opponents-table th:first-child,
.opponents-table td:first-child {
  padding-left: 24px;
}

.opponents-table th:last-child,
.opponents-table td:last-child {
  padding-right: 24px;
}

.opponents-table td {
  height: 52px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.opponents-table tbody tr:last-child td {
  border-bottom: 0;
}

.opponents-table .opp-col-numeric,
.opponents-table .opp-cell-numeric,
.opponents-table .opp-col-record,
.opponents-table .opp-cell-record,
.opponents-table .opp-col-last,
.opponents-table .opp-cell-last {
  text-align: right;
}

.opponents-table .opp-cell-numeric {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 600;
}

.opponents-table .opp-cell-record,
.opponents-table .opp-cell-last {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.opponents-table .opp-col-rate {
  width: 220px;
}

.wbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wbar .t {
  flex: 1;
  height: 6px;
  background: var(--sunk);
  border-radius: 3px;
  overflow: hidden;
}

.wbar .f {
  display: block;
  height: 6px;
  border-radius: 3px;
}

.wbar .f.a { background: var(--a); }
.wbar .f.b { background: var(--b); }
.wbar .f.d { background: var(--draw); }

.wbar .p {
  width: 40px;
  text-align: right;
  font-weight: 600;
}

.opp-compare {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.opp-compare svg {
  width: 16px;
  height: 16px;
}

.opp-compare:hover {
  text-decoration: underline;
}

.opponents-table .opponent-select-btn {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  min-height: 0;
}

.opponents-table .opponent-select-btn:hover {
  text-decoration: underline;
}

.opponents-table .sort-indicator {
  margin-left: 2px;
}

.opponents-sort-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sortable-col.active-sort .opponents-sort-btn {
  color: var(--ink);
}

.opponents-count {
  color: var(--ink-2);
  font-weight: 500;
}

/* ── Every game table ────────────────────────────────────────────── */
.matches-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 0;
}

.matches-header .sec-head {
  margin-bottom: 16px;
}

.matches-card .table-wrap {
  overflow-x: auto;
}

.matches-card #pagination-bottom {
  margin-top: 16px;
}

/* ── Empty, error and loading states ─────────────────────────────── */
.empty-state {
  margin-top: 40px;
  padding-top: 40px;
  padding-bottom: 40px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.empty-state h3 {
  font-size: 20px;
  line-height: 28px;
}

.empty-state p {
  color: var(--ink-2);
}

.results-skeleton {
  display: none;
  padding-top: 40px;
}

body.is-loading .results-skeleton {
  display: block;
}

.skeleton-hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: end;
  margin: 24px 0 28px;
}

.skeleton-hero .skeleton-line--name:last-child {
  justify-self: end;
}

.skeleton-line,
.skeleton-panel {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--sunk) 0%, var(--line) 50%, var(--sunk) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
}

.skeleton-line--crumbs { width: 180px; }
.skeleton-line--name { width: 220px; height: 36px; }
.skeleton-line--record { width: 280px; height: 96px; }
.skeleton-line--bar { height: 10px; }
.skeleton-line--text { width: 60%; height: 18px; margin-top: 24px; }

.skeleton-panel {
  height: 320px;
  margin-top: 40px;
  border-radius: 12px;
}

@keyframes skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* Slim sticky bar on phones that keeps the matchup in view. */
.score-bug {
  display: none;
}

@media (max-width: 700px) {
  body.show-score-bug .score-bug {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 700;
    animation: score-bug-in 0.18s ease-out;
  }
}

.score-bug-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-bug-name--a { color: var(--a); }
.score-bug-name--b { color: var(--b-text); text-align: right; }
.score-bug-name--field { color: var(--ink-2); text-align: right; }

.score-bug-record {
  font-family: var(--num);
  font-size: 20px;
  font-weight: 600;
}

@keyframes score-bug-in {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* View switching: matchup and player sections share one results area. */
body[data-comparison-mode="single"] .matchup-only,
body[data-comparison-mode="matchup"] .player-only {
  display: none;
}

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 56px;
  border-top: 1px solid var(--line);
}

.footer-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding-top: 16px;
  padding-bottom: 16px;
  font-size: 13px;
  color: var(--ink-3);
}

.footer-inner a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.data-freshness {
  margin-left: auto;
}

/* ── Phones ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav {
    display: none;
  }

  .header-search {
    width: auto;
    flex: 1;
    max-width: 320px;
  }

  body[data-home="true"] .top-grid {
    grid-template-columns: 1fr;
    padding-top: 40px;
  }

  body[data-home="true"] .feature {
    grid-column: 1;
    grid-row: auto;
    margin-top: 32px;
  }

  .c-7-5 {
    grid-template-columns: 1fr;
    gap: 40px;
  }

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

  .kpi {
    border-bottom: 1px solid var(--line);
  }

  .kpi:nth-child(3) {
    border-right: 0;
  }

  .kpi:nth-child(n + 4) {
    border-bottom: 0;
  }
}

@media (max-width: 700px) {
  .wrap {
    padding: 0 16px;
  }

  .only-m {
    display: inline-flex !important;
  }

  .only-d {
    display: none !important;
  }

  .topbar-inner {
    height: 56px;
    gap: 12px;
  }

  .header-search {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .home-title {
    font-size: 34px;
    line-height: 38px;
  }

  .home-sub {
    font-size: 16px;
    line-height: 24px;
    margin-top: 12px;
  }

  body[data-home="true"] .top-grid {
    padding-top: 32px;
  }

  body[data-home="true"] .finder {
    margin-top: 24px;
  }

  .finder {
    padding: 16px;
  }

  .selection-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .swap-btn {
    display: none;
  }

  .finder-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .status {
    margin-left: 0;
  }

  .feature {
    padding: 16px;
  }

  .feature .sc {
    font-size: 40px;
    line-height: 40px;
  }

  #rivalries,
  #players {
    padding-top: 40px;
  }

  .rrow {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 8px 12px;
    padding: 14px 16px;
  }

  .rrow.head,
  .rrow .rank,
  .rrow .mut,
  .rrow .chev {
    display: none;
  }

  .rrow .rec {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .prow {
    grid-template-columns: 28px minmax(0, 1fr) 64px;
  }

  .prow .rank {
    display: block;
    font-size: 16px;
  }

  .view-hero {
    padding-top: 24px;
  }

  .board {
    grid-template-columns: 1fr 1fr;
    row-gap: 20px;
    gap: 12px;
    margin-top: 16px;
  }

  .board .mid {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .score {
    font-size: 80px;
    line-height: 70px;
    gap: 14px;
  }

  .score .dash {
    font-size: 56px;
  }

  .who .name {
    font-size: 22px;
    line-height: 28px;
  }

  .who .switch-trigger {
    font-size: 22px;
    line-height: 28px;
  }

  .switch-name {
    text-underline-offset: 4px;
  }

  .switch-chevron {
    width: 22px;
    height: 22px;
    padding: 2px;
    margin-left: 4px;
    vertical-align: -4px;
  }

  .who .meta {
    font-size: 13px;
    margin-top: 2px;
  }

  .tick {
    margin-bottom: 10px;
    width: 24px;
  }

  .facts {
    font-size: 13px;
  }

  .verdict {
    font-size: 16px;
    line-height: 24px;
  }

  .form-strip {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .form-head {
    flex-direction: row;
    justify-content: space-between;
  }

  .form-chips {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .form-latest,
  .form-order {
    display: none;
  }

  .chip {
    width: auto;
  }

  .form-chips .streak-chip,
  .form-chips .form-detail {
    grid-column: 1 / -1;
  }

  .controls-bar {
    margin-top: 20px;
  }

  .controls-inner {
    gap: 8px;
  }

  .stage-card,
  .filter-card {
    flex-basis: 100%;
  }

  .stage-card .seg {
    flex: 1;
    min-width: 0;
  }

  .seg .tab,
  .seg .mode-btn {
    flex: 1;
    justify-content: center;
    padding: 0 6px;
    font-size: 13px;
  }

  .seg .tab-count {
    display: none;
  }

  .filter-bar {
    gap: 8px;
  }

  /* Years and tournaments share the first row; Filters, copy and share the second. */
  .filter-bar-primary {
    display: contents;
  }

  .filter-bar-period,
  .filter-bar-tournament {
    flex: 1 1 140px;
    min-width: 0;
    max-width: none;
  }

  .filter-bar-period .select-btn {
    width: 100%;
    justify-content: space-between;
  }

  .controls-actions {
    margin-left: auto;
  }

  .controls-actions .btn {
    width: 40px;
    padding: 0;
  }

  .controls-actions .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .section {
    padding-top: 32px;
  }

  .sec-head .right {
    margin-left: 0;
    width: 100%;
  }

  .chart-panel {
    padding: 16px;
  }

  .chart-head {
    flex-direction: column;
    gap: 8px;
  }

  .legend {
    margin-left: 0;
    justify-content: flex-start;
  }

  .heat {
    padding: 16px;
  }

  .tape-row {
    padding: 12px 0;
  }

  .srow {
    grid-template-columns: 52px minmax(0, 1fr) 64px;
    gap: 10px;
  }

  .srow .rec {
    display: none;
  }

  .srow .edge {
    font-size: 13px;
    line-height: 16px;
  }

  .srow.head .half {
    font-size: 11px;
    white-space: nowrap;
  }

  .trow {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 14px 16px;
    align-items: start;
  }

  .trow .date,
  .trow .stage,
  .trow .chev,
  .trow .res .pill {
    display: none;
  }

  .trow .tsub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-2);
  }

  .trow .tsub .pill {
    height: 20px;
    padding: 0 8px;
    font-size: 11px;
  }

  .games {
    padding: 0 16px 16px;
    gap: 6px;
  }

  .p-top {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .p-top .actions {
    margin-left: 0;
  }

  .p-top .actions .btn {
    flex: 1;
  }

  .p-name {
    font-size: 32px;
    line-height: 38px;
  }

  .p-meta {
    font-size: 14px;
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
  }

  .kpi,
  .kpi:nth-child(n) {
    padding: 14px 16px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .kpi:nth-child(2) {
    grid-column: 1 / 3;
    order: -1;
    border-right: 0;
  }

  .kpi:nth-child(3),
  .kpi:nth-child(5) {
    border-right: 0;
  }

  .kpi:nth-child(4),
  .kpi:nth-child(5) {
    border-bottom: 0;
  }

  .kpi .v {
    font-size: 30px;
    line-height: 34px;
  }

  .callout {
    padding: 16px;
  }

  .callout .big {
    font-size: 18px;
    line-height: 26px;
  }

  .opponents-table th:first-child,
  .opponents-table td:first-child {
    padding-left: 16px;
  }

  .opponents-table th:last-child,
  .opponents-table td:last-child {
    padding-right: 16px;
  }

  .opponents-table .opp-col-record,
  .opponents-table .opp-cell-record,
  .opponents-table .opp-col-last,
  .opponents-table .opp-cell-last,
  .opponents-table .opp-col-action,
  .opponents-table .opp-cell-action,
  .opponents-table .wbar .t {
    display: none;
  }

  .opponents-table .opp-col-rate {
    width: auto;
    text-align: right;
  }

  .opponents-table .wbar {
    justify-content: flex-end;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .data-freshness {
    margin-left: 0;
  }

  .skeleton-hero {
    grid-template-columns: 1fr 1fr;
  }

  .skeleton-line--record {
    grid-column: 1 / -1;
    justify-self: center;
    order: -1;
    width: 220px;
    height: 70px;
  }

  .skeleton-line--name {
    width: 120px;
  }
}

@media print {
  .topbar,
  .controls-bar,
  .score-bug,
  .results-skeleton,
  .finder {
    display: none !important;
  }
}

