/* ================================================================
   Xì Dách Scoreboard – Design System
   Dark theme · Glassmorphism · Mobile-first
   ================================================================ */

/* ========================
   DESIGN TOKENS
   ======================== */
:root {
  /* Backgrounds */
  --bg-body: #08080f;
  --bg-surface: #10101c;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-input-focus: rgba(255, 255, 255, 0.08);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* Accent colors */
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.12);
  --gold-glow: rgba(245, 158, 11, 0.25);
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.14);
  --rose-glow: rgba(244, 63, 94, 0.25);
  --blue: #3b82f6;
  --neutral: #6b7280;
  --neutral-soft: rgba(107, 114, 128, 0.14);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #a1a1b5;
  --text-muted: #6b6b80;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing scale */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;
  --sp-3xl: 48px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);

  /* Transitions */
  --ease-fast: 150ms ease;
  --ease: 250ms ease;
  --ease-slow: 400ms ease;
  --ease-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========================
   RESET & BASE
   ======================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

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

  /* Subtle ambient gradients */
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(16, 185, 129, 0.045) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, rgba(59, 130, 246, 0.035) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 85%, rgba(245, 158, 11, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

/* ========================
   LAYOUT
   ======================== */
#app {
  position: relative;
  min-height: 100dvh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-lg);
  padding-bottom: var(--sp-3xl);
}

/* ========================
   SCREENS
   ======================== */
.screen {
  display: none;
  animation: fadeIn 400ms ease forwards;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================
   GLASS CARD
   ======================== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

/* ========================
   BUTTONS
   ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--ease);
  user-select: none;
  white-space: nowrap;
  -webkit-user-select: none;
}

.btn-lg {
  padding: var(--sp-lg) var(--sp-2xl);
  font-size: 1rem;
  border-radius: var(--r-lg);
}

/* Primary (emerald) */
.btn-primary {
  background: var(--emerald);
  color: #fff;
  box-shadow: 0 2px 12px var(--emerald-glow);
}

.btn-primary:hover {
  background: #0ea572;
  box-shadow: 0 4px 24px var(--emerald-glow);
  transform: translateY(-1px);
}

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

.btn-primary:disabled {
  background: var(--neutral);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

/* Ghost */
.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-ghost:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-ghost:disabled:hover {
  background: var(--bg-card);
  border-color: var(--border-default);
  color: var(--text-secondary);
  transform: none;
}

/* Danger ghost */
.btn-danger-ghost {
  background: var(--rose-soft);
  border: 1px solid rgba(244, 63, 94, 0.18);
  color: var(--rose);
}

.btn-danger-ghost:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-icon {
  font-size: 1.2em;
  line-height: 1;
}

/* ========================
   SETUP SCREEN
   ======================== */
#setup-screen .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: var(--sp-xl);
}

.setup-card {
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.setup-header {
  text-align: center;
  padding: var(--sp-2xl) var(--sp-xl) var(--sp-lg);
}

.logo-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: var(--sp-md);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.setup-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--emerald) 0%, #34d399 40%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: var(--sp-xs);
}

.setup-body {
  padding: 0 var(--sp-xl) var(--sp-lg);
}

.section-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-md);
}

/* Player inputs */
.player-inputs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.player-input-row {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  animation: slideInLeft 250ms ease both;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.player-input-row .player-number {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 22px;
  text-align: center;
  font-weight: 600;
}

.player-input-row input {
  flex: 1;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--ease);
}

.player-input-row input:focus {
  background: var(--bg-input-focus);
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}

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

.player-input-row .remove-player-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all var(--ease-fast);
  flex-shrink: 0;
}

.player-input-row .remove-player-btn:hover {
  background: var(--rose-soft);
  color: var(--rose);
}

.setup-body > .btn-ghost {
  width: 100%;
}

/* Setup config block */
.setup-config-block {
  margin-top: var(--sp-lg);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--border-subtle);
}

.rounds-stepper-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.rounds-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 3px 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--ease);
}

.rounds-stepper:focus-within {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}

.rounds-stepper-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--r-sm);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all var(--ease-fast);
}

.rounds-stepper-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

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

.rounds-input-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}

#rounds-per-dealer-input {
  width: 34px;
  height: 32px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--emerald);
  background: transparent;
  border: none;
  outline: none;
  -moz-appearance: textfield;
}

#rounds-per-dealer-input::-webkit-outer-spin-button,
#rounds-per-dealer-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rounds-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rounds-preset-chips {
  display: flex;
  gap: 6px;
}

.preset-chip {
  height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--ease-fast);
  user-select: none;
  -webkit-user-select: none;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-card-hover);
}

.preset-chip.selected {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 10px var(--emerald-glow);
}

.setup-footer {
  padding: var(--sp-lg) var(--sp-xl) var(--sp-2xl);
}

.setup-footer .btn-primary {
  width: 100%;
}

/* Resume card */
.resume-card {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-xl);
  text-align: center;
}

.resume-card p {
  margin-bottom: var(--sp-lg);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.resume-actions {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
}

/* ========================
   GAME SCREEN
   ======================== */

/* Header */
.game-header {
  padding: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  text-align: center;
}

.game-info {
  display: flex;
  justify-content: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
  flex-wrap: wrap;
}

.info-badge {
  padding: var(--sp-xs) var(--sp-lg);
  border-radius: var(--r-full);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
}

.info-badge.accent {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.2);
}

.info-badge.gold {
  background: var(--gold-soft);
  border-color: rgba(245, 158, 11, 0.2);
}

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

.info-value {
  font-weight: 700;
  font-size: 0.9rem;
}

.info-badge.accent .info-value {
  color: var(--emerald);
}

.info-badge.gold .info-value {
  color: var(--gold);
}

.dealer-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  font-size: 1.05rem;
}

.dealer-crown {
  font-size: 1.3rem;
  animation: crownPulse 2s ease-in-out infinite;
}

@keyframes crownPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.dealer-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dealer-name {
  font-weight: 700;
  color: var(--gold);
}

/* Section blocks */
.section-block {
  margin-bottom: var(--sp-xl);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-md);
  width: 100%;
  text-align: left;
}

.section-title.clickable {
  cursor: pointer;
  padding: var(--sp-sm) 0;
  transition: color var(--ease-fast);
  border-radius: var(--r-sm);
}

.section-title.clickable:hover {
  color: var(--text-secondary);
}

.section-icon {
  font-size: 1rem;
}

.toggle-icon {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform var(--ease);
}

.toggle-icon.open {
  transform: rotate(180deg);
}

/* ========================
   SCOREBOARD
   ======================== */
.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all var(--ease);
}

.score-entry.is-dealer {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.06);
}

.score-entry.rank-1 {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.03));
  border-color: rgba(245, 158, 11, 0.18);
}

.score-rank {
  font-size: 1.1rem;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.score-rank-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.score-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-dealer-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.score-value {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
  transition: all var(--ease);
  font-variant-numeric: tabular-nums;
}

.score-positive {
  color: var(--emerald);
}

.score-negative {
  color: var(--rose);
}

.score-zero {
  color: var(--text-muted);
}

/* ========================
   ROUND INPUT
   ======================== */
.round-input {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.round-player-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all var(--ease);
}

.round-player-card.has-selection {
  border-color: var(--border-default);
}

.round-player-card.status-win {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(16, 185, 129, 0.02));
}

.round-player-card.status-lose {
  border-color: rgba(244, 63, 94, 0.3);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.06), rgba(244, 63, 94, 0.02));
}

.round-player-card.status-draw {
  border-color: rgba(107, 114, 128, 0.3);
  background: linear-gradient(135deg, rgba(107, 114, 128, 0.06), rgba(107, 114, 128, 0.02));
}

.round-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.round-player-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-player-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transition: all var(--ease);
}

.round-player-badge.score-positive {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.round-player-badge.score-negative {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.round-player-badge.score-zero {
  background: var(--neutral-soft);
  color: var(--text-secondary);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.round-player-badge.unselected {
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  background: transparent;
  font-weight: 500;
}

.round-player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.result-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.result-btn {
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  transition: all var(--ease-fast);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.result-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-card-hover);
}

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

/* Selected states */
.result-btn.win.selected {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 10px var(--emerald-glow);
}

.result-btn.lose.selected {
  background: var(--rose-soft);
  border-color: var(--rose);
  color: var(--rose);
  box-shadow: 0 0 10px var(--rose-glow);
}

.result-btn.draw.selected {
  background: var(--neutral-soft);
  border-color: var(--neutral);
  color: var(--text-secondary);
}

/* Point Stepper */
.point-stepper {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-input);
  padding: 3px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--ease);
}

.point-stepper:focus-within {
  border-color: var(--border-strong);
}

.stepper-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 2px;
  user-select: none;
}

.stepper-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all var(--ease-fast);
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

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

.stepper-input {
  width: 38px;
  height: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  -moz-appearance: textfield;
}

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

/* ========================
   DEALER SELECTION
   ======================== */
.dealer-selection {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.dealer-option {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--ease);
  user-select: none;
  -webkit-user-select: none;
}

.dealer-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.dealer-option:active {
  transform: scale(0.98);
}

.dealer-option.selected {
  background: var(--gold-soft);
  border-color: var(--gold);
  box-shadow: 0 0 14px var(--gold-glow);
}

.dealer-option-icon {
  font-size: 1.4rem;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.3;
  transition: opacity var(--ease);
}

.dealer-option.selected .dealer-option-icon {
  opacity: 1;
}

.dealer-option-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dealer-option-score {
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.dealer-option-prev {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--neutral-soft);
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* Dealer score card */
.dealer-score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.06);
}

.dealer-score-info {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.95rem;
  overflow: hidden;
}

.dealer-crown-sm {
  font-size: 1.1rem;
  flex-shrink: 0;
}

#dealer-score-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dealer-auto-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dealer-score-value {
  font-weight: 800;
  font-size: 1.25rem;
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
  transition: all var(--ease);
  font-variant-numeric: tabular-nums;
}

/* ========================
   ACTION BUTTONS
   ======================== */
.action-buttons {
  margin-bottom: var(--sp-xl);
}

.action-buttons > .btn-primary {
  width: 100%;
  margin-bottom: var(--sp-md);
}

.secondary-actions {
  display: flex;
  gap: var(--sp-sm);
}

.secondary-actions .btn {
  flex: 1;
}

/* ========================
   HISTORY
   ======================== */
.history-container {
  overflow: hidden;
  transition: max-height var(--ease-slow) ease;
}

.history-container.collapsed {
  max-height: 0;
}

.history-container.expanded {
  max-height: 5000px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding-top: var(--sp-xs);
}

.history-entry {
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  animation: slideInLeft 200ms ease both;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-sm);
  font-size: 0.82rem;
}

.history-round-num {
  font-weight: 700;
  color: var(--text-primary);
}

.history-dealer {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 500;
}

.history-results {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-lg);
}

.history-result {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: 0.8rem;
}

.history-result-name {
  color: var(--text-secondary);
}

.history-result-score {
  font-weight: 700;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.empty-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: var(--sp-xl);
}

/* ========================
   RESULTS SCREEN
   ======================== */
#results-screen .container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.results-header {
  text-align: center;
  margin-bottom: var(--sp-2xl);
}

.results-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: var(--sp-md);
  animation: bounce 1.2s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.results-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-xs);
}

.results-leaderboard {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  margin-bottom: var(--sp-2xl);
}

.results-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  padding: var(--sp-lg) var(--sp-xl);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  animation: slideUp var(--ease-slow) both;
}

.results-entry:nth-child(1) { animation-delay: 100ms; }
.results-entry:nth-child(2) { animation-delay: 200ms; }
.results-entry:nth-child(3) { animation-delay: 300ms; }
.results-entry:nth-child(4) { animation-delay: 400ms; }
.results-entry:nth-child(5) { animation-delay: 500ms; }
.results-entry:nth-child(6) { animation-delay: 600ms; }
.results-entry:nth-child(7) { animation-delay: 700ms; }
.results-entry:nth-child(8) { animation-delay: 800ms; }
.results-entry:nth-child(9) { animation-delay: 900ms; }
.results-entry:nth-child(10) { animation-delay: 1000ms; }

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-entry.winner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.04));
  border-color: rgba(245, 158, 11, 0.25);
  box-shadow: 0 0 24px var(--gold-glow);
}

.results-rank {
  font-size: 1.6rem;
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.results-rank-number {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.results-name {
  flex: 1;
  font-weight: 600;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-score {
  font-weight: 800;
  font-size: 1.3rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 100%;
  max-width: 400px;
}

.results-actions .btn {
  width: 100%;
}

/* ========================
   TOAST
   ======================== */
.toast {
  position: fixed;
  bottom: var(--sp-xl);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toastIn 300ms ease both;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  white-space: nowrap;
}

.toast.hiding {
  animation: toastOut 250ms ease both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
}

/* ========================
   MODAL
   ======================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: var(--sp-lg);
  animation: fadeIn 200ms ease;
}

.modal {
  width: 100%;
  max-width: 340px;
  padding: var(--sp-2xl);
  text-align: center;
}

.modal-message {
  margin-bottom: var(--sp-xl);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
}

/* ========================
   SCORE ANIMATION
   ======================== */
@keyframes scorePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.score-pop {
  animation: scorePop 400ms var(--ease-spring);
}

/* ========================
   CONFETTI (Results screen)
   ======================== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 380px) {
  .container {
    padding: var(--sp-md);
  }

  .result-btn {
    padding: 0 8px;
    height: 34px;
    font-size: 0.76rem;
    min-width: 48px;
  }

  .result-buttons {
    gap: 4px;
  }

  .stepper-label {
    display: none;
  }

  .stepper-btn {
    width: 26px;
    height: 26px;
    font-size: 0.9rem;
  }

  .stepper-input {
    width: 32px;
    height: 26px;
    font-size: 0.85rem;
  }

  .info-badge {
    padding: var(--sp-xs) var(--sp-md);
  }

  .score-entry {
    padding: var(--sp-sm) var(--sp-md);
    gap: var(--sp-sm);
  }

  .round-player-card {
    padding: var(--sp-sm) var(--sp-md);
    gap: var(--sp-sm);
  }

  .setup-header h1 {
    font-size: 1.8rem;
  }
}

@media (min-width: 600px) {
  .container {
    padding: var(--sp-xl);
  }
}
