/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #111;
  background: #f5f5f7;
}
/* Touch-friendly defaults: no double-tap zoom, no text-selection flicker on taps. */
button, a.btn, .ball, input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ===================================================================
   Landing / match list
   =================================================================== */
body.landing {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
  padding: 32px 16px;
}
.landing-wrap {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.landing-header h1 { margin: 0 0 8px; font-size: 32px; }
.landing-header p { margin: 0; color: #94a3b8; font-size: 14px; }

.new-match-card {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.new-match-card h2 { margin: 0 0 16px; font-size: 18px; }
.new-match-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.new-match-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  gap: 6px;
}
.new-match-form label .muted { text-transform: none; letter-spacing: 0; color: #64748b; }
.new-match-form input {
  padding: 10px 12px;
  background: #020617;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 15px;
}
.new-match-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Checkbox + label on one line (used in both new-match form and scorer controls) */
.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: #2563eb;
}
.checkbox-label span { font-size: 13px; color: #94a3b8; }
.new-match-form .checkbox-label { grid-column: 1 / -1; }

/* Shared button styles (used on landing + match rows) */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #334155; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: white; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: transparent; border-color: #7f1d1d; color: #fca5a5; }
.btn.danger:hover { background: #450a0a; }

/* Match list */
.matches-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.matches-header h2 { margin: 0; font-size: 18px; }
.match-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px 18px;
}
.match-info { flex: 1; min-width: 0; }
.match-players { font-size: 16px; font-weight: 700; color: #e2e8f0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.match-players .vs { color: #64748b; font-weight: 400; margin: 0 6px; }
.sport-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sport-pill.snooker { background: #1e3a8a; color: #93c5fd; }
.sport-pill.pool    { background: #14532d; color: #86efac; }
.sport-pill.darts   { background: #7f1d1d; color: #fecaca; }
.match-meta { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.match-meta code { background: #020617; padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.match-actions { display: flex; gap: 8px; flex-shrink: 0; }
.empty-state {
  text-align: center;
  color: #64748b;
  padding: 32px;
  background: #0b1220;
  border: 1px dashed #1e293b;
  border-radius: 10px;
  margin: 0;
}

/* ===================================================================
   Scorer
   =================================================================== */
body.scorer {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
  color: #e2e8f0;
  position: relative;
}
/* Viewport-wide dark background without breaking the centered max-width body. */
body.scorer::before {
  content: '';
  position: fixed;
  inset: 0;
  background: #020617;
  z-index: -1;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.top-nav .nav-link {
  color: #e2e8f0;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}
.top-nav .nav-link:hover { background: #1e293b; }
.top-nav .nav-spacer { flex: 1; }
.top-nav .nav-meta { font-size: 13px; color: #94a3b8; }
.top-nav .nav-meta code {
  background: #020617;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #e2e8f0;
  margin-left: 4px;
}

.scorer-header {
  margin-bottom: 20px;
}
.scorer-header h1 { margin: 0; font-size: 22px; color: #e2e8f0; }

.game-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  background: #0b1220;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #1e293b;
  margin-bottom: 20px;
}
/* Section header always takes a full row so it doesn't fight flex children */
.game-controls .section-header,
.snooker-controls .section-header,
.frame-end-controls .section-header,
.players-section .section-header {
  flex-basis: 100%;
}
.game-controls label { display: flex; flex-direction: column; font-size: 13px; color: #94a3b8; }
.game-controls input {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 16px;
  width: 140px;
}
.game-controls .danger {
  margin-left: auto;
  padding: 10px 16px;
  background: #ef4444;
  color: white;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.game-controls .danger:hover { background: #dc2626; }

/* Arm-then-confirm state — button visibly waits for a second tap. */
button.armed {
  background: #f59e0b !important;
  border-color: #b45309 !important;
  color: #1a1a1a !important;
  animation: pulse-armed 0.9s ease-in-out infinite;
}
@keyframes pulse-armed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* ---------- Snooker controls ---------- */
.snooker-controls,
.frame-end-controls {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Section headings shared across scorer sections */
.section-header {
  border-bottom: 1px solid #1e293b;
  padding-bottom: 12px;
  margin-bottom: 4px;
}
.section-heading {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.2px;
}
.section-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}

/* Tiny hint shown under field labels (or inline in checkboxes) */
.field-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #64748b;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  margin: 2px 0 4px;
  line-height: 1.4;
}
.field-hint.inline {
  display: inline;
  margin: 0;
}

/* Players section frame mirrors the snooker-controls look */
.players-section {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Overlay-toggle checkboxes group */
.overlay-toggles {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
.overlay-toggles .checkbox-label { margin: 0; }

/* Reset-frame row inside the End-of-frame section */
.reset-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px dashed #1e293b;
}
.reset-row .danger {
  padding: 10px 16px;
  background: #ef4444;
  color: white;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.reset-row .danger:hover { background: #dc2626; }
.row-hint.inline-hint {
  margin: 0;
  flex: 1;
  min-width: 240px;
}

/* Free-ball toggle dot — empty ring when off, filled green when on */
.action-row .toggle .toggle-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: transparent;
  margin-right: 8px;
  vertical-align: middle;
  transition: background 120ms ease, border-color 120ms ease;
}
.action-row .toggle.on .toggle-dot {
  background: #fff;
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

/* Active-player highlight on the score preview */
.score-preview .sp-side {
  position: relative;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.score-preview .sp-side:has(.sp-arrow:not(:empty)) {
  background: rgba(201, 162, 39, 0.08);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.35);
}
.score-preview .sp-side:has(.sp-arrow:not(:empty)) .sp-name {
  color: #fde68a;
}

/* Subtle dividers between rows inside the Live scoring panel */
.snooker-controls > .ball-row,
.snooker-controls > .action-row,
.snooker-controls > .foul-row {
  padding-top: 14px;
  border-top: 1px dashed #1e293b;
}

.multi-red-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.multi-red-row button {
  padding: 6px 14px;
  border: 1px solid #7f1d1d;
  background: #450a0a;
  color: #fca5a5;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.multi-red-row button:hover:not(:disabled) { background: #7f1d1d; color: #fee2e2; }
.multi-red-row button:disabled { opacity: 0.35; cursor: not-allowed; }

.ball-row { display: flex; gap: 12px; justify-content: center; }
.ball {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 100ms ease, opacity 100ms ease;
  /* Inner shading + highlight to feel spherical rather than flat. */
  box-shadow:
    inset -6px -6px 10px rgba(0, 0, 0, 0.35),
    inset 4px 4px 8px rgba(255, 255, 255, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2);
}
.ball:hover:not(:disabled) { transform: scale(1.05); }
.ball:disabled { opacity: 0.25; cursor: not-allowed; }
.ball-red    { background: #dc2626; color: #fff; }
.ball-yellow { background: #fbbf24; color: #000; }
.ball-green  { background: #16a34a; color: #fff; }
.ball-brown  { background: #7c4a1e; color: #fff; }
.ball-blue   { background: #2563eb; color: #fff; }
.ball-pink   { background: #f472b6; color: #000; }
.ball-black  { background: #111827; color: #fff; }

.action-row, .foul-row, .frame-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.action-row .action,
.foul-row button,
.frame-row button {
  padding: 10px 16px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.action-row .action:hover,
.foul-row button:hover,
.frame-row button:hover { background: #334155; }
.action-row .toggle.on {
  background: #16a34a;
  border-color: #15803d;
  color: white;
}
.action-row .undo {
  background: #451a03;
  border-color: #7c2d12;
  color: #fdba74;
}
.action-row .undo:hover { background: #7c2d12; color: #ffedd5; }
.row-label {
  min-width: 120px;
  font-size: 13px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.row-hint {
  margin: -6px 0 0 132px;  /* aligns under the buttons, past the 120px row-label */
  font-size: 12px;
  color: #64748b;
  font-style: italic;
  line-height: 1.4;
}
@media (max-width: 900px) {
  .row-hint { margin-left: 0; }
}
.foul-row button {
  min-width: 56px;
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}
.foul-row button:hover { background: #7f1d1d; color: #fee2e2; }
.frame-row button { background: #172554; border-color: #1e3a8a; color: #93c5fd; }
.frame-row button:hover { background: #1e3a8a; color: #dbeafe; }
.frame-row button.big {
  flex: 1;
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 700;
}

/* Match-winner row — gold tint so it reads as more significant than a frame award. */
.frame-row.match-row button {
  background: #451a03;
  border-color: #c9a227;
  color: #fde68a;
}
.frame-row.match-row button:hover { background: #78350f; color: #fff; }

.snooker-result {
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #cbd5e1;
}
.snooker-result.is-foul { color: #fca5a5; }

/* ---------- Score preview at top of scorer ---------- */
/* Sticks to the top of the viewport so the score stays visible while scrolling
   the controls below — important for tablet scoring where the live-scoring
   section is below the fold. */
.score-preview {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.sp-side { min-width: 0; }
.sp-left { text-align: left; }
.sp-right { text-align: right; }
.sp-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-right .sp-name { justify-content: flex-end; }
.sp-arrow { color: #c9a227; font-size: 14px; }
.sp-arrow:empty { display: none; }

.sp-score {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.sp-sub { font-size: 13px; color: #94a3b8; margin-top: 4px; }
.sp-sub strong { color: #e2e8f0; font-weight: 700; margin-left: 2px; }

.sp-center { text-align: center; }
.sp-dash {
  font-size: 48px;
  color: #475569;
  line-height: 1;
  font-weight: 400;
}
.sp-meta {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  justify-content: center;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-wrap: wrap;
}
.sp-meta strong {
  color: #e2e8f0;
  font-weight: 700;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .score-preview { padding: 14px; }
  .sp-score { font-size: 44px; }
  .sp-dash { font-size: 36px; }
}

/* ====================================================================
   Touch / narrow-viewport pass — tablets, phones, scoring court-side
   ==================================================================== */
@media (max-width: 900px) {
  body.scorer { padding: 16px; }

  .game-controls {
    flex-wrap: wrap;
    gap: 12px;
  }
  .game-controls input { font-size: 18px; padding: 12px; }
  .game-controls .danger { margin-left: 0; width: 100%; padding: 14px; }

  .active-toggle .active-buttons button {
    flex: 1;
    padding: 14px 10px;
    font-size: 15px;
  }

  .status-bar {
    flex-wrap: wrap;
    gap: 12px 24px;
  }

  .snooker-controls { padding: 14px; gap: 16px; }

  /* Balls: full row on tablet, wrap to 2 rows below ~600px */
  .ball-row { flex-wrap: wrap; gap: 10px; }
  .ball { width: 66px; height: 66px; font-size: 22px; }

  .multi-red-row { flex-wrap: wrap; }
  .multi-red-row button { padding: 10px 16px; font-size: 15px; }

  .action-row, .foul-row, .frame-row { flex-wrap: wrap; gap: 8px; }
  .action-row .action,
  .foul-row button,
  .frame-row button {
    padding: 14px 18px;
    font-size: 16px;
    min-height: 48px;       /* Apple HIG minimum tap target */
  }
  .foul-row button { min-width: 60px; }
  .row-label {
    min-width: 100%;
    font-size: 11px;
    margin-bottom: -4px;
  }

  .players { grid-template-columns: 1fr !important; }
  .player-card input { font-size: 18px; padding: 12px; }
  .score-row button { width: 52px; height: 52px; font-size: 22px; }
}

@media (max-width: 600px) {
  .new-match-form { grid-template-columns: 1fr; }
  .match-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .match-actions { justify-content: space-between; }
  .match-actions .btn { flex: 1; justify-content: center; }

  .ball { width: 56px; height: 56px; font-size: 18px; }
  .ball-row { justify-content: space-around; }
}

/* Remove hover scale on coarse pointers (touch) — feels janky after a tap */
@media (hover: none) and (pointer: coarse) {
  .ball:hover:not(:disabled) { transform: none; }
}

.active-toggle { display: flex; flex-direction: column; gap: 6px; }
.active-toggle .active-label { font-size: 13px; color: #94a3b8; }
.active-toggle .active-buttons { display: flex; gap: 6px; }
.active-toggle button {
  padding: 8px 12px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.active-toggle button:hover { background: #334155; }
.active-toggle button.selected {
  background: #2563eb;
  color: white;
  border-color: #1d4ed8;
}

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.player-card {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 20px;
}
.player-card label {
  display: block;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 12px;
}
.player-card input {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 16px;
  width: 100%;
}
.player-card .handicap-label input { width: 120px; }
.total-line {
  font-size: 14px;
  color: #94a3b8;
  margin: 8px 0 16px;
}
.total-line .total { font-size: 28px; color: #e2e8f0; font-weight: 700; margin: 0 8px; }
.total-line .breakdown { font-size: 13px; color: #64748b; margin-left: 4px; }

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.score-row .label { width: 60px; color: #94a3b8; font-size: 13px; }
.score-row button {
  width: 44px; height: 44px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}
.score-row button:hover { background: #334155; }
.score-row .score {
  min-width: 60px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: #e2e8f0;
}
.score-row .score.small { font-size: 24px; }

/* ===================================================================
   Table view — big-screen player-facing scoreboard (/table/:gameId)
   Designed for a TV / large monitor in the room, readable at distance.
   =================================================================== */
body.table-view {
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  height: 100vh;
  overflow: hidden;
  font-family: "Arial Narrow", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.table-board {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: #222;  /* thin divider between the two sides */
  min-height: 0;
}

.table-side {
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2vh 4vw;
  position: relative;
  transition: background 200ms ease, box-shadow 200ms ease;
  min-width: 0;
  overflow: hidden;
}

/* Active player glows gold — visible from across the room. */
.table-side.active {
  background: #0a0a0a;
  box-shadow: inset 0 0 0 6px #c9a227;
  animation: table-pulse 2s ease-in-out infinite;
}
.table-side.active .table-name { color: #c9a227; }
@keyframes table-pulse {
  0%, 100% { box-shadow: inset 0 0 0 6px #c9a227, inset 0 0 30px rgba(201, 162, 39, 0.15); }
  50%      { box-shadow: inset 0 0 0 6px #c9a227, inset 0 0 60px rgba(201, 162, 39, 0.35); }
}

.table-name {
  font-size: clamp(24px, 4vw, 72px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #cbd5e1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: color 200ms ease;
}

.table-score {
  font-size: clamp(160px, 30vw, 560px);
  font-weight: 900;
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
  color: #fff;
  letter-spacing: -0.05em;
  margin: 2vh 0;
}

.table-frames {
  font-size: clamp(18px, 2.4vw, 42px);
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.table-frames strong {
  color: #fff;
  font-weight: 800;
  margin-left: 10px;
  font-size: 1.4em;
  font-variant-numeric: tabular-nums;
}

/* Darts variant — remaining score replaces snooker total; smaller darts stats below. */
.table-score-darts { color: #fff; }
.table-darts-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  font-size: clamp(14px, 1.6vw, 28px);
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 10px;
}
.table-darts-stats strong {
  color: #fff;
  font-weight: 800;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Pool: Frames are the headline number — scale them up to fill the space the
 * snooker score would normally occupy. */
.table-view[data-sport="pool"] .table-frames {
  font-size: clamp(40px, 6vw, 96px);
  margin: 2vh 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.table-view[data-sport="pool"] .table-frames strong {
  margin-left: 0;
  font-size: clamp(160px, 30vw, 560px);
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: #fff;
}

.table-footer {
  background: #111;
  padding: 1.5vh 4vw;
  display: flex;
  justify-content: center;
  gap: 4vw;
  flex-wrap: wrap;
  font-size: clamp(14px, 1.6vw, 28px);
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-top: 1px solid #222;
}
.table-footer strong {
  color: #fff;
  font-weight: 800;
  margin-left: 10px;
  font-variant-numeric: tabular-nums;
}
.table-footer [hidden] { display: none; }

/* League / match-label header on table view — big, gold, prominent */
.table-header {
  background: #0a0a0a;
  padding: 2vh 4vw 1.5vh;
  text-align: center;
  border-bottom: 2px solid #c9a227;
}
.table-header[hidden] { display: none; }
.table-league {
  font-size: clamp(20px, 2.6vw, 44px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: #c9a227;
}
.table-league:empty { display: none; }
.table-match-label {
  font-size: clamp(14px, 1.6vw, 26px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #cbd5e1;
  margin-top: 0.6vh;
}
.table-match-label:empty { display: none; }

/* Portrait / phone fallback: stack the two sides vertically */
@media (orientation: portrait) and (max-width: 900px) {
  .table-board { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .table-score { font-size: clamp(120px, 40vw, 300px); }
}

/* ===================================================================
   Scoreboard — TV snooker lower-third, OBS overlay
   =================================================================== */
body.scoreboard {
  background: transparent;
  overflow: hidden;
  height: 100vh;
  font-family: Arial, sans-serif;
}
body.scoreboard.bg-dark {
  background: #111;
}

.tv-bar {
  position: fixed;
  top: 28px;    /* leaves room for the league strip above */
  left: 0;
  display: flex;
  width: 100%;
  height: 44px;                  /* 40 content + 2×2 border */
  border: 2px solid #000;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  z-index: 3;  /* sits above the break/ahead bars so they slide out from behind */
}
/* Black dividers between the inner cells. */
.tv-bar .player:not(.right),
.tv-bar .score-box,
.tv-bar .frames {
  border-right: 2px solid #000;
}

/* League strip sits above the tv-bar. Hidden when no league + no label. */
.league-strip {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 28px;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 2px solid #000;
}
.league-strip[hidden] { display: none; }
.league-strip .league-sep { color: #c9a227; font-weight: 400; }

/* Name blocks — gold */
.tv-bar .player {
  flex: 1;
  background: #c9a227;
  color: #000;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-weight: bold;
  font-size: 17px;
  text-transform: uppercase;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}
/* Extra padding on the OUTSIDE edge (away from the scoring area) so the
   names aren't flush against the edge of the screen / stream frame. */
.tv-bar .player:not(.right) { padding-left: 28px; }
.tv-bar .player.right { justify-content: flex-end; padding-right: 28px; }

.tv-bar .arrow { font-size: 18px; color: #000; text-shadow: none; }
.tv-bar .arrow:empty { display: none; }
/* Push arrows to the inside edge of each gold block, next to the scoring area. */
.tv-bar .player:not(.right) .arrow { margin-left: auto; }
.tv-bar .player.right .arrow { margin-right: auto; }

.tv-bar .hcap {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.7;
}
.tv-bar .hcap:empty { display: none; }

/* Center block — holds the two score-boxes and the frames display */
.tv-bar .center {
  display: flex;
  align-items: center;
  background: #ddd;
}

/* Current-score boxes — light grey, black text */
.tv-bar .score-box {
  width: 70px;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  background: #e5e5e5;
  color: #000;
  padding: 0;
  line-height: 40px;
  font-variant-numeric: tabular-nums;
}

/* Center frames block — teal (World Snooker style), shows "P1frames (bestOf) P2frames" */
.tv-bar .frames {
  min-width: 90px;
  text-align: center;
  background: #0e6e5a;
  color: #fff;
  font-weight: bold;
  font-size: 18px;
  padding: 0 14px;
  line-height: 40px;
  font-variant-numeric: tabular-nums;
}
.tv-bar .frames .target {
  margin: 0 8px;
  color: #9fd9cb;
  font-weight: 600;
}
.tv-bar .frames .target:empty { display: none; }

/* =================================================================== */
/* Pool lower-third — Brownz Media brand (deep navy + accent red).      */
/* Bigger, bolder, with stacked "Race to N" in the centre.              */
/* =================================================================== */
.pool-bar {
  position: fixed;
  top: 28px;             /* sits below the league strip */
  left: 0;
  width: 100%;
  height: 96px;
  display: flex;
  background: #0E1A2B;   /* deep navy — Brownz Media base */
  color: #fff;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  border: 2px solid #000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  z-index: 3;
  overflow: hidden;
}
.pool-bar[hidden] { display: none; }

/* Subtle red + yellow stripe along the bottom edge — a quiet nod to UK 8-ball
 * ball colours without painting whole panels in them. */
.pool-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    to right,
    #E63946 0%, #E63946 48%,
    #FFD400 52%, #FFD400 100%
  );
  pointer-events: none;
}

/* Player name panels — flex to fill the outer ends */
.pool-player {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 36px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  background: #0E1A2B;
  transition: background 180ms ease, box-shadow 180ms ease;
}
.pool-player-right { justify-content: flex-end; }
.pool-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Active-player accent — brightens the panel and adds a red top-edge glow */
.pool-player.is-active {
  background: #1F2F4A;
  box-shadow: inset 0 4px 0 0 #E63946;
}
.pool-player.is-active .pool-name {
  color: #fff;
  text-shadow: 0 0 18px rgba(230, 57, 70, 0.55);
}

.pool-arrow {
  color: #E63946;
  font-size: 26px;
  text-shadow: 0 0 10px rgba(230, 57, 70, 0.7);
  flex-shrink: 0;
}
.pool-arrow:empty { display: none; }
.pool-player-left .pool-arrow { margin-left: auto; }
.pool-player-right .pool-arrow { margin-right: auto; }

/* Frame numbers — huge, dominant, centre-flanking */
.pool-frame {
  flex: 0 0 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  background: #162338;          /* one shade lighter than the player panels */
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}

/* Centre "RACE TO N" panel — accent-red, label stacked above the number */
.pool-target {
  flex: 0 0 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #E63946;          /* Brownz Media accent red */
  color: #fff;
  padding: 6px 0;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}
.pool-target-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
  margin-bottom: 4px;
}
.pool-target-value {
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* The pool-bar replaces the tv-bar — push the league strip's neighbours down. */
.scoreboard[data-sport="pool"] .league-strip {
  background: #0E1A2B;        /* match the pool-bar base, no harsh black gap */
  border-color: #0E1A2B;
}
.scoreboard[data-sport="pool"] .league-strip .league-sep {
  color: #E63946;
}

/* Responsive squeeze for narrower OBS scenes (e.g. 1280px composing) */
@media (max-width: 1400px) {
  .pool-bar { height: 88px; }
  .pool-player { font-size: 26px; padding: 0 24px; }
  .pool-frame { flex-basis: 110px; font-size: 56px; }
  .pool-target { flex-basis: 130px; }
  .pool-target-value { font-size: 38px; }
}
@media (max-width: 1100px) {
  .pool-bar { height: 80px; }
  .pool-player { font-size: 22px; padding: 0 18px; letter-spacing: 1px; }
  .pool-frame { flex-basis: 90px; font-size: 48px; }
  .pool-target { flex-basis: 110px; }
  .pool-target-label { font-size: 11px; letter-spacing: 3px; }
  .pool-target-value { font-size: 32px; }
}

/* =================================================================== */
/* Darts lower-third — Brownz Media brand (deep navy + accent red).     */
/* Remaining-score-driven; remaining is the headline, surrounded by     */
/* name + AVG/LAST stats on each side and a legs-won panel in the mid.  */
/* =================================================================== */
.darts-bar {
  position: fixed;
  top: 28px;
  left: 0;
  width: 100%;
  height: 110px;
  display: flex;
  background: #0E1A2B;
  color: #fff;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  border: 2px solid #000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  z-index: 3;
  overflow: hidden;
}
.darts-bar[hidden] { display: none; }
.darts-bar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(to right, #E63946 0%, #E63946 48%, #FFD400 52%, #FFD400 100%);
  pointer-events: none;
}

.darts-player {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 0 28px;
  background: #0E1A2B;
  transition: background 180ms ease, box-shadow 180ms ease;
  min-width: 0;
}
.darts-player.is-active {
  background: #1F2F4A;
  box-shadow: inset 0 4px 0 0 #E63946;
}
.darts-player-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}
.darts-player-right .darts-player-name { justify-content: flex-end; }
.darts-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.darts-bar-arrow {
  color: #E63946;
  font-size: 20px;
  text-shadow: 0 0 10px rgba(230, 57, 70, 0.7);
}
.darts-bar-arrow:empty { display: none; }
.darts-player-stats {
  display: flex;
  gap: 18px;
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
}
.darts-player-right .darts-player-stats { justify-content: flex-end; }
.darts-player-stats strong {
  color: #fff;
  font-weight: 900;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.darts-bar-score {
  flex: 0 0 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 900;
  color: #fff;
  background: #162338;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
  line-height: 1;
}

.darts-bar-mid {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #E63946;
  color: #fff;
  padding: 8px 0;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}
.darts-bar-legs {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.darts-bar-legs-sep { font-size: 22px; opacity: 0.7; }
.darts-bar-target {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}
.darts-bar-target strong { font-weight: 900; margin-left: 2px; }

.scoreboard[data-sport="darts"] .league-strip {
  background: #0E1A2B;
  border-color: #0E1A2B;
}
.scoreboard[data-sport="darts"] .league-strip .league-sep {
  color: #E63946;
}

@media (max-width: 1400px) {
  .darts-bar { height: 96px; }
  .darts-player { padding: 0 20px; }
  .darts-player-name { font-size: 22px; }
  .darts-bar-score { flex-basis: 130px; font-size: 60px; }
  .darts-bar-mid { flex-basis: 120px; }
  .darts-bar-legs { font-size: 32px; }
}
@media (max-width: 1100px) {
  .darts-bar { height: 88px; }
  .darts-player { padding: 0 14px; gap: 4px; }
  .darts-player-name { font-size: 18px; letter-spacing: 0.5px; }
  .darts-player-stats { font-size: 11px; gap: 12px; letter-spacing: 1.5px; }
  .darts-bar-score { flex-basis: 110px; font-size: 52px; }
  .darts-bar-mid { flex-basis: 100px; }
  .darts-bar-legs { font-size: 28px; }
  .darts-bar-target { font-size: 10px; letter-spacing: 2px; }
}

/* =================================================================== */
/* Scoreline theme for the snooker overlay — overrides the BBC palette  */
/* to match Brownz Media's brand (deep navy + accent red). Only applies */
/* when the game's `theme` field is set to 'scoreline'. Pool always     */
/* uses its own dedicated pool-bar so this section doesn't touch it.    */
/* =================================================================== */
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .league-strip {
  background: #0E1A2B;
  color: #fff;
  border-color: #0E1A2B;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .league-strip .league-sep {
  color: #E63946;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar {
  border-color: #000;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .player {
  background: #0E1A2B;
  color: #fff;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .arrow {
  color: #E63946;
  text-shadow: 0 0 8px rgba(230, 57, 70, 0.6);
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .center {
  background: #0E1A2B;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .score-box {
  background: #162338;
  color: #fff;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .frames {
  background: #E63946;
  color: #fff;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .tv-bar .frames .target {
  color: rgba(255, 255, 255, 0.8);
}

/* Break bar + ahead tracker also adopt the Scoreline palette so the
 * full broadcast feels consistent. */
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .break-bar {
  background: #0E1A2B;
  border-color: #000;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .break-balls {
  background: #0a1422;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .break-stat .stat-label {
  color: rgba(255, 255, 255, 0.7);
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .break-stat .stat-value {
  color: #fff;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .ahead-tracker {
  background: #0E1A2B;
  border-color: #000;
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .ahead-stat .stat-label {
  color: rgba(255, 255, 255, 0.7);
}
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .ahead-stat .stat-value {
  color: #fff;
}

/* =================================================================== */
/* Scoreline credit bug — small top-right pill, like a TV channel bug.  */
/* Always visible on Scoreline-themed snooker and on pool overlays      */
/* (which always use the Scoreline aesthetic). Hidden when the per-     */
/* match `showScorelineCredit` flag is set to false.                    */
/* =================================================================== */
.scoreline-bug {
  position: fixed;
  top: 5px;             /* sits inside the 28px league strip */
  right: 8px;
  z-index: 10;
  display: none;        /* hidden by default — sport/theme rules below opt in */
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 0 9px;
  background: rgba(14, 26, 43, 0.85);
  border: 1px solid rgba(230, 57, 70, 0.4);
  border-radius: 999px;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.scoreline-bug-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #E63946;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(230, 57, 70, 0.8);
}
/* Show on Scoreline-themed snooker AND on pool */
.scoreboard[data-sport="snooker"][data-theme="scoreline"] .scoreline-bug,
.scoreboard[data-sport="pool"] .scoreline-bug {
  display: inline-flex;
}
/* Per-match opt-out */
.scoreboard.no-scoreline-credit .scoreline-bug {
  display: none !important;
}

/* ===== Break bar (docked directly below the score bar) ===== */
.break-bar {
  position: fixed;
  left: 0;
  top: 72px;           /* league strip (28) + tv-bar (44 incl. border) */
  display: flex;
  align-items: stretch;
  background: #1a1a1a;
  color: #fff;
  font-family: Arial, sans-serif;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  border: 2px solid #000;
  border-top: 0;                /* share the tv-bar's bottom edge */
  border-bottom-right-radius: 4px;
  overflow: hidden;
  z-index: 1;
  /* Hidden state — slides up behind the tv-bar. */
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease-out;
}
.break-bar.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.break-balls {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #0f3520;  /* snooker-cloth green */
  min-height: 0;
}
.break-balls:empty { display: none; }

.break-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.4), 0 0 2px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.break-ball-red    { background: #dc2626; }
.break-ball-yellow { background: #fbbf24; }
.break-ball-green  { background: #16a34a; }
.break-ball-brown  { background: #7c4a1e; }
.break-ball-blue   { background: #2563eb; }
.break-ball-pink   { background: #f472b6; }
.break-ball-black  { background: #111827; }

.break-stats {
  display: flex;
  align-items: stretch;
}
.break-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  min-width: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
.break-stat .stat-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #c9a227;  /* gold, matches name blocks */
}
.break-stat .stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ===== Winner banners — overlay the lower-third ===== */
/* Brownz Media colour scheme: deep navy with accent red.                */
/* Sits at top: 28px (under the league strip) so it covers the tv-bar /  */
/* pool-bar entirely for the duration of the celebration.                */

.winner-banner,
.match-winner-banner {
  position: fixed;
  top: 28px;
  left: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  border: 2px solid #000;
  border-top: 0;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease-out;
}
.winner-banner.visible,
.match-winner-banner.visible {
  transform: translateY(0);
  opacity: 1;
}

/* --- Frame-winner: red wash with white type, height matches the lower-third --- */
.winner-banner {
  height: 44px;        /* default: matches snooker tv-bar */
  background:
    linear-gradient(90deg,
      #B12734 0%, #E63946 50%, #B12734 100%);
  color: #fff;
  z-index: 4;
  box-shadow: 0 6px 18px rgba(230, 57, 70, 0.45);
}
.scoreboard[data-sport="pool"] .winner-banner { height: 96px; }

.winner-banner-inner {
  display: inline-block;
  padding-left: 100%;  /* start off-screen right */
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 22px;
  line-height: 40px;
  letter-spacing: 3px;
}
.scoreboard[data-sport="pool"] .winner-banner-inner {
  font-size: 36px;
  line-height: 92px;
  letter-spacing: 4px;
}
.winner-banner.visible .winner-banner-inner {
  animation: banner-scroll 10s linear 1;
}
@keyframes banner-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* --- Match-winner: deeper red with a gold edge gradient — most prominent --- */
.match-winner-banner {
  height: 64px;        /* default: snooker height (a bit taller than frame banner) */
  background:
    linear-gradient(90deg,
      #5A0F18 0%, #C42E3A 18%, #E63946 50%, #C42E3A 82%, #5A0F18 100%);
  color: #fff;
  z-index: 5;          /* above frame-winner banner */
  box-shadow: 0 8px 28px rgba(230, 57, 70, 0.6);
  position: relative;
}
.match-winner-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 212, 0, 0.18) 100%);
  pointer-events: none;
}
.scoreboard[data-sport="pool"] .match-winner-banner { height: 120px; }

.match-winner-inner {
  display: inline-block;
  padding-left: 100%;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  font-size: 28px;
  line-height: 60px;
  letter-spacing: 4px;
  position: relative;  /* sits above the inner gold gradient overlay */
  z-index: 1;
}
.scoreboard[data-sport="pool"] .match-winner-inner {
  font-size: 44px;
  line-height: 116px;
  letter-spacing: 5px;
}
.match-winner-banner.visible .match-winner-inner {
  animation: banner-scroll 20s linear 1;
}

/* ===== Ahead / remaining tracker — docks under the active player's side ===== */
.ahead-tracker {
  position: fixed;
  top: 72px;           /* same level as break bar, under the tv-bar */
  display: flex;
  align-items: stretch;
  background: #1a1a1a;
  color: #fff;
  font-family: Arial, sans-serif;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  border: 2px solid #000;
  border-top: 0;
  overflow: hidden;
  z-index: 1;
  /* Hidden state — slides up behind the tv-bar. */
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease-out;
}
.ahead-tracker.side-left  { left: 0;  right: auto; border-bottom-right-radius: 4px; }
.ahead-tracker.side-right { right: 0; left: auto;  border-bottom-left-radius: 4px; }
.ahead-tracker.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.ahead-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
.ahead-stat:first-child { border-left: 0; }
.ahead-stat .stat-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #c9a227;       /* gold accent — matches name blocks */
}
.ahead-stat .stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ahead-stat .stat-value:empty { display: none; }

/* ===================================================================
   Auth pages (login, signup, reset) + dashboard club cards
   =================================================================== */
.auth-wrap {
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.auth-card {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.auth-card h2 { margin: 0 0 16px; font-size: 18px; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form h3 { margin: 0 0 4px; font-size: 14px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.auth-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  gap: 6px;
}
.auth-form label .muted { text-transform: none; letter-spacing: 0; color: #64748b; }
.auth-form input {
  padding: 10px 12px;
  background: #020617;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 15px;
}
.auth-form button { align-self: flex-start; }
.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.auth-banner {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.auth-links {
  margin-top: 16px;
  font-size: 13px;
  color: #94a3b8;
}
.auth-links a { color: #60a5fa; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* Dashboard header (logged-in user banner + sign-out) */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.muted-line { color: #94a3b8; font-size: 14px; margin: 0; }
.header-actions { display: flex; gap: 8px; }

/* Club cards on the dashboard — one per club the user belongs to */
.club-card {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin-bottom: 24px;
}
.club-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e293b;
}
.club-header h2 { margin: 0 0 4px; font-size: 20px; }
.club-meta { font-size: 13px; }
.club-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
}
.club-invite code {
  background: #020617;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #334155;
  font-size: 13px;
  color: #e2e8f0;
}
.club-body { display: flex; flex-direction: column; gap: 20px; }
.club-new-match { padding: 16px; background: #020617; border: 1px solid #1e293b; border-radius: 8px; }

/* Add-club / join-club composite card at the bottom of the dashboard */
.add-club-card {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.add-club-card h2 { margin: 0 0 16px; font-size: 18px; }
.add-club-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 640px) {
  .add-club-grid { grid-template-columns: 1fr; }
  .new-match-form { grid-template-columns: 1fr; }
}

/* =================================================================== */
/* Darts scorer — number-pad UI                                        */
/* =================================================================== */
.darts-board {
  display: grid;
  grid-template-columns: 1fr 220px 1fr;
  gap: 16px;
  margin: 18px 0;
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 22px;
  align-items: stretch;
}
.darts-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 22px;
  border-radius: 10px;
  background: #0f172a;
  border: 2px solid transparent;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  min-width: 0;
}
.darts-side.is-active {
  border-color: #E63946;
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.25);
}
.darts-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.darts-side-right .darts-side-head { justify-content: flex-end; }
.darts-side-right .darts-side-meta { text-align: right; }
.darts-arrow { color: #E63946; font-size: 18px; }
.darts-arrow:empty { display: none; }
.darts-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.darts-remaining {
  font-size: 96px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: -2px;
}
.darts-side.is-active .darts-remaining {
  text-shadow: 0 0 24px rgba(230, 57, 70, 0.45);
}
.darts-side-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  font-size: 13px;
  color: #94a3b8;
}
.darts-side-meta strong {
  color: #e2e8f0;
  font-weight: 700;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.darts-board-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.darts-board-mid strong { color: #e2e8f0; font-weight: 800; font-size: 22px; }
.darts-board-mid .darts-format strong { font-size: 22px; }
.darts-board-mid .darts-leg-num strong { font-size: 28px; color: #E63946; }
.darts-throw-indicator {
  font-size: 12px;
  color: #cbd5e1;
  letter-spacing: 1px;
}

/* Visit entry */
.darts-entry {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 22px;
  margin: 18px 0;
}
.darts-input-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  margin: 10px 0 18px;
}
.darts-visit-display {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020617;
  border: 2px solid #1e293b;
  border-radius: 10px;
  font-size: 64px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  min-height: 96px;
}
.darts-input-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
}
.darts-input-actions .btn.big {
  font-size: 18px;
  padding: 14px 18px;
  font-weight: 800;
}

.darts-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 460px;
}
.darts-key {
  font-size: 28px;
  font-weight: 800;
  padding: 18px 0;
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 10px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.darts-key:hover { background: #334155; }
.darts-key:active { background: #475569; }
.darts-key-wide { grid-column: 2 / 4; font-size: 22px; }

.darts-undo-row { margin-top: 14px; }

@media (max-width: 900px) {
  .darts-board { grid-template-columns: 1fr; }
  .darts-board-mid { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .darts-remaining { font-size: 72px; }
  .darts-input-row { flex-direction: column; }
  .darts-input-actions { flex-direction: row; min-width: 0; }
  .darts-input-actions .btn.big { flex: 1; }
}

