/* ─── Family Quiz MVP — Design System ────────────────────────────
 * Soft premium: deep navy / blush / gold / cream palette
 * Mobile-first, rounded cards, large touch targets
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&display=swap');

:root {
  --bg: #0f0e1a;
  --surface: #1a1930;
  --surface-light: #242242;
  --primary: #6c63ff;
  --primary-glow: rgba(108, 99, 255, 0.3);
  --accent: #ff6b9d;
  --accent-glow: rgba(255, 107, 157, 0.3);
  --gold: #ffd166;
  --gold-glow: rgba(255, 209, 102, 0.25);
  --success: #06d6a0;
  --text: #f0eff5;
  --text-muted: #8a86b2;
  --text-dim: #5e5a82;
  --danger: #ef476f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: 3px; }

/* ─── Layout ─── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-wide {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100vh;
}

.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
}

/* ─── Typography ─── */
h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

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

.text-gold {
  color: var(--gold);
}

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid rgba(108, 99, 255, 0.1);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-light {
  background: var(--surface-light);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  min-height: 48px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover { background: #5a52e0; }

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-accent:hover { background: #e85a8a; }

.btn-success {
  background: var(--success);
  color: #0f0e1a;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--surface-light);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 36px;
}

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

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

/* ─── Inputs ─── */
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition);
  outline: none;
  min-height: 48px;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input::placeholder {
  color: var(--text-dim);
}

/* ─── Badge ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-glow); color: var(--primary); }
.badge-accent { background: var(--accent-glow); color: var(--accent); }
.badge-gold { background: var(--gold-glow); color: var(--gold); }
.badge-success { background: rgba(6, 214, 160, 0.2); color: var(--success); }

/* ─── Answer choice buttons ─── */
.answer-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  margin-bottom: 10px;
  background: var(--surface-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  min-height: 60px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.answer-btn:active { transform: scale(0.98); }
.answer-btn:hover { border-color: var(--primary); background: rgba(108, 99, 255, 0.08); }

.answer-btn .label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.answer-btn.selected {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.15);
}

.answer-btn.correct-reveal {
  border-color: var(--success);
  background: rgba(6, 214, 160, 0.12);
}
.answer-btn.correct-reveal .label { background: var(--success); color: #0f0e1a; }

.answer-btn.wrong-reveal {
  border-color: var(--danger);
  background: rgba(239, 71, 111, 0.12);
  opacity: 0.6;
}
.answer-btn.wrong-reveal .label { background: var(--danger); }

.answer-btn.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* ─── Timer bar ─── */
.timer-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.timer-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 1s linear;
}
.timer-fill.warning { background: var(--gold); }
.timer-fill.danger { background: var(--danger); }

/* ─── Player list ─── */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface-light);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}
.player-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ─── Leaderboard ─── */
.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 6px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.leaderboard-entry .rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.leaderboard-entry.rank-1 .rank { background: var(--gold); color: #0f0e1a; }
.leaderboard-entry.rank-2 .rank { background: #c0c0c0; color: #0f0e1a; }
.leaderboard-entry.rank-3 .rank { background: #cd7f32; color: #fff; }
.leaderboard-entry .rank-other { background: var(--surface-light); color: var(--text-muted); }

.leaderboard-entry .name { flex: 1; font-weight: 600; }
.leaderboard-entry .points { font-weight: 700; color: var(--gold); }

.leaderboard-entry.current-player {
  border: 1px solid var(--primary);
  background: rgba(108, 99, 255, 0.08);
}

/* ─── Podium ─── */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  margin: 24px 0;
}

.podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.podium-item .trophy {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.podium-item .podium-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.podium-item .podium-score {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.podium-item .podium-bar {
  width: 80px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-weight: 800;
  font-size: 1.2rem;
}

.podium-1 .podium-bar { height: 180px; background: linear-gradient(180deg, #ffd166, #f0a500); }
.podium-2 .podium-bar { height: 130px; background: linear-gradient(180deg, #e0e0e0, #a0a0a0); }
.podium-3 .podium-bar { height: 90px; background: linear-gradient(180deg, #cd7f32, #a0522d); }

/* ─── Nav ─── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 16px;
}

.brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
}

/* ─── Code display ─── */
.code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.code-digit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 68px;
  background: var(--surface-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text);
}

/* ─── Join URL ─── */
.join-url {
  padding: 12px 16px;
  background: var(--surface-light);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.9rem;
  word-break: break-all;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Question card (player) ─── */
.question-number {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 20px;
}

/* ─── Result reveal ─── */
.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.result-row.correct { background: rgba(6, 214, 160, 0.08); }
.result-row.wrong { background: rgba(239, 71, 111, 0.06); }
.result-row .icon { font-size: 1.2rem; }
.result-row .rname { flex: 1; font-weight: 500; }
.result-row .rpoints { font-weight: 700; color: var(--gold); }

/* ─── Confetti overlay ─── */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ─── Utility ─── */
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .page { padding: 16px 12px; }
  h1 { font-size: 1.5rem; }
  .answer-btn { padding: 16px; min-height: 56px; }
  .code-digit { width: 48px; height: 56px; font-size: 1.5rem; }
}

@media (min-width: 768px) {
  .page-wide { padding: 32px; }
  .answer-btn { padding: 20px 24px; }
}

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.pulse { animation: pulse 1.5s ease infinite; }

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.08); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}
.bounce-in { animation: bounceIn 0.5s ease forwards; }

/* ─── Question editor ─── */
.question-editor {
  margin-bottom: 16px;
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}
.question-editor .q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.question-editor .q-number { font-weight: 700; color: var(--primary); }
.question-editor textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--transition);
  outline: none;
}
.question-editor textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.question-editor .choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.question-editor .choice-row input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.question-editor .choice-row input[type="text"]:focus {
  border-color: var(--primary);
}
.question-editor .correct-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.question-editor .correct-radio input[type="radio"] {
  accent-color: var(--success);
}
.question-editor .remove-choice {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
}
.question-editor .add-choice-btn {
  margin-top: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1.5px dashed var(--surface-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  width: 100%;
  transition: all var(--transition);
}
.question-editor .add-choice-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ─── Host game screen ─── */
.host-lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.host-lobby-header h2 { margin-bottom: 0; }

/* ─── Question preview on host ─── */
.host-question-preview {
  text-align: center;
  padding: 32px 16px;
}
.host-question-preview h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
}
.host-question-preview .choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
}
.host-question-preview .choice-card {
  padding: 20px;
  background: var(--surface-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
}
.host-question-preview .choice-card.winner {
  border-color: var(--success);
  background: rgba(6, 214, 160, 0.1);
}
.host-question-preview .choice-card.loser {
  opacity: 0.5;
  border-color: var(--danger);
}

/* ─── Response-rate bar (host) ─── */
.response-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}
.response-bar .answered-fill { background: var(--gold); }
.response-bar .unanswered-fill { background: var(--surface-light); }

/* ─── QR code container ─── */
.qr-container {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.qr-container img { border-radius: var(--radius-sm); max-width: 200px; }

/* ─── Question timer next to title ─── */
.timer-display {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  min-width: 48px;
  text-align: center;
}
.timer-display.warning { color: var(--danger); }
