/* ═══════════════════════════════════════════
   Darts — Impeccable Edition
   Typography: Bricolage Grotesque + Figtree
   Color: OKLCH warm-tinted (hue 75)
   ═══════════════════════════════════════════ */

/* ─── Design Tokens ─── */

:root {
  /* Palette — warm cream, hue 75 */
  --bg: oklch(0.955 0.012 75);
  --panel: oklch(0.935 0.014 75);
  --surface: oklch(0.925 0.015 75);
  --line: oklch(0.855 0.010 75);
  --text: oklch(0.155 0.010 75);
  --sub: oklch(0.35 0.008 75);
  --muted: oklch(0.52 0.008 75);
  --accent: oklch(0.50 0.14 155);
  --accent-dim: oklch(0.50 0.14 155 / 0.10);
  --red: oklch(0.52 0.16 25);
  --red-dim: oklch(0.52 0.16 25 / 0.10);

  /* Player accents */
  --p1: oklch(0.50 0.14 155);
  --p2: oklch(0.50 0.14 260);
  --p3: oklch(0.50 0.14 310);
  --p4: oklch(0.55 0.13 65);

  /* Input surfaces */
  --key-bg: oklch(0.915 0.012 75);
  --key-alt: oklch(0.89 0.012 75);
  --key-press: oklch(0.84 0.012 75);

  /* Spacing — 4pt base */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Radius */
  --radius: 10px;
  --radius-sm: 6px;

  /* Typography */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

/* Explicit dark */
[data-theme="dark"] {
  --bg: oklch(0.155 0.010 75);
  --panel: oklch(0.19 0.012 75);
  --surface: oklch(0.21 0.014 75);
  --line: oklch(0.28 0.010 75);
  --text: oklch(0.925 0.010 75);
  --sub: oklch(0.72 0.008 75);
  --muted: oklch(0.50 0.008 75);
  --accent: oklch(0.62 0.14 155);
  --accent-dim: oklch(0.62 0.14 155 / 0.12);
  --red: oklch(0.62 0.16 25);
  --red-dim: oklch(0.62 0.16 25 / 0.12);
  --p1: oklch(0.65 0.14 155);
  --p2: oklch(0.65 0.14 260);
  --p3: oklch(0.65 0.14 310);
  --p4: oklch(0.68 0.13 65);
  --key-bg: oklch(0.24 0.012 75);
  --key-alt: oklch(0.22 0.012 75);
  --key-press: oklch(0.30 0.012 75);
  color-scheme: dark;
}

/* ─── Reset ─── */

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

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  padding: var(--space-lg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ─── App Shell ─── */

.app-shell {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  gap: var(--space-lg);
  overflow: hidden;
}

/* ─── Panels ─── */

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 20px;
  min-width: 0;
  max-width: 100%;
}

/* ─── Setup Panel (lobby) ─── */

.setup-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0 var(--space-xl);
  max-width: 100%;
  overflow: hidden;
}

.app-logo {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  margin: var(--space-sm) auto calc(var(--space-lg) + 4px);
  border-radius: 28px;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px color-mix(in oklch, var(--red) 22%, transparent),
    0 12px 28px -10px color-mix(in oklch, var(--red) 55%, transparent),
    0 24px 60px -20px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 480ms var(--ease-out),
    box-shadow 480ms var(--ease-out);
  animation: logo-float 7s ease-in-out infinite;
  will-change: transform;
}

.app-logo:hover {
  transform: translateY(-3px) rotate(-1.2deg) scale(1.03);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 0 0 1px color-mix(in oklch, var(--red) 35%, transparent),
    0 18px 40px -10px color-mix(in oklch, var(--red) 70%, transparent),
    0 36px 80px -24px rgba(0, 0, 0, 0.6),
    0 4px 10px rgba(0, 0, 0, 0.3);
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-4px) rotate(-0.6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .app-logo {
    animation: none;
    transition: none;
  }
  .app-logo:hover {
    transform: none;
  }
}

/* Rule chips */
.rule-chips {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
  margin-bottom: 8px;
}

.rule-chips + .rule-chips {
  margin-top: 0;
}

.rule-chips:last-of-type {
  margin-bottom: 20px;
}

.rule-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  user-select: none;
}

.rule-chip:hover {
  color: var(--sub);
  border-color: var(--sub);
}

.rule-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Player roster */
.roster {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  padding: 0 var(--space-xs);
}

.player-card {
  position: relative;
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 20px 14px 16px;
  text-align: center;
  box-shadow: 0 1px 4px oklch(0 0 0 / 0.06);
  transition: border-color 0.15s var(--ease-out);
  overflow: hidden;
}

.player-card:hover {
  border-color: var(--sub);
}

.card-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
}

.player-card[data-player="1"] .card-stripe { background: var(--p1); }
.player-card[data-player="2"] .card-stripe { background: var(--p2); }
.player-card[data-player="3"] .card-stripe { background: var(--p3); }
.player-card[data-player="4"] .card-stripe { background: var(--p4); }

.card-remove {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.12s;
}

.card-remove:hover {
  color: var(--red);
}

.player-card input[type="text"] {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  padding: 6px 4px;
  min-height: auto;
  width: 100%;
  transition: border-color 0.15s;
}

.player-card input[type="text"]:focus {
  border-color: var(--line);
  box-shadow: none;
}

.player-card input[type="text"]::placeholder {
  color: var(--muted);
}

.card-opts {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.bot-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  user-select: none;
  white-space: nowrap;
}

.bot-icon {
  flex-shrink: 0;
  vertical-align: middle;
}

.bot-chip:hover {
  background: var(--key-alt);
  border-color: var(--sub);
  color: var(--sub);
}

.bot-chip:active {
  transform: scale(0.96);
}

.bot-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(0.98 0.005 75);
}

.bot-chip.active:hover {
  opacity: 0.9;
}

.bot-fields {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.bot-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.58rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bot-avg {
  width: 48px;
  min-height: 26px;
  padding: 3px 4px;
  font-size: 16px;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  touch-action: manipulation;
}

.add-card {
  width: 150px;
  min-height: 120px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 300;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-card:hover {
  border-color: var(--sub);
  color: var(--sub);
}

/* Start button */
.start-btn {
  width: 100%;
  max-width: 340px;
  margin-top: 20px;
  padding: var(--space-lg) 20px;
  border: none;
  border-radius: var(--radius);
  background: oklch(0.45 0.14 155);
  color: oklch(0.98 0.005 75);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.08s var(--ease-out);
  box-shadow: 0 4px 12px oklch(0.45 0.14 155 / 0.2);
}

.start-btn:hover {
  opacity: 0.92;
}

.start-btn:active {
  transform: scale(0.98);
}

/* ─── Form elements (global) ─── */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

input,
select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
  font-family: var(--font-body);
  min-height: 42px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}

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

input:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* ─── Buttons ─── */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.08s var(--ease-out), opacity 0.12s;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-primary {
  color: oklch(0.98 0.005 75);
  background: oklch(0.45 0.14 155);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  color: var(--text);
  background: var(--key-alt);
  border-color: transparent;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--key-press);
}

/* ─── Theme toggle ─── */

.theme-toggle {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  z-index: 100;
  overflow: hidden;
  transition: border-color 0.3s var(--ease-out);
}

/* Expanded tap target */
.theme-toggle::before {
  content: '';
  position: absolute;
  inset: -8px;
}

/* Fill indicator — empty in light, filled in dark */
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--text);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.3s var(--ease-out);
}

.theme-toggle:hover {
  border-color: var(--sub);
}

[data-theme="dark"] .theme-toggle::after {
  transform: scale(1);
}

body.playing .theme-toggle {
  display: none;
}

/* ─── Toolbar ─── */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 2px 6px;
  min-width: 0;
}

.toolbar-status {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-status:empty {
  display: none;
}

.pubdarts-badge {
  font-family: var(--font-display, var(--font-body));
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  background: var(--accent, #c0392b);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.pubdarts-badge.hidden {
  display: none;
}

/* ─── Scoreboard (block columns) ─── */

.scoreboard {
  --player-count: 2;
  display: grid;
  grid-template-columns: repeat(var(--player-count), minmax(0, 1fr));
  gap: 0;
  padding: 0;
}

.player-col {
  --p-color: var(--muted);
  min-width: 0;
  background: var(--surface);
  padding: var(--space-sm);
  text-align: center;
  border-right: 1px solid var(--line);
  border-top: 3px solid transparent;
  transition: background 0.15s var(--ease-out);
}

.player-col:last-child {
  border-right: none;
}

.player-col.p1 { --p-color: var(--p1); border-top-color: var(--p1); }
.player-col.p2 { --p-color: var(--p2); border-top-color: var(--p2); }
.player-col.p3 { --p-color: var(--p3); border-top-color: var(--p3); }
.player-col.p4 { --p-color: var(--p4); border-top-color: var(--p4); }

.player-col.active {
  background: color-mix(in oklch, var(--surface), var(--p-color) 18%);
  border-top-width: 6px;
  box-shadow: inset 0 0 0 2px var(--p-color);
}

.player-col.winner {
  background: color-mix(in oklch, var(--surface), var(--accent) 6%);
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.col-name {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}

.player-col.active .col-name {
  color: var(--p-color);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.col-legs {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1;
  color: var(--sub);
  font-variant-numeric: tabular-nums lining-nums;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--surface), var(--p-color, var(--muted)) 10%);
  border: 1px solid color-mix(in oklch, var(--line), var(--p-color, var(--muted)) 25%);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.col-legs b {
  font-weight: 800;
  color: var(--text);
  font-size: 1.05rem;
}

.col-legs-sep {
  opacity: 0.55;
  margin: 0 2px;
}

.player-col.active .col-legs {
  background: color-mix(in oklch, var(--surface), var(--p-color) 20%);
  border-color: color-mix(in oklch, var(--line), var(--p-color) 55%);
}

.col-score {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--text);
  margin: 2px 0;
  text-align: center;
}

.col-stats {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: var(--space-xs);
  border-top: 1px solid var(--line);
  padding-top: var(--space-xs);
}

.col-stat-header {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 5px 0 1px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.col-stat-header:first-child {
  padding-top: 0;
}

.col-stat {
  display: flex;
  justify-content: space-between;
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 2px 0;
  font-weight: 600;
}

.col-stat b {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ─── Entry area ─── */

.entry-area {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
}

.entry-display {
  display: none;
}

.entry-feedback {
  font-size: 0.72rem;
  font-family: var(--font-body);
  color: var(--sub);
  text-align: center;
}

.entry-feedback:empty {
  display: none;
}

.entry-feedback[data-tone="warn"] {
  color: var(--red);
}

.entry-feedback[data-tone="good"] {
  color: var(--accent);
}

/* ─── Pad row: quick scores left + keypad right ─── */

.pad-row {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* Quick scores — vertical column on the left */
.quick-scores {
  display: flex;
  flex-direction: column;
  width: 80px;
  flex-shrink: 0;
}

.quick {
  flex: 1;
  border: none;
  border-radius: 0;
  background: var(--key-alt);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-bottom: 1px solid var(--bg);
  transition: background 0.06s;
}

.quick:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.quick:last-child {
  border-radius: 0 0 0 var(--radius-sm);
  border-bottom: none;
}

.quick:active:not(:disabled) {
  background: var(--key-press);
}

.quick-label {
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1;
}

.quick-num {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
}

/* Keypad — 3-col grid, no gaps, fills remaining space */
.keypad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 0;
}

.key {
  border: none;
  border-radius: 0;
  background: var(--key-bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--bg);
  border-bottom: 1px solid var(--bg);
  transition: background 0.06s, transform 0.06s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.key:nth-child(3n) {
  border-right: none;
}

.key:nth-child(n+10) {
  border-bottom: none;
}

/* top-right corner radius */
.key:nth-child(3) {
  border-radius: 0 var(--radius-sm) 0 0;
}

/* bottom-right corner radius */
.key:nth-child(12) {
  border-radius: 0 0 var(--radius-sm) 0;
}

.key:active:not(:disabled) {
  background: var(--key-press);
  transform: scale(0.94);
}

.key.flash {
  animation: key-flash 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes key-flash {
  0% {
    transform: scale(1);
    background: var(--key-bg);
    box-shadow: none;
  }
  22% {
    transform: scale(0.9);
    background: var(--key-press);
    box-shadow: inset 0 0 0 2px var(--text);
  }
  55% {
    transform: scale(1.02);
    background: var(--key-bg);
    box-shadow: inset 0 0 0 1px var(--text);
  }
  100% {
    transform: scale(1);
    background: var(--key-bg);
    box-shadow: none;
  }
}

.key-alt.flash {
  animation-name: key-alt-flash;
}

@keyframes key-alt-flash {
  0% {
    transform: scale(1);
    background: var(--key-alt);
  }
  22% {
    transform: scale(0.9);
    background: var(--key-press);
    box-shadow: inset 0 0 0 2px var(--text);
  }
  55% {
    transform: scale(1.02);
    background: var(--key-alt);
    box-shadow: inset 0 0 0 1px var(--text);
  }
  100% {
    transform: scale(1);
    background: var(--key-alt);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .key.flash,
  .key-alt.flash {
    animation: none;
  }
}

.key-alt {
  background: var(--key-alt);
  color: var(--sub);
}

/* ─── Submit / Undo bar ─── */

.visit-actions {
  display: flex;
  margin-top: 1px;
}

.submit-group {
  flex: 1;
  display: flex;
  min-width: 0;
}

.dbl-darts {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px;
  background: oklch(0.4 0.13 155);
  border-left: 1px solid var(--bg);
}

.dbl-darts.hidden {
  display: none;
}

.dbl-darts-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: oklch(0.92 0.02 150);
  opacity: 0.85;
}

.dbl-darts-row {
  display: flex;
  gap: 5px;
}

.dbl-dart {
  width: 34px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: oklch(0.98 0.005 75 / 0.16);
  color: oklch(0.98 0.005 75);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.08s, transform 0.08s var(--ease-out);
}

.dbl-dart:active:not(:disabled) {
  transform: scale(0.94);
  background: oklch(0.98 0.005 75 / 0.32);
}

.dbl-dart:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.submit-bar {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0 0 0 var(--radius-sm);
  background: oklch(0.45 0.14 155);
  color: oklch(0.98 0.005 75);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  padding: 34px 8px;
  cursor: pointer;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em;
  transition: opacity 0.08s, transform 0.08s var(--ease-out);
}

.submit-bar:active:not(:disabled) {
  transform: scale(0.99);
  opacity: 0.85;
}

.submit-bar:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bust-bar {
  width: 96px;
  flex-shrink: 0;
  border: none;
  border-radius: 0;
  background: oklch(0.55 0.18 28);
  color: oklch(0.98 0.005 75);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 34px 6px;
  cursor: pointer;
  transition: opacity 0.08s, transform 0.08s var(--ease-out);
  border-left: 1px solid var(--bg);
}

.bust-bar:active:not(:disabled) {
  transform: scale(0.99);
  opacity: 0.85;
}

.bust-bar:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bust-bar.hidden {
  display: none;
}

.undo-bar {
  width: 72px;
  flex-shrink: 0;
  border: none;
  border-radius: 0 0 var(--radius-sm) 0;
  background: var(--key-alt);
  color: var(--sub);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 34px 8px;
  cursor: pointer;
  transition: background 0.08s;
  border-left: 1px solid var(--bg);
}

.undo-bar:active:not(:disabled) {
  background: var(--key-press);
}

.undo-bar:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ─── History ─── */

.history-panel h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-xs);
}

.history li {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--sub);
  line-height: 1.4;
}

.history li.bust {
  border-color: color-mix(in oklch, var(--red) 30%, transparent);
  color: var(--red);
}

.history li.win {
  border-color: color-mix(in oklch, var(--accent) 30%, transparent);
  color: var(--accent);
}

.history li.start {
  border-color: var(--line);
  color: var(--muted);
}

.win-text {
  color: var(--accent);
}

/* ─── Match summary ─── */

.match-summary {
  text-align: center;
}

.summary-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 var(--space-lg);
  color: var(--text);
}

.summary-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.summary-section-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 var(--space-sm);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(var(--player-count, 2), 1fr);
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.summary-col {
  background: var(--surface);
  padding: var(--space-md);
  text-align: center;
}

.summary-col.winner {
  background: color-mix(in oklch, var(--surface), var(--accent) 8%);
}

.summary-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-col.winner .summary-name {
  color: var(--accent);
}

.summary-legs {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.summary-col.winner .summary-legs {
  color: var(--accent);
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--line);
  padding-top: var(--space-xs);
}

.summary-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--sub);
  padding: 2px 0;
}

.summary-stat b {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.match-summary .start-btn {
  margin-top: 0;
}

/* ─── Winner hero ─── */

.summary-hero {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  background: color-mix(in oklch, var(--surface), var(--accent) 10%);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xs);
}

.hero-crown {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px oklch(0.2 0.06 75 / 0.4));
  animation: hero-crown-bob 2.4s ease-in-out infinite;
}

@keyframes hero-crown-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-5px) rotate(2deg); }
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6.5vw, 2.3rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-top: var(--space-xs);
  word-break: break-word;
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-legs {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .hero-crown { animation: none; }
}

/* ─── Crown stats rows (inline crown on per-row winner) ─── */

.summary-stat .stat-val {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.summary-stat .stat-emoji {
  font-size: 0.95em;
}

.summary-stat .stat-crown {
  font-size: 0.95em;
  line-height: 1;
  filter: drop-shadow(0 1px 2px oklch(0.2 0.06 75 / 0.4));
}

.summary-stat-crowned {
  color: var(--accent) !important;
  font-weight: 700;
}

.summary-stat-crowned b {
  color: var(--accent) !important;
}

/* ─── Scores-per-visit bar chart ─── */

.score-charts {
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-align: left;
}

.chart-block {
  --p-color: var(--accent);
  padding: var(--space-md);
}

.chart-block.p1 { --p-color: var(--p1); }
.chart-block.p2 { --p-color: var(--p2); }
.chart-block.p3 { --p-color: var(--p3); }
.chart-block.p4 { --p-color: var(--p4); }

.chart-block + .chart-block {
  border-top: 1px solid var(--line);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.chart-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--p-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-meta {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.score-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 108px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.score-col {
  flex: 1 0 auto;
  min-width: 15px;
  max-width: 38px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Subtle solid hairline between legs — the app's divider idiom, not a dashed line */
.score-col.leg-start {
  margin-left: 11px;
  position: relative;
}

.score-col.leg-start::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 8px;
  bottom: 0;
  border-left: 1px solid var(--line);
}

.score-val {
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums lining-nums;
}

/* Milestone visits (100+) read as events: heavier, full-strength — not a new hue */
.score-col.is-ton .score-val {
  font-weight: 800;
  color: var(--text);
}

.score-col.is-bust .score-val {
  color: color-mix(in oklch, var(--muted), oklch(0.55 0.18 28) 55%);
}

.score-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
  background: var(--p-color);
  transition: height 0.4s var(--ease-out);
}

.score-col.is-bust .score-bar {
  background: var(--line);
}

.chart-empty {
  align-self: center;
  margin: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .score-bar { transition: none; }
}

/* ─── Podium (winner column) ─── */

.summary-podium {
  margin-top: var(--space-sm);
}

.summary-podium .summary-grid {
  overflow: visible;
  margin-top: 2.2rem;
}

.podium-col {
  position: relative;
  padding-top: var(--space-md);
}

.podium-col.winner {
  background: color-mix(in oklch, var(--surface), var(--accent) 12%);
  box-shadow: inset 0 2px 0 0 var(--accent);
}

.podium-col.winner .summary-name {
  color: var(--accent);
  font-size: 1rem;
}

.podium-col.winner .summary-legs {
  color: var(--accent);
  font-size: 1.8rem;
}

.podium-crown {
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px oklch(0.2 0.06 75 / 0.35));
  animation: podium-crown-bob 2.4s ease-in-out infinite;
  pointer-events: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .podium-crown { animation: none; }
}

/* ═══════════════════════════════════════════
   Playing mode — fit on one screen
   ═══════════════════════════════════════════ */

body.playing {
  height: 100dvh;
  padding: 0;
  overflow: hidden;
}

body.playing .app-shell {
  max-width: 100%;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

body.playing #setupPanel,
body.playing .history-panel {
  display: none !important;
}

body.playing .game-panel {
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 6px 0 0 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

/* Scoreboard — compact in playing mode */
body.playing .player-col {
  padding: 6px;
}

body.playing .col-score {
  font-size: clamp(2.6rem, 9vw, 3.4rem);
}

body.playing .col-stats {
  margin-top: 2px;
  padding-top: 2px;
}

/* Entry — compact in playing mode */
body.playing .entry-area {
  margin-top: 0;
  flex: 1 1 auto;
  min-height: 0;
}

body.playing .entry-feedback {
  font-size: 0.62rem;
}

body.playing .quick {
  font-size: 0.75rem;
}

body.playing .quick-scores {
  width: 72px;
}

body.playing .key {
  font-size: 1.2rem;
}

body.playing .submit-bar {
  font-size: 1.4rem;
  padding: 40px 8px;
}

body.playing .bust-bar {
  width: 84px;
  font-size: 0.95rem;
  padding: 40px 4px;
}

body.playing .undo-bar {
  width: 60px;
  font-size: 0.75rem;
  padding: 40px 6px;
}

/* ─── 2–3 players playing — bigger scores ─── */

body.playing .scoreboard[data-players="2"] .col-score {
  font-size: clamp(4.4rem, 17vw, 6.4rem);
  margin: 6px 0 4px;
}

body.playing .scoreboard[data-players="2"] .col-stat {
  font-size: 1.12rem;
}

body.playing .scoreboard[data-players="2"] .col-stat b {
  font-size: 0.92rem;
}

body.playing .scoreboard[data-players="2"] .col-stat-header {
  font-size: 0.85rem;
}

body.playing .scoreboard[data-players="2"] .col-legs {
  font-size: 1.05rem;
  padding: 4px 10px;
}

body.playing .scoreboard[data-players="2"] .col-legs b {
  font-size: 1.2rem;
}

body.playing .scoreboard[data-players="3"] .col-score {
  font-size: clamp(3.2rem, 11vw, 4.4rem);
}

body.playing .scoreboard[data-players="3"] .col-stat {
  font-size: 1.05rem;
}

body.playing .scoreboard[data-players="3"] .col-stat b {
  font-size: 0.85rem;
}

/* ─── 4 players playing — tighter ─── */

body.playing .scoreboard[data-players="4"] .player-col {
  padding: var(--space-xs);
}

body.playing .scoreboard[data-players="4"] .col-score {
  font-size: clamp(1.9rem, 6vw, 2.4rem);
}

body.playing .scoreboard[data-players="4"] .col-stat {
  font-size: 0.88rem;
}

body.playing .scoreboard[data-players="4"] .col-stat b {
  font-size: 0.74rem;
}

body.playing .scoreboard[data-players="4"] .col-legs {
  font-size: 0.78rem;
  padding: 2px 6px;
}

body.playing .scoreboard[data-players="4"] .col-legs b {
  font-size: 0.88rem;
}

body.playing[data-players="4"] .entry-feedback {
  display: none;
}

body.playing[data-players="4"] .quick-scores {
  width: 64px;
}

body.playing[data-players="4"] .quick {
  font-size: 0.68rem;
}

body.playing[data-players="4"] .key {
  font-size: 1rem;
}

body.playing[data-players="4"] .submit-bar {
  font-size: 1.2rem;
  padding: 32px 6px;
}

body.playing[data-players="4"] .bust-bar {
  width: 72px;
  font-size: 0.85rem;
  padding: 32px 4px;
}

body.playing[data-players="4"] .dbl-darts {
  padding: 0 5px;
  gap: 3px;
}

body.playing[data-players="4"] .dbl-dart {
  width: 27px;
  height: 34px;
  font-size: 1rem;
}

body.playing[data-players="4"] .undo-bar {
  width: 52px;
  font-size: 0.68rem;
  padding: 32px 4px;
}

/* ─── Responsive ─── */

@media (max-width: 430px) {
  body {
    padding: var(--space-sm);
  }

  .panel {
    padding: 14px;
  }

  .player-card {
    width: 130px;
    padding: 16px 10px 14px;
  }

  .add-card {
    width: 130px;
    min-height: 100px;
  }

  .start-btn {
    max-width: 100%;
  }

  body.playing .col-name {
    font-size: 0.74rem;
  }

  body.playing .col-score {
    font-size: clamp(2.4rem, 8.5vw, 3.2rem);
  }

  body.playing .scoreboard[data-players="2"] .col-score {
    font-size: clamp(3.8rem, 17vw, 5.6rem);
  }

  body.playing .scoreboard[data-players="3"] .col-score {
    font-size: clamp(2.8rem, 10.5vw, 3.8rem);
  }

  body.playing .scoreboard[data-players="4"] .col-score {
    font-size: clamp(1.7rem, 5.6vw, 2.1rem);
  }

  body.playing .col-stat {
    font-size: 0.92rem;
  }

  body.playing .col-stat b {
    font-size: 0.78rem;
  }

  body.playing .scoreboard[data-players="2"] .col-stat {
    font-size: 1.02rem;
  }

  body.playing .scoreboard[data-players="2"] .col-stat b {
    font-size: 0.84rem;
  }

  body.playing .col-legs {
    font-size: 0.88rem;
    padding: 2px 7px;
  }

  body.playing .col-legs b {
    font-size: 1rem;
  }

  body.playing .scoreboard[data-players="4"] .col-legs {
    font-size: 0.72rem;
    padding: 2px 5px;
  }

  body.playing .quick-scores {
    width: 64px;
  }

  body.playing .quick {
    font-size: 0.82rem;
  }

  body.playing .key {
    font-size: 1.1rem;
  }

  body.playing .submit-bar {
    font-size: 1.3rem;
    padding: 28px 8px;
  }

  body.playing .bust-bar {
    width: 74px;
    padding: 28px 4px;
  }

  body.playing .dbl-darts {
    padding: 0 6px;
    gap: 4px;
  }

  body.playing .dbl-dart {
    width: 29px;
    height: 36px;
    font-size: 1.05rem;
  }

  body.playing .undo-bar {
    width: 54px;
    padding: 28px 6px;
  }
}

/* ═══════════════════════════════════════════
   Score celebrations
   ═══════════════════════════════════════════ */

@keyframes firework-burst {
  0%   { transform: scale(0.28); opacity: 0; }
  15%  { transform: scale(0.7);  opacity: 1; }
  55%  { transform: scale(1.15); opacity: 0.85; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes sparkle-particle {
  0%   { transform: translate(0, 0) scale(0.85); opacity: 0; }
  12%  { transform: translate(calc(var(--tx) * 0.14), calc(var(--ty) * 0.14)) scale(1.05); opacity: 1; }
  70%  { transform: translate(calc(var(--tx) * 0.82), calc(var(--ty) * 0.82)) scale(0.6); opacity: 0.8; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.score-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

.score-overlay .particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: sparkle-particle 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.score-overlay .burst {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  animation: firework-burst 0.62s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Classic celebration overlay */

@keyframes classic-26-backdrop {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes classic-26-pop {
  0%   { transform: scale(0.62) rotate(-4deg); opacity: 0; }
  55%  { transform: scale(1.04) rotate(0.6deg); opacity: 1; }
  78%  { transform: scale(0.99) rotate(-0.3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes classic-26-wobble {
  0%, 100% { transform: rotate(0deg); }
  18%  { transform: rotate(-2.6deg); }
  38%  { transform: rotate(2.1deg); }
  58%  { transform: rotate(-1.4deg); }
  78%  { transform: rotate(0.9deg); }
}

@keyframes classic-26-badge {
  0%   { opacity: 0; letter-spacing: 0.55em; transform: translateY(-4px); }
  60%  { opacity: 1; }
  100% { opacity: 1; letter-spacing: 0.35em; transform: translateY(0); }
}

@keyframes classic-26-bed-chip {
  0%   { transform: translateY(14px) scale(0.82) rotate(-4deg); opacity: 0; }
  60%  { transform: translateY(-2px) scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes classic-26-fall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translateY(110vh) translateX(var(--drift)) rotate(320deg); opacity: 0; }
}

@keyframes classic-26-spark {
  0%   { transform: translate(-50%, -50%) scale(0.18); opacity: 0; }
  18%  { transform: translate(calc(-50% + var(--sx) * 0.2), calc(-50% + var(--sy) * 0.2)) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0); opacity: 0; }
}

.score-overlay.classic-26 {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 120% 80% at 50% 45%,
    oklch(0.18 0.01 75 / 0.80) 0%,
    oklch(0.10 0.005 75 / 0.65) 55%,
    oklch(0.08 0.005 75 / 0.58) 100%);
  animation: classic-26-backdrop var(--overlay-duration, 1260ms) ease-out forwards;
}

.classic-26-inner {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  padding: 12px 20px 20px;
  text-align: center;
  animation: classic-26-pop 0.36s cubic-bezier(0.22, 1.35, 0.36, 1) forwards;
}

.classic-26-badge {
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: oklch(0.92 0.01 75 / 0.92);
  text-shadow: 0 1px 2px oklch(0.10 0.01 75 / 0.45);
  margin-bottom: 8px;
  opacity: 0;
  animation: classic-26-badge 0.29s cubic-bezier(0.22, 1, 0.36, 1) 0.06s forwards;
}

.classic-26-num {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
  margin: 0 0 10px;
  color: oklch(0.75 0.05 75);
  text-shadow: 0 3px 0 oklch(0.12 0.01 75 / 0.45);
  animation: classic-26-wobble 0.36s ease-in-out 0.22s 2;
}

/* 60 variant — warm amber */
.score-overlay.classic-26.classic-60 {
  background: radial-gradient(ellipse 120% 80% at 50% 45%,
    oklch(0.20 0.03 70 / 0.85) 0%,
    oklch(0.12 0.015 70 / 0.68) 55%,
    oklch(0.09 0.008 70 / 0.58) 100%);
}

.score-overlay.classic-26.classic-60 .classic-26-num {
  color: oklch(0.80 0.13 70);
  text-shadow: 0 4px 0 oklch(0.15 0.02 70 / 0.5);
}

/* 100 variant — ice blue */
.score-overlay.classic-26.classic-100 {
  background: radial-gradient(ellipse 120% 80% at 50% 45%,
    oklch(0.18 0.02 230 / 0.85) 0%,
    oklch(0.12 0.01 230 / 0.70) 55%,
    oklch(0.08 0.005 230 / 0.58) 100%);
}

.score-overlay.classic-26.classic-100 .classic-26-num {
  color: oklch(0.82 0.08 230);
  text-shadow: 0 4px 0 oklch(0.12 0.01 230 / 0.5);
}

.score-overlay.classic-26.classic-60 .classic-26-badge,
.score-overlay.classic-26.classic-100 .classic-26-badge {
  color: oklch(0.96 0.005 75 / 0.96);
  text-shadow: 0 2px 6px oklch(0.10 0.01 75 / 0.45);
}

.score-overlay.classic-26.classic-60 .classic-26-bed .bed-hit {
  background: linear-gradient(180deg, oklch(0.94 0.05 75) 0%, oklch(0.82 0.08 75) 100%);
}

.score-overlay.classic-26.classic-100 .classic-26-bed .bed-hit {
  background: linear-gradient(180deg, oklch(0.92 0.03 230) 0%, oklch(0.78 0.06 230) 100%);
}

.score-overlay.classic-26.classic-26--celebratory .classic-26-inner {
  filter: drop-shadow(0 0 20px oklch(0.95 0.01 75 / 0.12));
}

.score-overlay.classic-26.classic-26--max .classic-26-inner {
  filter: drop-shadow(0 0 28px oklch(0.80 0.08 230 / 0.22));
}

.classic-26-bed {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 10px;
}

.classic-26-bed .bed-hit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  padding: 7px 12px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: oklch(0.15 0.01 75);
  background: linear-gradient(180deg, oklch(0.90 0.015 75) 0%, oklch(0.78 0.03 75) 100%);
  box-shadow:
    0 2px 0 oklch(0.15 0.01 75 / 0.2),
    inset 0 1px 0 oklch(0.95 0.01 75 / 0.35);
  opacity: 0;
  animation: classic-26-bed-chip 0.29s cubic-bezier(0.22, 1.3, 0.36, 1) backwards;
}

.classic-26-bed .bed-plus {
  font-weight: 700;
  font-size: 1.15rem;
  color: oklch(0.92 0.02 75 / 0.55);
  opacity: 0;
  animation: classic-26-bed-chip 0.22s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.classic-26-tag {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 3.4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: oklch(0.92 0.02 75 / 0.82);
  text-shadow: 0 1px 2px oklch(0.10 0.01 75 / 0.35);
}

.classic-26-flake {
  position: fixed;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  opacity: 0.9;
  z-index: 0;
  animation: classic-26-fall 1.2s cubic-bezier(0.45, 0, 0.75, 0.55) forwards;
  animation-delay: var(--delay);
}

.classic-26-spark {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 1;
  opacity: 0;
  box-shadow: 0 0 10px oklch(0.95 0.01 75 / 0.6);
  animation: classic-26-spark 0.46s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .score-overlay.classic-26 {
    animation: none;
    opacity: 0.92;
  }

  .classic-26-inner,
  .classic-26-badge,
  .classic-26-num,
  .classic-26-bed .bed-hit,
  .classic-26-bed .bed-plus,
  .classic-26-flake,
  .classic-26-spark {
    animation: none !important;
  }

  .classic-26-badge {
    opacity: 1;
    letter-spacing: 0.35em;
  }

  .classic-26-bed .bed-hit,
  .classic-26-bed .bed-plus {
    opacity: 1;
    transform: none;
  }

  .classic-26-flake,
  .classic-26-spark {
    display: none;
  }
}

/* ─── Forest celebration (score 3) ─── */

@keyframes forest-backdrop {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes forest-pop {
  0%   { transform: scale(0.48) translateY(24px); opacity: 0; }
  55%  { transform: scale(1.05) translateY(-3px); opacity: 1; }
  78%  { transform: scale(0.99) translateY(1px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes forest-grow {
  0%   { transform: scaleY(0) scaleX(var(--tree-scale, 1)); opacity: 0; }
  40%  { opacity: 1; }
  65%  { transform: scaleY(1.1) scaleX(var(--tree-scale, 1)); opacity: 1; }
  82%  { transform: scaleY(0.97) scaleX(var(--tree-scale, 1)); }
  100% { transform: scaleY(1) scaleX(var(--tree-scale, 1)); opacity: 1; }
}

@keyframes forest-leaf-fall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translateY(110vh) translateX(var(--leaf-drift)) rotate(var(--leaf-spin, 300deg)); opacity: 0; }
}

@keyframes forest-sway {
  0%, 100% { transform: rotate(0deg); }
  28%  { transform: rotate(-1.8deg); }
  72%  { transform: rotate(1.8deg); }
}

.score-overlay.forest-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 130% 90% at 50% 55%,
    oklch(0.16 0.04 145 / 0.88) 0%,
    oklch(0.10 0.03 145 / 0.75) 50%,
    oklch(0.07 0.02 145 / 0.65) 100%);
  animation: forest-backdrop var(--overlay-duration, 2400ms) ease-out forwards;
}

.forest-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: forest-pop 0.48s cubic-bezier(0.22, 1.35, 0.36, 1) forwards;
}

.forest-badge {
  font-family: var(--font-body);
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: oklch(0.85 0.12 145 / 0.95);
  text-shadow: 0 2px 4px oklch(0.08 0.03 145 / 0.6);
  margin-bottom: 8px;
}

.forest-num {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 14vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin: 0 0 10px;
  color: oklch(0.72 0.14 145);
  text-shadow: 0 4px 0 oklch(0.10 0.04 145 / 0.5);
  animation: forest-sway 1.08s ease-in-out 0.34s 2;
}

.forest-tag {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 3.4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: oklch(0.88 0.06 145 / 0.85);
  text-shadow: 0 1px 2px oklch(0.08 0.02 145 / 0.4);
}

.forest-tree {
  position: fixed;
  bottom: 0;
  width: 0;
  height: 0;
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 80px solid oklch(0.30 0.08 145);
  transform-origin: bottom center;
  z-index: 1;
  opacity: 0;
  animation: forest-grow 0.72s cubic-bezier(0.22, 1.1, 0.36, 1) forwards;
  animation-delay: var(--grow-delay, 0s);
}

.forest-tree::before {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -20px;
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 60px solid oklch(0.35 0.10 145);
}

.forest-tree::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -5px;
  width: 10px;
  height: 20px;
  background: oklch(0.28 0.04 55);
}

.forest-leaf {
  position: fixed;
  width: 10px;
  height: 6px;
  border-radius: 50% 0 50% 0;
  z-index: 3;
  opacity: 0;
  animation: forest-leaf-fall 1.8s cubic-bezier(0.45, 0, 0.6, 1) forwards;
  animation-delay: var(--leaf-delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .score-overlay.forest-overlay {
    animation: none;
    opacity: 0.92;
  }

  .forest-inner,
  .forest-num,
  .forest-tree,
  .forest-leaf {
    animation: none !important;
  }

  .forest-tree {
    opacity: 1;
    transform: scaleY(1) scaleX(var(--tree-scale, 1));
  }

  .forest-leaf {
    display: none;
  }
}

/* ─── Leg-won celebration ─── */

@keyframes leg-won-backdrop {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes leg-won-pop {
  0%   { transform: scale(0.55) translateY(24px); opacity: 0; }
  55%  { transform: scale(1.05) translateY(-3px); opacity: 1; }
  78%  { transform: scale(0.99) translateY(1px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes leg-won-shine {
  0%   { background-position: -120% 50%; }
  100% { background-position: 220% 50%; }
}

@keyframes leg-won-fall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.95; }
  100% { transform: translateY(110vh) translateX(var(--drift)) rotate(360deg); opacity: 0; }
}

.score-overlay.leg-won-overlay {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 22vh;
  /* Backdrop center pushed down + softened so the toolbar / Next-leg button
     at the top of the game panel stays visible during celebration. */
  background: radial-gradient(ellipse 90% 55% at 50% 70%,
    oklch(0.14 0.015 75 / 0.55) 0%,
    oklch(0.10 0.008 75 / 0.30) 60%,
    oklch(0.08 0.005 75 / 0) 100%);
  animation: leg-won-backdrop var(--overlay-duration, 2040ms) ease-out forwards;
}

.leg-won-inner {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  padding: 14px 24px 18px;
  text-align: center;
  animation: leg-won-pop 0.46s cubic-bezier(0.22, 1.35, 0.36, 1) forwards;
}

.leg-won-text {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6.5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  background: linear-gradient(90deg,
    #ffd166 0%, #f6b73c 25%, #fff8d9 50%, #f6b73c 75%, #ffd166 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: 0 2px 18px oklch(0.05 0 0 / 0.45);
  animation: leg-won-shine 1.92s ease-in-out both;
}

.leg-won-flake {
  position: fixed;
  width: 10px;
  height: 10px;
  z-index: 0;
  animation: leg-won-fall 1.8s cubic-bezier(0.45, 0, 0.75, 0.55) forwards;
  animation-delay: var(--delay);
}

@media (prefers-reduced-motion: reduce) {
  .score-overlay.leg-won-overlay {
    animation: none;
    opacity: 0.94;
  }
  .leg-won-inner,
  .leg-won-text,
  .leg-won-flake {
    animation: none !important;
  }
  .leg-won-flake { display: none; }
}

/* ─── KRUIPEN! prompt (loser had ≥ 200 left) ─── */

@keyframes kruipen-backdrop-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes kruipen-dialog-in {
  0%   { transform: scale(0.6) translateY(30px); opacity: 0; }
  60%  { transform: scale(1.06) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes kruipen-title-shake {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-2.5deg); }
  75%      { transform: rotate(2.5deg); }
}

@keyframes kruipen-flake-fall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.95; }
  100% { transform: translateY(110vh) translateX(var(--drift)) rotate(540deg); opacity: 0; }
}

.score-overlay.kruipen-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(0.06 0.005 75 / 0.78);
  pointer-events: auto;
  animation: kruipen-backdrop-in 0.36s ease-out forwards;
}

.kruipen-dialog {
  position: relative;
  z-index: 1;
  max-width: min(440px, 92vw);
  padding: 28px 32px 24px;
  border: 2px solid oklch(0.78 0.13 65 / 0.85);
  border-radius: var(--radius);
  background: linear-gradient(180deg,
    oklch(0.18 0.02 65) 0%,
    oklch(0.12 0.015 65) 100%);
  box-shadow:
    0 20px 60px oklch(0 0 0 / 0.55),
    0 0 80px oklch(0.78 0.18 65 / 0.20),
    inset 0 1px 0 oklch(0.95 0.02 65 / 0.10);
  text-align: center;
  animation: kruipen-dialog-in 0.5s cubic-bezier(0.22, 1.4, 0.36, 1) forwards;
}

.kruipen-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #ffd166 0%, #f6892c 60%, #d63a1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: 0 3px 18px oklch(0.45 0.18 50 / 0.4);
  animation: kruipen-title-shake 0.4s ease-in-out 0.5s 3;
  transform-origin: center;
}

.kruipen-sub {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: oklch(0.86 0.02 65 / 0.85);
  margin-bottom: 18px;
  line-height: 1.4;
}

.kruipen-confirm {
  width: 100%;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kruipen-flake {
  position: fixed;
  width: 9px;
  height: 9px;
  z-index: 0;
  animation: kruipen-flake-fall 1.8s cubic-bezier(0.45, 0, 0.75, 0.55) forwards;
  animation-delay: var(--delay);
}

@media (prefers-reduced-motion: reduce) {
  .kruipen-dialog,
  .kruipen-title,
  .kruipen-flake {
    animation: none !important;
  }
  .kruipen-flake { display: none; }
}

/* ─── Wind celebration (score 15 — Oostenwind) ─── */

@keyframes wind-backdrop {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes wind-pop {
  0%   { transform: translateX(60px) scale(0.85); opacity: 0; }
  55%  { transform: translateX(-6px) scale(1.04); opacity: 1; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes wind-shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-3px); }
  40%  { transform: translateX(2px); }
  60%  { transform: translateX(-2px); }
  80%  { transform: translateX(1px); }
}

@keyframes wind-streak-fly {
  0%   { transform: translateX(0); opacity: 0; }
  20%  { opacity: var(--streak-opacity, 0.7); }
  100% { transform: translateX(calc(var(--travel) * -1)); opacity: 0; }
}

@keyframes wind-leaf-fly {
  0%   { transform: translateX(0) translateY(0) rotate(0deg); opacity: 0; }
  15%  { opacity: 0.95; }
  100% { transform: translateX(calc(var(--travel) * -1)) translateY(var(--rise)) rotate(calc(var(--spin) * -1)); opacity: 0; }
}

.score-overlay.wind-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 130% 90% at 50% 50%,
    oklch(0.20 0.04 220 / 0.82) 0%,
    oklch(0.13 0.03 220 / 0.70) 55%,
    oklch(0.09 0.02 220 / 0.60) 100%);
  animation: wind-backdrop var(--overlay-duration, 2280ms) ease-out forwards;
  overflow: hidden;
}

.wind-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: wind-pop 0.5s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
}

.wind-badge {
  font-family: var(--font-body);
  font-size: clamp(1.4rem, 5.6vw, 2.1rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: oklch(0.93 0.05 220 / 0.96);
  text-shadow: 0 2px 6px oklch(0.10 0.03 220 / 0.6);
  margin-bottom: 10px;
  animation: wind-shake 0.5s ease-in-out 0.6s 2;
}

.wind-num {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 13vw, 5.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin: 0 0 10px;
  color: oklch(0.86 0.10 220);
  text-shadow:
    0 4px 0 oklch(0.12 0.03 220 / 0.5),
    -8px 0 12px oklch(0.86 0.10 220 / 0.35);
  animation: wind-shake 0.6s ease-in-out 0.38s 3;
}

.wind-tag {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 3.4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: oklch(0.90 0.04 220 / 0.85);
  text-shadow: 0 1px 2px oklch(0.08 0.02 220 / 0.4);
}

.wind-streak {
  position: fixed;
  height: 2px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  filter: blur(0.5px);
  animation: wind-streak-fly 1.44s linear forwards;
  animation-delay: var(--delay, 0s);
}

.wind-leaf {
  position: fixed;
  width: 10px;
  height: 6px;
  border-radius: 50% 0 50% 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  box-shadow: 0 1px 2px oklch(0.10 0.02 220 / 0.4);
  animation: wind-leaf-fly 1.8s cubic-bezier(0.4, 0, 0.6, 1) forwards;
  animation-delay: var(--delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .score-overlay.wind-overlay {
    animation: none;
    opacity: 0.92;
  }
  .wind-inner,
  .wind-badge,
  .wind-num,
  .wind-streak,
  .wind-leaf {
    animation: none !important;
  }
  .wind-streak,
  .wind-leaf { display: none; }
}

/* ─── Theme polygon view transition ─── */

::view-transition-group(root) {
  animation-duration: 1s;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

::view-transition-new(root) {
  animation-name: reveal-light;
  animation-fill-mode: both;
}

::view-transition-old(root),
[data-theme="dark"]::view-transition-old(root) {
  animation: none;
  animation-fill-mode: both;
  z-index: -1;
}

[data-theme="dark"]::view-transition-new(root) {
  animation-name: reveal-dark;
  animation-fill-mode: both;
}

@keyframes reveal-dark {
  from { clip-path: polygon(50% -71%, -50% 71%, -50% 71%, 50% -71%); }
  to   { clip-path: polygon(50% -71%, -50% 71%, 50% 171%, 171% 50%); }
}

@keyframes reveal-light {
  from { clip-path: polygon(171% 50%, 50% 171%, 50% 171%, 171% 50%); }
  to   { clip-path: polygon(171% 50%, 50% 171%, -50% 71%, 50% -71%); }
}
