/* ==========================================================================
   Speedyruns design system — app.css
   --------------------------------------------------------------------------
   FONTS: templates must include this <link> in <head> (no @import here, a
   <link> starts the font download earlier than an @import inside the CSS):

   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Barlow:wght@400;500;600&family=JetBrains+Mono:wght@500;700&display=swap">

   MODE: set <html data-mode="classic|pure">. Pure swaps --accent to amber.

   Layout is mobile-first: base = phone (<768), then 768+ (desktop), 1200+ (wide).
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg: #0a0c10;
  --surface: #12151c;
  --surface-raised: #1b1f28;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --ink: #f1f3f7;
  --muted: #8d95a5;
  --classic: #ff4d2e;
  --accent: #ff4d2e;
  --accent-rgb: 255, 77, 46;
  --accent-soft: rgba(255, 77, 46, 0.45);
  --accent-tint: rgba(255, 77, 46, 0.08);
  --accent-contrast: #0a0c10;
  --pure: #ffb020;
  --pure-soft: rgba(255, 176, 32, 0.15);
  --gold: #ffcf3f;
  --silver: #c4cbd6;
  --bronze: #d08a4b;
  --good: #3ddc97;
  --bad: #ff6b6b;
  --records: #3b9ddd;
  --hover: rgba(255, 255, 255, 0.03);
  --font-display: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
  --font-body: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --gutter: 16px;
  --maxw: 1600px;
}
html[data-mode="pure"] {
  --accent: #ffb020;
  --accent-rgb: 255, 176, 32;
  --accent-soft: rgba(255, 176, 32, 0.45);
  --accent-tint: rgba(255, 176, 32, 0.08);
  --accent-contrast: #0a0c10;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
/* cap content width on very wide screens (4K etc.) so nothing stretches edge-to-edge */
body > header, body > .stripe, body > section, body > footer { max-width: var(--maxw); margin-left: auto; margin-right: auto; }

/* ---------- typography ---------- */
.display { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.label {
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}

/* ---------- stripe ---------- */
.stripe { height: 4px; background: repeating-linear-gradient(135deg, var(--accent) 0 14px, transparent 14px 28px); }
.stripe--dim { opacity: 0.5; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter); position: relative; z-index: 20;
}
.topbar__logo { display: flex; align-items: center; gap: 10px; height: 56px; font-size: 24px; }
.topbar__logo svg { width: 22px; height: 22px; color: var(--accent); }
.topbar__logo em { font-style: normal; color: var(--accent); }
.topbar__logo:hover { color: var(--ink); }
.topbar__nav { display: none; align-items: center; gap: 28px; }
.topbar__nav > a { color: var(--ink); }
.topbar__nav > a:hover { color: var(--accent); }
.topbar__icons { display: flex; align-items: center; gap: 18px; color: var(--ink); }
.topbar__icon { display: flex; width: 22px; height: 22px; }
.topbar__icon svg { width: 22px; height: 22px; }
/* phone: the hazard stripe is drawn between the bar and the mode switch */
.topbar::after { content: ''; order: 5; flex: 0 0 100%; height: 4px; margin: 0 calc(-1 * var(--gutter)); background: repeating-linear-gradient(135deg, var(--accent) 0 14px, transparent 14px 28px); }
.topbar + .stripe { display: none; }

.mode-switch {
  order: 10; flex: 0 0 100%;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  margin: 12px 0 0; padding: 4px; border: 1px solid var(--line-strong); border-radius: 4px;
}
.mode-switch__btn {
  display: block; padding: 10px 0; text-align: center; border-radius: 3px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.mode-switch__btn--classic { color: var(--classic); }
.mode-switch__btn--pure { color: var(--pure); }
.mode-switch__btn.is-active { background: var(--accent); color: var(--accent-contrast); }
.mode-switch__btn:hover { color: var(--ink); }
.mode-switch__btn.is-active:hover { color: var(--accent-contrast); }

/* search box (topbar + map filter share the look) */
.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted);
}
.search svg { width: 16px; height: 16px; flex: 0 0 16px; }
.search__input {
  flex: 1 1 auto; min-width: 0; height: 100%; background: none; border: 0; outline: 0; padding: 0;
  color: var(--ink); font-size: 14px;
}
.search__input::placeholder { color: var(--muted); }
.search:focus-within { border-color: rgba(255, 255, 255, 0.3); }
.search__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface-raised); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 4px;
  padding: 6px 0; max-height: 360px; overflow-y: auto; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.search__group { padding: 8px 12px 4px; }
.search__item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 12px; color: var(--ink); }
.search__item:hover, .search__item.is-active { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.search__item small { color: var(--muted); font-size: 12px; }
.search__empty { padding: 10px 12px; color: var(--muted); }
/* phone: the search box is revealed by the icon button */
.topbar .search { display: none; order: 8; flex: 0 0 100%; margin: 10px 0 0; }
.topbar.is-search-open .search { display: flex; }
.topbar.is-menu-open .topbar__nav { display: flex; order: 9; flex: 0 0 100%; gap: 20px; margin-top: 10px; }
.topbar.is-menu-open .topbar__nav .search { display: none; }

/* ---------- hero ---------- */
.hero { position: relative; height: 280px; overflow: hidden; margin-top: 12px; }
.hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(1.1) contrast(1.05); }
.hero__shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 12, 16, 0.2) 0%, rgba(10, 12, 16, 0.92) 75%); }
.hero__top { position: absolute; left: var(--gutter); top: 16px; display: flex; gap: 12px; align-items: center; }
.hero__back { color: var(--muted); }
.hero__content {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 18px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
}
.hero__main { min-width: 0; }
.hero__eyebrow { color: var(--accent); }
.hero__title { display: block; font-size: 40px; line-height: 1; margin-top: 6px; overflow-wrap: anywhere; }
.hero__title:hover { color: var(--ink); }
.hero__line { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.hero__time { font-size: 38px; line-height: 1; font-weight: 700; }
.hero__player { font-size: 16px; font-weight: 600; }
.hero__gap { color: var(--bad); font-size: 16px; }
.hero__meta { color: var(--muted); }
.hero__note { margin-top: 12px; color: var(--muted); }
.hero__stats { display: none; gap: 12px; }
.hero .btn-outline { display: none; }
.stat { padding: 14px 18px; background: rgba(10, 12, 16, 0.7); border: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.stat__value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat__sub { color: var(--muted); font-size: 13px; }

/* player header (no image) */
.page-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 24px var(--gutter); }
.page-head__inner { display: flex; flex-direction: column; gap: 20px; }
.page-head__top { display: flex; gap: 12px; align-items: center; }
.page-head__title { font-size: 40px; line-height: 0.95; margin-top: 10px; overflow-wrap: anywhere; }
.page-head__sub { margin-top: 8px; color: var(--muted); }
.page-head__sub b { font-weight: 400; color: var(--ink); }
.page-head__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ---------- sections & grids ---------- */
.section { padding: 24px var(--gutter) 0; }
.section--last { padding-bottom: 28px; }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 14px; margin-bottom: 10px; }
.section__head .search--filter { flex: 1 1 100%; }
.section__head--center { align-items: center; }
.section__title { font-size: 24px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.section__title .label { font-size: 12px; }
.section__title .text-muted { font-weight: 700; }
.section__count { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
.section__right { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; }
.grid-12 > * { grid-column: span 12; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.grid-2 > * { min-width: 0; }
.stack-24 > * + * { margin-top: 24px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding-bottom: 8px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; flex: 0 0 auto;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- range toggle ---------- */
.range { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 4px; flex: 0 0 auto; }
.range__btn {
  font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 3px; color: var(--muted); white-space: nowrap;
}
.range__btn:hover { color: var(--ink); }
.range__btn.is-active { background: rgba(255, 255, 255, 0.1); color: var(--ink); }

/* ---------- tables ---------- */
.table { --cols: 1fr 90px; }
.table__head, .table__row {
  display: grid; grid-template-columns: var(--cols-sm, var(--cols)); gap: 10px; align-items: center;
}
.table__head { padding: 0 4px 8px; }
.table__head > * { min-width: 0; }
.table__row { padding: 0 4px; min-height: 48px; border-top: 1px solid var(--line); }
.table__row > * { min-width: 0; }
.table__row:hover { background: var(--hover); }
.table__row--last { border-bottom: 1px solid var(--line); }
.table__row--compact { min-height: 42px; }
.table__row--tight { min-height: 40px; }
.table__row--me { background: var(--accent-tint); }
.table__row--me:hover { background: var(--accent-tint); }
.table__row a { font-weight: 600; }
.table__row a.text-muted { font-weight: 400; }
.table__name { font-weight: 600; font-size: 14px; }
.table__cell--muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.table__row .sub a { font-weight: 400; }
/* phone: two-line stack — first cell + number column on line 1, .sub cells on line 2 */
.table__row--stack { display: flex; flex-wrap: wrap; align-items: center; row-gap: 0; column-gap: 10px; padding: 8px 4px; }
.table__row--stack::before { content: ''; order: 2; flex: 0 0 100%; height: 0; }
.table__row--stack > * { order: 0; }
.table__row--stack > :first-child { flex: 1 1 0; min-width: 0; order: 0; }
.table__row--stack > .table__num { order: 1; flex: 0 0 auto; margin-left: auto; text-align: right; }
.table__row--stack > .sub { order: 3; flex: 0 0 auto; margin-top: 2px; }
.table__row--stack > .sub ~ .sub::before { content: '· '; }
:where(.table__row--stack > .sub) a { font-weight: 400; color: var(--muted); }
:where(.table__row--stack > .sub) a:hover { color: var(--accent); }
.table__note { margin-top: 12px; color: var(--muted); font-size: 13px; }

/* rank numbers */
.rank { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1; color: var(--muted); letter-spacing: 0.03em; }
.rank--gold { color: var(--gold); }
.rank--silver { color: var(--silver); }
.rank--bronze { color: var(--bronze); }
.rank--sm { font-size: 20px; }

/* bars */
.bar { height: 5px; border-radius: 2px; background: var(--accent); max-width: 100%; }
.bar--accent { background: var(--accent); }
.bar--soft { background: var(--accent-soft); }
.bar--gold { background: var(--gold); }
.bar--silver { background: var(--silver); }
.bar--bronze { background: var(--bronze); }
.bar--under { margin-top: 5px; }
.bar-stack { display: flex; gap: 3px; margin-top: 5px; overflow: hidden; }
.bar-stack--inline { margin-top: 0; }

/* ---------- tiles ---------- */
.tile { background: var(--surface); border: 1px solid var(--line); overflow: hidden; min-width: 0; }
.tile__img { width: 100%; height: 140px; object-fit: cover; }
.tile__placeholder {
  display: flex; align-items: center; justify-content: center; height: 140px;
  background: repeating-linear-gradient(135deg, #12151c 0 12px, #161a22 12px 24px);
}
.tile__caption { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 12px; }
.tile__caption a, .tile__name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__caption span { flex: 0 0 auto; white-space: nowrap; }
.tile-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* ---------- stat cards ---------- */
.stat-card { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.stat-card__label { }
.stat-card__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.stat-card__value--display { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 22px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card__sub { font-size: 13px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.stat-grid--3 .stat-card { padding: 10px 12px; }
.stat-grid--3 .stat-card__value { font-size: 22px; margin-top: 0; }

/* ---------- chart panel ---------- */
.chart-panel { background: var(--surface); border: 1px solid var(--line); padding: 10px 12px 4px; min-width: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-bottom: 8px; }
.chart-legend__swatch { display: inline-block; vertical-align: -1px; margin-right: 6px; }
.chart-legend__swatch.is-bar { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.chart-legend__swatch.is-marker { width: 8px; height: 8px; background: var(--records); transform: rotate(45deg); vertical-align: 0; margin-right: 8px; }
.chart-legend__swatch.is-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.chart-legend__swatch.is-dot--records { background: var(--records); }
.chart-legend__swatch.is-line { width: 18px; height: 0; border-top: 2px dashed var(--records); vertical-align: 3px; }
.chart-legend__note { margin-left: auto; }
.chart { position: relative; min-width: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; outline: none; }
.chart svg:focus-visible { outline: 1px dashed var(--line-strong); outline-offset: 4px; }
.chart-toggle { display: flex; justify-content: flex-end; gap: 4px; margin-top: 6px; }
.chart-toggle__btn {
  font-family: var(--font-display); font-weight: 600; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); padding: 2px 8px; border-radius: 3px;
}
.chart-toggle__btn:hover { color: var(--ink); }
.chart-toggle__btn.is-active { color: var(--ink); background: rgba(255, 255, 255, 0.08); }
.chart-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.chart-table th { font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); text-align: right; padding: 4px 8px 8px; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table td { text-align: right; padding: 6px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.chart-table tr:hover td { background: var(--hover); }
.chart-table__wrap { max-height: 320px; overflow: auto; }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; line-height: 1.4; vertical-align: 1px; }
.chip--accent { background: var(--accent); color: var(--accent-contrast); }
.chip--classic { background: var(--classic); color: #0a0c10; }
.chip--pure { background: var(--pure-soft); color: var(--pure); }
.chip--pure-solid { background: var(--pure); color: #0a0c10; }
.chip--rx { background: rgba(255, 255, 255, 0.12); color: var(--silver); }

/* ---------- buttons & links ---------- */
.btn-outline {
  display: inline-block; padding: 12px 22px; border: 1px solid var(--ink); white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.2;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.link-more { display: inline-block; margin-top: 12px; color: var(--accent); }
.link-more:hover { color: var(--ink); }
.link-pure { color: var(--pure); }

/* ---------- footer ---------- */
.footer { padding: 16px var(--gutter) 24px; line-height: 1.8; }
.footer span { display: block; }

/* ==========================================================================
   Desktop (768+)
   ========================================================================== */
@media (min-width: 768px) {
  :root { --gutter: 32px; }
  .label { font-size: 13px; }
  .section__title .label { font-size: 13px; }

  /* topbar */
  .topbar { flex-wrap: nowrap; height: 68px; }
  .topbar::after { content: none; }
  .topbar + .stripe { display: block; }
  .topbar__logo { height: auto; gap: 12px; font-size: 28px; }
  .topbar__logo svg { width: 26px; height: 26px; }
  .topbar__nav { display: flex; }
  .topbar__icons { display: none; }
  .topbar .search { display: flex; order: 0; flex: 0 0 220px; width: 220px; height: 36px; margin: 0; }
  .topbar.is-menu-open .topbar__nav { order: 0; flex: 0 0 auto; gap: 28px; margin-top: 0; }
  .topbar.is-menu-open .topbar__nav .search { display: flex; }
  .mode-switch { order: 0; flex: 0 0 auto; display: flex; gap: 6px; margin: 0; }
  .mode-switch__btn { padding: 6px 20px; }
  .search { height: 36px; }
  .search--filter { width: 320px; }

  /* hero */
  .hero { height: 420px; margin-top: 0; }
  .hero--home { height: 440px; }
  .hero--map { height: 420px; }
  .hero__shade { background: linear-gradient(90deg, rgba(10, 12, 16, 0.96) 0%, rgba(10, 12, 16, 0.7) 50%, rgba(10, 12, 16, 0.2) 100%); }
  .hero--home .hero__shade { background: linear-gradient(90deg, rgba(10, 12, 16, 0.96) 0%, rgba(10, 12, 16, 0.75) 45%, rgba(10, 12, 16, 0.15) 100%); }
  .hero__top { top: 36px; }
  .hero__content { bottom: 40px; gap: 32px; }
  .hero--home .hero__content { bottom: 44px; }
  .hero__title { font-size: 64px; line-height: 0.95; margin-top: 10px; }
  .hero__line { gap: 18px; margin-top: 14px; flex-wrap: nowrap; }
  .hero--map .hero__line { margin-top: 16px; }
  .hero__time { font-size: 48px; }
  .hero__player { font-size: 18px; }
  .hero__gap { font-size: 18px; }
  .hero__holder { padding-bottom: 6px; }
  .hero__holder-name { font-size: 18px; }
  .hero__holder-meta { color: var(--muted); margin-top: 2px; }
  .hero__note { margin-top: 18px; }
  .hero__stats { display: flex; flex: 0 0 auto; }
  .hero .btn-outline { display: inline-block; }

  /* player header */
  .page-head { padding: 36px var(--gutter); }
  .page-head__inner { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 40px; }
  .page-head__title { font-size: 64px; margin-top: 12px; }
  .page-head__sub { margin-top: 10px; }
  .page-head__stats { display: flex; gap: 12px; }
  .page-head__stats .stat-card { min-width: 140px; }

  /* sections */
  .section { padding: 40px var(--gutter) 0; }
  .section--lg { padding-top: 44px; }
  .section--last { padding-bottom: 48px; }
  .section__head { flex-wrap: nowrap; margin-bottom: 14px; }
  .section__head .search--filter { flex: 0 0 320px; }
  .section__title { font-size: 28px; }
  .section__title--sm { font-size: 26px; }
  .grid-12 > .col-8 { grid-column: span 8; }
  .grid-12 > .col-7 { grid-column: span 7; }
  .grid-12 > .col-6 { grid-column: span 6; }
  .grid-12 > .col-5 { grid-column: span 5; }
  .grid-12 > .col-4 { grid-column: span 4; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .grid-2--wide { gap: 32px; }

  /* tabs */
  .tabs { gap: 20px; overflow: visible; }
  .tab { font-size: 13px; }
  .range__btn { font-size: 13px; }

  /* tables */
  .table__head, .table__row { grid-template-columns: var(--cols); gap: 12px; }
  .table__head { padding: 0 12px 8px; }
  .table__row { padding: 0 12px; }
  .table__row--stack { display: grid; padding: 0 12px; }
  .table__row--stack::before { content: none; }
  .table__row--stack > *, .table__row--stack > :first-child, .table__row--stack > .table__num, .table__row--stack > .sub { order: 0; flex: none; margin: 0; }
  :where(.table__row--stack) > .sub { color: inherit; font-size: inherit; }
  :where(.table__row--stack > .sub) a { color: var(--ink); }
  .table__row--stack > .sub ~ .sub::before { content: none; }
  .table__name { font-size: 15px; }
  .rank { font-size: 24px; }
  .rank--sm { font-size: 20px; }
  .bar { height: 6px; }
  .bar--under, .bar-stack { margin-top: 6px; }
  .bar-stack--inline { margin-top: 0; }

  /* tiles */
  .tile__img, .tile__placeholder { height: 150px; }
  .tile__caption { padding: 12px 14px; }
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

  /* stat cards */
  .stat-grid--3 { gap: 12px; margin-bottom: 0; }
  .stat-grid--3 .stat-card { padding: 16px 18px; }
  .stat-grid--3 .stat-card__value { font-size: 30px; margin-top: 4px; }

  /* charts */
  .chart-panel { padding: 18px 20px 12px; }
  .chart-legend { margin-bottom: 14px; }
  .chart-legend--tight { margin-bottom: 12px; }

  /* footer */
  .footer { display: flex; justify-content: space-between; padding: 20px var(--gutter) 28px; line-height: 1.4; }
  .footer span { display: inline; }

}

/* ==========================================================================
   Wide (1200+) — the 1440 mockups
   ========================================================================== */
@media (min-width: 1200px) {
  :root { --gutter: 48px; }
  .hero__title { font-size: 84px; }
  .hero--map .hero__title { font-size: 72px; }
  .hero__time { font-size: 64px; }
  .hero--map .hero__time { font-size: 56px; }
  .page-head__title { font-size: 72px; }
  .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .tab, .range__btn, .mode-switch__btn, .chip, a { transition: color 0.12s, background-color 0.12s, border-color 0.12s; }
}


/* ---------- additions: classes used by the templates ---------- */
.topbar__wordmark { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.label--ink { color: var(--ink); }
.label--accent { color: var(--accent); }
.section--first { padding-top: 28px; }
.section__subhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.table--compact .table__row { min-height: 40px; }
.table__row--empty { color: var(--muted); min-height: 40px; }
.table__row--empty:hover { background: none; }
.tile-grid--wide { gap: 12px; }
.error { min-height: 40vh; }
.error__title { font-size: 40px; margin: 8px 0 12px; }
.error a { color: var(--accent); }
.heat-note { margin-top: 8px; color: var(--muted); font-size: 13px; }
@media (min-width: 768px) {
  .section--first { padding-top: 36px; }
  .tile-grid--wide { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .error__title { font-size: 56px; }
}
@media (min-width: 1200px) {
  .tile-grid--wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- utilities (last on purpose: they win over component rules) ---------- */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-silver { color: var(--silver); }
.text-bronze { color: var(--bronze); }
.text-records { color: var(--records); }
.text-pure { color: var(--pure); }
.text-accent { color: var(--accent); }
.num-good { color: var(--good); }
.num-bad { color: var(--bad); }
.bold { font-weight: 700; }
.semibold { font-weight: 600; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nowrap { white-space: nowrap; }
.fs-13 { font-size: 13px; }
.fs-15 { font-size: 15px; }
.fs-18 { font-size: 18px; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
@media (max-width: 767.98px) { .hide-sm { display: none !important; } }
@media (min-width: 768px) { .show-sm { display: none !important; } }
