*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111110;
  --bg2: #181816;
  --bg3: #1F1E1C;
  --amber: #F5A623;
  --amber-dim: rgba(245,166,35,0.12);
  --amber-border: rgba(245,166,35,0.22);
  --amber-glow: rgba(245,166,35,0.35);
  --white: #F0EDE8;
  --grey: #7A7670;
  --light: #C4BFB8;
  --border: rgba(240,237,232,0.08);
  --danger: #E85D4C;
  --danger-dim: rgba(232,93,76,0.15);
  --success: #4ECB71;
  --success-dim: rgba(78,203,113,0.15);
  --radius: 10px;
  --nav-h: 64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(245,166,35,0.06), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(245,166,35,0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  height: var(--nav-h);
  background: rgba(17,17,16,0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--white);
  text-decoration: none;
}
.nav-logo span { color: var(--amber); }

.nav-links { display: flex; gap: 24px; list-style: none; }
.nav-links a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--grey);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--white); }

.nav-cta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--amber);
  padding: 9px 18px;
  border-radius: 4px;
  text-decoration: none;
}

.page-wrap {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 32px) 24px 48px;
}

.page-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
}

.page-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 10px;
  transition: font-size 0.2s;
}

.page-header p {
  color: var(--light);
  font-weight: 300;
  max-width: 560px;
  font-size: 0.95rem;
}

/* Compact header when game is active */
body.game-active .page-header { margin-bottom: 0; }
body.game-active .page-header h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: 0; }
body.game-active #page-desc { display: none; }
body.game-active .page-wrap { padding-top: calc(var(--nav-h) + 20px); }

.mobile-only { display: none; }
.desktop-only { display: block; }

/* Setup panel */
.setup-panel {
  margin-top: 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.setup-panel h2,
.panel-toggle span:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--grey);
  margin-bottom: 16px;
}

.panel-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  border: none;
  background: none;
  color: var(--grey);
  cursor: pointer;
  font-family: inherit;
}

.panel-toggle .toggle-icon {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  color: var(--amber);
}

.panel-body:not(.open) { display: none; }

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.preset-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 12px 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--light);
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover { border-color: var(--amber-border); color: var(--white); }
.preset-btn.active {
  background: var(--amber-dim);
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 24px var(--amber-dim);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.field label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
}

.field input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.number-stepper {
  display: flex;
  align-items: stretch;
}

.number-stepper input {
  flex: 1;
  min-width: 0;
  text-align: center;
  border-radius: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.number-stepper input::-webkit-outer-spin-button,
.number-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-btn {
  flex-shrink: 0;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--white);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.stepper-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.stepper-btn:last-child {
  border-radius: 0 6px 6px 0;
}

.stepper-btn:hover {
  border-color: var(--amber-border);
  background: var(--amber-dim);
  color: var(--amber);
}

.stepper-btn:active {
  transform: scale(0.96);
}

.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.player-names {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.player-names input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white);
  font-size: 0.95rem;
}

.btn-primary {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 14px 28px;
  border: none;
  border-radius: 6px;
  background: var(--amber);
  color: var(--bg);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px var(--amber-glow);
}

.btn-ghost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--light);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover { border-color: var(--amber-border); color: var(--white); }
.btn-ghost.amber { border-color: var(--amber-border); color: var(--amber); }

/* Game board */
.game-board { display: none; margin-top: 16px; }
.game-board.active { display: block; }
body.game-active .game-board { margin-top: 12px; }

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--amber);
  padding: 8px 16px;
  background: var(--amber-dim);
  border-radius: 6px;
  min-width: 100px;
  text-align: center;
}

.timer.stopped {
  color: var(--grey);
  background: var(--bg3);
}

.game-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--grey);
  flex: 1;
  min-width: 120px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-mobile { display: none; }

/* Round banner */
.round-banner {
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  background: var(--bg2);
}

.round-banner.active {
  border-color: var(--amber-border);
  background: var(--amber-dim);
}

.round-banner.complete {
  border-color: rgba(78,203,113,0.3);
  background: var(--success-dim);
}

.round-banner.done {
  border-color: rgba(78,203,113,0.4);
  background: var(--success-dim);
}

.banner-label { color: var(--amber); font-weight: 600; margin-right: 8px; }
.round-banner.complete .banner-label,
.round-banner.done .banner-label { color: var(--success); }
.banner-detail { color: var(--light); }

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey);
  margin-bottom: 12px;
}

/* Player list */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.player-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.player-list-item[role="button"] {
  cursor: pointer;
}

.player-list-item[role="button"]:hover {
  border-color: var(--amber-border);
  background: var(--bg3);
}

.player-list-item[role="button"]:active {
  transform: scale(0.99);
}

.player-list-item.leader {
  border-color: var(--amber);
  box-shadow: 0 0 20px var(--amber-dim);
}

.player-list-item.needs-score {
  border-color: var(--amber-border);
  animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 var(--amber-dim); }
  50% { box-shadow: 0 0 16px var(--amber-dim); }
}

.player-list-item.eliminated {
  opacity: 0.6;
  border-color: var(--danger);
  background: var(--danger-dim);
}

.player-list-item.eliminated[role="button"] { cursor: default; }

.player-list-item.winner {
  border-color: var(--success);
  box-shadow: 0 0 24px rgba(78,203,113,0.2);
}

.player-main { flex: 1; min-width: 0; }

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.crown { font-size: 1rem; line-height: 1; }

.player-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status { font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; }

.status.pending { color: var(--amber); }
.status.scored { color: var(--success); }
.status.out { color: var(--danger); }
.status.win { color: var(--success); font-weight: 600; }

.player-right {
  text-align: right;
  min-width: 72px;
}

.player-total {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--white);
}

.player-total.bump {
  animation: score-bump 0.4s ease;
}

@keyframes score-bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); color: var(--amber); }
  100% { transform: scale(1); }
}

.player-right .progress-wrap {
  margin-top: 8px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  width: 72px;
  margin-left: auto;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), #FFD080);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
}

.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #FF8A7A); }
.progress-bar.safe { background: linear-gradient(90deg, var(--success), #7AE89A); }

/* Collapsibles */
.collapsible { margin-bottom: 16px; }

.collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--grey);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.2s;
}

.collapsible-toggle:hover { border-color: var(--amber-border); }
.collapsible-toggle .toggle-icon { color: var(--amber); font-size: 1.1rem; }

.collapsible-body {
  display: none;
  padding-top: 12px;
}

.collapsible-body.open { display: block; }

/* Score table */
.score-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.score-table th,
.score-table td {
  padding: 12px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.score-table th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--grey);
  text-transform: uppercase;
  background: var(--bg3);
}

.score-table td:first-child,
.score-table th:first-child {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--grey);
}

.score-table .cell-pending { color: var(--grey); opacity: 0.5; }

.score-table .total-row td {
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-dim);
}

.score-table tr.round-new td {
  animation: row-flash 0.6s ease;
}

@keyframes row-flash {
  from { background: var(--amber-dim); }
  to { background: transparent; }
}

.chart-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.chart-wrap {
  position: relative;
  height: min(320px, 45vh);
}

/* Score entry sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 280;
  opacity: 0;
  transition: opacity 0.25s;
}

.sheet-backdrop.show { opacity: 1; }

.score-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 290;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.score-sheet.show { transform: translateY(0); }

.score-sheet-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}

.score-sheet-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.score-sheet-inner h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.75rem;
  margin-bottom: 20px;
}

#score-input {
  width: 100%;
  padding: 18px;
  font-family: 'DM Serif Display', serif;
  font-size: 2.5rem;
  text-align: center;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  -moz-appearance: textfield;
  margin-bottom: 20px;
}

#score-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-dim);
}

#score-input::-webkit-outer-spin-button,
#score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.score-sheet-actions {
  display: flex;
  gap: 12px;
}

.score-sheet-actions .btn-ghost,
.score-sheet-actions .btn-primary {
  flex: 1;
  text-align: center;
  padding: 14px;
}

/* Game menu */
.game-menu {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 290;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.game-menu.show { transform: translateY(0); }

.game-menu-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.game-menu-inner h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--grey);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  cursor: pointer;
}

.menu-item:hover { border-color: var(--amber-border); }
.menu-item.danger { color: var(--danger); border-color: rgba(232,93,76,0.3); }

.end-game-only { display: none !important; }

body:not(.view-only).game-in-progress .end-game-only.scorer-only {
  display: inline-flex !important;
}

body:not(.view-only).game-in-progress .game-menu .end-game-only.scorer-only {
  display: block !important;
}
.menu-close { width: 100%; margin-top: 8px; text-align: center; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg3);
  border: 1px solid var(--amber-border);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  z-index: 300;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}

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

/* Winner overlay */
.winner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(17,17,16,0.92);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.winner-overlay.show {
  display: flex;
}

.winner-card {
  width: min(420px, 100%);
  padding: 28px 24px 24px;
  border-radius: 16px;
  border: 1px solid var(--amber-border);
  background: linear-gradient(165deg, rgba(31,30,28,0.98) 0%, rgba(17,17,16,0.98) 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 0 48px rgba(245,166,35,0.08);
  text-align: center;
}

.winner-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid var(--amber-border);
}

.winner-badge--manual {
  color: var(--light);
  background: rgba(240,237,232,0.08);
  border-color: var(--border);
}

.winner-card--manual {
  border-color: var(--border);
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  background: var(--bg2);
}

.winner-overlay--manual .winner-actions .btn-primary {
  background: var(--bg3);
  color: var(--white);
  border: 1px solid var(--border);
}

.winner-scoreline[hidden] {
  display: none !important;
}

.winner-trophy[hidden] {
  display: none !important;
}

.winner-trophy {
  font-size: 3.5rem;
  margin-bottom: 8px;
  animation: crown-bob 1.5s ease-in-out infinite;
}

@keyframes crown-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.winner-overlay h2,
.winner-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin: 0 0 10px;
  line-height: 1.1;
}

.winner-lede {
  color: var(--grey);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0 0 18px;
}

.winner-scoreline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px 12px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(245,166,35,0.08);
  border: 1px solid var(--amber-border);
}

.winner-scoreline .winner-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--white);
}

.winner-scoreline .winner-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: var(--amber);
  font-weight: 600;
}

.winner-scoreline .winner-max {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--grey);
}

.winner-standings {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.winner-standing {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.winner-standing:last-child {
  border-bottom: none;
}

.winner-standing.is-winner {
  background: var(--amber-dim);
}

.winner-standing-rank {
  font-family: 'DM Serif Display', serif;
  color: var(--amber);
}

.winner-standing.is-leader {
  background: rgba(240,237,232,0.06);
}

.winner-standing-leader {
  margin-left: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--light);
  background: rgba(240,237,232,0.1);
  vertical-align: middle;
}

.winner-standing-name {
  color: var(--white);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-standing-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.winner-standing-out {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: var(--danger);
}

.winner-standing-score {
  font-family: 'JetBrains Mono', monospace;
  color: var(--light);
}

.winner-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--grey);
  margin: 0 0 20px;
}

.winner-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.winner-actions .btn-primary,
.winner-actions .btn-ghost {
  width: 100%;
  justify-content: center;
  text-align: center;
}

body.view-only .winner-actions .scorer-only {
  display: none !important;
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 260;
}

/* TV mode */
body.tv-mode .page-wrap { max-width: 1600px; padding-top: calc(var(--nav-h) + 16px); }
body.tv-mode nav { display: none; }
body.tv-mode .setup-panel,
body.tv-mode .hide-tv,
body.tv-mode .collapsible-toggle { display: none !important; }
body.tv-mode .collapsible-body { display: block !important; padding-top: 0; }

body.tv-mode .game-toolbar {
  justify-content: center;
  border: none;
  background: transparent;
}

body.tv-mode .timer { font-size: 2rem; padding: 12px 28px; }
body.tv-mode .game-meta { font-size: 1rem; }
body.tv-mode .player-name { font-size: 1.4rem; }
body.tv-mode .player-total { font-size: 3.5rem; }
body.tv-mode .player-right .progress-wrap { width: 120px; height: 8px; }
body.tv-mode .player-list-item { padding: 24px 28px; }
body.tv-mode .chart-wrap { height: min(480px, 50vh); }

@media (min-width: 1400px) and (min-height: 800px) {
  .game-layout-wide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
  }

  .player-list-wrap { grid-column: 1 / -1; }
}

footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--grey);
}

footer a { color: var(--grey); text-decoration: none; }
footer a:hover { color: var(--amber); }

/* Mobile */
@media (max-width: 768px) {
  nav { padding: 14px 18px; }
  .nav-links { display: none; }
  .page-wrap { padding: calc(var(--nav-h) + 20px) 16px 32px; }
  .mobile-only { display: flex; }
  .desktop-only { display: none; }

  .setup-panel { padding: 16px; }
  .panel-toggle { display: flex; margin-bottom: 0; }
  .panel-toggle span:first-child { margin-bottom: 0; }
  .panel-body.open { padding-top: 16px; }
  .panel-body.open h2:first-of-type { display: none; }

  .toolbar-desktop { display: none; }
  .toolbar-mobile { display: flex; width: 100%; }
  .toolbar-mobile .btn-ghost { flex: 1; text-align: center; min-width: 0; }

  .game-meta { width: 100%; order: 3; }
  .player-total { font-size: 1.75rem; }
  .player-list-item { padding: 14px 16px; }

  .collapsible-body:not(.open) { display: none; }
}

@media (max-width: 480px) {
  .preset-btn { flex: 1; min-width: calc(50% - 5px); text-align: center; }
}

@media (min-width: 769px) {
  .collapsible-toggle {
    display: flex;
    cursor: default;
    pointer-events: none;
    margin-bottom: 12px;
    padding: 0;
    background: none;
    border: none;
  }
  .collapsible-toggle .toggle-icon { display: none; }
  .collapsible-toggle span:first-child {
    color: var(--grey);
    font-size: 0.68rem;
  }
  .collapsible-body { display: block !important; padding-top: 0; }
  .collapsible { margin-bottom: 24px; }
}

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

.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.home-card {
  display: block;
  padding: 28px 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s;
}

.home-card:hover { border-color: var(--amber-border); transform: translateY(-2px); }
.home-card.primary { border-color: var(--amber-border); background: var(--amber-dim); }
.home-card-icon { font-size: 2rem; margin-bottom: 12px; display: block; }
.home-card h2 { font-family: 'DM Serif Display', serif; font-size: 1.5rem; margin-bottom: 8px; font-weight: 400; }
.home-card p { color: var(--light); font-size: 0.92rem; }
.home-recent { margin-top: 36px; }
.recent-club-link { display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--amber); text-decoration: none; }

.code-display {
  text-align: center;
  padding: 28px 20px;
  background: var(--bg2);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.code-display.compact { padding: 20px; margin-bottom: 16px; }
.code-label { font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--grey); margin-bottom: 12px; }
.code-digits { font-family: 'JetBrains Mono', monospace; font-size: clamp(2.5rem, 8vw, 4rem); font-weight: 600; letter-spacing: 0.2em; color: var(--amber); line-height: 1.1; }
.code-hint { margin-top: 14px; color: var(--light); font-size: 0.88rem; }
.qr-block { display: flex; justify-content: center; margin-bottom: 24px; }
.qr-block.small canvas { max-width: 140px; height: auto !important; }
.share-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.club-code-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 28px; }
.club-code-actions { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: center; margin-top: 16px; }
.club-code-buttons { display: flex; flex-direction: column; gap: 10px; min-width: 180px; }
.club-code-buttons .btn-ghost { text-align: center; text-decoration: none; }

.live-card { background: var(--amber-dim); border: 1px solid var(--amber-border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.live-card-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.live-card p { color: var(--light); font-size: 0.9rem; margin-top: 4px; }
.club-actions { margin: 28px 0; }
.club-actions .btn-primary { display: inline-block; text-decoration: none; }

.game-history-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.history-game-item a { display: block; padding: 14px 16px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; }
.history-game-item a:hover { border-color: var(--amber-border); }
.history-game-title { display: block; font-weight: 500; margin-bottom: 4px; }
.history-game-meta { font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; color: var(--grey); }
.session-block { margin-bottom: 24px; }
.session-title { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--amber); margin-bottom: 10px; text-transform: uppercase; }
.empty-note { color: var(--grey); font-size: 0.9rem; padding: 12px 0; }

.collapsible-toggle.open-static { pointer-events: none; cursor: default; margin-bottom: 12px; padding: 0; background: none; border: none; width: 100%; text-align: left; }

.join-wrap { max-width: 520px; margin: 0 auto; }
.join-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 24px; margin-top: 24px; }
.code-input-tv { width: 100%; padding: 24px 16px; font-family: 'JetBrains Mono', monospace; font-size: clamp(2.5rem, 10vw, 4rem); font-weight: 600; letter-spacing: 0.25em; text-align: center; background: var(--bg); border: 2px solid var(--border); border-radius: var(--radius); color: var(--amber); margin-bottom: 20px; }
.code-input-tv:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-dim); }
.btn-join { width: 100%; padding: 16px; font-size: 1rem; }
.join-error { color: var(--danger); font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; margin-top: 12px; text-align: center; }
.join-alt { text-align: center; margin-top: 24px; font-size: 0.9rem; }
.join-alt a { color: var(--amber); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.club-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; }
.club-bar-link { color: var(--amber); text-decoration: none; }
.club-bar-code { color: var(--grey); }
.view-only-banner { padding: 12px 16px; margin-bottom: 16px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--grey); text-align: center; }
body.view-only .scorer-only { display: none !important; }
body.view-only .player-list-item[role="button"] { cursor: default; pointer-events: none; }
body.join-page .page-wrap { padding-top: calc(var(--nav-h) + 40px); }
