/* ================================================
   SUMMER GAMES — Styles globaux
   ================================================ */

:root {
  --bg:        #0d0d1a;
  --surface:   #1a1a2e;
  --surface2:  #16213e;
  --border:    rgba(255,255,255,0.08);
  --primary:   #e94560;
  --primary-h: #ff5f7e;
  --blue:      #1565c0;
  --purple:    #7b1fa2;
  --teal:      #00897b;
  --text:      #eaeaea;
  --text-dim:  #9090a0;
  --success:   #00d4aa;
  --warning:   #ffd700;
  --danger:    #ff4444;

  --ans-a: #c0392b;
  --ans-b: #1565c0;
  --ans-c: #6a1b9a;
  --ans-d: #00695c;

  --radius:    12px;
  --radius-lg: 20px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typographie ─── */
h1 { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: clamp(1.1rem, 4vw, 1.4rem); font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p  { line-height: 1.55; }

/* ─── Utilitaires ─── */
.hidden       { display: none !important; }
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-sm       { gap: 0.5rem; }
.gap          { gap: 1rem; }
.gap-lg       { gap: 1.5rem; }
.text-center  { text-align: center; }
.text-dim     { color: var(--text-dim); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.w-full       { width: 100%; }
.mt           { margin-top: 1rem; }
.mt-lg        { margin-top: 1.5rem; }

/* ─── Carte ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-lg {
  padding: 1.75rem;
  border-radius: var(--radius-lg);
}

/* ─── Boutons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--primary); color: #fff; box-shadow: 0 4px 16px rgba(233,69,96,0.4); }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); box-shadow: 0 6px 24px rgba(233,69,96,0.5); }

.btn-success   { background: var(--success); color: #000; }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.07); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.btn-ghost     { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); color: var(--text); }

.btn-lg  { padding: 1rem 2rem; font-size: 1.1rem; border-radius: var(--radius-lg); }
.btn-sm  { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-xl  { padding: 1.25rem 2.5rem; font-size: 1.25rem; border-radius: var(--radius-lg); }

/* ─── Inputs ─── */
.input, .select, .textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.2);
}
.input::placeholder { color: var(--text-dim); }
.textarea { resize: vertical; min-height: 80px; }
.select option { background: var(--surface); }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.form-group { margin-bottom: 1rem; }

/* ─── Badge ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-primary { background: rgba(233,69,96,0.2); color: var(--primary); }
.badge-success { background: rgba(0,212,170,0.2); color: var(--success); }
.badge-warning { background: rgba(255,215,0,0.2); color: var(--warning); }
.badge-dim     { background: rgba(255,255,255,0.08); color: var(--text-dim); }

/* ─── Header ─── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header-logo {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff6b35, #ffd23f 55%, #00c9a7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-sub { font-size: 0.75rem; color: var(--text-dim); }

/* ─── Page principale ─── */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem;
  min-height: calc(100vh - 60px);
}

/* ─── Timer ─── */
.timer-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
  border-radius: 999px;
  transition: width 1s linear;
}

.timer-display {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
  text-align: center;
}
.timer-critical { color: var(--danger); animation: pulse 0.5s infinite alternate; }

@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: 0.5; }
}

/* ─── Boutons réponse (joueur) ─── */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.answer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 90px;
  padding: 1rem 0.75rem;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, filter 0.2s;
  line-height: 1.3;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.answer-btn:active { transform: scale(0.94); filter: brightness(0.85); }
.answer-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.answer-btn .answer-letter {
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 900;
  flex-shrink: 0;
}

.answer-btn-a { background: var(--ans-a); box-shadow: 0 4px 16px rgba(192,57,43,0.4); }
.answer-btn-b { background: var(--ans-b); box-shadow: 0 4px 16px rgba(21,101,192,0.4); }
.answer-btn-c { background: var(--ans-c); box-shadow: 0 4px 16px rgba(106,27,154,0.4); }
.answer-btn-d { background: var(--ans-d); box-shadow: 0 4px 16px rgba(0,105,92,0.4); }

.answer-btn.correct { filter: brightness(1.3); outline: 4px solid #fff; transform: scale(1.03); }
.answer-btn.wrong   { opacity: 0.35; filter: grayscale(0.6); }
.answer-btn.selected { outline: 3px solid rgba(255,255,255,0.7); }

/* ─── Joueur — score panel ─── */
.score-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.score-name { font-weight: 700; font-size: 1rem; }
.score-value {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--warning);
  font-variant-numeric: tabular-nums;
}

/* ─── Résultat joueur ─── */
.result-banner {
  text-align: center;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  margin: 1rem 0;
}
.result-correct   { background: rgba(0,212,170,0.15); border: 2px solid var(--success); }
.result-incorrect { background: rgba(255,68,68,0.12); border: 2px solid var(--danger); }
.result-timeout   { background: rgba(144,144,160,0.12); border: 2px solid var(--text-dim); }

.result-points {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--warning);
}
.result-points.zero { color: var(--text-dim); }

/* ─── Classement ─── */
.leaderboard { display: flex; flex-direction: column; gap: 0.5rem; }
.lb-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.lb-rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.lb-rank-1 { background: #ffd700; color: #000; }
.lb-rank-2 { background: #c0c0c0; color: #000; }
.lb-rank-3 { background: #cd7f32; color: #fff; }
.lb-rank-n { background: var(--surface); color: var(--text-dim); }

.lb-name  { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 900; font-size: 0.95rem; color: var(--warning); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-entry.me { border-color: var(--primary); background: rgba(233,69,96,0.08); }

/* ─── Podium ─── */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.podium-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-score { font-size: 0.75rem; color: var(--warning); font-weight: 700; }
.podium-block {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  font-size: 1.5rem;
  width: 70px;
}
.podium-block-1 { background: linear-gradient(180deg, #ffd700, #ff8c00); height: 90px; }
.podium-block-2 { background: linear-gradient(180deg, #c0c0c0, #808080); height: 65px; }
.podium-block-3 { background: linear-gradient(180deg, #cd7f32, #8B4513); height: 45px; }

/* ─── QR Code ─── */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: #fff;
  border-radius: var(--radius-lg);
  width: fit-content;
  margin: 0 auto;
}
.room-code-display {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--primary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ─── Admin — liste joueurs ─── */
.player-list { display: flex; flex-direction: column; gap: 0.4rem; }
.player-entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.9rem;
}
.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.player-dot.offline { background: var(--text-dim); }
.player-dot.answered { background: var(--warning); }
.player-name-cell { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score-cell { font-weight: 700; font-size: 0.85rem; color: var(--warning); min-width: 50px; text-align: right; }

/* ─── Admin — contrôles musique ─── */
.music-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.progress-bar {
  background: var(--surface2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  width: 100%;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ─── Spotify embed ─── */
.spotify-embed {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.spotify-embed iframe {
  display: block;
  width: 100%;
  height: 80px;
  border: none;
}

/* ─── Toast notification ─── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 400px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}
.toast-success { border-color: var(--success); color: var(--success); }
.toast-error   { border-color: var(--danger);  color: var(--danger); }
.toast-info    { border-color: var(--primary); color: var(--primary); }

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

/* ─── Loading spinner ─── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Splash / landing ─── */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: radial-gradient(ellipse at top, #1a1a3a 0%, var(--bg) 70%);
}
.splash-logo {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  background: linear-gradient(135deg, #ff6b35 0%, #ffd23f 45%, #00c9a7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  line-height: 1;
  letter-spacing: -0.01em;
}
.splash-sub {
  font-size: 1rem;
  color: var(--text-dim);
  text-align: center;
  margin: 0.5rem 0 2.5rem;
}

/* ─── Séparateur ─── */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 1rem 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.25rem;
}
.tab-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
}

/* ─── Panel flottant ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
.modal-center {
  border-radius: var(--radius-lg);
  max-height: 80vh;
  margin: 1rem;
}
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── Responsive ─── */
@media (max-width: 400px) {
  .answer-grid { grid-template-columns: 1fr; }
  .answer-btn  { min-height: 70px; }
}

@media (min-width: 640px) {
  .page { padding: 1.5rem; }
  .answer-btn { min-height: 110px; font-size: 1rem; }
}
