/* ============================================================
   Peel Position — refined pool hall design system
   Responsive: phone (≤640) / tablet (641-1024) / desktop (1025+)
   ============================================================ */

/* ---- Tokens ---- */
:root {
  /* Felt — refined deep green, lower chroma than before */
  --felt-950: oklch(16% 0.025 155);
  --felt-900: oklch(20% 0.035 155);
  --felt-800: oklch(25% 0.045 155);
  --felt-700: oklch(31% 0.055 155);
  --felt-600: oklch(38% 0.05  155);

  /* Wood / rail — warm walnut */
  --wood-900: oklch(22% 0.035 50);
  --wood-700: oklch(38% 0.07  45);
  --wood-500: oklch(54% 0.10  50);
  --wood-300: oklch(72% 0.08  60);

  /* Chalk — warm off-white text on felt */
  --chalk-50:  oklch(96% 0.012 85);
  --chalk-100: oklch(92% 0.014 85);
  --chalk-200: oklch(82% 0.015 85);
  --chalk-300: oklch(70% 0.013 85);
  --chalk-400: oklch(58% 0.012 85);
  --chalk-500: oklch(48% 0.012 85);

  /* Cue chalk blue (default accent) */
  --cue-200: oklch(88% 0.07 230);
  --cue-400: oklch(72% 0.12 230);
  --cue-500: oklch(64% 0.14 230);
  --cue-600: oklch(55% 0.14 230);

  /* Accent — bound by tweaks (default = cue) */
  --accent: var(--cue-500);
  --accent-soft: color-mix(in oklab, var(--accent) 22%, transparent);
  --accent-on:   #fff;

  /* Outcomes */
  --win:  oklch(72% 0.18 145);
  --loss: oklch(64% 0.20 25);
  --gold: oklch(82% 0.16 85);
  --flame-red: oklch(62% 0.22 28);

  /* Pool ball colors — 1..9 */
  --ball-1: #f0c64a; /* yellow */
  --ball-2: #295db0; /* blue */
  --ball-3: #c83631; /* red */
  --ball-4: #6c378c; /* purple */
  --ball-5: #d97032; /* orange */
  --ball-6: #1e8a4b; /* green */
  --ball-7: #802826; /* maroon */
  --ball-8: #161616; /* black */
  --ball-9: #f0c64a; /* yellow stripe */

  /* Surfaces */
  --bg:        var(--felt-950);
  --surface:   var(--felt-900);
  --surface-2: var(--felt-800);
  --surface-3: var(--felt-700);
  --rail:      var(--wood-900);
  --border:    color-mix(in oklab, var(--chalk-50) 10%, transparent);
  --border-strong: color-mix(in oklab, var(--chalk-50) 18%, transparent);

  /* Density */
  --density: 1;        /* 1 = cozy, 0.78 = compact */
  --space-1: calc(4px  * var(--density));
  --space-2: calc(8px  * var(--density));
  --space-3: calc(12px * var(--density));
  --space-4: calc(16px * var(--density));
  --space-5: calc(24px * var(--density));
  --space-6: calc(32px * var(--density));
  --space-7: calc(48px * var(--density));

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Type */
  --font-sans: "Geist", "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: "Geist", var(--font-sans);

  /* Shadow — soft, layered, never harsh */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-md: 0 6px 18px -8px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.18);
  --shadow-lg: 0 18px 40px -16px rgba(0,0,0,0.7), 0 6px 14px rgba(0,0,0,0.22);
}

/* Theme: chalk (light) */
[data-theme="chalk"] {
  --bg:        oklch(95% 0.012 85);
  --surface:   oklch(98% 0.008 85);
  --surface-2: oklch(94% 0.014 85);
  --surface-3: oklch(90% 0.018 85);
  --rail:      oklch(88% 0.022 60);
  --chalk-50:  oklch(22% 0.02 155);
  --chalk-100: oklch(28% 0.02 155);
  --chalk-200: oklch(36% 0.018 155);
  --chalk-300: oklch(46% 0.015 155);
  --chalk-400: oklch(58% 0.013 85);
  --chalk-500: oklch(68% 0.010 85);
  --border:    color-mix(in oklab, var(--felt-900) 12%, transparent);
  --border-strong: color-mix(in oklab, var(--felt-900) 22%, transparent);
  --accent:    var(--cue-600);
  --accent-soft: color-mix(in oklab, var(--accent) 16%, transparent);
}

/* Theme: midnight */
[data-theme="midnight"] {
  --bg:        oklch(13% 0.02 260);
  --surface:   oklch(17% 0.025 260);
  --surface-2: oklch(22% 0.03 260);
  --surface-3: oklch(28% 0.035 260);
  --rail:      oklch(20% 0.04 270);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--chalk-50);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Felt texture — a barely-there cross-hatch */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, color-mix(in oklab, var(--felt-700) 50%, transparent) 0%, transparent 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.04) 0 1px, transparent 1px 3px);
  z-index: 0;
}
[data-theme="chalk"] body::before {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, color-mix(in oklab, var(--chalk-50) 0%, transparent) 0%, transparent 70%),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.015) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.025) 0 1px, transparent 1px 3px);
}

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.mono { font-family: var(--font-mono); font-feature-settings: "ss01", "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }

::selection { background: color-mix(in oklab, var(--accent) 35%, transparent); }

/* ---- App shell ---- */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--rail) 92%, black) 0%,
    color-mix(in oklab, var(--rail) 85%, black) 100%);
  border-bottom: 1px solid var(--wood-700);
  box-shadow: inset 0 -1px 0 color-mix(in oklab, var(--wood-300) 18%, transparent),
              0 2px 12px rgba(0,0,0,0.4);
}
[data-theme="chalk"] .topbar {
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--rail) 95%, white) 0%,
    color-mix(in oklab, var(--rail) 88%, white) 100%);
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-logo { height: 36px; width: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--chalk-50);
  white-space: nowrap;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chalk-300);
  margin-top: 3px;
  white-space: nowrap;
}

/* Game-type segmented control */
.gt-seg {
  display: inline-flex;
  background: color-mix(in oklab, black 30%, var(--rail));
  border: 1px solid var(--wood-700);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.gt-seg button {
  background: transparent;
  border: 0;
  color: var(--chalk-300);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .15s, color .15s;
  white-space: nowrap;
}
.gt-seg button:hover { color: var(--chalk-50); }
.gt-seg button.active {
  background: color-mix(in oklab, var(--accent) 22%, var(--felt-900));
  color: var(--chalk-50);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 60%, transparent);
}
[data-theme="chalk"] .gt-seg {
  background: color-mix(in oklab, white 70%, var(--rail));
  border-color: color-mix(in oklab, var(--rail) 70%, transparent);
}
[data-theme="chalk"] .gt-seg button.active {
  background: color-mix(in oklab, var(--accent) 18%, white);
}

.topbar-right { display: flex; gap: var(--space-3); align-items: center; justify-self: end; }

/* Division chip */
.chip-btn {
  background: color-mix(in oklab, black 25%, var(--rail));
  border: 1px solid var(--wood-700);
  color: var(--chalk-100);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .15s;
}
.chip-btn:hover { background: color-mix(in oklab, black 15%, var(--rail)); }
.chip-btn .caret { opacity: 0.6; font-size: 10px; }

/* Content */
.content {
  padding: var(--space-5) var(--space-5) calc(124px + env(safe-area-inset-bottom));
  max-width: 1280px; width: 100%;
  margin: 0 auto;
}

/* Bottom nav (mobile) / side rail (desktop) */
/* Fixed bottom stack: nav tabs on top, About link beneath them. */
.bottom-dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
}
.navbar {
  display: flex;
  background: color-mix(in oklab, var(--rail) 90%, black);
  border-top: 1px solid var(--wood-700);
  backdrop-filter: blur(8px);
}
.nav-tab {
  flex: 1;
  background: transparent; border: 0;
  padding: 10px 4px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--chalk-300);
  transition: color .15s;
  min-height: 56px;
  position: relative;
}
.nav-tab .nav-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  color: currentColor;
}
.nav-tab .nav-icon svg { width: 100%; height: 100%; }
.nav-tab .nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-tab.active {
  color: var(--accent);
}
.nav-tab.active .nav-icon {
  filter: drop-shadow(0 0 8px color-mix(in oklab, var(--accent) 60%, transparent));
}
.nav-tab.active .nav-label {
  color: var(--accent);
}
.nav-tab.active::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%;
  height: 3px; background: var(--accent);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 12px var(--accent);
}

/* Status footer */
.status-footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--chalk-400);
  padding: 4px 8px;
  pointer-events: none;
  z-index: 24;
  /* Hide for now — folded into navbar below if needed */
  display: none;
}

/* ---- Cards & surfaces ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card-padded { padding: var(--space-5); }
.card-tight { padding: var(--space-3); }

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chalk-300);
  margin: 0 0 var(--space-3);
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
}
.card-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.card-title > span:not(.dot) { white-space: nowrap; }

/* Page header */
.page-h {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  flex-wrap: wrap;
}
.page-h h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-h .lede {
  color: var(--chalk-300);
  font-size: 14px;
  max-width: 56ch;
  text-wrap: pretty;
}

/* ---- Pool ball badge ---- */
.ball {
  --size: 32px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  display: inline-grid; place-items: center;
  position: relative;
  background: var(--ball-color, var(--ball-1));
  box-shadow:
    inset -3px -4px 8px rgba(0,0,0,0.35),
    inset 2px 3px 4px rgba(255,255,255,0.35),
    0 1px 2px rgba(0,0,0,0.35);
  flex-shrink: 0;
  overflow: hidden;
}
.ball::after {
  /* Highlight */
  content: ""; position: absolute;
  top: 12%; left: 20%;
  width: 30%; height: 22%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.85), transparent 70%);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
}
.ball .num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: calc(var(--size) * 0.42);
  color: #1a1a1a;
  background: #f4ecdc;
  border-radius: 50%;
  width: 52%; height: 52%;
  display: grid; place-items: center;
  line-height: 1;
  z-index: 3;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
  position: relative;
}
/* Striped: white top + bottom with the colored band across the middle */
.ball.striped {
  background:
    linear-gradient(to bottom,
      #f4ecdc 0%, #f4ecdc 22%,
      var(--ball-color, var(--ball-1)) 22%,
      var(--ball-color, var(--ball-1)) 78%,
      #f4ecdc 78%, #f4ecdc 100%);
}
/* SL → ball color mapping (set inline via style var) */
.ball.sl-1 { --ball-color: var(--ball-1); }
.ball.sl-2 { --ball-color: var(--ball-2); }
.ball.sl-3 { --ball-color: var(--ball-3); }
.ball.sl-4 { --ball-color: var(--ball-4); }
.ball.sl-5 { --ball-color: var(--ball-5); }
.ball.sl-6 { --ball-color: var(--ball-6); }
.ball.sl-7 { --ball-color: var(--ball-7); }
.ball.sl-8 { --ball-color: var(--ball-8); }
.ball.sl-9 { --ball-color: var(--ball-1); }

/* ---- Stat tiles ---- */
.stat-grid {
  display: grid;
  /* Mobile: 2 columns so 4 stats render 2×2 */
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 600px) {
  /* Wider screens: auto-fit so 3 or 4 stats stretch across one row */
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}
/* Stat tile — white background per design comment */
.stat {
  background: #ffffff;
  color: #2a2a2e;
  border: 1px solid color-mix(in oklab, #2a2a2e 8%, transparent);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  display: flex; flex-direction: column; gap: 2px;
  min-height: 64px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.stat .stat-label { color: #7a7a82; }
.stat .stat-value { color: #1f1f24; }
.stat .stat-sub { color: #5a5a62; }
.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-400);
  white-space: nowrap;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--chalk-50);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-value.big { font-size: 32px; }
.stat-sub {
  font-size: 11px;
  color: var(--chalk-300);
  font-family: var(--font-mono);
}
.stat-pos { color: var(--win) !important; }
.stat-neg { color: var(--loss) !important; }

/* ---- Form controls ---- */
.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (min-width: 720px) { .controls { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-400);
}
.field select, .field input[type="text"], .field input[type="number"] {
  width: 100%;
  background: var(--surface-2);
  color: var(--chalk-50);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 11px 12px;
  font-size: 15px;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field select:focus, .field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--chalk-300) 50%),
    linear-gradient(135deg, var(--chalk-300) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.btn {
  background: var(--accent);
  color: var(--accent-on);
  border: 0;
  border-radius: var(--r-md);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 8px;
  transition: filter .15s, transform .05s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--chalk-100);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 12px; }

/* Segmented (in-content) */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.seg button {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--chalk-300);
  border-radius: calc(var(--r-md) - 3px);
  transition: background-color .15s, color .15s;
  white-space: nowrap;
}
.seg button:hover { color: var(--chalk-50); }
.seg button.active {
  background: color-mix(in oklab, var(--accent) 18%, var(--surface));
  color: var(--chalk-50);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 50%, transparent);
}

/* ---- Verdict / quote ---- */
.verdict {
  position: relative;
  background:
    linear-gradient(135deg,
      color-mix(in oklab, var(--accent) 18%, var(--surface)) 0%,
      var(--surface) 100%);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: flex-start; gap: var(--space-3);
}
.verdict::before {
  content: """;
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 0.7;
  color: var(--accent);
  opacity: 0.5;
  margin-top: 8px;
}
.verdict-text {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--chalk-50);
  text-wrap: balance;
}

/* ---- Scoreboard ---- */
.scoreboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
}
.sb-side { display: flex; flex-direction: column; }
.sb-side.right { text-align: right; align-items: flex-end; }
.sb-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--chalk-100);
  max-width: 14ch;
  text-wrap: pretty;
}
.sb-score {
  font-family: var(--font-mono);
  font-size: clamp(42px, 8vw, 64px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}
.sb-score.win { color: var(--accent); }
.sb-score.lose { color: var(--chalk-300); }
.sb-dash {
  font-family: var(--font-mono);
  font-size: clamp(28px, 5vw, 44px);
  color: var(--chalk-400);
  font-weight: 400;
}
.sb-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-400);
  margin-top: 4px;
}

/* ---- Bars ---- */
.bar-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--chalk-400);
  margin: var(--space-4) 0 6px;
  font-weight: 600;
}
.bar-label .v { font-family: var(--font-mono); color: var(--chalk-100); letter-spacing: 0.04em; }
.bar {
  display: flex;
  height: 8px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-3);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.bar-a { background: var(--accent); }
.bar-b { background: var(--wood-500); }

/* ---- Tables ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-400);
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--chalk-100);
}
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; transition: background-color .12s; }
.table tr.clickable:hover { background: color-mix(in oklab, var(--accent) 6%, transparent); }

/* Sortable column headers */
.table th.sortable { cursor: pointer; user-select: none; transition: color .12s, background-color .12s; }
.table th.sortable:hover { color: var(--chalk-200); background: color-mix(in oklab, var(--accent) 8%, var(--surface-2)); }
.table th.sortable.sorted { color: var(--accent); }
.table th.sortable .sort-th-inner { display: inline-flex; align-items: center; gap: 4px; }
.table th.num.sortable .sort-th-inner { flex-direction: row-reverse; }
.sort-arrow { font-size: 8px; line-height: 1; }
/* Roster SL ball cells — center the ball icon */
.roster-table td.num .ball { vertical-align: middle; }
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-wrap.scroll {
  overflow-x: auto;
}

td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

.outcome-W { color: var(--win); font-weight: 600; }
.outcome-L { color: var(--loss); font-weight: 600; }
.outcome-T { color: var(--chalk-400); font-style: italic; }

/* Subtle row shading + left accent for win/loss rows */
.outcome-row-W > td {
  background: color-mix(in oklab, var(--win) 6%, transparent);
  box-shadow: inset 3px 0 0 color-mix(in oklab, var(--win) 70%, transparent);
}
.outcome-row-L > td {
  background: color-mix(in oklab, var(--loss) 6%, transparent);
  box-shadow: inset 3px 0 0 color-mix(in oklab, var(--loss) 70%, transparent);
}
.outcome-row-W > td:first-child,
.outcome-row-L > td:first-child {
  /* Box-shadow keeps the colored bar inside the row regardless of border-radius */
}
.outcome-row-W.clickable:hover > td,
.outcome-row-L.clickable:hover > td {
  filter: brightness(1.04);
}
[data-theme="chalk"] .outcome-row-W > td {
  background: color-mix(in oklab, var(--win) 10%, transparent);
}
[data-theme="chalk"] .outcome-row-L > td {
  background: color-mix(in oklab, var(--loss) 10%, transparent);
}

/* ---- Player row (compact list) ---- */
.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color .12s, border-color .12s, transform .05s;
  text-align: left;
  font-family: inherit;
}
.player-row:hover { background: var(--surface-2); border-color: color-mix(in oklab, var(--accent) 30%, var(--border)); }
.player-row:active { transform: translateY(1px); }
.player-row .rank {
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
  color: var(--chalk-400);
  width: 22px;
  text-align: right;
}
.player-row .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--chalk-50);
  letter-spacing: -0.005em;
  min-width: 0;
}
.player-row .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chalk-300);
  margin-top: 2px;
  display: block;
}
.player-row .pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 600;
  color: var(--chalk-50);
  letter-spacing: -0.02em;
}
.player-row .pct.good { color: var(--win); }
.player-row .pct.bad  { color: var(--loss); }
.player-row .arrow { color: var(--chalk-400); font-family: var(--font-mono); }

/* ---- Player header (profile hero) ---- */
.player-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-5);
  align-items: end;
  padding: var(--space-6) var(--space-5) var(--space-5);
  background:
    radial-gradient(ellipse 80% 100% at 80% 0%, color-mix(in oklab, var(--accent) 16%, transparent) 0%, transparent 70%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: var(--space-4);
  position: relative;
  overflow: hidden;
}
.player-hero h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1;
}
.player-hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-300);
  margin-bottom: var(--space-2);
}
.player-hero .teams {
  margin-top: var(--space-3);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.team-chip {
  background: color-mix(in oklab, var(--chalk-50) 8%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--chalk-200);
  white-space: nowrap;
  font: inherit;
  font-size: 12px;
}
.team-chip.clickable {
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.team-chip.clickable:hover,
.team-chip.clickable:focus-visible {
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  border-color: var(--accent);
  color: var(--chalk-50);
  outline: none;
}
/* Historical (past) team chip — clearly distinguished from active teams */
.team-chip.past {
  background: transparent;
  border-style: dashed;
  color: var(--chalk-300);
  position: relative;
  padding-left: 22px;
}
.team-chip.past::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--chalk-300) 60%, transparent);
}
.team-chip.past:hover,
.team-chip.past:focus-visible {
  background: color-mix(in oklab, var(--accent) 10%, transparent);
  border-style: solid;
  color: var(--chalk-50);
}
.player-hero .balls {
  display: flex; gap: 12px; align-items: center;
}
.player-hero .ball-block {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.player-hero .ball-block .label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chalk-300);
  white-space: nowrap;
}
.player-hero .ball { --size: 56px; }

/* ---- Subsection (details) ---- */
.subsection {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}
.subsection summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chalk-300);
  padding: 2px 0 6px;
  white-space: nowrap;
}
.subsection summary::-webkit-details-marker { display: none; }
.subsection summary::before {
  content: "";
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--accent);
  transition: transform .15s;
}
.subsection[open] > summary::before { transform: rotate(90deg); }

/* ---- Trend chart ---- */
.trend-svg { width: 100%; height: auto; display: block; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-line-fill { fill: var(--accent); opacity: 0.10; }
.trend-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend-grid { stroke: color-mix(in oklab, var(--chalk-50) 8%, transparent); stroke-width: 1; }
.trend-grid-mid { stroke: color-mix(in oklab, var(--chalk-50) 14%, transparent); stroke-dasharray: 3 3; }
.trend-axis { fill: var(--chalk-400); font-size: 8px; font-family: var(--font-mono); }
.trend-val { fill: var(--chalk-100); font-size: 7px; font-family: var(--font-mono); font-weight: 600; }

/* Trend series colors — 8-Ball black, 9-Ball yellow */
:root {
  --trend-8: oklch(28% 0.012 240);   /* near-black, slightly cool */
  --trend-9: oklch(82% 0.16 88);     /* warm pool-ball yellow */
}
[data-theme="chalk"] {
  --trend-8: #16181b;
  --trend-9: oklch(72% 0.18 80);     /* slightly deeper yellow on cream */
}
[data-theme="midnight"] {
  --trend-8: oklch(85% 0.01 240);    /* invert: light on dark midnight */
  --trend-9: oklch(82% 0.16 88);
}

/* Stack of trend verdicts (one per series) */
.trend-verdicts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: var(--space-3);
}
@media (min-width: 720px) { .trend-verdicts { grid-template-columns: 1fr 1fr; } }

/* Team trend legend — one chip per player */
.team-trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chalk-300);
}
.team-trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.team-trend-legend-item .swatch {
  width: 14px; height: 3px;
  border-radius: 2px;
}

.trend-verdict {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: var(--space-3);
}
.trend-verdict .icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.trend-verdict .label { font-weight: 500; font-size: 13px; color: var(--chalk-100); }

/* ---- Form pills (recent results) ---- */
.form-pills { display: inline-flex; gap: 3px; }
.form-pill {
  width: 16px; height: 16px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  color: #fff;
}
.form-pill.W { background: var(--win); }
.form-pill.L { background: var(--loss); }
.form-pill.T { background: var(--chalk-500); }

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--chalk-300);
  font-size: 14px;
}
.empty .eight {
  font-size: 56px;
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

/* ---- Layouts ---- */
.grid-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 900px) { .grid-two { grid-template-columns: 1fr 1fr; } }

.grid-three {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 720px) { .grid-three { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-three { grid-template-columns: repeat(3, 1fr); } }

/* ---- Loading / shell skeleton ---- */
.loader-wrap {
  display: grid; place-items: center;
  min-height: 60vh;
  text-align: center;
  color: var(--chalk-300);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.loader-ball {
  --size: 64px;
  animation: roll 2.4s linear infinite;
  margin: 0 auto var(--space-4);
}
@keyframes roll {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}

/* ---- Lineup planner ---- */
.lineup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 800px) { .lineup-grid { grid-template-columns: 1fr 1fr; } }

.roster-pick {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
}
.roster-pick h3 {
  margin: 0 0 var(--space-3);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-300);
  font-weight: 600;
}
.roster-chip-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.roster-chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--chalk-100);
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
  text-align: left;
}
.roster-chip:hover { background: var(--surface-3); }
.roster-chip.selected {
  background: color-mix(in oklab, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
  color: var(--chalk-50);
}
.roster-chip .sl-mini {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--chalk-400);
}

.pairing-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
.pairing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.pairing:hover { border-color: color-mix(in oklab, var(--accent) 35%, var(--border)); }
.pairing .vs {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--chalk-400);
  letter-spacing: 0.1em;
}
.pairing .player {
  font-weight: 600;
  font-size: 14px;
}
.pairing .player.right { text-align: right; }
.pairing .prob {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--chalk-100);
}
.pairing .prob.strong { background: color-mix(in oklab, var(--win) 30%, var(--surface)); color: var(--win); }
.pairing .prob.weak   { background: color-mix(in oklab, var(--loss) 25%, var(--surface)); color: var(--loss); }

/* ---- Movers row ---- */
.mover-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
  text-align: left;
}
.mover-row:hover { border-color: color-mix(in oklab, var(--accent) 30%, var(--border)); }
.mover-row .name { font-weight: 600; font-size: 15px; color: var(--chalk-50); }
.mover-row .sub {
  font-family: var(--font-mono); font-size: 11px; color: var(--chalk-400);
  margin-top: 2px;
}
.mover-row .change {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mover-row .change > * { white-space: nowrap; }
.mover-row .change .arrow.up { color: var(--win); }
.mover-row .change .arrow.down { color: var(--loss); }
.mover-row .change .new { color: var(--chalk-50); font-weight: 700; font-size: 14px; }
.mover-row .change .old { color: var(--chalk-400); }
.mover-row .change .big-arrow {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  margin: 0 2px;
}
.mover-row .change .big-arrow.up   { color: var(--win); }
.mover-row .change .big-arrow.down { color: var(--loss); }
.mover-row .mover-mood {
  width: 32px; height: 32px;
  display: grid; place-items: center;
}

/* ---- Search dropdown ---- */
.combo {
  position: relative;
}
.combo-input {
  width: 100%;
  background: var(--surface-2);
  color: var(--chalk-50);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 11px 12px;
  font-size: 15px;
}
.combo-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.combo-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
.combo-item {
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px;
  align-items: center;
  white-space: nowrap;
}
.combo-item > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.combo-item:hover, .combo-item[aria-selected="true"] {
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
}
.combo-item .meta { color: var(--chalk-400); font-family: var(--font-mono); font-size: 11px; }

/* ---- Misc ---- */
.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}
.muted { color: var(--chalk-400); }
.hint { color: var(--chalk-300); font-size: 13px; }
.small { font-size: 12px; }

/* Mobile-only: hide brand-sub for space */
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .topbar { padding: var(--space-3); gap: var(--space-2); }
  .gt-seg button { padding: 6px 8px; font-size: 11px; }
  .gt-seg button .label-long { display: none; }
  .chip-btn .settings-label { display: none; }
  .chip-btn .caret { display: none; }
  .content { padding: var(--space-4) var(--space-3) calc(124px + env(safe-area-inset-bottom)); }
  /* Hide the matches-played column in every table to save horizontal space. */
  .mp-col { display: none; }
  /* Stack team chips vertically. */
  .teams { flex-direction: column; align-items: flex-start; }
  .team-chip { width: 100%; }
  /* Recent form pills wrap under their label. */
  .recent-form-wrap { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
  .recent-form-wrap .form-pills { flex-wrap: wrap; }
  /* By Location / By Opponent SL on mobile — fixed 40/40/20 width layout
     after the MP column collapses. */
  .mp-hidable-table { table-layout: fixed; width: 100%; }
  .mp-hidable-table th:nth-child(1),
  .mp-hidable-table td:nth-child(1) { width: 40%; }
  .mp-hidable-table th:nth-child(3),
  .mp-hidable-table td:nth-child(3) { width: 40%; }
  .mp-hidable-table th:nth-child(4),
  .mp-hidable-table td:nth-child(4) { width: 20%; }
}
/* On wider screens the recent-form block is a single inline row. */
.recent-form-wrap { display: flex; align-items: center; gap: 10px; }

/* Containers that must never horizontally scroll. Tables/charts inside
   cards still get their own horizontal scroll via .table-wrap.scroll. */
.app, .content, .topbar, .navbar, .about-link { max-width: 100vw; }
.card { overflow-x: hidden; }
.card > .table-wrap.scroll,
.card > * > .table-wrap.scroll { overflow-x: auto; }

/* Desktop: side rail layout option */
@media (min-width: 1100px) {
  .navbar {
    /* Keep at bottom for now; could switch to side rail later */
  }
}

/* Inline compact select for use inside card titles, headers, etc. */
.inline-select {
  background: var(--surface-2);
  color: var(--chalk-100);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  -webkit-appearance: none; appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--chalk-300) 50%),
    linear-gradient(135deg, var(--chalk-300) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.inline-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Awards section — bright white card to contrast the felt page */
.awards-card {
  background: #fdfaf2;
  color: #2a2a2e;
  border: 1px solid #e3dec9;
  box-shadow: 0 6px 18px -10px rgba(0,0,0,0.18);
  margin-bottom: var(--space-4);
}
[data-theme="chalk"] .awards-card {
  background: #fffdf6;
  border-color: #e0d9c2;
}
.awards-card .card-title {
  color: #5a5a62;
}
.awards-card .card-title .dot { background: #c89832; }
.awards-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 720px) {
  .awards-list { grid-template-columns: 1fr 1fr; }
}
.award-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #fffaee;
  border: 1px solid #ebe2c4;
  border-radius: var(--r-md);
  min-width: 0;
}
.award-meta { min-width: 0; flex: 1; overflow: hidden; }
.award-title {
  display: flex; align-items: baseline; gap: 4px 8px;
  flex-wrap: wrap;
  line-height: 1.2;
}
.award-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #2a2a2e;
  white-space: nowrap;
}
.award-gt, .award-tier {
  font-size: 11px;
  color: #7a7a82;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.award-sub {
  font-size: 12px;
  color: #5a5a62;
  margin-top: 3px;
  line-height: 1.45;
  word-break: break-word;
}
.award-sub.muted { color: #8a8a92; }

/* ---- Collapsible sections ---- */
.collapsible {
  /* Consistent vertical breathing room between every collapsible section */
  margin-bottom: var(--space-4);
}
.collapsible-head {
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}
.collapsible.is-open .collapsible-head { margin-bottom: var(--space-3); }
.collapsible-tri {
  display: inline-block;
  font-size: 9px;
  line-height: 1;
  color: var(--accent);
  transition: transform .15s ease-out;
  width: 12px;
  flex-shrink: 0;
}
.collapsible.is-open .collapsible-tri { transform: rotate(90deg); }
.collapsible-head:hover .collapsible-tri,
.collapsible-head:focus-visible .collapsible-tri { color: var(--chalk-50); }
.collapsible-head:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 40%, transparent);
  outline-offset: 4px;
  border-radius: var(--r-md);
}
.collapsible-body { animation: collapsible-fade .15s ease-out; }
@keyframes collapsible-fade {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Awards-card variant of Collapsible — keeps the warm cream background and
   golden treatment from before, plus dark-on-light text for legibility. */
.collapsible.awards-card {
  background: #fdfaf2;
  color: #2a2a2e;
  border: 1px solid #e3dec9;
  box-shadow: 0 6px 18px -10px rgba(0,0,0,0.18);
}
[data-theme="chalk"] .collapsible.awards-card {
  background: #fffdf6;
  border-color: #e0d9c2;
}
.collapsible.awards-card .collapsible-head { color: #5a5a62; }
.collapsible.awards-card .collapsible-tri { color: #c89832; }
.collapsible.awards-card .collapsible-head:hover .collapsible-tri,
.collapsible.awards-card .collapsible-head:focus-visible .collapsible-tri { color: #a07418; }

/* Sub-section inside a GameSection (By Location / By Opponent SL) — flatten,
   no longer a <details> toggle. Add a small label above each table. */
.game-subsection {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.game-subsection-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chalk-300);
  margin-bottom: 4px;
}

/* Player hero v2 — mobile-first stacked layout. Order on mobile:
   eyebrow → name → balls → teams → recent form. Desktop reflows the balls
   into a right column. */
.player-hero.hero-v2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  align-items: start;
}
.player-hero.hero-v2 .hero-eyebrow,
.player-hero.hero-v2 .hero-name,
.player-hero.hero-v2 .hero-balls,
.player-hero.hero-v2 .hero-teams,
.player-hero.hero-v2 .hero-form { grid-column: 1; }
.player-hero.hero-v2 .hero-name { margin: 0; }
.player-hero.hero-v2 .hero-eyebrow,
.player-hero.hero-v2 .hero-name { margin-bottom: 0; }
.player-hero.hero-v2 .hero-balls {
  margin-top: 0;
  display: flex;
  gap: 14px;
  align-items: center;
}
.player-hero.hero-v2 .hero-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.player-hero.hero-v2 .hero-form {
  display: flex; align-items: center; gap: 10px;
  margin-top: 0;
}
@media (max-width: 640px) {
  .player-hero.hero-v2 .hero-teams .team-chip { flex: 0 1 auto; }
  .player-hero.hero-v2 .hero-form { flex-direction: column; align-items: flex-start; gap: 6px; }
  .player-hero.hero-v2 .hero-form .form-pills { flex-wrap: wrap; }
}
@media (min-width: 641px) {
  .player-hero.hero-v2 {
    grid-template-columns: 1fr auto;
    column-gap: var(--space-5);
    row-gap: var(--space-3);
  }
  .player-hero.hero-v2 .hero-eyebrow,
  .player-hero.hero-v2 .hero-name,
  .player-hero.hero-v2 .hero-teams,
  .player-hero.hero-v2 .hero-form { grid-column: 1; }
  .player-hero.hero-v2 .hero-balls {
    grid-column: 2;
    grid-row: 1 / span 4;
    align-self: end;
  }
}
.team-recent-form-wrap {
  margin-top: var(--space-3);
  display: flex; align-items: center; gap: 10px;
}
@media (max-width: 520px) {
  .team-recent-form-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  .team-recent-form-wrap .form-pills { flex-wrap: wrap; }
}

/* Spicy one-liner under each award */
.award-quip {
  margin-top: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  line-height: 1.4;
  color: #6a4e1e;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
[data-density="compact"] { --density: 0.78; }
[data-density="compact"] .stat-value { font-size: 19px; }
[data-density="compact"] .stat-value.big { font-size: 26px; }

.about-link {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px env(safe-area-inset-right) calc(11px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 16%, var(--rail));
  border: none;
  border-top: 1px solid color-mix(in oklab, var(--accent) 45%, var(--wood-700));
  text-decoration: none;
  cursor: pointer;
  z-index: 22;
  transition: color .12s, background-color .12s;
}
.about-link svg { color: var(--accent); }
.about-link:hover {
  color: var(--accent-on);
  background: var(--accent);
}
.about-link:hover svg { color: var(--accent-on); }

/* ===========================================================
   Modal system + Settings + Welcome
   =========================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in oklab, var(--bg) 75%, black);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: modal-fade .18s ease-out;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.45), 0 8px 22px rgba(0,0,0,0.18);
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: flex; flex-direction: column;
  animation: modal-slide .22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-slide {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-sm { width: 420px; }
.modal-md { width: 540px; }
.modal-lg { width: 640px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px;
  background: transparent; border: 0;
  display: grid; place-items: center;
  color: var(--chalk-300);
  border-radius: var(--r-md);
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-2); color: var(--chalk-50); }
.modal-header {
  padding: 32px 36px 8px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
  color: var(--chalk-50);
}
.modal-subtitle {
  margin: 10px 0 0;
  color: var(--chalk-300);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}
.modal-body { padding: 24px 36px 28px; }
.modal-footer {
  padding: 18px 36px 26px;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-2) 50%, transparent);
}

/* Settings panel */
.settings-field { display: grid; gap: 8px; }
.settings-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-400);
}
.settings-help {
  font-size: 13px;
  color: var(--chalk-300);
  line-height: 1.5;
  margin-bottom: 4px;
  text-wrap: pretty;
}

/* Multi-check list (divisions etc.) */
.multi-check {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}
.multi-check-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
}
.multi-check-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.multi-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--chalk-100);
  transition: background-color .12s;
}
.multi-check-item:hover { background: color-mix(in oklab, var(--accent) 8%, transparent); }
.multi-check-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Welcome modal extras */
.beta-note {
  background: color-mix(in oklab, var(--accent) 10%, var(--surface-2));
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: var(--r-md);
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--chalk-100);
  display: flex; flex-direction: column; gap: 6px;
}
.beta-tag {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-on);
}
.welcome-cta {
  display: flex; gap: 12px; justify-content: flex-end;
  margin-top: 6px;
  flex-wrap: wrap;
}

.dyk-card.is-fact {
  border-left-color: #2a6fbd;
}
.dyk-card.is-fact .dyk-category {
  color: #2a6fbd;
  background: color-mix(in oklab, #2a6fbd 14%, transparent);
}
.dyk-card.is-fact .dyk-ref { color: #2a6fbd; }

/* Did You Know — rules popup */
.dyk-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.dyk-category {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}
.dyk-rule {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--chalk-50);
  text-wrap: pretty;
}
.dyk-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--chalk-200);
  text-wrap: pretty;
}
.dyk-ref {
  display: inline-flex; align-items: center; gap: 5px;
  align-self: flex-start;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.dyk-ref svg { flex-shrink: 0; }
.dyk-ref:hover { text-decoration: underline; }

/* Inline email link inside modals */
.modal-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.modal-link:hover { text-decoration: underline; }

/* Gear / settings chip label */
.settings-label {  /* defined above already; this is the button content */ }
.chip-btn .settings-label {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--chalk-100);
  font-weight: 600;
}

/* Match list popup (team-vs-team matches) */
.match-popup-list {
  display: grid;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}
.match-popup-row {
  display: grid;
  grid-template-columns: 80px 28px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
}
.match-popup-row .date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chalk-300);
}
.match-popup-row .venue {
  color: var(--chalk-200);
  font-size: 13px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-popup-row .score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.match-popup-row .badge {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.match-popup-row .badge.W { background: color-mix(in oklab, var(--win) 25%, transparent); color: var(--win); }
.match-popup-row .badge.L { background: color-mix(in oklab, var(--loss) 25%, transparent); color: var(--loss); }
.match-popup-row .badge.T { background: var(--surface-3); color: var(--chalk-300); }

/* Win % by location bar chart */
.win-bar-row {
  display: grid;
  grid-template-columns: 1fr 60px;
  gap: var(--space-3);
  align-items: center;
  padding: 8px 0;
}
.win-bar-row + .win-bar-row { border-top: 1px dashed var(--border); }
.win-bar-row .venue-info {
  min-width: 0;
}
.win-bar-row .venue-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--chalk-100);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win-bar-row .venue-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--chalk-400);
  margin-top: 2px;
}
.win-bar-row .bar-track {
  position: relative;
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  margin-top: 6px;
  overflow: hidden;
}
.win-bar-row .bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklab, var(--accent) 60%, white));
  border-radius: var(--r-pill);
  transition: width .3s ease-out;
}
.win-bar-row .bar-pct {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  color: var(--chalk-50);
  font-variant-numeric: tabular-nums;
}
/* Pool-ball motif off — generic flat SL badge */
body.no-ball-motif .ball {
  background: var(--surface-3) !important;
  box-shadow: inset 0 0 0 1px var(--border-strong) !important;
}
body.no-ball-motif .ball::after,
body.no-ball-motif .ball::before { display: none !important; }
body.no-ball-motif .ball .num {
  background: transparent;
  color: var(--chalk-100);
  width: 100%; height: 100%;
  box-shadow: none;
}

/* Tweaks panel adjustments (the starter handles most chrome) */
.tweaks-panel { z-index: 100; }
