/* ══════════════════════════════════════════════════════
   DESIGN TOKENS
   ══════════════════════════════════════════════════════ */
:root {
  --bg: #0a0907;            /* oklch(.139 .006 80) */
  --surface: #12100d;       /* oklch(.176 .007 80) */
  --surface2: #1d1a17;      /* oklch(.220 .008 80) */
  --surface3: #282521;      /* oklch(.267 .009 80) */
  --border: #383530;        /* oklch(.330 .010 80) */
  --border-light: rgba(56,53,48,.6);
  --text: #eeece8;          /* oklch(.943 .006 80) */
  --text2: #d2cfcb;         /* oklch(.857 .007 80) */
  --muted: #96928c;         /* oklch(.662 .010 80) */
  --blue: #58a6ff;
  --blue-bright: #79c0ff;
  --blue-dim: rgba(56,139,253,.12);
  --gold: #f0c040;
  --gold-bright: #f7d970;
  --gold-dim: rgba(240,192,64,.10);
  --green: #3fb950;
  --green-bright: #56d364;
  --green-dim: rgba(63,185,80,.10);
  --red: #f85149;
  --red-dim: rgba(248,81,73,.10);
  --orange: #d29922;
  --orange-bright: #f59e0b;
  --orange-dim: rgba(210,153,34,.10);
  --ink: #1a1a1a;
  --purple: #bc8cff;
  --purple-dim: rgba(188,140,255,.10);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: .2s ease;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --glow-blue: 0 0 20px rgba(56,139,253,.15);
  --glow-gold: 0 0 20px rgba(240,192,64,.15);

  /* Spacing scale (mobile-first) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;
  --s-7: 40px;

  /* Page gutter — base is tight for 320px; tablets+ widen it */
  --gutter: 12px;

  /* Touch target minimum (WCAG 2.5.5) */
  --touch: 48px;

  /* Type ramp (phase 4): 12px functional floor, ~1.125 steps.
     fs-1 captions/chips/meta - fs-2 secondary/table - fs-3 body -
     fs-4 panel titles - fs-5 section heads - fs-6 tab head. */
  --fs-1: .75rem;
  --fs-2: .8125rem;
  --fs-3: .875rem;
  --fs-4: .95rem;
  --fs-5: 1.1rem;
  --fs-6: 1.5rem;
}

/* ══════════════════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  overflow-x: clip;
  overscroll-behavior-y: contain;
  background-image: radial-gradient(ellipse at 50% 0%, rgba(240,192,64,.02) 0%, transparent 60%);
  background-attachment: fixed;
}
img, canvas, svg, video { max-width: 100%; height: auto; display: block; }
::selection { background: rgba(240,192,64,.25); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 0 4px rgba(240,192,64,.18);
}
/* Don't double-paint the ring on inputs that already light their border on
   focus (data-entry tables, email inputs, compare dropdown). */
input:focus-visible, select:focus-visible, textarea:focus-visible {
  box-shadow: none;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ══════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* First-run hint: one-time pointer for new visitors (splash replacement) */
.first-run-hint {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 2px; padding: 10px 14px;
  background: rgba(240,192,64,.06);
  border: 1px solid rgba(240,192,64,.25);
  border-radius: 8px;
  font-size: var(--fs-2); color: var(--text2); line-height: 1.5;
}
.first-run-hint[hidden] { display: none; }
.first-run-hint-dismiss {
  margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin-top: -6px; margin-bottom: -6px;
  background: none; border: none; color: var(--muted);
  font-size: var(--fs-5); line-height: 1; cursor: pointer;
}
.first-run-hint-dismiss:hover { color: var(--text); }

/* ══════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════ */
header {
  border-bottom: 1px solid var(--border);
  padding: max(var(--s-3), env(safe-area-inset-top)) 0 var(--s-3);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(18,16,13,.88);
  box-shadow: 0 1px 0 rgba(56,53,48,.5), 0 4px 16px rgba(0,0,0,.2);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); flex-wrap: wrap;
}
.logo {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 1.05rem; font-weight: 800; letter-spacing: -.5px;
  min-width: 0;
}
.logo-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), #e6a817);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #000;
  box-shadow: 0 2px 12px rgba(240,192,64,.25);
}
.logo span { color: var(--gold); }
.header-right {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
}
/* Tournament search button (header) — opens the command palette. Visible
   trigger because the user base skews older and hotkeys aren't load-bearing
   here. Sized to a tappable 32px+ min-height. */
.search-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px 6px 12px;
  color: var(--text2);
  font-size: var(--fs-2); font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  min-height: 32px;
}
.search-btn:hover {
  border-color: var(--blue);
  background: var(--surface3);
  color: var(--text);
}
.search-btn-icon { font-size: var(--fs-4); opacity: .8; }
.search-btn-kbd {
  display: inline-block; margin-left: 4px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-1); font-weight: 600;
  line-height: 1.4;
}
@media (max-width: 639px) {
  .search-btn-text, .search-btn-kbd { display: none; }
  .search-btn { padding: 6px 10px; }
}

/* ── Command palette modal ── */
.cmdk[hidden] { display: none; }
.cmdk {
  position: fixed; inset: 0;
  z-index: 10000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: cmdkFadeIn .15s ease-out;
}
@keyframes cmdkFadeIn { from { opacity: 0; } to { opacity: 1; } }
.cmdk-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cmdk-panel {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  animation: cmdkSlideUp .25s cubic-bezier(.22,1,.36,1);
}
@keyframes cmdkSlideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.cmdk-input-icon { font-size: var(--fs-5); color: var(--muted); }
.cmdk-input {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
}
.cmdk-input::placeholder { color: var(--muted); }
.cmdk-close {
  background: none; border: none;
  color: var(--muted);
  font-size: 1.4rem; line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  min-height: 32px;
}
.cmdk-close:hover { background: var(--surface3); color: var(--text); }
.cmdk-results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-empty {
  padding: 32px var(--s-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-3);
}
.cmdk-recent {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; padding: 8px 10px;
  border-bottom: 1px dashed var(--border-light);
  margin-bottom: 6px;
}
.cmdk-recent-label {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.cmdk-recent-chip {
  padding: 6px 10px; min-height: 32px;
  border-radius: 100px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: var(--fs-2); font-weight: 600;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.cmdk-recent-chip:hover { border-color: var(--blue); color: var(--blue); }
.cmdk-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 10px 12px;
  background: none; border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-3);
  transition: background .12s;
}
.cmdk-row:hover, .cmdk-row-active { background: var(--surface2); }
.cmdk-row-active { box-shadow: inset 0 0 0 1px var(--blue); }
.cmdk-row-status {
  font-size: var(--fs-1); font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
}
.cmdk-status-live { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.cmdk-status-complete { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,139,253,.3); }
.cmdk-status-hist { background: var(--surface3); color: var(--muted); border: 1px solid var(--border); }
.cmdk-row-name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.cmdk-row-year { color: var(--muted); font-weight: 500; margin-left: 4px; }
.cmdk-row-num {
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-3);
}
@media (max-width: 639px) {
  .cmdk { padding-top: 6vh; }
  .cmdk-row { grid-template-columns: 48px 1fr auto; padding: 10px; }
  .cmdk-input { font-size: 1rem; }
  .cmdk-results { max-height: 60vh; }
}

/* Sticky scroll-context header strip removed in iter 23 — it duplicated
   the hero numbers a few inches above where they already lived. The
   header is back to logo + tournament label + search + last-updated. */
.header-meta { font-size: var(--fs-2); color: var(--muted); }
.header-tourn-label {
  display: flex; align-items: center; gap: var(--s-2);
  min-width: 0; max-width: 100%;
}
.header-tourn-label #tournLabel {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* Single source for the desktop width; the <640px block widens it to 22ch
     for the chevron. (Was three scattered rules: 16ch base / 22ch / 20ch.) */
  max-width: 20ch;
}

/* ══════════════════════════════════════════════════════
   TOURNAMENT SELECTOR
   ══════════════════════════════════════════════════════ */
.tab-bar {
  display: flex; gap: var(--s-2); padding: var(--s-4) 0 0;
  flex-wrap: wrap; align-items: center;
}
.cat-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  min-height: var(--touch);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2); font-size: var(--fs-2); font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap; user-select: none;
}
.cat-btn:hover { border-color: var(--blue); color: var(--text); background: var(--surface3); }
.cat-btn.open { border-color: var(--blue); background: var(--blue-dim); color: var(--text); }
/* Category tint replaces the prior `border-left: 3px solid <color>`
   side-stripe inline style (banned side-stripe anti-pattern). The full
   1px border picks up the category color at low opacity; background
   sits at the matching -dim token. */
.cat-btn--live      { border-color: rgba(63,185,80,.45);  background: rgba(63,185,80,.06); }
.cat-btn--complete  { border-color: rgba(56,139,253,.45); background: rgba(56,139,253,.06); }
.cat-btn--hist      { border-color: rgba(188,140,255,.45); background: rgba(188,140,255,.06); }
.cat-btn--live:hover,
.cat-btn--complete:hover,
.cat-btn--hist:hover { color: var(--text); background: var(--surface3); }
.cat-btn .cat-count {
  background: var(--surface3); padding: 1px 7px; border-radius: 100px;
  font-size: var(--fs-1); color: var(--muted);
}
.tab-search-panel {
  position: absolute; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 200; overflow: hidden;
  max-width: calc(100vw - 24px);
}
.tab-search-bar {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.tab-search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: var(--fs-4); font-family: inherit;
  min-height: var(--touch);
}
.tab-search-input::placeholder { color: var(--muted); }
.tab-search-results { max-height: 50vh; overflow-y: auto; }
.cat-arrow { font-size: var(--fs-1); color: var(--muted); transition: transform .15s; }
.cat-btn.open .cat-arrow { transform: rotate(180deg); }
.drop-wrap { position: relative; }
.drop-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: min(320px, calc(100vw - 24px));
  max-height: 60vh; overflow-y: auto;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0,0,0,.15); z-index: 200;
  animation: dropSlide .15s ease;
}
@keyframes dropSlide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.drop-menu-search { overflow: hidden; }
.drop-menu-search .tab-search-results { max-height: 50vh; overflow-y: auto; }
.cat-item {
  padding: 10px 14px;
  min-height: var(--touch);
  font-size: var(--fs-3); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  border-bottom: 1px solid rgba(56,53,48,.2); transition: background .1s; color: var(--text2);
}
.cat-item:hover { background: var(--surface2); color: var(--text); }
.cat-item.highlighted { background: var(--surface2); color: var(--text); outline: 2px solid var(--blue); outline-offset: -2px; }
.cat-item.active { color: var(--blue); background: var(--blue-dim); font-weight: 600; }
.cat-item:last-child { border-bottom: none; }
.cat-item-name { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.cat-item-meta { font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.tab-sep {
  width: 1px; height: 24px; background: var(--border); margin: 0 4px; align-self: center;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }

/* ══════════════════════════════════════════════════════
   DELTA BANNER
   ══════════════════════════════════════════════════════ */
.delta-banner {
  border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin: var(--s-4) 0;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  transition: all .3s ease;
}
.delta-banner.green { background: var(--green-dim); border: 1px solid rgba(63,185,80,.35); box-shadow: 0 0 30px rgba(63,185,80,.05); }
.delta-banner.gold { background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }
.delta-banner.red { background: var(--red-dim); border: 1px solid rgba(248,81,73,.35); box-shadow: 0 0 30px rgba(248,81,73,.05); }
.delta-banner.muted { background: var(--surface2); border: 1px solid var(--border); }
.delta-icon { font-size: 1.2rem; }
.delta-text { flex: 1 1 200px; min-width: 0; }
.delta-main { font-size: 1rem; font-weight: 700; }
.delta-sub { font-size: var(--fs-3); color: var(--muted); margin-top: 3px; }
/* Multi-year at-T pace context. Lives inside the delta banner as a sub-line
   beneath delta-sub, replacing the standalone "lightning bolt" banner that
   used to stack below this one. Hidden via :empty so tournaments without a
   pace_alert don't render an extra gap. */
.delta-context {
  font-size: var(--fs-2);
  color: var(--muted);
  opacity: .8;
  margin-top: 5px;
  line-height: 1.4;
}
.delta-context:empty { display: none; }
.delta-value {
  font-size: 1.4rem; font-weight: 900; margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.delta-value.green { color: var(--green-bright); }
.delta-value.gold { color: var(--gold-bright); }
.delta-value.red { color: var(--red); }

/* ══════════════════════════════════════════════════════
   MOBILE PREDICTIONS REORIENTATION (< 640px)
   ──────────────────────────────────────────────────────
   Flips #panel-predictions into a flex-column on mobile so we can use
   `order:` to put the hero (882) ABOVE the tournament-browser dropdowns,
   following the inverted-pyramid dashboard pattern. Source order in
   index.html stays the same so desktop (>=640px) is completely untouched.
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  /* L1 (CRITICAL): keep inactive tab panels hidden on phones. The
     `#panel-predictions { display: flex }` rule below has ID specificity and
     otherwise beats `.page-tab-panel { display: none }`, leaving Predictions
     rendered under every other tab and burying the tapped panel far off-screen.
     This mobile-scoped counter-rule (previously only in @media print) fixes it. */
  .page-tab-panel:not(.active) { display: none !important; }

  /* --- Hide redundant chrome on phones --- */
  #summaryBar { display: none !important; }   /* duplicates dropdown counts + mini-grid */
  .header-meta { display: none; }              /* "Updated:" timestamp eats vertical space */

  /* --- Predictions panel: flex column with explicit order (only when active) --- */
  #panel-predictions.active {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
  }
  /* Reset margin/padding on direct children so the gap controls vertical rhythm */
  #panel-predictions > * { margin-top: 0; margin-bottom: 0; }

  /* Inverted-pyramid order (smaller = higher on screen) */
  #panel-predictions > #skeletonLoader { order: 0; }
  #panel-predictions > .hero           { order: 1; }
  #panel-predictions > .delta-banner   { order: 2; }
  #panel-predictions > .chart-card     { order: 3; }
  #panel-predictions > #tabBar         { order: 4; }   /* 3 category dropdowns, now below the hero+chart */
  #panel-predictions > .calendar-strip { order: 5; }
  #panel-predictions > .accuracy-strip { order: 6; }
  #panel-predictions > .mini-grid      { order: 7; }
  #panel-predictions > .kpi-row        { order: 8; }
  #panel-predictions > .progress-row   { order: 9; }
  #panel-predictions > #sect-milestones { order: 10; }
  #panel-predictions > #sect-curve      { order: 11; }
  #panel-predictions > #sect-model      { order: 12; }
  #panel-predictions > #sect-table      { order: 13; }

  /* --- Delta banner: tighter, single-row feel --- */
  .delta-banner {
    padding: var(--s-2) var(--s-3);
    margin: 0;
    gap: var(--s-2);
  }
  .delta-icon { font-size: 1rem; }
  .delta-main { font-size: var(--fs-3); }
  .delta-sub { font-size: var(--fs-1); line-height: 1.35; margin-top: 1px; }
  .delta-value { font-size: var(--fs-5); }

  /* --- Hero: a touch more vertical breathing as the hero card --- */
  .hero { padding-top: var(--s-3); padding-bottom: var(--s-3); }

  /* --- Tournament browser: slim horizontal chip strip (compact, all 3 visible) --- */
  #tabBar.tab-bar {
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    padding: var(--s-2) 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000, #000 calc(100% - 24px), transparent);
  }
  #tabBar.tab-bar::-webkit-scrollbar { display: none; }
  #tabBar.tab-bar .drop-wrap { width: auto; flex-shrink: 0; }
  #tabBar.tab-bar .cat-btn {
    width: auto;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: var(--fs-2);
    border-left-width: 0 !important;        /* override the inline 3px colored border */
    border: 1px solid var(--border);
    background: var(--surface2);
    min-height: 44px;
  }
  #tabBar.tab-bar .cat-btn .cat-count { font-size: var(--fs-1); padding: 1px 6px; }
  /* v4 W2: .5rem (8px) sat under the type ramp's 12px functional floor. */
  #tabBar.tab-bar .cat-btn .cat-arrow { font-size: var(--fs-1); }
}

/* Lock body scroll while a bottom-sheet drawer is open (feels native, prevents
   the page from scrolling behind the drawer). Round 16 added the scrim; this
   completes the modal lock. */
body.drawer-open { overflow: hidden; touch-action: none; }
/* Keep the back-to-top FAB (z-index 900) from painting over the picker sheet
   and dismissing it on tap while the drawer is open. */
body.drawer-open .back-to-top { display: none !important; }

/* ══════════════════════════════════════════════════════
   MOBILE UNIFIED TOURNAMENT PICKER (< 640px only)
   ──────────────────────────────────────────────────────
   Modal bottom sheet with iOS HIG segmented control + filterable lists.
   Replaces the 3 cat-btn pills (still used on desktop). Trigger is the
   header tournament label (Spotify "Now Playing" pattern).
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  /* Hide the 3 cat-btn pills entirely on phones — picker covers all 3 */
  #panel-predictions > #tabBar { display: none; }

  /* Trigger affordance: clearly button-like (subtle chip with border + colored
     chevron) so users discover that the tournament name is the picker. */
  #headerTournLabel {
    cursor: pointer;
    border-radius: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    transition: background .15s, border-color .15s, transform .12s;
  }
  #headerTournLabel:active {
    background: var(--surface3);
    border-color: var(--blue);
    transform: scale(.98);
  }
  #tournLabel::after {
    content: ' \25BE';
    font-size: var(--fs-2);
    color: var(--blue);
    margin-left: 6px;
    font-weight: 700;
  }

  /* Picker drawer base styles inherit from .drop-menu (round 12 bottom-sheet);
     this overrides the layout for the unified picker shell. */
  .drop-menu-tourney {
    padding: 0;
  }
  .drop-menu-tourney::before {
    /* drag handle inherited from .drop-menu, ensure it's visible */
    margin: 10px auto 6px;
  }
  .tourney-picker-header {
    padding: var(--s-2) var(--s-4) 0;
    background: transparent;
  }
  .tourney-picker-body {
    padding: var(--s-2) 0 var(--s-4);
    overflow-y: auto;
    max-height: calc(82vh - 72px);
  }
  .tourney-picker-body .tab-search-bar {
    margin: 0 var(--s-4) var(--s-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
  }

  /* Segmented control (iOS HIG ≤5 segments — we have 3) */
  .seg-control {
    display: flex;
    gap: 2px;
    background: var(--surface3);
    padding: 3px;
    border-radius: 10px;
    margin: 0 0 var(--s-2);
  }
  .seg-btn {
    flex: 1 1 0;
    padding: 8px 10px;
    min-height: 36px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    font-size: var(--fs-3);
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
  }
  .seg-btn .seg-count {
    font-size: var(--fs-1);
    background: rgba(255,255,255,.06);
    padding: 1px 6px;
    border-radius: 100px;
    color: var(--muted);
  }
  .seg-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
  }
  .seg-btn.active .seg-count { background: var(--gold-dim); color: var(--gold); }
  .seg-btn:active { transform: scale(.97); }

  /* List styles inside the picker — full-width tap targets */
  .tourney-list { padding: 0 var(--s-2); }
  .tourney-list .cat-item {
    padding: 12px var(--s-3);
    border-radius: 8px;
  }
  .tourney-list .cat-item.active {
    background: var(--gold-dim);
    color: var(--gold);
  }
}
@media (min-width: 640px) {
  /* Desktop safety: ensure the unified picker is fully suppressed and the
     trigger affordance never shows. */
  #dropMenu_tourney { display: none !important; }
  #tournLabel::after { content: none; }
}

/* ══════════════════════════════════════════════════════
   MOBILE CHART COMPACTNESS (< 640px)
   ──────────────────────────────────────────────────────
   Reclaim chrome (title/legend/card padding) so the actual plot area
   gets more screen real estate. Also widen the tournament label cap
   to fit "Chicago Open 2026 ▾" without ellipsis.
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  /* Header tournament label: widen past the 20ch desktop base to fit the chevron. */
  .header-tourn-label #tournLabel { max-width: 22ch; }
  /* Tighter chart-card padding gives the canvas ≈16px more horizontal room. */
  .chart-card { padding: var(--s-3); min-height: 280px; }
  /* More plot area on mobile (was 300px). With title+legend ~75px overhead,
     this gives ≈265px of actual chart so the trajectory line reads cleanly
     at phone widths. */
  .chart-wrap { height: 340px; }
  /* Subtitle smaller AND single-line on mobile — wrapping to 2-3 lines
     was eating ~30px of plot area on long family names ("World Open
     Under 13 Championship 2026 — Registration Trajectory · Early bird
     in 16d"). Truncate with ellipsis; full text is still visible via
     the title attribute on long-press. */
  .chart-subtitle {
    font-size: var(--fs-1); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
  }
  /* Stack chart title + legend vertically on mobile so neither is cramped. */
  .chart-top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }
  .chart-top-right { align-items: flex-start; }
  /* Compare/hist chart inline-height divs also need the bump. */
  #histChart, #regCurveChart { /* canvas inherits parent height attr */ }
}

/* ══════════════════════════════════════════════════════
   HERO KPI
   ══════════════════════════════════════════════════════ */
.hero {
  padding: var(--s-5) 0 var(--s-4);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  align-items: start;
}
.hero-primary { min-width: 0; }
.hero-week { min-width: 0; }
.hero-week-label {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px;
}
.hero-week-bars {
  display: flex; flex-direction: column; gap: 2px;
  justify-content: center; height: calc(100% - 18px);
}
.hero-week-empty {
  font-size: var(--fs-1);
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 12px 8px;
  opacity: .7;
}
.hero-kpis {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
}
/* Desktop / tablet: editorial stat strip. Strip the card chrome
   (background, border, hover transform, box-shadow) and replace
   internal cards with vertical-divider columns. Numbers grow,
   labels shrink, the whole hero KPI row reads as a single
   instrument cluster rather than four floating boxes. */
@media (min-width: 768px) {
  .hero-kpis {
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: var(--s-3) 0;
    background: linear-gradient(180deg, rgba(255,255,255,.01), transparent);
  }
  .hero-kpis .kpi-card {
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding: 0 var(--s-4);
    transition: none;
  }
  .hero-kpis .kpi-card:first-child { border-left: none; }
  .hero-kpis .kpi-card:hover {
    border-color: transparent;
    box-shadow: none;
    transform: none;
  }
  .hero-kpis .kpi-card:first-child:hover { border-left: none; }
  .hero-kpis .kpi-card:not(:first-child):hover { border-left-color: var(--border); }
  .hero-kpis .kpi-label {
    font-size: var(--fs-1);
    letter-spacing: 1px;
    margin-bottom: 6px;
  }
  .hero-kpis .kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.015em;
  }
  .hero-kpis .kpi-sub {
    font-size: var(--fs-1);
    margin-top: 6px;
  }
}
.hero-label {
  font-size: var(--fs-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
  margin-bottom: 8px;
}
.hero-number {
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  font-weight: 900;
  line-height: 1; letter-spacing: -2px;
  color: var(--gold);
  position: relative;
}
.hero-number::after {
  content: '';
  position: absolute;
  inset: -20px -30px;
  background: radial-gradient(ellipse, rgba(240,192,64,.06) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}
.hero-ci {
  font-size: 1rem; color: var(--muted); margin-top: 14px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.005em;
  max-width: 360px;
}
/* Hero narrative — plain-English summary beneath the CI bar. Reads as a
   single short paragraph; the comparison verdict is highlighted via
   .hn-verdict pos/neg/flat colors so the eye lands on the qualitative
   call before parsing the rest. */
.hero-narrative {
  margin-top: 16px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text2);
  max-width: 600px;
}
.hero-narrative p { margin: 0; }
.hero-narrative strong {
  color: var(--text); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hn-verdict { font-weight: 700; }
.hn-pos { color: var(--green); }
.hn-neg { color: var(--red); }
.hn-flat { color: var(--gold); }
@media (max-width: 639px) {
  .hero-narrative { font-size: var(--fs-3); line-height: 1.5; margin-top: 10px; }
}

/* Mobile bottom-nav: removed in iter 22. Top page-tabs strip already
   serves both desktop and mobile; the duplicate bottom nav was extra
   chrome for an audience that isn't gesture/thumb-first. */

/* Confidence breakdown panel removed in iter 25 — the hero narrative +
   confidence badge cover the same ground in plain English. */

/* Festival cluster — sibling sub-events of a multi-event festival
   (e.g. World Open's three sub-events). Renders below the hero
   narrative when applicable. Each card switches the selected
   tournament; the active one carries a gold border. */
.festival-cluster:empty { display: none; }
.festival-cluster {
  margin-top: 16px;
  max-width: 560px;
}
.fc-head {
  display: flex; align-items: baseline; gap: var(--s-2);
  margin-bottom: 8px;
}
.fc-title {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
}
.fc-sub {
  font-size: var(--fs-1); color: var(--muted);
  opacity: .7;
}
.fc-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
}
.fc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  min-width: 0;
}
.fc-card:hover {
  border-color: var(--gold);
  background: var(--surface2);
  transform: translateY(-1px);
}
.fc-card-active {
  border-color: var(--blue);
  background: var(--blue-dim);
  box-shadow: 0 0 0 1px var(--blue);
}
.fc-card-label {
  font-size: var(--fs-1); font-weight: 700;
  color: var(--text2);
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-card-active .fc-card-label { color: var(--blue); }
.fc-card-num {
  font-size: var(--fs-5); font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  margin: 2px 0;
}
.fc-card-sub {
  font-size: var(--fs-1); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hero-ci strong { color: var(--text); font-weight: 700; }
.ci-final { color: var(--text2); font-weight: 600; }

/* ── Confidence-interval visualization ──
   The point estimate is the headline number (.hero-number). The CI bar
   below it shows the 80% range visually with the point estimate marker
   positioned proportionally. Avoids the prior "175 — 219 (80% CI)" wall
   of text by encoding the range as a visual scale. */
.ci-bar {
  display: flex; align-items: center;
  gap: 10px; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.ci-bound {
  font-size: var(--fs-4); font-weight: 700; color: var(--text2);
  flex-shrink: 0; min-width: 2.5ch; text-align: center;
}
.ci-bound-lo { text-align: right; }
.ci-bound-hi { text-align: left; }
.ci-track {
  flex: 1; position: relative;
  height: 6px; border-radius: 100px;
  background: var(--surface3);
  overflow: visible;
}
/* Subtle CI band tint — green at lower bound, gold center, soft edge at upper. */
.ci-track-fill {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    rgba(63,185,80,.35) 0%,
    rgba(240,192,64,.55) 50%,
    rgba(248,81,73,.30) 100%);
}
.ci-marker {
  position: absolute; top: 50%;
  width: 14px; height: 14px; border-radius: 100px;
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--text2), 0 2px 6px rgba(0,0,0,.4);
  transform: translate(-50%, -50%);
  transition: left .5s cubic-bezier(.22,1,.36,1);
  pointer-events: auto; cursor: help;
}
.ci-meta {
  margin-top: 8px;
  font-size: var(--fs-2); color: var(--muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}

/* KPI Cards */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.kpi-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kpi-label {
  font-size: var(--fs-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 1.45rem; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.kpi-sub { font-size: var(--fs-2); color: var(--muted); margin-top: 6px; }
.v-blue { color: var(--blue); }
.v-gold { color: var(--gold); }
.v-green { color: var(--green); }
.v-orange { color: var(--orange); }
.v-red { color: var(--red); }
.v-purple { color: var(--purple); }

/* ══════════════════════════════════════════════════════
   PROGRESS BARS
   ══════════════════════════════════════════════════════ */
.progress-row {
  display: grid; grid-template-columns: 1fr; gap: var(--s-4);
  margin: var(--s-4) 0;
}
.progress-header {
  display: flex; justify-content: space-between;
  font-size: var(--fs-2); color: var(--muted); margin-bottom: 6px;
}
.progress-header span:last-child { color: var(--text); font-weight: 600; }
.progress-bar {
  height: 7px; background: var(--surface3);
  border-radius: 4px; overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }
.pf-blue { background: linear-gradient(90deg, #1c3a6e, var(--blue)); box-shadow: 0 0 8px rgba(56,139,253,.2); }
.pf-gold { background: linear-gradient(90deg, #3a2e00, var(--gold)); box-shadow: 0 0 8px rgba(240,192,64,.2); }
.pf-green { background: linear-gradient(90deg, #0d2a1a, var(--green)); box-shadow: 0 0 8px rgba(63,185,80,.2); }

/* ══════════════════════════════════════════════════════
   CHART
   ══════════════════════════════════════════════════════ */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  transition: opacity .25s ease, border-color .3s;
  position: relative;
}
/* Chart card has no click affordance, so don't fake one on hover.
   Keep the .live-glow accent (separate rule below) since that's
   semantic — live tournaments visually distinct from completed. */
.chart-card.live-glow {
  border-color: rgba(56,139,253,.3);
  box-shadow: 0 0 30px rgba(56,139,253,.06), 0 0 60px rgba(240,192,64,.03);
}
.chart-top {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: var(--s-3);
  flex-wrap: wrap; gap: var(--s-3);
}
.chart-title { margin: 0; font-weight: 700; font-size: var(--fs-4); }
.chart-subtitle { font-size: var(--fs-2); color: var(--muted); margin-top: 2px; }
.chart-top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.chart-legend { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
.chart-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chart-seg button {
  padding: 4px 10px;
  background: var(--surface2); color: var(--text2);
  font-size: var(--fs-1); font-weight: 600;
  border: none; cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.chart-seg button:last-child { border-right: none; }
.chart-seg button.active { background: var(--gold); color: var(--ink); font-weight: 700; }
.chart-seg button:disabled { opacity: .45; cursor: default; }
/* v4 W3: min-width too — the render pass measured All/90d/30d at 37-42px wide
   on a 390px viewport; height alone met the 44px target. */
@media (pointer: coarse) { .chart-seg button { min-height: 44px; min-width: 44px; } }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2); color: var(--muted); }
@media (max-width: 639px) {
  .chart-legend { gap: var(--s-2); }
  .legend-item { font-size: var(--fs-1); gap: 4px; }
}
.legend-swatch { width: 16px; height: 3px; border-radius: 2px; }
.legend-swatch.dashed { background: repeating-linear-gradient(90deg, var(--gold) 0 6px, transparent 6px 10px); }
.legend-swatch.band { width: 16px; height: 10px; border-radius: 2px; opacity: .4; }
.chart-wrap { position: relative; height: 320px; }
.chart-wrap canvas { border-radius: 8px; }
.chart-mobile-dates { display: none; }
.about-jump {
  font-size: var(--fs-2); color: var(--muted);
  margin: 0 0 22px;
  display: block;
}
.about-jump a {
  color: var(--text2); text-decoration: none;
  border-bottom: 1px dashed var(--border);
  transition: color .15s, border-color .15s;
}
.about-jump a:hover, .about-jump a:focus-visible { color: var(--blue); border-bottom-color: var(--blue); }
@media (max-width: 639px) {
  .chart-mobile-dates {
    display: flex; flex-wrap: wrap; gap: 14px;
    margin-top: 8px; padding: 6px 2px 0;
    font-size: var(--fs-2); color: var(--muted);
    border-top: 1px dashed var(--border-light);
  }
  .chart-mobile-dates .cmd-eb { color: #3fb950; font-weight: 600; }
  .chart-mobile-dates .cmd-event { color: #f85149; font-weight: 600; }
}

/* ══════════════════════════════════════════════════════
   TWO-COL GRID
   ══════════════════════════════════════════════════════ */
.grid-2 {
  display: grid; grid-template-columns: 1fr;
  gap: var(--s-4); margin-bottom: var(--s-5);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  transition: border-color .2s, box-shadow .2s;
}
.panel:hover { border-color: rgba(88,166,255,.15); box-shadow: 0 2px 12px rgba(0,0,0,.15); }
.panel-title {
  margin-top: 0;
  font-size: var(--fs-1); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: var(--s-3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════════════════
   TIMELINE
   ══════════════════════════════════════════════════════ */
.timeline {
  position: relative;
  display: grid; grid-template-columns: 1fr;
  gap: var(--s-3);
  padding: var(--s-4) 0 var(--s-2);
}
.timeline-node {
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1;
}
.timeline-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface3); border: 2px solid var(--border);
  margin-bottom: 8px;
}
.timeline-dot.past { background: var(--green); border-color: var(--green); }
.timeline-dot.now { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-dim); }
.timeline-dot.future { background: var(--surface3); border-color: var(--muted); }
.timeline-label { font-size: var(--fs-1); color: var(--muted); text-align: center; }
.timeline-date { font-size: var(--fs-2); font-weight: 600; color: var(--text2); text-align: center; }
.timeline-count { font-size: var(--fs-1); color: var(--text2); margin-top: 2px; text-align: center; }

/* ── Milestone horizontal timeline strip ──
   Replaces the prior table layout. Each node is a stacked dot + label +
   date + count column. A horizontal background line runs behind the
   dots; .ms-line-past fills the line gold up to the first non-past node
   so the user sees visually where "now" sits on the journey. */
.ms-strip {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 20px 0 8px;
  margin-top: 4px;
}
.ms-line {
  position: absolute; left: 8%; right: 8%; top: 28px;
  height: 2px; background: var(--border); border-radius: 100px;
  z-index: 0;
}
.ms-line-past {
  height: 100%; background: var(--text3, var(--muted)); border-radius: 100px;
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.ms-node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  text-align: center;
  min-width: 0;
}
.ms-dot {
  width: 14px; height: 14px; border-radius: 100px;
  background: var(--surface3);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  transition: background .25s, box-shadow .25s, transform .25s;
}
.ms-node.ms-past .ms-dot {
  background: var(--text3, var(--muted));
  box-shadow: 0 0 0 1px var(--text3, var(--muted));
}
.ms-node.ms-now .ms-dot {
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 0 16px rgba(56,139,253,.5);
  transform: scale(1.15);
}
.ms-node.ms-future .ms-dot {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border-light);
}
.ms-node-label {
  font-size: var(--fs-1); font-weight: 700;
  color: var(--text2);
  margin-top: 6px;
  line-height: 1.25;
  text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.ms-node.ms-past .ms-node-label { color: var(--muted); }
.ms-node.ms-now .ms-node-label { color: var(--blue); }
.ms-node-date {
  font-size: var(--fs-1); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ms-node-count {
  font-size: var(--fs-3); font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.ms-node.ms-past .ms-node-count {
  color: var(--text2); font-weight: 600;
}
@media (max-width: 639px) {
  /* Mobile: 3-up rows. Beyond 3 nodes the labels overlap. Split the
     strip onto two rows by changing grid columns. */
  .ms-strip {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-columns: auto;
    gap: var(--s-3) 4px;
    padding-top: 16px;
  }
  .ms-line { display: none; }
  .ms-node-label { font-size: var(--fs-1); }
  .ms-node-count { font-size: var(--fs-2); }
  /* When the strip has 6+ nodes, drop dot size and column gap so labels stay readable. */
  .ms-strip:has(.ms-node:nth-child(7)) {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-2) 2px;
  }
  .ms-strip:has(.ms-node:nth-child(7)) .ms-dot { width: 10px; height: 10px; }
  .ms-strip:has(.ms-node:nth-child(7)) .ms-node-label { font-size: var(--fs-1); }
}

/* Legacy milestone table CSS retained but unused (rendering now uses
   .ms-strip). Kept for any external surfaces that still reference it. */
.milestone-table { width: 100%; border-collapse: collapse; }
.milestone-table th {
  text-align: left; font-size: var(--fs-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  padding: 8px; border-bottom: 1px solid var(--border);
}
.milestone-table td {
  padding: 8px; font-size: var(--fs-2);
  border-bottom: 1px solid var(--border-light);
}
.milestone-table tr:last-child td { border-bottom: none; }
.ms-badge {
  display: inline-block; padding: 2px 8px; border-radius: 100px;
  font-size: var(--fs-1); font-weight: 700;
}
.ms-past { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.ms-now { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,139,253,.3); }
.ms-future { background: var(--surface3); color: var(--muted); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════
   COMPARISON TABLE (historical)
   ══════════════════════════════════════════════════════ */
.comp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.comp-table { width: 100%; border-collapse: collapse; min-width: 420px; }
.comp-table th {
  text-align: left; font-size: var(--fs-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.comp-table td {
  padding: 9px 10px; font-size: var(--fs-3);
  border-bottom: 1px solid var(--border-light);
}
.comp-table tr:last-child td { border-bottom: none; }
.comp-table .current-year td { color: var(--gold); font-weight: 700; background: var(--gold-dim); }
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }

/* ── Mobile card layout for comp-table (year-over-year, < 640px) ── */
@media (max-width: 639px) {
  .comp-table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  .comp-table { display: block; min-width: 0; }
  .comp-table thead { display: none; }
  .comp-table tbody { display: block; }
  .comp-table tr {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--s-2);
    padding: var(--s-3) var(--s-4);
  }
  .comp-table tr.current-year {
    border-color: var(--gold);
    background: var(--gold-dim);
  }
  .comp-table tr.current-year td { background: transparent; }
  .comp-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
  }
  .comp-table td::before {
    content: attr(data-label);
    font-size: var(--fs-1);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .comp-table tr td:last-child { border-bottom: none; }
}

/* ══════════════════════════════════════════════════════
   MODEL INFO
   ══════════════════════════════════════════════════════ */
.model-info p {
  font-size: var(--fs-2); color: var(--muted); line-height: 1.6; margin-bottom: 8px;
}
.tag {
  display: inline-block; padding: 3px 10px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 100px; font-size: var(--fs-1); color: var(--text2);
  margin-right: 6px; margin-bottom: 6px;
}

/* ══════════════════════════════════════════════════════
   ALL TOURNAMENTS TABLE
   ══════════════════════════════════════════════════════ */
.all-tournaments { margin-bottom: var(--s-7); }
.tourney-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.tourney-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.tourney-table th {
  text-align: left; font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tourney-table th.sortable { cursor: pointer; user-select: none; position: relative; }
.tourney-table th.sortable:hover { color: var(--blue); }
.tourney-table th.sortable::after {
  content: '\21F5'; /* ⇅ both arrows — sort affordance, always visible */
  font-size: var(--fs-1); opacity: .35; margin-left: 4px;
  vertical-align: middle;
}
.tourney-table th.sortable:hover::after { opacity: .7; }
.tourney-table th.sortable.asc::after { content: '\25B2'; opacity: 1; color: var(--blue); }
.tourney-table th.sortable.desc::after { content: '\25BC'; opacity: 1; color: var(--blue); }

/* Tournament table header + controls row (title, status filter
   buttons, free-text search) lives above the table itself. */
.tt-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); margin-bottom: 16px;
  flex-wrap: wrap;
}
.tt-controls {
  display: flex; align-items: center; gap: var(--s-3);
  flex-wrap: wrap;
}
.tt-filters {
  display: flex; gap: 2px;
  padding: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
}
.tt-filter {
  background: none; border: none;
  padding: 10px 14px;
  font-size: var(--fs-2); font-weight: 600;
  color: var(--muted);
  border-radius: 100px;
  cursor: pointer;
  transition: color .15s, background .15s;
  min-height: 44px;
}
.tt-filter:hover { color: var(--text); }
.tt-filter-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.tt-search {
  display: flex; align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--s-3);
  min-width: 220px;
  transition: border-color .15s, box-shadow .15s;
}
.tt-search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.tt-search-icon { font-size: var(--fs-4); opacity: .5; margin-right: 6px; }
.tt-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: var(--fs-3);
  padding: 7px 0;
  min-height: 32px;
}
.tt-search input::placeholder { color: var(--muted); }
@media (max-width: 639px) {
  .tt-controls { width: 100%; }
  .tt-search { flex: 1; min-width: 0; }
  .tt-filters { flex-shrink: 0; }
}
.tourney-table td {
  padding: 10px; font-size: var(--fs-3);
  border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
.tourney-table tr { cursor: pointer; transition: background .15s; }
.tourney-table tbody tr:nth-child(even) td { background: rgba(29,26,23,.3); }
.tourney-table tbody tr:hover td { background: var(--surface2); }
.tourney-table tbody tr:hover .t-name { color: var(--blue); }
.tourney-table tbody tr:active td { background: var(--blue-dim); transition: background 0s; }
/* v4 U5: row flash for chart click-to-highlight (app.js onClick adds the class
   for 2.5s on the matching table row). Existed as a classList call with no
   rule, so the highlight was invisible. */
.tourney-table tbody tr.chart-highlight td,
.comp-table tbody tr.chart-highlight td { background: var(--blue-dim); }
.tourney-table tr:last-child td { border-bottom: none; }
.t-name { font-weight: 600; }
.t-sub { font-size: var(--fs-1); color: var(--muted); margin-top: 2px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: var(--fs-1); font-weight: 700;
}
.pill-live { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.pill-complete { background: var(--surface3); color: var(--muted); border: 1px solid var(--border); }
.pill-hist { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(188,140,255,.3); }
.pace-bar-wrap {
  width: 60px; height: 5px; background: var(--surface3);
  border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px;
}
.pace-bar-fill { height: 100%; border-radius: 3px; transition: width .4s; }

/* ── Mobile card layout for tournament table (< 640px) ── */
@media (max-width: 639px) {
  .tourney-table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  .tourney-table { display: block; min-width: 0; }
  .tourney-table thead { display: none; }
  .tourney-table tbody { display: block; }
  .tourney-table tr {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  .tourney-table tbody tr:nth-child(even) td,
  .tourney-table tbody tr:hover td,
  .tourney-table tbody tr:active td { background: transparent; }
  .tourney-table tr:active { background: var(--surface3); }
  .tourney-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-3);
  }
  .tourney-table td::before {
    content: attr(data-label);
    font-size: var(--fs-1);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .tourney-table td:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding-top: 0;
    padding-bottom: var(--s-2);
    margin-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
  }
  .tourney-table td:first-child::before { display: none; }
  .tourney-table td:last-child { border-bottom: none; padding-bottom: 0; }
}

/* Recent finishes feed removed in iter 26 — the data table at the
   bottom of the predictions tab is the all-tournaments view, now
   sortable + filterable. Keep the placeholder block for the bracket
   match below. */
@media (max-width: 639px) {
  .rr-removed-placeholder { display: none; }
}

/* ══════════════════════════════════════════════════════
   INLINE MODEL ACCURACY STRIP
   ══════════════════════════════════════════════════════ */
.accuracy-strip:empty { display: none; }
.acc-row {
  display: grid;
  grid-template-columns: minmax(0,1.4fr) repeat(2, minmax(0,1fr)) auto;
  align-items: center;
  gap: var(--s-4);
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  margin: var(--s-3) 0;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s, background .2s, transform .2s;
}
.acc-row:hover {
  border-color: var(--blue);
  background: var(--surface2);
  transform: translateY(-1px);
}
.acc-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc-grade { flex-direction: row; align-items: center; gap: var(--s-3); }
.acc-grade-letter {
  font-size: 1.6rem; font-weight: 900;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  line-height: 1;
  min-width: 1.4em; text-align: center;
}
.acc-pos { color: var(--green); }
.acc-flat { color: var(--gold); }
.acc-neg { color: var(--red); }
.acc-grade-label {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
}
.acc-num {
  font-size: var(--fs-5); font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.acc-lab {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
.acc-cta {
  font-size: var(--fs-2); color: var(--blue);
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 639px) {
  .acc-row {
    grid-template-columns: auto 1fr 1fr;
    gap: var(--s-3);
    padding: var(--s-3);
  }
  .acc-cta { display: none; }
  .acc-grade-letter { font-size: 1.35rem; }
  .acc-num { font-size: 1rem; }
  .acc-grade { flex-direction: column; align-items: flex-start; gap: 0; }
  .acc-grade-label { white-space: nowrap; }
}

/* ══════════════════════════════════════════════════════
   UPCOMING-EVENTS CALENDAR STRIP
   ══════════════════════════════════════════════════════ */
.calendar-strip:empty { display: none; }
.calendar-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4) var(--s-4);
  margin: var(--s-3) 0;
}
.cal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; gap: var(--s-3);
}
.cal-title {
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
}
.cal-legend {
  display: flex; gap: var(--s-3);
  font-size: var(--fs-1); color: var(--muted);
  flex-wrap: wrap;
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.cal-dot-mini {
  display: inline-block; width: 8px; height: 8px; border-radius: 100px;
}
.cal-pace-pos { background: var(--green); }
.cal-pace-flat { background: var(--gold); }
.cal-pace-neg { background: var(--red); }
.cal-track-wrap {
  position: relative;
  padding: 14px 14px 26px;
}
.cal-track {
  position: relative;
  height: 30px;
  background: linear-gradient(180deg, transparent 13px, var(--border) 13px,
    var(--border) 17px, transparent 17px);
  border-radius: 2px;
}
/* "Today" marker — gold vertical line at x=0 (leftmost). */
.cal-axis-now {
  position: absolute; left: 0; top: -4px; bottom: -4px;
  width: 2px;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(240,192,64,.5);
  border-radius: 100px;
  pointer-events: none;
}
.cal-dot {
  position: absolute; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--gold);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border-light);
  border-radius: 100px;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s;
  padding: 0;
}
.cal-dot.cal-pace-pos { background: var(--green); box-shadow: 0 0 0 1px rgba(63,185,80,.4), 0 0 12px rgba(63,185,80,.3); }
.cal-dot.cal-pace-flat { background: var(--gold); box-shadow: 0 0 0 1px rgba(240,192,64,.4), 0 0 12px rgba(240,192,64,.2); }
.cal-dot.cal-pace-neg { background: var(--red); box-shadow: 0 0 0 1px rgba(248,81,73,.4), 0 0 12px rgba(248,81,73,.3); }
.cal-dot:hover, .cal-dot:focus-visible {
  transform: translate(-50%, -50%) scale(1.25);
  z-index: 2;
  box-shadow: 0 0 0 2px var(--text), 0 4px 16px rgba(0,0,0,.4);
}

/* Premium hover tooltip for upcoming-events dots. One floating element
   repositioned per dot; fades in, pace-tinted accent border, generous
   typography hierarchy so the tournament name reads first. */
.cal-tooltip {
  position: absolute;
  z-index: 9999;
  min-width: 220px; max-width: 320px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .16s ease-out, transform .16s ease-out;
  font-family: inherit;
}
.cal-tooltip[hidden] { display: none; }
.cal-tooltip.cal-tooltip-show { opacity: 1; transform: translateY(0); }
.cal-tooltip::after {
  content: ''; position: absolute;
  left: 50%; bottom: -6px; transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px;
  background: var(--surface2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-tip-name {
  font-size: var(--fs-4); font-weight: 800; color: var(--text);
  letter-spacing: -.01em; line-height: 1.25;
  margin-bottom: 4px;
}
.cal-tip-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-2); color: var(--muted);
  margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.cal-tip-date { font-weight: 600; color: var(--text2); }
.cal-tip-days { font-variant-numeric: tabular-nums; }
.cal-tip-sep { opacity: .6; }
.cal-tip-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--fs-2);
  margin-top: 4px;
}
.cal-tip-label {
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  font-size: var(--fs-1); font-weight: 700;
}
.cal-tip-value {
  font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cal-tip-pace-pos { color: var(--green); }
.cal-tip-pace-flat { color: var(--text2); }
.cal-tip-pace-neg { color: var(--red); }
/* Pace tint: full border + faint wash matching the dot color (the border+tint
   pattern from .cat-btn; side-stripe ribbons are banned). */
.cal-tooltip-pos  { box-shadow: 0 12px 32px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3); border-color: rgba(63,185,80,.4); background-color: rgba(63,185,80,.05); }
.cal-tooltip-flat { box-shadow: 0 12px 32px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3); border-color: rgba(240,192,64,.4); background-color: rgba(240,192,64,.05); }
.cal-tooltip-neg  { box-shadow: 0 12px 32px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3); border-color: rgba(248,81,73,.4); background-color: rgba(248,81,73,.05); }
.cal-axis {
  position: relative; height: 14px;
  margin-top: 6px;
}
.cal-axis-tick {
  position: absolute; transform: translateX(-50%);
  font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  white-space: nowrap;
}
@media (max-width: 639px) {
  /* Calendar-strip is hover-driven and the dots are <14px each — they tap
     poorly on phones, the custom tooltip can't fit, and 26 events cluster
     unreadably on a 375px viewport. The mini-cards grid below already
     covers the "what's upcoming" job on mobile, so hide the strip outright. */
  .calendar-strip { display: none; }
}

/* Portfolio movements strip removed in iter 24 — duplicated the
   mini-card delta chips (iter 9). */

/* ══════════════════════════════════════════════════════
   UPCOMING MINI CARDS
   ══════════════════════════════════════════════════════ */
.mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}
.mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-4);
  cursor: pointer;
  min-height: var(--touch);
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.mini-card:hover { border-color: var(--blue); box-shadow: var(--glow-blue); transform: translateY(-2px); }
.mini-card-active { border-color: var(--gold); box-shadow: var(--glow-gold); background: linear-gradient(135deg, var(--surface), rgba(240,192,64,.04)); }
.mini-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.mini-card-name { font-weight: 700; font-size: var(--fs-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; padding-right: var(--s-2); }
.mini-badge {
  font-size: var(--fs-1); font-weight: 700;
  padding: 2px 8px; border-radius: 100px;
}
.badge-live { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.badge-complete { background: var(--surface3); color: var(--muted); border: 1px solid var(--border); }
.badge-upcoming { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(56,139,253,.3); }
.mini-card-number { font-size: 1.4rem; font-weight: 800; color: var(--gold); line-height: 1; }
.mini-card-chips { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mini-card-delta {
  font-size: var(--fs-1); font-weight: 800;
  padding: 2px 7px; border-radius: 100px;
  font-variant-numeric: tabular-nums;
}
.mini-card-delta.pos { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.mini-card-delta.neg { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,81,73,.3); }
.mini-card-details { font-size: var(--fs-2); color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════
   PAGE TABS
   ══════════════════════════════════════════════════════ */
.page-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: var(--s-4); padding-top: var(--s-2);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.page-tab {
  padding: 12px 16px;
  min-height: var(--touch);
  font-size: var(--fs-2); font-weight: 600;
  color: var(--muted); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .2s, border-color .2s; white-space: nowrap;
  flex-shrink: 0;
}
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.page-tab-panel { display: none; }
.page-tab-panel.active { display: block; }

/* ── "Menu" page-tab dropdown ── */
.page-tab-more-wrap { display: inline-flex; flex-shrink: 0; }
.page-tab-more { display: inline-flex; align-items: center; gap: 6px; }
.page-tab-more .menu-caret { font-size: var(--fs-1); opacity: .85; transition: transform .15s ease; }
.page-tab-more[aria-expanded="true"] .menu-caret { transform: rotate(180deg); }
.page-tab-drop {
  position: fixed; top: 0; left: 0;
  display: none;
  min-width: 220px; max-width: min(320px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0,0,0,.15);
  z-index: 300;
  animation: dropSlide .15s ease;
  padding: 4px 0;
}
.page-tab-drop.open { display: block; }
.page-tab-drop .cat-item {
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: var(--fs-3); font-weight: 600;
  color: var(--text2);
}
.page-tab-drop .cat-item.active { color: var(--blue); background: var(--blue-dim); }

/* ── Edge fade hint for scrollable tab strip on mobile ── */
@media (max-width: 639px) {
  .page-tabs {
    /* Widened fade region (was 16px) so tab labels with emoji/icons
       don't clip visibly before content wraps. */
    -webkit-mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
    scroll-behavior: smooth;
  }
}

/* ══════════════════════════════════════════════════════
   CHESS PUZZLE BOARD
   ══════════════════════════════════════════════════════ */
.puzzle-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  margin-top: var(--s-4);
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
}
.chess-board-wrap { position: relative; width: 100%; max-width: 480px; margin: 0 auto; }
.chess-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  border: 2px solid var(--border); border-radius: 6px; overflow: hidden;
  aspect-ratio: 1; user-select: none;
}
.chess-sq {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 0; position: relative; cursor: pointer; transition: background .15s;
}
.chess-sq .piece { font-size: clamp(24px, 5.5vw, 48px); line-height: 1; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.chess-sq.light { background: #b8b090; }
.chess-sq.dark { background: #6b8a5e; }
.chess-sq.selected { background: #f0c040 !important; }
.chess-sq.hint { background: rgba(240,192,64,.35) !important; }
.chess-sq.last-move { background: rgba(56,139,253,.25) !important; }
.chess-sq.correct { background: rgba(63,185,80,.35) !important; }
.chess-sq.wrong { background: rgba(248,81,73,.35) !important; }
.puzzle-info {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4);
}
.puzzle-rating { font-size: 1.6rem; font-weight: 900; color: var(--gold); }
.puzzle-themes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.puzzle-theme-tag {
  background: var(--surface2); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 2px 10px; font-size: var(--fs-1); color: var(--muted);
}
.puzzle-status { font-size: 1rem; font-weight: 700; margin: var(--s-3) 0; min-height: 28px; }
.puzzle-nav { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.puzzle-btn {
  padding: 10px 16px;
  min-height: var(--touch);
  border-radius: 6px; font-weight: 600; font-size: var(--fs-2);
  cursor: pointer; transition: opacity .2s; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
}
.puzzle-btn:hover { opacity: .8; }
.puzzle-btn.primary { background: var(--gold); color: #000; border-color: var(--gold); }
.puzzle-btn:disabled { opacity: .4; cursor: not-allowed; }
.puzzle-progress { display: flex; gap: 6px; margin: var(--s-3) 0; flex-wrap: wrap; }
.puzzle-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface3); border: 1px solid var(--border);
  transition: background .3s;
}
.puzzle-dot.solved { background: var(--green); border-color: var(--green); }
.puzzle-dot.failed { background: var(--red); border-color: var(--red); }
.puzzle-dot.current { border-color: var(--gold); box-shadow: 0 0 6px var(--gold); }
.puzzle-score { font-size: var(--fs-3); color: var(--muted); margin-top: 4px; }

/* History card */
.history-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4); margin-top: var(--s-4);
}
.history-card h3 { font-size: var(--fs-4); font-weight: 700; color: var(--gold); margin-bottom: var(--s-3); }
.history-event {
  padding: 10px 0; border-bottom: 1px solid var(--border-light);
  font-size: var(--fs-3); line-height: 1.5;
}
.history-event:last-child { border-bottom: none; }
.history-year { font-weight: 700; color: var(--blue); margin-right: 6px; }
.history-cat {
  display: inline-block; font-size: var(--fs-1); padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .5px; margin-left: 6px;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════════════════
   DATA ENTRY PANEL
   ══════════════════════════════════════════════════════ */
.data-entry-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: var(--s-3) var(--s-4); margin: var(--s-4) 0 0;
  min-height: var(--touch);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--fs-3); font-weight: 600; color: var(--text2);
  transition: border-color .2s;
}
.data-entry-toggle:hover { border-color: var(--blue); color: var(--blue); }
.data-entry-toggle .arrow { transition: transform .2s; font-size: var(--fs-1); }
.data-entry-toggle.open .arrow { transform: rotate(90deg); }
.data-entry-panel {
  display: none; background: var(--surface); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  padding: var(--s-4); margin-bottom: var(--s-5);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.data-entry-panel.open { display: block; }
.de-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.de-table thead { position: sticky; top: 0; z-index: 1; background: var(--bg); }
.de-table th {
  text-align: left; font-size: var(--fs-1); color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
/* Visual group separators between (Name+Entries) | (Dates) | (Fees). */
.de-table .de-colgroup-dates { border-left: 1px solid var(--border-light); }
.de-table .de-colgroup-fees  { border-left: 1px solid var(--border-light); }
.de-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.de-table input[type="text"], .de-table input[type="number"], .de-table input[type="date"] {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 6px 8px; font-size: var(--fs-3); width: 100%;
  min-height: 36px; font-family: inherit;
}
.de-table input:focus { border-color: var(--blue); outline: none; }
.de-table input.de-input-invalid,
.de-table input:invalid { border-color: var(--red); background: rgba(248,81,73,.08); }
.de-table .fam-name { font-weight: 600; font-size: var(--fs-3); white-space: nowrap; }
.de-toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  padding: 10px 18px; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--fs-3); font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease-out, transform .25s ease-out;
  z-index: 10000;
}
.de-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.de-toast-success { border-color: var(--green); color: var(--green); }
.de-toast-error { border-color: var(--red); color: var(--red); }
.de-save-btn {
  background: var(--green); color: #000; border: none; border-radius: 6px;
  padding: 12px 20px;
  min-height: var(--touch);
  font-weight: 700; font-size: var(--fs-2); cursor: pointer;
  margin-top: var(--s-3); transition: opacity .2s;
}
.de-save-btn:hover { opacity: .85; }
.de-saved-msg { color: var(--green); font-size: var(--fs-2); margin-left: var(--s-3); opacity: 0; transition: opacity .3s; }
.de-saved-msg.show { opacity: 1; }

/* ── Mobile card layout for data-entry table (< 640px) ── */
@media (max-width: 639px) {
  .de-table { display: block; min-width: 0; }
  .de-table thead { display: none; }
  .de-table tbody { display: block; }
  .de-table tr {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  .de-table td {
    display: block;
    padding: 4px 0 8px;
    border-bottom: none;
  }
  .de-table td::before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-1);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 4px;
  }
  .de-table td.fam-name {
    font-size: 1rem;
    font-weight: 700;
    padding-bottom: var(--s-2);
    margin-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
    white-space: normal;
  }
  .de-table td.fam-name::before { display: none; }
  .de-table input[type="number"],
  .de-table input[type="date"],
  .de-table input[type="text"] { min-height: var(--touch); }
}

/* ══════════════════════════════════════════════════════
   EMAIL GENERATOR
   ══════════════════════════════════════════════════════ */
.email-hint { font-size: var(--fs-2); color: var(--muted); margin: var(--s-3) 0 var(--s-4); }
.email-meta {
  display: grid; grid-template-columns: 1fr; gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.email-meta-row {
  display: flex; flex-direction: column; gap: 4px;
}
.email-meta-label {
  font-size: var(--fs-1); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.email-meta-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 10px 12px; min-height: var(--touch);
  font-size: var(--fs-3); font-family: inherit; width: 100%;
}
.email-meta-input:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-dim);
}
.email-toolbar {
  display: flex; align-items: center; gap: var(--s-3);
  flex-wrap: wrap; margin-bottom: var(--s-3);
}
.email-toolbar-label {
  font-size: var(--fs-1); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.email-link-btn {
  font-size: var(--fs-2); color: var(--blue); background: none;
  border: none; cursor: pointer; padding: 8px 4px;
  min-height: var(--touch);
  text-decoration: underline;
}
.email-link-btn:hover { color: var(--blue-bright); }
.email-seg {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.email-seg button {
  padding: 8px 14px; min-height: var(--touch);
  background: var(--surface2); color: var(--text2);
  font-size: var(--fs-2); font-weight: 500;
  border: none; cursor: pointer; transition: background .15s;
  border-right: 1px solid var(--border);
}
.email-seg button:last-child { border-right: none; }
.email-seg button.active { background: var(--gold); color: #000; font-weight: 700; }
.email-generate-btn {
  padding: 10px 18px; min-height: var(--touch);
  border-radius: var(--radius-sm);
  background: var(--blue); color: #fff;
  font-size: var(--fs-3); font-weight: 600;
  border: none; cursor: pointer;
  margin-left: auto;
}
.email-generate-btn:hover { background: var(--blue-bright); }

/* ── Email toolbar mobile polish (< 640px) ── */
@media (max-width: 639px) {
  /* Selection controls wrap as a chip row instead of four full-width stacked
     links that used to eat the whole first viewport (L11). */
  .email-toolbar {
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
  }
  .email-toolbar-label { width: 100%; margin-bottom: 2px; }
  .email-toolbar .email-link-btn {
    flex: 0 0 auto;
    min-height: 0;
    padding: 8px 14px;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface2);
    color: var(--blue);
    font-weight: 600;
  }
  .email-toolbar .email-link-btn:hover,
  .email-toolbar .email-link-btn:active {
    border-color: var(--blue); color: var(--blue-bright);
  }
  .email-generate-btn {
    margin-left: 0;
    width: 100%;
    padding: 12px 18px;
    font-size: var(--fs-4);
  }
  .email-seg { width: 100%; display: flex; }
  .email-seg button { flex: 1 1 0; }
}
.email-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-1);
  margin-bottom: var(--s-4);
}
.email-grid label {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; user-select: none; font-size: var(--fs-3);
  min-height: var(--touch);
}
.email-grid label:hover { background: var(--surface2); }
.email-grid input[type="checkbox"] {
  accent-color: var(--gold); width: 16px; height: 16px; cursor: pointer;
}
.email-grid .email-tourn-days {
  font-size: var(--fs-2); color: var(--muted); margin-left: auto;
}
.email-output-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--s-2); gap: var(--s-2); flex-wrap: wrap;
}
.email-copy-row { display: flex; gap: var(--s-2); }
.email-action-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap;
  padding: var(--s-3) 0; margin: 0 0 var(--s-2);
  background: var(--bg); border-bottom: 1px solid var(--border-light);
}
.email-copy-btn {
  padding: 8px 14px; min-height: var(--touch);
  border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--fs-2); font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.email-copy-btn:hover { border-color: var(--blue); color: var(--blue); }
.email-copy-btn.copied { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.email-split-tabs {
  display: flex; gap: 0;
  margin-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
}
.email-split-tab {
  flex: 1;
  background: none; border: none; color: var(--muted);
  padding: 10px 16px;
  min-height: var(--touch);
  font-size: var(--fs-3); font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.email-split-tab:hover { color: var(--text); }
.email-split-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.email-split {
  display: grid; grid-template-columns: 1fr;
  gap: var(--s-3);
}
.email-output {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4);
  white-space: pre-wrap; tab-size: 16; -moz-tab-size: 16;
  font-family: -apple-system, 'Segoe UI', system-ui, Roboto, sans-serif;
  font-size: var(--fs-4); line-height: 1.6;
  min-height: 180px; color: var(--text2);
  overflow-x: auto;
}
.email-output.mode-html {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: var(--fs-2); color: var(--muted);
}
.email-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  min-height: 320px;
}

/* ══════════════════════════════════════════════════════
   FAVORITES (My Tournaments)
   ══════════════════════════════════════════════════════ */
.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-5); line-height: 1;
  padding: 6px 8px; min-width: var(--touch); min-height: var(--touch);
  color: var(--muted); transition: color .15s, transform .15s;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.fav-btn:hover { color: var(--gold); transform: scale(1.1); }
.fav-btn.fav-active { color: var(--gold); text-shadow: 0 0 8px rgba(240,192,64,.5); }
.fav-remove:hover { color: var(--red); }
.fav-empty {
  text-align: center; padding: var(--s-7) var(--s-4); color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  margin-top: var(--s-4);
}
.fav-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
  margin-top: var(--s-3);
}
.fav-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4);
  cursor: pointer; transition: border-color .2s, transform .15s, box-shadow .2s;
}
.fav-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--glow-gold); }
.fav-card:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.fav-card-header {
  display: flex; justify-content: space-between; align-items: start;
  margin-bottom: var(--s-3); gap: var(--s-2);
}
.fav-card-name { font-weight: 700; font-size: var(--fs-4); flex: 1; min-width: 0; }
.fav-card-status {
  display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.fav-card-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2);
}
.fav-stat {
  padding: var(--s-2); background: var(--surface2); border-radius: var(--radius-sm); text-align: center;
}
.fav-stat-label {
  font-size: var(--fs-1); color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  display: block; margin-bottom: 4px;
}
.fav-stat-value { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fav-pace-row {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border-light);
  font-size: var(--fs-2);
}
.fav-pace-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.fav-pace-dot.above { background: var(--green); box-shadow: 0 0 6px rgba(63,185,80,.4); }
.fav-pace-dot.below { background: var(--red); box-shadow: 0 0 6px rgba(248,81,73,.4); }
.fav-pace-dot.on    { background: var(--blue); box-shadow: 0 0 6px rgba(56,139,253,.3); }

/* ══════════════════════════════════════════════════════
   COMPARE
   ══════════════════════════════════════════════════════ */
.compare-add-btn {
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-5); line-height: 1;
  padding: 6px 8px; min-width: var(--touch); min-height: var(--touch);
  color: var(--muted); transition: color .15s, transform .15s;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.compare-add-btn:hover { color: var(--blue); transform: scale(1.1); }
.compare-add-btn.compare-active { color: var(--blue); text-shadow: 0 0 8px rgba(56,139,253,.5); }
.compare-selectors {
  display: grid; grid-template-columns: 1fr;
  gap: var(--s-2); margin: var(--s-4) 0;
}
.compare-selector {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.compare-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.compare-dropdown {
  flex: 1; min-width: 0; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 10px; min-height: var(--touch);
  font-size: var(--fs-3); font-family: inherit; cursor: pointer;
}
.compare-dropdown:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }
.compare-remove-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  padding: 0; min-width: var(--touch); min-height: var(--touch); border-radius: var(--radius-sm);
  font-size: var(--fs-3); cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.compare-remove-btn:hover { border-color: var(--red); color: var(--red); }
.compare-empty {
  text-align: center; padding: var(--s-7) var(--s-4); color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.compare-insights {
  margin: var(--s-4) 0;
  display: flex; flex-direction: column; gap: var(--s-2);
}
.compare-insight {
  padding: var(--s-3); background: var(--blue-dim);
  border: 1px solid rgba(56,139,253,.25);
  border-radius: var(--radius-sm); font-size: var(--fs-3); line-height: 1.5;
}
.compare-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) var(--s-4); }
.compare-table {
  width: 100%; border-collapse: collapse; min-width: 480px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.compare-table th,
.compare-table td {
  padding: 10px var(--s-3); text-align: left; border-bottom: 1px solid var(--border-light);
  font-size: var(--fs-3);
}
.compare-table th {
  font-weight: 700; font-size: var(--fs-2); background: var(--surface2);
  text-transform: uppercase; letter-spacing: .5px;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table td { font-variant-numeric: tabular-nums; }
.compare-stat-label { font-weight: 600; color: var(--muted); font-size: var(--fs-2); text-transform: none; letter-spacing: 0; }

/* ── Mobile card layout for compare-table (transposed stats, < 640px) ── */
@media (max-width: 639px) {
  .compare-table-wrap { overflow-x: visible; margin: 0; padding: 0 0 var(--s-4); }
  .compare-table { display: block; min-width: 0; }
  .compare-table thead { display: none; }
  .compare-table tbody { display: block; }
  .compare-table tr {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  .compare-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-3);
  }
  .compare-table td.compare-stat-label {
    font-size: var(--fs-4);
    font-weight: 700;
    color: var(--text);
    padding-bottom: var(--s-2);
    margin-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
    text-transform: none;
    letter-spacing: 0;
  }
  .compare-table td:not(.compare-stat-label)::before {
    content: attr(data-label);
    font-size: var(--fs-1);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .compare-table tr td:last-child { border-bottom: none; }
}
.compare-chart-wrap {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4);
  height: min(300px, 55vh); position: relative;
}

/* ══════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════ */
footer {
  border-top: 1px solid var(--border);
  padding: var(--s-5) 0 max(var(--s-5), env(safe-area-inset-bottom));
  text-align: center; font-size: var(--fs-2); color: var(--muted);
}
footer a { color: var(--muted); }

/* ══════════════════════════════════════════════════════
   ABOUT TAB — sub-model grid (collapses on mobile)
   ══════════════════════════════════════════════════════ */
.about-submodels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 639px) {
  .about-submodels { grid-template-columns: 1fr; gap: 12px; }
}

/* ══════════════════════════════════════════════════════
   PERFORMANCE TAB — tournament-results table (mobile cards)
   Direct port of round-4 .tourney-table flip pattern.
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  #perfTable { overflow-x: visible !important; }
  #perfTable table { display: block; min-width: 0; }
  #perfTable thead { display: none; }
  #perfTable tbody { display: block; }
  #perfTable tr {
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  #perfTable td {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--s-3); padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-3); text-align: left !important;
    white-space: normal !important;
  }
  #perfTable td::before {
    content: attr(data-label);
    font-size: var(--fs-1); color: var(--muted);
    text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
    flex-shrink: 0;
  }
  #perfTable td:first-child {
    flex-direction: column; align-items: flex-start; gap: 2px;
    padding-top: 0; padding-bottom: var(--s-2); margin-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: 1rem;
  }
  #perfTable td:first-child::before { display: none; }
  #perfTable td:last-child { border-bottom: none; }
}

/* ══════════════════════════════════════════════════════
   PERFORMANCE TAB
   ══════════════════════════════════════════════════════ */
.perf-grade-card {
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 36px;
  background: rgba(240,192,64,.06);
  border: 1px solid rgba(240,192,64,.2);
  border-radius: 16px;
  min-width: 140px;
}
.perf-charts-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 22px;
}
@media (max-width: 639px) {
  .perf-charts-grid { grid-template-columns: 1fr; }
  .perf-grade-card { padding: 20px 24px; }
}

/* ── Narrow-phone card padding tightening (< 420px) ── */
@media (max-width: 419px) {
  .chart-card, .panel { padding: var(--s-3); }
  .mini-card { padding: var(--s-3); }
  .kpi-card { padding: var(--s-2) var(--s-3); }
  .hero-label { letter-spacing: 1.2px; }
}

/* ══════════════════════════════════════════════════════
   TRANSITIONS
   ══════════════════════════════════════════════════════ */
.fade-enter { animation: fadeSlideIn .45s cubic-bezier(.22,1,.36,1) forwards; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero, .chart-card, .delta-banner, .kpi-row, .progress-row, .grid-2,
.all-tournaments, .movements-strip {
  transition: opacity .35s cubic-bezier(.22,1,.36,1),
              transform .35s cubic-bezier(.22,1,.36,1);
}
@media (prefers-reduced-motion: reduce) {
  .fade-enter { animation: none; }
  .hero, .chart-card, .delta-banner, .kpi-row, .progress-row, .grid-2,
  .all-tournaments, .movements-strip { transition: none; }
}

/* ══════════════════════════════════════════════════════
   BACK TO TOP BUTTON
   ══════════════════════════════════════════════════════ */
.back-to-top {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: 20px; z-index: 900;
  width: var(--touch); height: var(--touch); border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: var(--fs-5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .3s, visibility .3s, transform .3s, background .2s, color .2s;
  box-shadow: var(--shadow-sm);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Keyboard hint */
.kbd-hint {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  background: var(--surface3); border: 1px solid var(--border);
  font-size: var(--fs-1); color: var(--muted); font-family: monospace;
  vertical-align: middle; margin: 0 1px;
}

/* ══════════════════════════════════════════════════════
   SKELETON LOADING STATES
   ══════════════════════════════════════════════════════ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1.0; }
}
.skeleton {
  background: var(--surface3);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-chart { height: 260px; width: 100%; border-radius: var(--radius); }
.skeleton-text { height: 14px; margin-bottom: 10px; border-radius: 4px; }
.skeleton-text:nth-child(1) { width: 80%; }
.skeleton-text:nth-child(2) { width: 60%; }
.skeleton-text:nth-child(3) { width: 70%; }
.skeleton-text:nth-child(4) { width: 50%; }
.skeleton-card { height: 80px; width: 100%; border-radius: var(--radius); }
@media (max-width: 639px) {
  /* Hero on mobile is ~150–180px tall (number + label + CI + 2-up KPIs).
     Bumping skeleton-card from 80px reduces CLS when real content lands. */
  .skeleton-card { height: 160px; }
  .skeleton-chart { height: 240px; }
  /* Tighten empty-state vertical padding so they don't dominate mobile screens */
  .fav-empty, .compare-empty { padding: var(--s-5) var(--s-4); }
}

/* ══════════════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════════════ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.chess-sq:focus {
  outline: 2px solid var(--gold, #C8971A);
  outline-offset: -2px;
  z-index: 1;
}

/* ══════════════════════════════════════════════════════
   BREAKPOINTS (mobile-first, min-width only)
   ══════════════════════════════════════════════════════ */

/* ── 480px: mid-size phones ── */
@media (min-width: 480px) {
  .timeline { grid-template-columns: repeat(2, 1fr); }
}

/* ── 640px: larger phones / small tablets ── */
@media (min-width: 640px) {
  :root { --gutter: 20px; }
  .logo { font-size: var(--fs-5); }
  .hero { grid-template-columns: auto 1fr; }
  .hero-kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-value { font-size: 1.4rem; }
  .chart-wrap { height: 320px; }
  .skeleton-chart { height: 320px; }
  .compare-chart-wrap { height: 340px; }
  .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-grid-featured { grid-template-columns: 1fr; }
  .mini-grid-rest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline { grid-template-columns: repeat(4, 1fr); }
  .fav-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-meta { grid-template-columns: 1fr 1fr; }
  .chart-title { font-size: 1rem; }
  .delta-value { font-size: 1.6rem; }
  .mini-card-number { font-size: 1.6rem; }
}

/* ── 768px: tablet portrait ── */
@media (min-width: 768px) {
  header { padding: var(--s-4) 0; }
  .hero {
    grid-template-columns: auto 1fr auto;
    gap: var(--s-5); padding: var(--s-6) 0 var(--s-4);
    align-items: center;
  }
  .puzzle-layout { grid-template-columns: 1fr 1fr; }
  .compare-selectors { grid-template-columns: repeat(3, 1fr); }
  .mini-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ── 768px: tablets (iPad portrait, large phones landscape) ──
   Bridges mobile (<640px) and laptop (>=1024px) which previously
   inherited mobile defaults at this range and wasted horizontal
   real estate. */
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .progress-row { grid-template-columns: 1fr 1fr; }
  .chart-wrap { height: 360px; }
  .skeleton-chart { height: 360px; }
}

/* ── 1024px: small laptops ── */
@media (min-width: 1024px) {
  .progress-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .chart-wrap { height: 380px; }
  .skeleton-chart { height: 380px; }
  .compare-chart-wrap { height: 360px; }
  .fav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .email-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .email-split { grid-template-columns: 1fr 1fr; }
  .email-split .email-output, .email-split .email-preview { min-height: 420px; }
  .chart-title { font-size: 1.05rem; }
  .kpi-value { font-size: var(--fs-6); }
  .delta-value { font-size: 1.8rem; }
  .hero-ci { font-size: var(--fs-4); }
  .mini-card-number { font-size: 1.7rem; }
  .puzzle-rating { font-size: 1.8rem; }
  .chart-card { padding: var(--s-5); }
  .panel { padding: var(--s-5) var(--s-6); }
}

/* ── 1440px: widescreen ── */
@media (min-width: 1440px) {
  .container { max-width: 1400px; }
}

/* ══════════════════════════════════════════════════════
   LANDSCAPE PHONE
   ══════════════════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 500px) {
  .drop-menu, .tab-search-results, .drop-menu-search .tab-search-results {
    max-height: 40vh;
  }
}

/* ══════════════════════════════════════════════════════
   MOBILE BOTTOM-SHEET DROPDOWNS (< 640px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  .drop-menu {
    position: fixed;
    left: 0; right: 0; top: auto; bottom: 0;
    width: 100%; max-width: 100%;
    max-height: 82vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.4);
    padding-bottom: env(safe-area-inset-bottom);
    animation: dropSlideUp .2s ease;
    z-index: 300;
  }
  .drop-menu::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 6px;
  }
  .drop-menu-search .tab-search-results { max-height: 60vh; }
  .tab-search-panel {
    position: fixed;
    left: 0; right: 0; top: auto; bottom: 0;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.4);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 300;
  }
  .tab-search-results { max-height: 60vh; }
}
@keyframes dropSlideUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile drawer backdrop scrim (< 640px) ── */
@media (max-width: 639px) {
  body.drawer-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 250;
    animation: scrimFadeIn .2s ease;
    pointer-events: none;
  }
}
@keyframes scrimFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════════════════════
   MOBILE PERF — REDUCE EXPENSIVE EFFECTS
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  /* Backdrop blur is expensive on every scroll-paint; drop blur on phones,
     keep the alpha-tinted background so the sticky header still feels separated. */
  header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(18,16,13,.95);
  }
  /* Hero number gradient text already costs; trim the 20px shadow blur */
  .hero-number { filter: drop-shadow(0 0 10px rgba(240,192,64,.18)); }
  /* Live-glow on chart-card uses two large box-shadows; tone down */
  .chart-card.live-glow { box-shadow: 0 0 20px rgba(56,139,253,.05); }
}

/* ══════════════════════════════════════════════════════
   STALE DATA BANNER
   ══════════════════════════════════════════════════════ */
.stale-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 99999;
  background: var(--orange-bright); color: var(--ink);
  padding: max(10px, env(safe-area-inset-top)) 48px 10px 16px;
  font-size: 14px; font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  font-family: Inter, system-ui, sans-serif;
}
.stale-banner-dismiss {
  position: absolute; right: 12px;
  top: max(50%, env(safe-area-inset-top));
  transform: translateY(-50%);
  background: none; border: none; color: var(--ink);
  font-size: 20px; line-height: 1;
  padding: 4px 8px;
  min-width: var(--touch); min-height: var(--touch);
  cursor: pointer;
}
@media (max-width: 639px) {
  .stale-banner {
    font-size: 13px;
    padding-left: 12px;
    padding-right: 44px;
    text-align: left;
    line-height: 1.35;
  }
  .stale-banner-dismiss { right: 6px; }
}

/* ══════════════════════════════════════════════════════
   TOUCH FEEDBACK
   ══════════════════════════════════════════════════════ */
/* Suppress the iOS gray tap-highlight flash; custom :active states below provide feedback. */
* { -webkit-tap-highlight-color: transparent; }

/* Subtle press feedback on interactive elements that mostly relied on :hover */
.mini-card, .fav-card, .puzzle-btn, .de-save-btn,
.email-generate-btn, .email-copy-btn, .email-link-btn,
.email-split-tab, .compare-add-btn, .fav-btn {
  transition: transform .12s ease, opacity .12s ease,
    color .15s, border-color .15s, background .15s, box-shadow .2s;
}
.mini-card:active, .fav-card:active { transform: scale(.985); }
.puzzle-btn:active, .de-save-btn:active, .email-generate-btn:active,
.email-copy-btn:active, .email-link-btn:active, .email-split-tab:active,
.compare-add-btn:active, .fav-btn:active { transform: scale(.96); opacity: .85; }

/* Prevent iOS auto-zoom on focused inputs (fires when computed font-size < 16px) */
@media (max-width: 639px) {
  .tab-search-input,
  .email-meta-input,
  .de-table input[type="text"],
  .de-table input[type="number"],
  .de-table input[type="date"] {
    font-size: 16px;
  }
}

/* ── Puzzles tab mobile polish (< 640px) — Round 32 ──
   - Button row: 2-col grid; primary "Next" spans full width as the prominent CTA.
   - Rating prominence: bump font-size, add letter-spacing.
   - Info card: tighten padding, larger status text. */
@media (max-width: 639px) {
  .puzzle-layout { gap: var(--s-3); }
  .puzzle-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
    margin-top: var(--s-3);
  }
  .puzzle-nav .puzzle-btn {
    width: 100%;
    padding: 12px 12px;
    font-size: var(--fs-3);
    margin: 0;
  }
  .puzzle-nav .puzzle-btn.primary { grid-column: 1 / -1; }
  .puzzle-rating { font-size: 2.1rem; letter-spacing: -.5px; }
  .puzzle-info { padding: var(--s-3); }
  .puzzle-status { font-size: var(--fs-4); min-height: 24px; margin: var(--s-2) 0; }
  .puzzle-themes { gap: 4px; margin-top: 6px; }
  .puzzle-theme-tag { font-size: var(--fs-1); padding: 2px 8px; }
  .puzzle-progress { gap: 4px; margin: var(--s-2) 0; }
  .puzzle-dot { width: 9px; height: 9px; }
  .puzzle-score { font-size: var(--fs-2); }
  .chess-board-wrap { max-width: 100%; }
}

/* ══════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════════════════════
   INFO PANELS + SHARED CLASSES
   Extracted from what were ~330 inline style attributes on the About,
   Performance, and Predictions markup (2026-07 makeover, phase 2).
   ══════════════════════════════════════════════════════ */
.info-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 18px;
  scroll-margin-top: 80px;
}
.info-panel.danger { border-color: rgba(248,81,73,.15); }
.about-submodels .info-panel { margin-bottom: 0; }
.info-panel > h3 { font-size: var(--fs-4); font-weight: 700; color: var(--text); margin: 0 0 10px; }
.info-panel > h3.accent-blue { font-size: var(--fs-4); color: var(--blue); }
.info-panel > h3.accent-red { color: var(--red); }
.info-panel h4 { font-size: var(--fs-3); font-weight: 700; color: var(--blue); margin: 0 0 8px; }
.h3-sub { font-weight: 400; color: var(--muted); font-size: var(--fs-2); }

.prose { font-size: var(--fs-3); color: var(--text2); line-height: 1.7; }
.prose.muted { color: var(--muted); }
.sp { margin-bottom: 14px; }
.info-note { font-size: var(--fs-2); color: var(--muted); margin-top: 10px; line-height: 1.6; }
.info-note.down { margin-top: 0; margin-bottom: 14px; }

.formula-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-2);
  color: var(--gold);
  overflow-x: auto;
}
.formula-box.center { text-align: center; padding: 14px 18px; margin-bottom: 14px; }
.formula-box.plain { color: var(--text2); font-size: var(--fs-2); }
.formula-lg { font-size: 1rem; font-weight: 700; color: var(--gold); font-family: var(--font-mono, ui-monospace, monospace); }

.table-scroll { overflow-x: auto; }
.info-table { width: 100%; font-size: var(--fs-2); border-collapse: collapse; }
.info-table.narrow { max-width: 420px; }
.info-table thead tr { border-bottom: 1px solid var(--border); }
.info-table th { text-align: left; padding: 8px 10px; color: var(--muted); font-weight: 600; }
.info-table tbody tr { border-bottom: 1px solid var(--border-light); }
.info-table tbody tr:last-child { border-bottom: none; }
.info-table td { padding: 8px 10px; color: var(--text2); }
.info-table .tc { text-align: center; }
.info-table td.gold { color: var(--gold); font-weight: 600; }
.info-table td.lbl { color: var(--muted); font-weight: 600; }
.info-table td.mut { color: var(--muted); }
.info-table tr.highlight { background: rgba(240,192,64,.04); }

.gold { color: var(--gold); }
.green { color: var(--green); }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono, ui-monospace, monospace); }
.w600 { font-weight: 600; }
.w700 { font-weight: 700; }
.gold-link { color: var(--gold); text-decoration: none; }
.code-chip { color: var(--text2); background: var(--surface); padding: 1px 4px; border-radius: 3px; }

.mb0 { margin-bottom: 0; }
.mt4 { margin-top: 4px; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.mb16 { margin-bottom: 16px; }
.mb24 { margin-bottom: 24px; }
.panel.roomy { padding: 22px; }

.tab-head { margin: 18px 0 14px; }
.tab-head h2 { font-size: var(--fs-6); font-weight: 800; color: var(--gold); margin: 0 0 4px; }
.tab-head p { font-size: var(--fs-3); color: var(--muted); margin: 0; }

.result-card {
  background: rgba(240,192,64,.06);
  border: 1px solid rgba(240,192,64,.25);
  border-radius: 12px;
  padding: 18px 24px;
  text-align: center;
}
.result-card-label { font-size: var(--fs-3); font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.result-card-num { font-size: 2.2rem; font-weight: 900; color: var(--gold); line-height: 1; }
.result-card-ci { font-size: var(--fs-3); color: var(--text2); margin-top: 4px; }
.about-footer { text-align: center; padding: 12px 0; font-size: var(--fs-1); color: var(--muted); }

.mh-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.mh-head h3 { margin: 0; }
.mh-updated { font-size: var(--fs-2); color: var(--muted); }
.mh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }

.summary-bar {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 14px 0 10px;
  font-size: var(--fs-2); color: var(--muted);
  border-bottom: 1px solid var(--border-light);
}
.chart-box { margin-bottom: 12px; }
.chart-box.h180 { height: 180px; }
.chart-box.h200 { height: 200px; }
.chart-caption { font-size: var(--fs-2); color: var(--muted); }
.tourn-label-text { font-weight: 700; font-size: var(--fs-3); }

.model-info-row { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.model-info-blurb { flex: 1; min-width: 240px; margin: 0; }
.stat-chip-row { display: flex; gap: 8px; flex-wrap: wrap; align-self: center; }
.stat-chip { padding: 8px 14px; background: var(--surface3); border-radius: 8px; text-align: center; min-width: 80px; }
.stat-chip-label { font-size: var(--fs-1); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-chip-num { font-size: 1rem; font-weight: 800; }
.stat-chip-sub { font-size: var(--fs-1); color: var(--muted); }

.override-banner {
  margin: 8px 0 12px; padding: 10px 14px;
  border-radius: 8px;
  background: rgba(240,192,64,0.08);
  border: 1px solid rgba(240,192,64,0.35);
  color: var(--gold);
  font-size: var(--fs-3); line-height: 1.45;
}
.ob-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.ob-icon { font-size: var(--fs-5); flex-shrink: 0; }
.ob-body { flex: 1; min-width: 200px; }
.ob-title { font-weight: 700; margin-bottom: 2px; }
.ob-detail { color: var(--text2); font-size: var(--fs-2); }
.ob-clear {
  background: rgba(240,192,64,0.15);
  border: 1px solid rgba(240,192,64,0.5);
  color: var(--gold);
  padding: 5px 12px; border-radius: 6px;
  font-size: var(--fs-2); font-weight: 600;
  cursor: pointer; flex-shrink: 0;
}

.perf-year-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 18px 0 14px; }
.perf-view-label { font-size: var(--fs-1); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
.perf-year-btn {
  padding: 6px 14px; border-radius: 8px;
  font-size: var(--fs-2); font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  cursor: pointer; transition: all .15s;
}
.perf-year-btn.active { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.perf-hero-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; align-items: stretch; }
.perf-grade-letter { font-size: 2.5rem; font-weight: 900; line-height: 1; }
.perf-grade-caption { font-size: var(--fs-1); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.perf-hero-col { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 240px; }
.perf-grade-detail { font-size: var(--fs-3); color: var(--text); font-weight: 600; }
.perf-meta { font-size: var(--fs-1); color: var(--muted); }
.perf-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 4px; }
.chart-tile { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.chart-tile-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.chart-tile-title { font-size: var(--fs-2); font-weight: 700; color: var(--text); }
.chart-tile-sub { font-size: var(--fs-1); color: var(--muted); }
/* Chart.js responsive mode sizes the canvas from its parent and injects
   inline canvas styles, so the fixed height lives on the wrapper (same
   pattern as .chart-box). */
.chart-tile-body { position: relative; height: 220px; }
.chart-tile-canvas { width: 100%; }
.perf-horizon-strip { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.perf-summary {
  font-size: var(--fs-2); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); cursor: pointer; padding: 10px 0; user-select: none;
  border-top: 1px solid var(--border);
}

.puzzle-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.puzzle-head h2 { font-size: var(--fs-5); font-weight: 700; margin: 0; }
.puzzle-count { font-size: var(--fs-1); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.puzzle-diff { font-size: var(--fs-2); color: var(--muted); margin-top: 2px; }
.puzzle-moves { font-size: var(--fs-2); color: var(--muted); margin-top: 8px; }
.puzzle-lichess { display: inline-block; margin-top: 12px; font-size: var(--fs-2); color: var(--blue); }

.email-split-tabs { margin-left: auto; }
.skip-link {
  position: absolute; top: -100%; left: 0;
  padding: 8px 16px;
  background: var(--gold); color: var(--ink);
  z-index: 10000; font-weight: 700; text-decoration: none;
  border-radius: 0 0 6px 0;
}
.footer-line { margin-bottom: 6px; }
.footer-hints { margin-top: 8px; font-size: var(--fs-1); opacity: .5; }

/* Programmatic focus lands on the active tab panel for screen-reader context;
   the global :focus-visible ring must not paint a frame around the whole tab. */
.page-tab-panel:focus, .page-tab-panel:focus-visible { outline: none; box-shadow: none; }


/* Touch targets (phase 4): on touch devices every small control clears 44px;
   the bottom-sheet segment buttons use the full 48px --touch token. */
.cmdk-close { min-width: 36px; min-height: 36px; }
@media (pointer: coarse) {
  .cmdk-close, .cmdk-recent-chip, .search-btn { min-height: 44px; }
  .cmdk-close { min-width: 44px; }
  .tt-search input, .de-table input[type="text"], .de-table input[type="number"], .de-table input[type="date"] { min-height: 44px; }
  .seg-btn { min-height: var(--touch); }
}


/* ── Progressive disclosure (phase 5): the four lower Predictions sections
   collapse behind native <details> on phones; desktop and print always render
   them open (JS syncSectionDisclosure + beforeprint force open). ── */
details.sect > .sect-summary { display: none; }
details.sect > .sect-summary::-webkit-details-marker { display: none; }
/* v4 W5: the summary text is a real h3 so screen-reader heading navigation
   lands on section boundaries on phones; inherit flattens the h3 defaults so
   the summary renders exactly as before. */
.sect-summary-h { font: inherit; margin: 0; display: inline; }
@media (max-width: 639px) {
  details.sect > .sect-summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: var(--touch);
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-3); font-weight: 700; color: var(--text);
    cursor: pointer; user-select: none;
    list-style: none;
  }
  details.sect > .sect-summary::after {
    content: '\25BE';
    color: var(--muted);
    transition: transform .2s;
  }
  details.sect[open] > .sect-summary::after { transform: rotate(180deg); }
  details.sect[open] > .sect-summary { margin-bottom: var(--s-3); }
  /* the summary already names these sections; drop the duplicated inner titles */
  #sect-model .model-info > .panel-title { display: none; }
  #sect-table .tt-head > .panel-title { display: none; }
}

/* ── Mini-grid hierarchy (phase 5): "Next up" featured row above a compact
   "Later" grid; renderMiniCards adds .mini-grid-tiered to the container. ── */
.mini-grid.mini-grid-tiered { display: block; }
.mini-section-label {
  font-size: var(--fs-1); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  margin: 2px 0 8px;
}
.mini-grid-featured {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.mini-grid-featured .mini-card { padding: var(--s-5); }
.mini-grid-featured .mini-card-number { font-size: 1.75rem; }
.mini-grid-rest {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s-2);
}
.mini-grid-rest .mini-card { padding: var(--s-3); }


/* Horizon strip (phase 6): neutral tiles, the MAE value is the one colored
   encoding; backgrounds no longer compete with the results table below. */
.horizon-tile {
  flex: 1; min-width: 80px;
  padding: 10px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.horizon-t { font-size: var(--fs-1); font-weight: 700; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.horizon-val { font-size: var(--fs-5); font-weight: 800; margin: 3px 0 2px; }
.horizon-ci { font-size: var(--fs-1); color: var(--muted); }

/* ══════════════════════════════════════════════════════
   PRINT — clean one-page tournament report
   ──────────────────────────────────────────────────────
   Older stakeholder prints tournament status for handouts /
   email attachments. Strip dark-mode chrome, kill chrome that
   doesn't translate (sticky header, page tabs, mini-cards,
   search bar), and lay the hero + chart + milestones + data
   table on white for legibility.
   ══════════════════════════════════════════════════════ */
@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f5f5f5;
    --surface3: #ebebeb;
    --text: #111;
    --text2: #222;
    --muted: #555;
    --border: #c8c8c8;
    --border-light: #d8d8d8;
  }
  body {
    background: #fff !important;
    color: #111 !important;
    font-size: 11pt;
    padding-bottom: 0 !important;
  }
  /* Suppress chrome that doesn't translate to print. */
  header,
  .page-tabs,
  .page-tab-drop,
  .tab-bar,
  .cmdk,
  .search-btn,
  .stale-banner,
  #overrideBanner,
  .compare-add-btn,
  .calendar-strip,
  .accuracy-strip,
  .all-tournaments,
  .panel.model-info,
  .mini-grid,
  .back-to-top,
  #weekBreakdown,
  .chart-card .vert-lines {
    display: none !important;
  }
  /* Only show the active tab panel. */
  .page-tab-panel:not(.active) { display: none !important; }
  /* No glow, no blur, no shadows on print. */
  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  /* Card surfaces become bordered light boxes. */
  .chart-card, .panel, .delta-banner {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    page-break-inside: avoid;
  }
  /* Hero number printable in black + gold tint. */
  .hero-number {
    color: #111 !important;
    font-size: 36pt !important;
  }
  .hero-number::after { display: none !important; }
  .hero-narrative strong { color: #000 !important; }
  .hn-pos { color: #1a6f30 !important; }
  .hn-neg { color: #a32a23 !important; }
  .hn-flat { color: #8a6b00 !important; }
  /* Delta banner becomes a plain bordered box on print. */
  .delta-banner.green, .delta-banner.red, .delta-banner.gold,
  .delta-banner.muted {
    background: #fff !important;
    border: 1px solid var(--border) !important;
  }
  /* Chart canvas: ensure it stays at a reasonable height. */
  .chart-wrap { height: 280px !important; }
  /* Milestone strip: dots become solid black; status colors keep. */
  .ms-line { background: #ddd !important; }
  .ms-line-past { background: #888 !important; }
  /* Page break opportunities */
  .grid-2 { page-break-inside: avoid; }
  a[href]:after { content: ""; }
}

/* ══════════════════════════════════════════════════════
   ASK TAB — chatbot UI
   ══════════════════════════════════════════════════════ */
.ask-wrap { max-width: 760px; margin: 24px auto 80px; padding: 0 8px; }
.ask-header { margin-bottom: 16px; }
.ask-title { font-size: 1.25rem; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.ask-sub { font-size: var(--fs-3); color: var(--muted); }
.ask-input-row {
  display: flex; gap: 10px; align-items: stretch;
  margin-bottom: 12px;
}
.ask-input {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 1.05rem; line-height: 1.4;
  padding: 14px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  resize: vertical; min-height: 56px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ask-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,139,253,.15); }
.ask-submit {
  flex-shrink: 0;
  padding: 0 26px; min-height: 56px;
  background: var(--gold); color: var(--ink);
  border: 1px solid var(--gold); border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 600; letter-spacing: .3px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.ask-submit:hover:not(:disabled) { background: var(--gold-bright); border-color: var(--gold-bright); }
.ask-submit:active:not(:disabled) { transform: translateY(1px); }
.ask-submit:disabled { opacity: .5; cursor: progress; }
.ask-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}
.ask-chip {
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: var(--fs-3);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.ask-chip:hover { background: var(--blue-dim); color: var(--blue-bright); border-color: var(--blue); }
.ask-banner {
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-3); line-height: 1.4;
}
.ask-banner.is-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,81,73,.4); }
.ask-banner.is-warn { background: var(--orange-dim); color: var(--orange-bright); border: 1px solid rgba(210,153,34,.4); }
.ask-answer {
  display: flex; flex-direction: column; gap: 14px;
  color: var(--text); font-size: 1rem;
}
.ask-answer:empty { display: none; }
.ask-turn { display: flex; }
.ask-turn-user { justify-content: flex-end; }
.ask-turn-assistant { justify-content: flex-start; }
.ask-bubble {
  max-width: 88%;
  padding: 12px 16px; border-radius: 14px;
  line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.ask-turn-user .ask-bubble {
  background: var(--blue-dim); border: 1px solid rgba(56, 139, 253, .35);
  color: var(--text); border-bottom-right-radius: 4px;
}
.ask-turn-assistant .ask-bubble {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 4px;
}
.ask-pending {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--muted); font-style: italic;
}
.ask-spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--blue);
  animation: ask-spin .8s linear infinite;
}
@keyframes ask-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ask-spinner { animation: none; } }
.ask-pending-label { font-variant-numeric: tabular-nums; font-style: normal; color: var(--text2); }
.ask-cancel {
  margin-left: auto; background: transparent; border: 1px solid var(--border);
  color: var(--text2); border-radius: var(--radius-sm);
  padding: 4px 11px; font-size: var(--fs-2); font-style: normal; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.ask-cancel:hover { border-color: var(--red); color: var(--red); }
.ask-answer-meta {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light);
  font-size: var(--fs-2); color: var(--muted);
  display: flex; gap: 14px; flex-wrap: wrap;
}
.ask-recent { margin-top: 22px; }
.ask-recent:empty { display: none; }
.ask-recent-title {
  font-size: var(--fs-2); text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--muted); margin-bottom: 8px;
}
.ask-recent-list { display: flex; flex-direction: column; gap: 6px; }
.ask-recent-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: var(--fs-3); color: var(--text2);
  text-align: left; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.ask-recent-item:hover { background: var(--blue-dim); border-color: var(--blue); color: var(--text); }
.ask-fallback-results {
  margin-top: 14px; display: flex; flex-direction: column; gap: 6px;
}
.ask-fallback-item {
  background: var(--surface2); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: var(--fs-3); color: var(--text2);
  display: flex; justify-content: space-between; gap: 12px;
}
.ask-fallback-item strong { color: var(--text); font-weight: 600; }
.ask-fallback-item .meta { color: var(--muted); font-size: var(--fs-2); white-space: nowrap; }
@media (max-width: 640px) {
  .ask-input-row { flex-direction: column; }
  .ask-submit { width: 100%; }
  .ask-wrap { padding: 0 12px; }
}

/* ── Audit tab ─────────────────────────────────────────────────────── */
.audit-wrap { max-width: 760px; margin: 0 auto; }
.audit-controls {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 14px;
}
.audit-label { font-size: var(--fs-2); color: var(--text2); }
.audit-select {
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 10px; font-size: var(--fs-4); max-width: 420px;
}
.audit-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audit-hint { font-size: var(--fs-2); color: var(--text2); opacity: .75; }
.audit-controls .ask-submit { align-self: flex-start; margin-top: 4px; }
.audit-banner {
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-3); line-height: 1.4;
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border);
}
.audit-banner.error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,81,73,.4); }
.audit-banner.ok { border-color: var(--gold-dim); color: var(--gold); }
.audit-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px;
}
.audit-summary-table { border-collapse: collapse; width: 100%; font-size: var(--fs-3); }
.audit-summary-table th {
  text-align: left; font-weight: 400; color: var(--text2);
  padding: 4px 14px 4px 0; white-space: nowrap;
}
.audit-summary-table td { text-align: right; color: var(--gold); font-variant-numeric: tabular-nums; }
.audit-download { margin-bottom: 16px; }
@media (max-width: 640px) {
  .audit-wrap { padding: 0 12px; }
  .audit-select { max-width: none; }
  .audit-controls .ask-submit, .audit-download { width: 100%; }
}
