/* ═══════════════════════════════════════════════════════════════════════════
   OCHE — Design System
   Aesthetic: "Brass & Blackboard" — dark pub atmosphere, warm metallic accents,
   chalk-texture hints, and the satisfying geometry of a precision sport.
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Outfit:wght@300;400;500;600&family=Orbitron:wght@500;700;900&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg-deep:       #06060c;
  --bg-primary:    #0b0b14;
  --bg-surface:    #111120;
  --bg-elevated:   #181830;
  --bg-hover:      #1f1f3a;

  --border:        #2a2a48;
  --border-light:  #35355a;

  --text-primary:  #ede8dc;
  --text-secondary:#8c8aa4;
  --text-muted:    #5a587a;

  --gold:          #c9a84c;
  --gold-bright:   #e8c860;
  --gold-dim:      #8a7030;
  --gold-glow:     rgba(201, 168, 76, 0.25);

  --teal:          #3ab8a0;
  --teal-dim:      #1a6858;

  --red:           #d44040;
  --red-dim:       #6b2020;

  --green:         #40b870;
  --green-dim:     #1a5830;

  --board-black:   #1a1a1e;
  --board-cream:   #f0e4c4;
  --board-red:     #c82828;
  --board-green:   #1a7a38;
  --board-wire:    #9a9a9a;
  --board-ring:    #222;

  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  --font-display:  'Chakra Petch', sans-serif;
  --font-body:     'Outfit', sans-serif;
  --font-mono:     'Orbitron', sans-serif;

  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

a { color: var(--gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold-bright); }

img { max-width: 100%; display: block; }

/* ── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.display-xl {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-text {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrapper {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 6, 12, 0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--gold-glow), 0 0 24px var(--gold-glow);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-links a.active {
  color: var(--gold);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem;
  }
  .nav-links.open { display: flex; }
}

/* ── Hero Section ───────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: 6rem 0 4rem;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
  opacity: 0.4;
  pointer-events: none;
}

.hero-title {
  position: relative;
  font-size: clamp(4rem, 12vw, 8rem);
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-shadow: 0 0 40px var(--gold-glow), 0 0 80px rgba(201, 168, 76, 0.1);
  margin-bottom: 1rem;
}

.hero-subtitle {
  position: relative;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Game Cards ─────────────────────────────────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding: 2rem 0 4rem;
}

@media (max-width: 960px) {
  .games-grid {
    grid-template-columns: 1fr;
  }
}

.game-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, var(--gold-glow));
  opacity: 0;
  transition: opacity 0.4s;
}

.game-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-4px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 30px var(--gold-glow);
}

.game-card:hover::before { opacity: 1; }

.game-card-icon {
  position: relative;
  width: 64px;
  height: 64px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.game-card-title {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.game-card-desc {
  position: relative;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.game-card-meta {
  position: relative;
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.game-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  text-decoration: none;
}

.btn-primary {
  background: var(--gold);
  color: #0a0a0a;
}
.btn-primary:hover {
  background: var(--gold-bright);
  box-shadow: 0 4px 20px var(--gold-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red-dim);
}
.btn-danger:hover {
  background: var(--red);
  color: white;
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Pre-game compact ──────────────────────────────────────────────────── */
.pre-game {
  max-width: 440px;
  margin: 3rem auto;
  text-align: center;
}

@media (max-width: 1100px) {
  .pre-game { margin: 1.5rem auto; }
}
@media (max-width: 640px) {
  .pre-game { margin: 1rem auto; }
}

/* ── Game Layout ────────────────────────────────────────────────────────── */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  padding: 1.5rem 0 4rem;
  align-items: start;
}

/* ── In-game side panel: fill viewport, log scrolls, controls pinned ──── */
body.in-game .game-layout {
  height: calc(100dvh - 80px);  /* below nav */
}
body.in-game .game-layout > :last-child {
  height: 100%;
  overflow: hidden;
}
body.in-game .game-layout > :last-child .dart-log {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* Tablet: hide nav/footer during gameplay, compact panels */
@media (max-width: 1200px) {
  body.in-game .nav { display: none; }
  body.in-game .footer { display: none; }
  body.in-game .page-wrapper { min-height: auto; }

  body.in-game .game-layout {
    height: calc(100dvh - 16px);  /* no nav, just padding */
  }

  .game-layout {
    grid-template-columns: 1fr 360px;
    gap: 1rem;
    padding: 0.75rem 0 1rem;
  }

  .dartboard-container { max-width: 320px; }

  .game-panel { padding: 0.85rem; }
  .game-panel-title { margin-bottom: 0.5rem; padding-bottom: 0.5rem; font-size: 0.75rem; }
  .target-display { padding: 0.5rem; }
  .target-number { font-size: 2.5rem; }
  .stat-card { padding: 0.75rem; }
  .stat-value { font-size: 1.2rem; }
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
    padding: 0.5rem 0 1rem;
    gap: 0.75rem;
  }
  .dart-log { max-height: 100px; }
}

.game-board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ── View Toggle (Board / Input Pad) ────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: 100%;
  max-width: 300px;
}
.view-toggle-btn {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 4px;
  background: none;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.view-toggle-btn:hover { color: var(--text-secondary); }
.view-toggle-btn.active { background: var(--bg-elevated); color: var(--gold); }

.view-board { display: none; width: 100%; }
.view-board.active { display: flex; flex-direction: column; align-items: center; }
.view-pad { display: none; width: 100%; }
.view-pad.active { display: block; }

.game-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.game-panel-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Stats Row ──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px;
  transition: width 0.5s var(--ease-out);
}

/* ── Target Display ─────────────────────────────────────────────────────── */
.target-display {
  text-align: center;
  padding: 1.5rem;
}

.target-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.target-number {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--gold-bright);
  text-shadow: 0 0 30px var(--gold-glow);
  line-height: 1;
}

/* ── Dart Log ───────────────────────────────────────────────────────────── */
.dart-log {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dart-log-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.dart-log-entry.hit {
  border-left: 3px solid var(--green);
}

.dart-log-entry.miss {
  border-left: 3px solid var(--red-dim);
  opacity: 0.6;
}

.btn-miss-sm {
  display: none;
  background: var(--red-dim);
  color: var(--red);
  border: none;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-miss-sm:hover { background: var(--red); color: white; }

.dart-log-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  opacity: 0.4;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.dart-log-delete:hover {
  opacity: 1;
  color: var(--red);
  background: var(--red-dim);
}

.dart-log-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 24px;
}

.dart-log-text {
  flex: 1;
  margin-left: 0.5rem;
}

/* ── Dartboard Container ────────────────────────────────────────────────── */
.dartboard-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
}

.dartboard-container svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 30px rgba(0,0,0,0.5));
}

/* Dartboard segment hover effects */
.dartboard-container svg .segment {
  cursor: pointer;
  transition: filter 0.1s, opacity 0.1s;
}

.dartboard-container svg .segment:hover {
  filter: brightness(1.3) saturate(1.5);
  stroke: var(--gold);
  stroke-width: 1.5;
}

.dartboard-container svg .segment.highlighted {
  stroke: var(--gold-bright);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(232, 200, 96, 0.6));
  animation: segment-glow 1.5s ease-in-out infinite;
}

@keyframes segment-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(232, 200, 96, 0.6)); }
  50% { filter: drop-shadow(0 0 12px rgba(232, 200, 96, 0.9)); }
}

.dartboard-container svg .segment.dimmed {
  opacity: 0.3;
}

/* dart landing marker */
.dart-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid white;
  box-shadow: 0 0 10px var(--gold);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: dart-land 0.3s var(--ease-spring);
}

@keyframes dart-land {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ── Leaderboard Table ──────────────────────────────────────────────────── */
.leaderboard-section {
  padding: 2rem 0 4rem;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.leaderboard-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.leaderboard-tab {
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.leaderboard-tab:hover { color: var(--text-secondary); }
.leaderboard-tab.active {
  background: var(--bg-elevated);
  color: var(--gold);
}

.leaderboard-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th {
  text-align: left;
  padding: 1rem 1.25rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.leaderboard-table td {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(42, 42, 72, 0.4);
  font-size: 0.9rem;
}

.leaderboard-table tr:last-child td { border-bottom: none; }

.leaderboard-table tr:hover td {
  background: var(--bg-elevated);
}

.rank-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 60px;
}

.rank-cell.gold { color: var(--gold-bright); }
.rank-cell.silver { color: #a0a8c0; }
.rank-cell.bronze { color: #b87333; }

.player-cell {
  font-weight: 500;
}

.score-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--gold);
}

.time-cell {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.date-cell {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Modal / Overlay ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 12, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 1rem;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 440px;
  width: 100%;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s var(--ease-spring);
  text-align: center;
}

.modal-detail {
  max-width: 520px;
  text-align: left;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-detail-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-detail-scroll::-webkit-scrollbar { width: 4px; }
.modal-detail-scroll::-webkit-scrollbar-track { background: transparent; }
.modal-detail-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.modal-detail-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.modal-score {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold-bright);
  text-shadow: 0 0 30px var(--gold-glow);
  margin: 1rem 0;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.modal-stats strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

/* ── Form Elements ──────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.input::placeholder {
  color: var(--text-muted);
}

.input-group {
  margin-bottom: 1rem;
}

.input-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Toast Notification ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  z-index: 300;
  opacity: 0;
  transition: all 0.4s var(--ease-spring);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--green-dim); color: var(--green); }
.toast.error { border-color: var(--red-dim); color: var(--red); }

/* ── Step indicator (8-step game) ───────────────────────────────────────── */
.steps-track {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.step-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  transition: background 0.3s;
}

.step-dot.completed { background: var(--gold); }
.step-dot.active { background: var(--gold-bright); box-shadow: 0 0 8px var(--gold-glow); }

.step-info {
  margin-bottom: 1rem;
}

.step-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.step-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.darts-remaining {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.dart-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.2s;
}

.dart-icon.used {
  background: var(--gold);
  border-color: var(--gold);
}

.dart-icon.active {
  border-color: var(--gold-bright);
  box-shadow: 0 0 8px var(--gold-glow);
}

/* ── Score Input Pad ────────────────────────────────────────────────────── */
.score-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.si-tabs {
  display: flex;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.si-tab {
  flex: 1;
  padding: 0.6rem 0.15rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.2;
}

.si-tab span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 1px;
}

.si-tab:hover { color: var(--text-secondary); background: var(--bg-surface); }
.si-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: var(--bg-surface);
}
.si-tab-bull.active { color: var(--red); border-bottom-color: var(--red); }

.si-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: rgba(42, 42, 72, 0.4);
}

.si-num {
  background: #1e1e38;
  border: none;
  padding: 0.8rem 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.1s;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.si-num:hover { background: #2a2a4e; }
.si-num:active {
  background: var(--gold-dim);
  color: var(--gold-bright);
  transform: scale(0.95);
}

.si-actions {
  display: flex;
  gap: 1px;
  background: rgba(42, 42, 72, 0.4);
  border-top: 1px solid var(--border);
}

.si-undo, .si-miss {
  flex: 1;
  padding: 0.7rem;
  background: var(--bg-elevated);
  border: none;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.si-undo { color: var(--text-secondary); }
.si-undo:hover { background: var(--bg-hover); }
.si-miss { color: var(--red); }
.si-miss:hover { background: var(--red-dim); }
.si-miss:active { background: var(--red); color: white; }

/* Target highlight on pad (warmup) */
.si-tab.si-target {
  background: var(--gold-dim) !important;
  color: var(--gold-bright) !important;
  border-bottom-color: var(--gold-bright) !important;
}
.si-num.si-target {
  background: var(--gold-dim);
  color: var(--gold-bright);
  animation: segment-pulse 1.5s ease-in-out infinite;
}

/* On desktop (>900px), score input is supplementary */
@media (min-width: 901px) {
  .score-input-area .score-input { border-radius: var(--radius-md); }
  .score-input-area .si-num { padding: 0.65rem 0; font-size: 1rem; }
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fade-in-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fade-in-up 0.6s var(--ease-out) both;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

/* ── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .games-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal { padding: 1.5rem; }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
  }

  .hero { padding: 3rem 0 2rem; }
}

/* ── Utility ────────────────────────────────────────────────────────────── */
.text-gold { color: var(--gold); }
.text-teal { color: var(--teal); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Game Badge ─────────────────────────────────────────────────────────── */
.game-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.game-badge.atc { background: rgba(201, 168, 76, 0.15); color: var(--gold); }
.game-badge.es  { background: rgba(58, 184, 160, 0.15); color: var(--teal); }

/* ── Stats Renderer (shared detail views) ───────────────────────────────── */
.sr-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sr-stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.5rem;
  text-align: center;
}
.sr-stat-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}
.sr-stat-lbl {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}
.sr-teal { color: var(--teal); }
.sr-gold { color: var(--gold-bright); }
.sr-red  { color: var(--red); }

.sr-highlights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sr-hl {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}
.sr-hl-lbl {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.sr-hl-val {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
}

.sr-breakdown-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.sr-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1rem;
}

/* Number breakdown bars (shared) */
.nb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.nb-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}
.nb-bar-wrap {
  flex: 1;
  height: 14px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}
.nb-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s var(--ease-out);
  min-width: 3px;
}
.nb-bar.perfect { background: var(--gold-bright); }
.nb-bar.good    { background: var(--gold-dim); }
.nb-bar.ok      { background: var(--teal-dim); }
.nb-bar.bad     { background: var(--red-dim); }
.nb-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  min-width: 16px;
}

/* ── Player Page: History Cards ─────────────────────────────────────────── */
.history-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}
.history-card:hover { border-color: var(--border-light); }

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  cursor: pointer;
  gap: 1rem;
}
.history-card-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.history-card-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.history-score {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
}
.history-score small {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}
.history-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.history-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.history-card-details {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

/* ── Player Index Cards ──────────────────────────────────────────────────── */
.player-index-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: block;
}
.player-index-card:hover {
  border-color: var(--gold-dim);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.player-index-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.player-index-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.player-index-meta .pi-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--gold);
  font-size: 0.75rem;
}
.pi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.pi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.7rem;
  color: var(--gold);
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.15);
}
.pi-chip.es {
  color: var(--teal);
  background: rgba(58, 184, 160, 0.1);
  border-color: rgba(58, 184, 160, 0.15);
}
.pi-chip-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
}
.pi-secondary {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.player-index-last {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .history-card-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .history-card-right { width: 100%; justify-content: space-between; }
  .sr-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sr-highlights { grid-template-columns: 1fr; }
}
