/* ── Variables & Reset ─────────────────────────────────────────────────────── */
:root {
  --bg: #0F0E17;
  --bg2: #1A1A2E;
  --surface: #16213E;
  --surface2: #1E2D4A;
  --primary: #E94560;
  --primary-dark: #C73652;
  --secondary: #0F3460;
  --accent: #F5A623;
  --accent2: #7B2FBE;
  --text: #FFFFFE;
  --text-muted: #A8B2D8;
  --success: #2ECC71;
  --danger: #E74C3C;
  --warning: #F39C12;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(233,69,96,0.4);
  --font: 'Nunito', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 0 calc(16px + var(--safe-bottom));
  animation: fadeSlideIn 0.35s ease;
}
.screen.active { display: flex; }

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

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.btn-back {
  background: var(--surface);
  border: none;
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s;
}
.btn-back:active { transform: scale(0.92); }

/* ── Home Screen ───────────────────────────────────────────────────────────── */
.home-bg {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 0;
}
.home-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(233,69,96,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(123,47,190,0.15) 0%, transparent 60%);
  pointer-events: none;
}

.floating-letters {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.float-letter {
  position: absolute;
  font-size: 3rem;
  font-weight: 900;
  opacity: 0.04;
  animation: floatUp linear infinite;
  user-select: none;
}

@keyframes floatUp {
  from { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.06; }
  90%  { opacity: 0.06; }
  to   { transform: translateY(-20vh) rotate(360deg); opacity: 0; }
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 40px;
  position: relative; z-index: 1;
}
.logo {
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(135deg, #E94560, #F5A623, #7B2FBE);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 8px;
  animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(233,69,96,0.5)); }
  50%       { filter: drop-shadow(0 0 40px rgba(245,166,35,0.6)); }
}
.logo-sub {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}

.home-actions {
  padding: 0 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative; z-index: 1;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 18px 24px;
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.15s;
}
.btn:active::after { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #C73652);
  color: #fff;
  box-shadow: 0 6px 24px rgba(233,69,96,0.45);
}
.btn-primary:active { box-shadow: 0 2px 12px rgba(233,69,96,0.3); }

.btn-secondary {
  background: linear-gradient(135deg, #7B2FBE, #5C1FA0);
  color: #fff;
  box-shadow: 0 6px 24px rgba(123,47,190,0.4);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #E8920A);
  color: #fff;
  box-shadow: 0 6px 24px rgba(245,166,35,0.4);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #25A25A);
  color: #fff;
  box-shadow: 0 6px 24px rgba(46,204,113,0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #B03A2E);
  color: #fff;
  box-shadow: 0 6px 24px rgba(231,76,60,0.4);
}

.btn-icon { font-size: 1.3rem; }
.btn-sm { padding: 12px 18px; font-size: 0.9rem; }
.btn-lg { padding: 22px 28px; font-size: 1.15rem; }
.btn-full { width: 100%; }

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-elevated {
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ── Form ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.form-input {
  background: var(--bg2);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.2);
}
.form-input::placeholder { color: rgba(255,255,255,0.3); }

.chip-group { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.15);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}
.chip.selected {
  border-color: var(--primary);
  background: rgba(233,69,96,0.15);
  color: var(--primary);
  box-shadow: 0 0 16px rgba(233,69,96,0.25);
}

/* ── Setup Screen ──────────────────────────────────────────────────────────── */
.setup-content {
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}
.screen-title {
  font-size: 1.6rem;
  font-weight: 900;
  padding: 8px 20px 0;
}
.screen-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0 20px 8px;
}

/* ── Room Code ─────────────────────────────────────────────────────────────── */
.room-code-display {
  background: linear-gradient(135deg, var(--secondary), #0A2540);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  border: 2px solid rgba(255,255,255,0.1);
}
.room-code-label {
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.room-code-value {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(135deg, #F5A623, #E94560);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
}
.room-code-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Waiting Room ──────────────────────────────────────────────────────────── */
.players-waiting {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.player-slot {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  border: 2px solid rgba(255,255,255,0.06);
  transition: all 0.3s;
}
.player-slot.connected {
  border-color: rgba(46,204,113,0.4);
  background: rgba(46,204,113,0.08);
}
.player-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  flex-shrink: 0;
}
.player-avatar.p1 { background: linear-gradient(135deg, var(--primary), #C73652); }
.player-avatar.p2 { background: linear-gradient(135deg, #7B2FBE, #5C1FA0); }
.player-slot-info { flex: 1; }
.player-slot-name { font-weight: 800; font-size: 1rem; }
.player-slot-status { font-size: 0.8rem; color: var(--text-muted); }

/* ── GAME SCREEN ───────────────────────────────────────────────────────────── */
#screen-game { padding-bottom: 0; }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
  flex-shrink: 0;
}

.scores-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}
.score-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 70px;
  border: 2px solid transparent;
  transition: all 0.3s;
}
.score-badge.active { border-color: var(--accent); }
.score-badge.winner { border-color: var(--success); background: rgba(46,204,113,0.1); }
.score-name {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.score-value {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}
.score-value.bounce { animation: scoreBounce 0.4s cubic-bezier(.36,.07,.19,.97); }

@keyframes scoreBounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.5); color: var(--success); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ── Timer ─────────────────────────────────────────────────────────────────── */
.timer-wrap {
  position: relative;
  width: 64px; height: 64px;
  flex-shrink: 0;
}
.timer-svg { transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 5; }
.timer-arc {
  fill: none;
  stroke: var(--success);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s;
  stroke-dasharray: 160;
  stroke-dashoffset: 0;
}
.timer-arc.yellow { stroke: var(--warning); }
.timer-arc.red    { stroke: var(--danger); animation: timerPulse 0.5s ease-in-out infinite; }
.timer-text {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
}
.timer-text.urgent { color: var(--danger); }

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── Category Card ─────────────────────────────────────────────────────────── */
.category-section {
  padding: 12px 16px;
  flex-shrink: 0;
}
.category-card {
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  animation: categoryReveal 0.5s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.category-card::after {
  content: '';
  position: absolute;
  top: -40%; right: -20%;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  pointer-events: none;
}

@keyframes categoryReveal {
  from { opacity: 0; transform: scale(0.85) translateY(-20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.category-emoji {
  font-size: 2.2rem;
  line-height: 1;
}
.category-label {
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  font-weight: 700;
}
.category-name {
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  line-height: 1.2;
}
.round-indicator {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
}

/* ── Letter Tiles ──────────────────────────────────────────────────────────── */
.letters-section {
  padding: 8px 16px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-shrink: 0;
}
.letter-tile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.letter-tile {
  width: 100%;
  aspect-ratio: 1;
  max-width: 130px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
  animation: tileFlip 0.6s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
.letter-tile.p1 {
  background: linear-gradient(145deg, #E94560, #C73652);
  box-shadow: 0 8px 32px rgba(233,69,96,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
.letter-tile.p2 {
  background: linear-gradient(145deg, #7B2FBE, #5C1FA0);
  box-shadow: 0 8px 32px rgba(123,47,190,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
.letter-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: rgba(255,255,255,0.1);
  border-radius: 20px 20px 0 0;
  pointer-events: none;
}

@keyframes tileFlip {
  0%   { transform: rotateY(90deg) scale(0.8); opacity: 0; }
  60%  { transform: rotateY(-10deg) scale(1.05); opacity: 1; }
  80%  { transform: rotateY(5deg); }
  100% { transform: rotateY(0deg) scale(1); }
}

.tile-player-name {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ── Solo Buzz Buttons ─────────────────────────────────────────────────────── */
.buzz-section {
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}
.buzz-btn {
  flex: 1;
  padding: 20px 12px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}
.buzz-btn:active { transform: scale(0.94); filter: brightness(0.9); }
.buzz-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.buzz-btn.p1-btn {
  background: linear-gradient(145deg, #E94560, #B02D48);
  box-shadow: 0 6px 24px rgba(233,69,96,0.5);
}
.buzz-btn.p2-btn {
  background: linear-gradient(145deg, #7B2FBE, #5018A0);
  box-shadow: 0 6px 24px rgba(123,47,190,0.5);
}
.buzz-btn .buzz-icon { font-size: 1.8rem; }

/* Multijoueur: un seul bouton central */
.buzz-multi {
  padding: 0 16px;
  flex-shrink: 0;
}
.buzz-multi .btn {
  width: 100%;
  padding: 24px;
  font-size: 1.2rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #E94560, #C73652);
  box-shadow: 0 8px 32px rgba(233,69,96,0.5);
  animation: buzzPulse 1.5s ease-in-out infinite;
}
.buzz-multi .btn:active { animation: none; }

@keyframes buzzPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(233,69,96,0.5); }
  50%       { box-shadow: 0 8px 48px rgba(233,69,96,0.8); transform: translateY(-2px); }
}

.buzz-multi .btn:disabled {
  background: var(--surface2);
  box-shadow: none;
  animation: none;
  opacity: 0.5;
}

/* ── History ───────────────────────────────────────────────────────────────── */
.history-section {
  padding: 8px 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 60px;
}
.history-title {
  font-size: 0.72rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  animation: slideInLeft 0.3s ease;
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.history-winner { font-weight: 800; }
.history-cat { color: var(--text-muted); flex: 1; font-size: 0.78rem; }
.history-word { font-weight: 700; color: var(--success); }
.history-draw { color: var(--warning); font-style: italic; }

/* ── Status Bar (feedback messages) ───────────────────────────────────────── */
.status-bar {
  padding: 0 16px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-msg {
  padding: 8px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  animation: fadeSlideIn 0.3s ease;
}
.status-msg.success { background: rgba(46,204,113,0.2); color: var(--success); }
.status-msg.error   { background: rgba(231,76,60,0.2); color: var(--danger); }
.status-msg.info    { background: rgba(52,152,219,0.2); color: #5DADE2; }
.status-msg.draw    { background: rgba(243,156,18,0.2); color: var(--warning); }

/* ── Word Input Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }

.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  animation: sheetUp 0.35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-drag { width: 40px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; margin: 0 auto 20px; }
.modal-title { font-size: 1.2rem; font-weight: 900; text-align: center; margin-bottom: 6px; }
.modal-hint  { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-bottom: 20px; }
.modal-letters { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.modal-letter-badge {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 900;
}
.modal-letter-badge.l1 { background: rgba(233,69,96,0.2); color: #E94560; border: 2px solid #E94560; }
.modal-letter-badge.l2 { background: rgba(123,47,190,0.2); color: #9B59B6; border: 2px solid #9B59B6; }
.modal-input-row { display: flex; gap: 10px; }
.modal-word-input {
  flex: 1;
  background: var(--bg2);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: border-color 0.2s;
}
.modal-word-input:focus { border-color: var(--primary); }

/* ── End Screen ────────────────────────────────────────────────────────────── */
.end-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 24px;
  text-align: center;
  position: relative;
}
.winner-crown {
  font-size: 5rem;
  animation: crownBounce 0.8s cubic-bezier(.34,1.56,.64,1);
  line-height: 1;
}
@keyframes crownBounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(5deg); }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}
.winner-label { font-size: 0.85rem; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); margin-top: 12px; }
.winner-name  { font-size: 2.2rem; font-weight: 900; background: linear-gradient(135deg,#F5A623,#E94560); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.end-scores {
  display: flex;
  gap: 16px;
  padding: 0 24px 20px;
}
.end-score-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  border: 2px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}
.end-score-card.winner-card {
  border-color: rgba(245,166,35,0.5);
  background: rgba(245,166,35,0.08);
}
.end-score-player { font-weight: 800; font-size: 0.9rem; margin-bottom: 8px; }
.end-score-num {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}
.end-score-card.winner-card .end-score-num { color: var(--accent); }

.end-stats {
  padding: 0 24px;
  background: var(--surface);
  border-radius: var(--radius);
  margin: 0 24px 20px;
}
.end-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.9rem;
}
.end-stat-row:last-child { border-bottom: none; }
.end-stat-label { color: var(--text-muted); }
.end-stat-value { font-weight: 800; }

.end-actions {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Rules Screen ──────────────────────────────────────────────────────────── */
.rules-content {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.rules-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.rules-num {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #C73652);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  flex-shrink: 0;
}
.rules-step-text { flex: 1; padding-top: 8px; }
.rules-step-title { font-weight: 800; margin-bottom: 4px; }
.rules-step-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.rules-example {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 3px solid var(--accent);
}
.rules-example-title { font-weight: 800; margin-bottom: 8px; color: var(--accent); font-size: 0.85rem; letter-spacing: 1px; }

/* ── Confetti Canvas ───────────────────────────────────────────────────────── */
#confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 40px);
  max-width: 440px;
}
.toast {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
  animation: toastIn 0.35s cubic-bezier(.34,1.56,.64,1);
  box-shadow: var(--shadow);
}
.toast.success { border-color: rgba(46,204,113,0.4); color: var(--success); }
.toast.error   { border-color: rgba(231,76,60,0.4); color: var(--danger); }
.toast.info    { border-color: rgba(52,152,219,0.4); color: #5DADE2; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Mode Select ───────────────────────────────────────────────────────────── */
.mode-cards {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mode-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.06);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 18px;
}
.mode-card:active { transform: scale(0.97); }
.mode-card:hover  { border-color: var(--primary); box-shadow: 0 0 24px rgba(233,69,96,0.2); }
.mode-card-icon {
  font-size: 3rem;
  width: 70px; height: 70px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mode-card-icon.solo  { background: linear-gradient(135deg, var(--primary), #C73652); }
.mode-card-icon.multi { background: linear-gradient(135deg, #7B2FBE, #5C1FA0); }
.mode-card-info { flex: 1; }
.mode-card-title { font-size: 1.2rem; font-weight: 900; margin-bottom: 4px; }
.mode-card-desc  { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.mode-card-arrow { font-size: 1.2rem; color: var(--text-muted); }

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.divider hr { flex: 1; border: none; border-top: 1px solid rgba(255,255,255,0.1); }
.divider span { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Buzzer Feedback Overlay ───────────────────────────────────────────────── */
.buzz-overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.buzz-overlay.show {
  display: flex;
  animation: buzzFlash 0.4s ease;
}
@keyframes buzzFlash {
  0%   { background: rgba(233,69,96,0.3); }
  100% { background: transparent; }
}
.buzz-overlay-text {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0,0,0,0.8);
  text-align: center;
}

/* ── Skip button voted state ───────────────────────────────────────────────── */
#btn-skip.voted {
  border: 2px solid var(--warning);
  color: var(--warning);
  opacity: 1 !important;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.pb-safe { padding-bottom: calc(16px + var(--safe-bottom)); }

.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  body { border-radius: var(--radius) var(--radius) 0 0; }
}
@media (max-height: 700px) {
  .home-hero { padding: 40px 24px 24px; }
  .logo { font-size: 3.5rem; }
}
