/* ==========================================================================
   QWIRKLE SCORE - DESIGN SYSTEM & STYLES (SOBRE & MODERNE)
   ========================================================================== */

:root {
  /* Color Palette - Dark & Sober */
  --bg-main: #0f1115;
  --bg-card: #171a21;
  --bg-card-hover: #1f232d;
  --bg-input: #121419;
  --border-subtle: #242934;
  --border-focus: #3d4659;
  
  /* Text */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Qwirkle Brand & Accent Colors */
  --q-orange: #ff7b00;
  --q-blue: #00b4d8;
  --q-yellow: #ffd166;
  --q-purple: #b5179e;
  --q-red: #ef4444;
  --q-green: #10b981;
  
  /* Player Colors (Assigned to players 1 to 4) */
  --p1-color: #00b4d8; /* Cyan Blue */
  --p2-color: #ff7b00; /* Orange */
  --p3-color: #ffd166; /* Amber / Yellow */
  --p4-color: #b5179e; /* Purple */
  
  /* UI Elements */
  --accent-primary: #00b4d8;
  --accent-primary-hover: #0096c7;
  --danger-color: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success-color: #10b981;
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-dock: 0 -8px 30px rgba(0, 0, 0, 0.6);
  
  /* Safe area for mobile notches / gestures */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

button:active {
  transform: scale(0.97);
}

/* Master App Container */
.app-container {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  overflow: hidden;
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Toast Notifications */
.toast-container {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: rgba(23, 26, 33, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: toastFadeIn 0.25s ease-out;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   1. SETUP SCREEN
   ========================================================================== */

#screen-setup {
  padding: calc(16px + var(--safe-top)) 18px calc(16px + var(--safe-bottom)) 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.logo-svg {
  width: 100%;
  height: 100%;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Resume Game Banner */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), rgba(181, 23, 158, 0.15));
  border: 1px solid rgba(0, 180, 216, 0.3);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  animation: pulseSubtle 3s infinite;
}

.resume-badge {
  display: inline-block;
  background: var(--accent-primary);
  color: #0f1115;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.resume-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
}

.resume-actions {
  display: flex;
  gap: 6px;
}

/* Card Container */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.section-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hint-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Player Count Segmented Buttons */
.player-count-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.count-btn {
  padding: 12px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s ease;
}

.count-btn.active {
  background: #252a36;
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

/* Player Input List */
.players-input-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px 6px 6px;
  transition: border-color 0.2s ease;
}

.player-input-row:focus-within {
  border-color: var(--border-focus);
}

.player-color-indicator {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #121418;
  flex-shrink: 0;
}

.player-name-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  outline: none;
}

.player-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.initials-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Recent Players Chips */
.recent-players-wrapper {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
}

.recent-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recent-chip {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.recent-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent-primary);
  color: #0c0d11;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

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

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

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-outline-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-color);
}

.btn-danger {
  background: var(--danger-color);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 20px;
  font-size: 15px;
}

.btn-xl {
  width: 100%;
  padding: 15px 20px;
  font-size: 16px;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0, 180, 216, 0.25);
}

.setup-actions {
  margin-top: 8px;
  margin-bottom: 20px;
}

.setup-footer {
  margin-top: auto;
  text-align: center;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.version-label {
  font-size: 11px;
  color: var(--text-muted);
}

.pwa-install-btn {
  color: var(--accent-primary);
  font-weight: 600;
}

/* ==========================================================================
   2. GAME SCREEN (TABLE & DOCKED KEYPAD)
   ========================================================================== */

#screen-game {
  height: 100%;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#screen-game.active {
  display: flex;
}

.game-header {
  padding: calc(10px + var(--safe-top)) 16px 10px 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.game-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
}

.badge-round {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.badge-player {
  background: rgba(0, 180, 216, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(0, 180, 216, 0.25);
}

.game-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Scoreboard Table Area */
.scoreboard-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
  position: relative;
  /* Extra bottom padding so table content isn't hidden behind keypad */
  padding-bottom: 24px;
}

.scoreboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: center;
}

/* Sticky Header on Scoreboard */
.scoreboard-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-main);
}

/* Row 1: Initials */
.row-initials th {
  padding: 10px 4px 4px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-main);
}

.th-tour {
  width: 52px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.player-header-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.player-initials-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  color: #121418;
}

/* Row 2: Live Totals */
.row-totals th {
  padding: 6px 4px 10px 4px;
  border-bottom: 2px solid var(--border-subtle);
  background: var(--bg-main);
}

.th-total-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.player-total-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
}

/* Table Body: Rounds */
.scoreboard-table tbody tr {
  transition: background 0.15s ease;
}

.scoreboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.td-tour-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.td-score-cell {
  padding: 4px 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.score-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.score-box.empty {
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  background: transparent;
}

.score-box.zero {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}

.score-box.has-qwirkle::after {
  content: "★";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 9px;
  color: var(--q-yellow);
}

/* Active Selected Cell */
.score-box.active {
  background: rgba(0, 180, 216, 0.12);
  border: 2px solid var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.3);
  animation: activeCellPulse 1.8s infinite alternate;
}

@keyframes activeCellPulse {
  from { border-color: var(--accent-primary); }
  to { border-color: #48cae4; }
}

/* ==========================================================================
   VIRTUAL KEYPAD DOCK (BOTTOM)
   ========================================================================== */

.keypad-dock {
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-dock);
  padding: 10px 14px calc(12px + var(--safe-bottom)) 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
}

/* Keypad Header / Current Target */
.keypad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.keypad-target {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.keypad-player-info {
  display: flex;
  flex-direction: column;
}

.target-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.target-round {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Display */
.keypad-display-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 10px;
}

.display-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.keypad-display {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-primary);
  min-width: 32px;
  text-align: right;
}

/* Quick Chips */
.keypad-quick-chips {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1.6fr;
  gap: 6px;
}

.chip-btn {
  padding: 7px 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.chip-sub {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.chip-btn:hover, .chip-btn:active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.chip-qwirkle {
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.3);
  color: var(--q-yellow);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 700;
}

.chip-qwirkle:hover {
  background: rgba(255, 209, 102, 0.2);
}

/* Numpad Grid */
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.num-btn {
  height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.num-btn:hover {
  background: #20242e;
}

.num-btn:active {
  background: #2a303e;
}

.num-backspace {
  color: var(--text-secondary);
}

.num-clear {
  color: #f87171;
  font-size: 15px;
  font-weight: 800;
}

/* Keypad Actions (Fin + Valider) */
.keypad-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 8px;
  margin-top: 2px;
}

.btn-submit {
  background: var(--accent-primary);
  color: #0f1115;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.btn-submit:hover {
  background: var(--accent-primary-hover);
}

/* ==========================================================================
   3. RESULTS / VICTORY SCREEN
   ========================================================================== */

#screen-results {
  padding: calc(20px + var(--safe-top)) 18px calc(20px + var(--safe-bottom)) 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.results-header {
  text-align: center;
  margin-bottom: 24px;
}

.trophy-badge {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 12px rgba(255, 209, 102, 0.4));
  animation: bounceTrophy 1.2s ease;
}

@keyframes bounceTrophy {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.results-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.results-winner-text {
  font-size: 14px;
  color: var(--accent-primary);
  font-weight: 600;
}

/* Podium Cards */
.podium-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.podium-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: transform 0.2s ease;
}

.podium-card.winner {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.12), rgba(255, 123, 0, 0.08));
  border-color: rgba(255, 209, 102, 0.4);
  box-shadow: 0 4px 20px rgba(255, 209, 102, 0.15);
}

.podium-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.podium-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  background: var(--bg-input);
  color: var(--text-secondary);
}

.podium-card.winner .podium-rank {
  background: var(--q-yellow);
  color: #121418;
}

.podium-player-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.podium-player-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.podium-score {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.podium-card.winner .podium-score {
  color: var(--q-yellow);
}

/* Stats Card */
.stats-card {
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.game-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-item {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Results Actions */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* ==========================================================================
   MODALS (POPUPS)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
  animation: modalScaleUp 0.2s ease-out;
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 18px;
}

.modal-instruction {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.modal-instruction strong {
  color: var(--text-primary);
}

.finish-bonus-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.bonus-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.bonus-btn.selected {
  background: rgba(0, 180, 216, 0.15);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
}

/* History Modal */
.history-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.summary-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.summary-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-primary);
}

.summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.history-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.history-item-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-item-date {
  font-size: 11px;
  color: var(--text-muted);
}

.history-item-winner {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--q-yellow);
}

.history-scores-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.history-score-chip {
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-danger {
  color: var(--danger-color) !important;
}
