/* ═══════════════════════════════════════════════════════════════════════
   Cortex design system — courtside. The whole app lives on a hardwood
   floor with painted court lines: broadcast-scoreboard typography, court
   orange, scoreboard chrome. Dense and engineered underneath,
   basketball on the surface. No external dependencies.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* night game: deep walnut floor, warm lacquered-wood cards */
  --bg:        #1c1208;
  --bg-2:      #251709;
  --surface:   #271a0e;
  --surface-2: #31210f;
  --surface-3: #3c2a14;
  --border:    rgba(255,214,170,0.11);
  --border-2:  rgba(255,214,170,0.22);

  --text:   #f6edda;
  --text-2: #d3bf9f;
  --text-3: #a1885f;

  --accent:     #ff6a3d;   /* game-ball orange */
  --accent-2:   #ff8a5d;
  --accent-bg:  rgba(255,106,61,0.14);
  --green:      #2fe0a0;
  --green-bg:   rgba(47,224,160,0.13);
  --amber:      #ffc14d;
  --amber-bg:   rgba(255,193,77,0.13);
  --red:        #ff5c72;
  --red-bg:     rgba(255,92,114,0.13);
  --teal:       #34e0d0;
  --purple:     #b39cff;

  --chart-grid: rgba(255,214,170,0.08);

  /* the court itself */
  --wood-base:  #38260f;
  --wood-plank: rgba(0,0,0,0.20);
  --court-line: rgba(245,236,222,0.16);

  --sans:    'Archivo', -apple-system, BlinkMacSystemFont, sans-serif;
  --display: 'Big Shoulders Display', 'Archivo', sans-serif;
  --mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --shadow-1: 0 1px 0 rgba(255,255,255,.02), 0 2px 6px rgba(0,0,0,.35);
  --shadow-2: 0 1px 0 rgba(255,255,255,.03), 0 14px 40px rgba(0,0,0,.5);
  --ease: cubic-bezier(.22,.61,.36,1);
}

[data-theme="light"] {
  /* day game on maple */
  --bg:        #ecd9b4;
  --bg-2:      #f3e7c9;
  --surface:   #fbf5e6;
  --surface-2: #f1e6cd;
  --surface-3: #e6d6b4;
  --border:    rgba(110,70,30,0.16);
  --border-2:  rgba(110,70,30,0.30);
  --text:   #2b1c0e;
  --text-2: #5d4527;
  --text-3: #8d7350;
  --accent:    #d84a18;
  --accent-2:  #b93a10;
  --accent-bg: rgba(216,74,24,0.11);
  --green:   #0e9f6e;
  --green-bg: rgba(14,159,110,0.12);
  --amber:   #b97d10;
  --amber-bg: rgba(185,125,16,0.13);
  --red:     #d4344c;
  --red-bg:  rgba(212,52,76,0.11);
  --teal:    #0d9e92;
  --purple:  #7757d6;
  --chart-grid: rgba(110,70,30,0.12);
  --wood-base:  #e0bd86;
  --wood-plank: rgba(110,70,30,0.16);
  --court-line: rgba(90,55,25,0.22);
  --shadow-1: 0 1px 2px rgba(80,50,20,.08);
  --shadow-2: 0 12px 36px rgba(80,50,20,.16);
}

/* ── Reset / base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--wood-base);
  /* hardwood: subtle planks one direction + gentle top light */
  background-image:
    repeating-linear-gradient(90deg, var(--wood-plank) 0 1px, transparent 1px 116px),
    linear-gradient(180deg, rgba(255,255,255,0.015), rgba(0,0,0,0.14));
  background-attachment: fixed;
  color: var(--text);
  font: 450 13.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* arena atmosphere: two spotlights raking the floor + a vignette, then a
   breath of photographic grain so the wood never reads as flat vector */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(52% 38% at 18% -6%, rgba(255,170,90,0.10), transparent 70%),
    radial-gradient(46% 34% at 82% -4%, rgba(255,140,70,0.07), transparent 70%),
    radial-gradient(130% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.32) 100%);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="light"] body::before {
  background:
    radial-gradient(52% 38% at 18% -6%, rgba(255,255,255,0.5), transparent 70%),
    radial-gradient(130% 100% at 50% 50%, transparent 60%, rgba(95,60,25,0.16) 100%);
}

/* painted court lines the content scrolls over */
.court-bg {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0;
  z-index: 0; display: flex; justify-content: center; pointer-events: none;
}
.court-bg svg { width: auto; height: 100%; color: var(--court-line); }
.shell { position: relative; z-index: 1; }

h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -0.011em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
kbd {
  font: 600 10px/1 var(--mono);
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 5px;
}
.mono { font-family: var(--mono); }
::selection { background: var(--accent-bg); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -48px; left: 12px; z-index: 200;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--r-sm);
  transition: top .15s var(--ease);
}
.skip-link:focus { top: 12px; }

@keyframes chart-draw { to { stroke-dashoffset: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Shell layout ───────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 9px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--accent-bg); color: var(--accent);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font: 800 16px/1 var(--display); letter-spacing: 0.2em; }
.brand-sub { font-size: 10.5px; color: var(--text-3); }
.topbar-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-2);
}
.tb-dim { color: var(--text-3); }
.tb-sep { width: 1px; height: 14px; background: var(--border-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: 0 0 8px; }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }
.tb-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12px; font-weight: 500;
  transition: border-color .12s, color .12s, background .12s;
}
.tb-btn:hover { color: var(--text); border-color: var(--border-2); }
.tb-btn svg { width: 14px; height: 14px; }
.tb-btn[aria-pressed="true"] { color: var(--accent-2); border-color: var(--accent); background: var(--accent-bg); }
[data-theme="light"] .tb-btn[aria-pressed="true"] { color: var(--accent); }
.tb-btn.refreshing svg { animation: spin 1s linear infinite; }
.tb-count { font-size: 10.5px; min-width: 24px; text-align: right; color: var(--text-3); }
.tb-icon { padding: 5px 7px; }

.views { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 16px; animation: fade-up .25s var(--ease); }
.view[hidden] { display: none; }



/* ── Primitives ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.card-head h3 {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}
.card-head h3::before {
  /* broadcast lower-third notch */
  content: ''; width: 4px; height: 13px; border-radius: 1.5px;
  background: var(--accent); flex: none;
  box-shadow: 0 0 8px rgba(255,106,61,0.45);
}
.card-hint { font-size: 11px; color: var(--text-3); font-weight: 450; margin-left: 6px; }
.card-sub { font-size: 12px; color: var(--text-3); margin: -6px 0 12px; max-width: 78ch; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
.grid-2 > .card { display: flex; flex-direction: column; min-width: 0; }
/* matched heights: the board pair and the chart pair each share one height,
   overflow scrolls inside the card instead of stretching the column */
#sec-board > .card { height: 600px; }
#sec-board .search-wrap { flex: none; }
#leaderboard-container { flex: 1; overflow: auto; min-height: 0; }
#sec-charts > .card { height: 430px; }
#sec-charts .chart-host { flex: 1; min-height: 0; }

.badge {
  display: inline-flex; align-items: center;
  font: 600 11px/1 var(--mono);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 99px;
}
.badge-accent { color: var(--accent-2); background: var(--accent-bg); border-color: transparent; }
[data-theme="light"] .badge-accent { color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 550 11px/1 var(--mono);
  color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 9px; border-radius: 99px;
}
.chip-live { color: var(--green); }
.chip-accent { color: var(--accent-2); }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.8s infinite; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2); background: var(--surface-2);
  font-size: 12.5px; font-weight: 600; color: var(--text);
  transition: transform .1s var(--ease), background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-family: var(--display); font-weight: 700; font-size: 14px;
  letter-spacing: .06em; text-transform: uppercase; padding: 7px 16px;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  border-radius: 2px;
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); transform: translateY(-1px); }
[data-theme="light"] .btn-primary:hover { background: var(--accent-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color .12s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.tabs { display: flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.tab {
  padding: 4px 9px; border-radius: 4px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  transition: background .12s, color .12s;
}
.tab:hover { color: var(--text-2); }
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; font-weight: 600; color: var(--text-3); }

.error-msg { color: var(--red); font-size: 12px; padding: 8px 0; }

/* skeletons */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: skel 1.3s infinite linear; border-radius: 4px; }
@keyframes skel { to { background-position: -200% 0; } }
.skeleton-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.skeleton-circle { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px; }
.skeleton-line { height: 12px; }

/* toasts */
.toast-container { position: fixed; bottom: 18px; right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--red); border-left-width: 3px;
  color: var(--text); border-radius: var(--r-sm); padding: 9px 13px;
  font-size: 12.5px; box-shadow: var(--shadow-2);
  animation: toast-in .18s var(--ease);
  max-width: 340px;
}
.toast-warn { border-color: var(--amber); }
.toast-info { border-color: var(--accent); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center;
  opacity: 0; pointer-events: none; transition: opacity .16s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(520px, calc(100vw - 32px)); max-height: 84vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  transform: translateY(8px) scale(.985); transition: transform .16s var(--ease);
}
.modal-backdrop.open .modal { transform: none; }

/* ── Court hero (overview) — broadcast open: hoop, ball, the works ──── */
.court-hero {
  position: relative; overflow: hidden;
  border: 1px solid rgba(245,236,222,0.14); border-radius: var(--r-lg);
  display: grid; grid-template-columns: 1.05fr 1fr; align-items: stretch; min-height: 252px;
  color: #f6ecdb;
  background:
    linear-gradient(120deg, rgba(28,16,7,0.05), rgba(20,11,4,0.5)),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 96px),
    linear-gradient(165deg, #714827 0%, #5a371d 46%, #432a15 100%);
  box-shadow: var(--shadow-2);
}
.court-hero-copy { padding: 36px 34px; align-self: center; position: relative; z-index: 2; }
.ch-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: #ffce9a; margin-bottom: 14px; display: flex; align-items: center; gap: 9px;
}
.ch-eyebrow::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #46e6a4; box-shadow: 0 0 0 3px rgba(70,230,164,0.22);
  animation: pulse 2.4s ease-in-out infinite;
}
.ch-title {
  font-family: var(--display); font-size: clamp(44px, 5.6vw, 72px); line-height: .88;
  letter-spacing: .012em; color: #f7eedd; margin: 0 0 14px;
  text-shadow: 0 2px 14px rgba(0,0,0,0.4); font-weight: 900;
}
.ch-title .acc { color: #ff8a4d; }
.ch-sub { font-family: var(--mono); font-size: 11.5px; letter-spacing: .4px; color: #d8c3a6; line-height: 1.7; max-width: 48ch; }
.hero-cta { display: flex; gap: 10px; margin-top: 18px; }
.court-stage { position: relative; }
.court-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.court-svg .shot-traj { stroke: rgba(255,160,110,0.55); stroke-width: 1.5; stroke-dasharray: 2 7; }
.court-svg .board { fill: rgba(255,255,255,0.05); stroke: rgba(245,236,222,0.55); stroke-width: 2; }
.court-svg .target { fill: none; stroke: #ff8a4d; stroke-width: 2; }
.court-svg .rim {
  fill: none; stroke: #ff6a3d; stroke-width: 3.5;
  filter: drop-shadow(0 0 6px rgba(255,106,61,0.85));
  animation: hoopPulse 3.4s ease-in-out infinite;
}
.court-svg .net { stroke: rgba(245,236,222,0.5); stroke-width: 1; fill: none; }
@keyframes hoopPulse { 0%,52% { stroke-width: 3.5; } 62% { stroke-width: 6; } 78%,100% { stroke-width: 3.5; } }

/* ── Bottom-line ticker — the sports-network strip, fed by real finals ── */
.ticker {
  display: flex; align-items: stretch; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: #150c04; box-shadow: var(--shadow-1);
}
[data-theme="light"] .ticker { background: #2b1c0e; }
.ticker-label {
  display: grid; place-items: center; padding: 7px 13px;
  font: 800 13px/1 var(--display); letter-spacing: .14em; color: #fff;
  background: var(--accent); flex: none;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  padding-right: 19px;
}
.ticker-clip { overflow: hidden; flex: 1; display: flex; align-items: center; }
.ticker-track {
  display: inline-flex; gap: 34px; white-space: nowrap; padding-left: 100%;
  font: 500 11.5px/1 var(--mono); color: #e8d9bf;
  animation: ticker 75s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-track .tk-win { color: #ffce86; font-weight: 700; }
.ticker-track .tk-final { color: var(--accent-2); font-weight: 700; letter-spacing: .1em; font-size: 9.5px; }
.ticker-track .tk-sep { color: rgba(255,214,170,0.28); }
@keyframes ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; padding-left: 12px; }
}

/* ── Jumbotron tiles — the hero metrics as scoreboard segments ─────── */
.hero-metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.hero-metrics .metric {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, #1b1006 0%, #241405 100%);
  border: 1px solid rgba(255,170,90,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -10px 24px rgba(0,0,0,0.45), var(--shadow-1);
}
.hero-metrics .metric::after {
  /* jumbotron scanlines */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
}
.hero-metrics .metric-v {
  color: #ffd9a3;
  text-shadow: 0 0 14px rgba(255,160,80,0.5), 0 0 3px rgba(255,180,100,0.7);
}
.hero-metrics .hero-metrics .metric-l { color: #b89468; }
[data-theme="light"] .hero-metrics .metric { background: linear-gradient(180deg, #34230f, #2a1a0a); border-color: rgba(255,190,120,0.3); }
.metric {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.metric-v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.metric-unit { font-size: 12px; color: var(--text-3); margin-left: 2px; }
.metric-l { font-size: 11px; color: var(--text-3); }
[data-theme="light"] 
/* ── Live stream ───────────────────────────────────────────────────── */
.stream-idle p { color: var(--text-3); font-size: 12.5px; max-width: 72ch; }
.live-board { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 6px 0 12px; }
.live-team { text-align: center; }
.live-team-name { font: 700 13px/1.2 var(--mono); color: var(--text-2); letter-spacing: .06em; }
.live-team-score { font-family: var(--display); font-size: 52px; font-weight: 800; letter-spacing: .01em; }
.live-team-score.pop { animation: score-pop .55s var(--ease); }
@keyframes score-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); color: var(--amber); text-shadow: 0 0 22px rgba(255,193,77,.7); }
  100% { transform: scale(1); }
}
.live-team-score.leading { color: var(--green); }
.live-clock { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-3); }
.live-clock-period { font-size: 12px; font-weight: 700; }
.live-clock-time { font-size: 18px; font-weight: 600; color: var(--text-2); }
.live-wp { padding: 6px 0 14px; }
.live-wp-row { display: flex; align-items: center; gap: 10px; }
.live-wp-pct { font-size: 13px; font-weight: 700; min-width: 42px; }
.live-wp-pct:last-child { text-align: right; }
.live-wp-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--red-bg); overflow: hidden; direction: rtl; }
.live-wp-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--teal)); border-radius: 99px; transition: width .5s var(--ease); }
.live-wp-labels { display: flex; justify-content: space-between; font: 600 10px/1 var(--mono); color: var(--text-3); margin-top: 5px; letter-spacing: .08em; }
.live-wp-tag { font-weight: 450; letter-spacing: 0; text-transform: none; }
.stream-box { display: flex; flex-direction: column; gap: 4px; }
.stream-empty { color: var(--text-3); font-size: 12px; padding: 6px 0; }
.stream-event {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 12px; animation: fade-up .2s var(--ease);
}
.ev-time { font-family: var(--mono); color: var(--text-3); font-size: 11px; min-width: 72px; }
.ev-tag {
  font: 700 9.5px/1 var(--mono); letter-spacing: .05em;
  padding: 3px 6px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-2); min-width: 38px; text-align: center;
}
.ev-tag.made { background: var(--green-bg); color: var(--green); }
.ev-tag.miss { background: var(--red-bg); color: var(--red); }
.ev-detail { color: var(--text-2); }
.ev-score { margin-left: auto; font-family: var(--mono); font-weight: 600; }
.ev-wp { font: 600 11px/1 var(--mono); padding: 3px 7px; border-radius: 99px; }
.ev-wp.high { background: var(--green-bg); color: var(--green); }
.ev-wp.mid { background: var(--amber-bg); color: var(--amber); }
.ev-wp.low { background: var(--red-bg); color: var(--red); }

/* ── Search overlays ───────────────────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 10px; }
.search-overlay {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  max-height: 320px; overflow: auto;
  display: none;
}
.search-overlay.open { display: block; }
.search-result-item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: default; }
.search-result-item:last-child { border-bottom: 0; }
.search-result-item:hover { background: var(--surface-3); }
.sr-name { font-weight: 600; font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sr-meta { color: var(--text-3); font-size: 11.5px; }
.sr-stats { display: flex; gap: 10px; color: var(--text-3); font-size: 11px; margin-top: 3px; flex-wrap: wrap; }
.sr-stat-val { color: var(--text); font-family: var(--mono); font-weight: 600; }

.team-badge, .pos-badge {
  font: 600 9.5px/1 var(--mono);
  padding: 2px 5px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-3);
}
.pos-badge { background: var(--accent-bg); color: var(--accent-2); }
[data-theme="light"] .pos-badge { color: var(--accent); }

/* ── Leaderboard table ─────────────────────────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lb-table th {
  text-align: left; font: 600 10.5px/1 var(--mono); letter-spacing: .07em;
  color: var(--text-3); text-transform: uppercase;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.lb-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.lb-table tr:last-child td { border-bottom: 0; }
.lb-table tr:hover td { background: var(--surface-2); }
.rank {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  font: 600 10.5px/1 var(--mono);
  background: var(--surface-3); color: var(--text-3);
  margin-right: 7px;
}
.rank.top { background: var(--accent-bg); color: var(--accent-2); }
[data-theme="light"] .rank.top { color: var(--accent); }
.player-name { font-weight: 600; margin-right: 6px; }
.ppg-bar { display: flex; align-items: center; gap: 8px; }
.stat-highlight { font-family: var(--mono); font-weight: 700; min-width: 44px; }
.bar-bg { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 50px; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--teal)); transition: width .4s var(--ease); }

/* ── Games list ────────────────────────────────────────────────────── */
.games-scroll { flex: 1; min-height: 0; overflow: auto; }
.game-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  border: 1px solid transparent;
}
.game-item:hover { background: var(--surface-2); }
.game-item.live-game { border-color: var(--green); cursor: pointer; }
.game-matchup { display: flex; gap: 6px; font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.game-matchup .vs { color: var(--text-3); }
.game-date-small { font-size: 11px; color: var(--text-3); }
.game-live-tip { font-size: 10.5px; color: var(--green); }
.game-right { display: flex; align-items: center; gap: 10px; }
.game-score { font-family: var(--mono); font-weight: 600; font-size: 13.5px; display: flex; gap: 5px; }
.game-score .sep { color: var(--text-3); }
.game-score .winner { color: var(--green); }
.game-score.tbd { color: var(--text-3); font-size: 12px; letter-spacing: 0; }
.status-badge { font: 600 10px/1 var(--mono); padding: 3px 7px; border-radius: 99px; letter-spacing: .04em; }
.status-final { background: var(--surface-3); color: var(--text-3); }
.status-live { background: var(--green-bg); color: var(--green); }
.status-sched { background: var(--accent-bg); color: var(--accent-2); }
[data-theme="light"] .status-sched { color: var(--accent); }

/* ── Similarity ────────────────────────────────────────────────────── */
.sim-form { display: grid; grid-template-columns: repeat(6, 1fr) auto; gap: 10px; align-items: end; }
.sim-btn { white-space: nowrap; }
.sim-meta { color: var(--text-3); font-size: 11.5px; margin-top: 10px; min-height: 16px; }
.sim-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.sim-note { color: var(--text-3); font-size: 12px; grid-column: 1/-1; }
.sim-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 13px; transition: border-color .12s, transform .12s var(--ease); }
.sim-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.sim-card-header { display: flex; justify-content: space-between; align-items: center; }
.sim-matchup { font: 600 12px/1 var(--mono); }
.sim-similarity { font: 700 11px/1 var(--mono); color: var(--accent-2); background: var(--accent-bg); padding: 3px 7px; border-radius: 99px; }
[data-theme="light"] .sim-similarity { color: var(--accent); }
.sim-score { font: 700 18px/1.3 var(--mono); margin: 7px 0 3px; }
.sim-details { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); }
.outcome-win { color: var(--green); font-weight: 600; }
.outcome-loss { color: var(--red); font-weight: 600; }

.team-autofill-wrap { position: relative; }
.team-autofill-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 168px; z-index: 40;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  max-height: 260px; overflow: auto; display: none;
}
.team-autofill-dropdown.open { display: block; }
.team-autofill-item { display: flex; align-items: center; gap: 9px; padding: 7px 11px; font-size: 12px; cursor: pointer; }
.team-autofill-item:hover, .team-autofill-item.highlighted { background: var(--surface-3); }
.taf-tricode { font: 700 12px/1 var(--mono); }
.taf-rating { font-family: var(--mono); color: var(--accent-2); }
[data-theme="light"] .taf-rating { color: var(--accent); }
.taf-record { margin-left: auto; color: var(--text-3); font-size: 11px; }

.win-prob-banner {
  display: flex; align-items: center; gap: 18px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 13px 16px; margin-top: 10px;
}
.wp-label { font: 600 10px/1 var(--mono); letter-spacing: .07em; color: var(--text-3); text-transform: uppercase; }
.wp-value { font: 700 24px/1.2 var(--mono); }
.wp-bar-outer { height: 8px; border-radius: 99px; background: var(--red-bg); overflow: hidden; }
.wp-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--green), var(--teal)); transition: width .5s var(--ease); }
.wp-sides { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.wp-note { font-size: 11px; color: var(--text-3); margin-top: 6px; }
.wp-elo-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 8px; padding: 9px 14px;
  background: var(--accent-bg); border-radius: var(--r-sm); font-size: 12px;
}
.wp-elo-row .lead { font-weight: 700; color: var(--accent-2); }
[data-theme="light"] .wp-elo-row .lead { color: var(--accent); }
.wp-elo-row .sep { color: var(--text-3); }
.wp-elo-row .tail { margin-left: auto; font-weight: 700; color: var(--accent-2); }
[data-theme="light"] .wp-elo-row .tail { color: var(--accent); }

/* ── Elo grid + modal ──────────────────────────────────────────────── */
.elo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.elo-team {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 9px 11px; cursor: pointer;
  transition: border-color .12s, transform .12s var(--ease);
}
.elo-team:hover { border-color: var(--accent); transform: translateY(-1px); }
.elo-rank {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 50%; font: 700 10.5px/1 var(--mono);
  background: var(--surface-3); color: var(--text-3);
}
.elo-rank.top3 { background: var(--accent-bg); color: var(--accent-2); }
[data-theme="light"] .elo-rank.top3 { color: var(--accent); }
.elo-info { min-width: 0; flex: 1; }
.elo-tricode { font: 700 12.5px/1.3 var(--mono); display: flex; gap: 7px; align-items: baseline; }
.elo-rating { color: var(--accent-2); font-weight: 600; font-size: 11.5px; }
[data-theme="light"] .elo-rating { color: var(--accent); }
.elo-record { font-size: 10.5px; color: var(--text-3); }
.elo-bar-outer { width: 52px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: 0 0 52px; }
.elo-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--teal)); border-radius: 99px; }

.elo-modal-header { display: flex; align-items: center; gap: 13px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.elo-modal-rank { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font: 700 13px/1 var(--mono); background: var(--surface-3); color: var(--text-3); }
.elo-modal-rank.top3 { background: var(--accent-bg); color: var(--accent-2); }
.elo-modal-tricode { font: 800 19px/1 var(--mono); margin-right: 9px; }
.elo-modal-rating { font: 700 15px/1 var(--mono); color: var(--accent-2); }
.elo-modal-record { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.elo-modal-close { margin-left: auto; font-size: 19px; color: var(--text-3); padding: 4px 9px; border-radius: var(--r-sm); }
.elo-modal-close:hover { background: var(--surface-3); color: var(--text); }
.elo-modal-body { padding: 16px 18px; }
.elo-modal-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.elo-modal-stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; }
.elo-modal-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.elo-modal-stat-value { font: 700 16px/1.4 var(--mono); }
.elo-modal-stat-value.positive { color: var(--green); }
.elo-modal-stat-value.negative { color: var(--red); }
.elo-modal-bar-section { margin: 13px 0; }
.elo-modal-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-bottom: 5px; }
.elo-modal-bar-outer { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.elo-modal-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--green), var(--teal)); }
.elo-modal-calc { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px; font-size: 12px; color: var(--text-2); line-height: 1.7; }

/* ── Charts ────────────────────────────────────────────────────────── */
.chart-host { width: 100%; min-height: 200px; }
.chart-host svg { width: 100%; height: auto; display: block; }
.chart-scroll { overflow-y: auto; }
.chart-tick { font: 500 10px var(--mono); }
.linechart { user-select: none; }
.chart-tip {
  position: absolute; z-index: 10; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); box-shadow: var(--shadow-2);
  padding: 8px 11px; font-size: 11.5px; min-width: 130px;
}
.chart-tip-title { font: 600 10.5px var(--mono); color: var(--text-3); margin-bottom: 5px; }
.chart-tip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.chart-tip-row .mono { margin-left: auto; font-weight: 600; }
.chart-tip-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }

.hbar { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 168px 1fr 86px; align-items: center; gap: 11px; font-size: 12px; }
.hbar-label { color: var(--text-2); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { position: relative; height: 18px; border-radius: 5px; background: var(--bg-2); border: 1px solid var(--border); overflow: visible; }
.hbar-fill {
  position: absolute; inset: 2px auto 2px 2px; border-radius: 3.5px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width .7s var(--ease);
  min-width: 2px;
}
.hbar-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--amber); border-radius: 2px; }
.hbar-value { text-align: right; font-weight: 650; font-size: 11.5px; }
.hbar-legend { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.hbar-target-key { width: 10px; height: 2px; background: var(--amber); border-radius: 2px; display: inline-block; }

.sparkline { width: 120px; height: 32px; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .court-hero { grid-template-columns: 1fr; min-height: 0; }
  .court-stage { min-height: 180px; }
  .hero-metrics { grid-template-columns: repeat(3, 1fr); }
  .sim-form { grid-template-columns: repeat(3, 1fr); }
  .sim-btn { grid-column: 1 / -1; }
}
@media (max-width: 880px) {
  .grid-2 { grid-template-columns: 1fr; }
  .views { padding: 14px; }
  .topbar { padding: 9px 14px; }
  .tb-btn span { display: none; }
  .elo-modal-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .sim-form { grid-template-columns: 1fr 1fr; }
  .hbar-row { grid-template-columns: 110px 1fr 70px; }
}
