/* =========================================================
🎨 VARIABLES & RESET
========================================================= */
:root {
  --bg: #0f1115;
  --fg: #eaeef2;
  --muted: #aab4c0;
  --primary: #4f8cff;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --card: #171a21;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

/* =========================================================
📦 STRUCTURE GLOBALE
========================================================= */
.container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 16px;
  padding-bottom: 90px;   /* espace pour le bouton mobile */
  padding-top: 110px;     /* espace réservé à la fiche joueur */
}

.center {
  text-align: center;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

input[type="text"] {
  background: var(--card);
  color: var(--fg);
  border: 1px solid #2a2f3a;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 18px;
  outline: none;
}

/* =========================================================
🔘 BOUTONS
========================================================= */
button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease-in-out;
}

button.primary { background: var(--primary); }
button.success { background: var(--success); }
button.warning { background: var(--warning); }
button.danger  { background: var(--danger); }
button.large   { font-size: 22px; padding: 16px 22px; }

button:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

button:disabled {
  background: #3a3f4a;
  color: #cfd5dd;
  opacity: 0.85;
  cursor: not-allowed;
  border: 1px solid #555;
}

button.primary:disabled { background: var(--primary); color: #fff; opacity: 0.6; }
button.success:disabled { background: var(--success); color: #fff; opacity: 0.6; }
button.warning:disabled { background: var(--warning); color: #fff; opacity: 0.6; }
button.danger:disabled  { background: var(--danger);  color: #fff; opacity: 0.6; }

/* =========================================================
🚨 BUZZER
========================================================= */
#buzzer:disabled {
  background: var(--danger);
  opacity: 0.6;
  cursor: not-allowed;
  color: #fff;
}

.buzzer-ready {
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(79, 140, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0); }
}

.buzzed {
  font-size: 24px;
  color: #7ef0c1;
  margin-top: 8px;
}

/* =========================================================
📊 SCOREBOARD
========================================================= */
.scoreboard {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.score-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 700;
  transform: translateY(10px);
  opacity: 0;
  animation: fadeInUp 0.4s ease-out forwards;
}

.score-card.gold   { background: #ffd700; color: #111; }
.score-card.silver { background: #c0c0c0; color: #111; }
.score-card.bronze { background: #cd7f32; color: #111; }

.score-left { opacity: 0.95; }
.score-right { min-width: 80px; text-align: right; }

@keyframes fadeInUp {
  to { transform: translateY(0); opacity: 1; }
}

/* =========================================================
🧠 RÉPONSES
========================================================= */
.answer-btn {
  display: inline-block;
  margin: 8px;
  padding: 12px 18px;
  background: #2a2f3a;
  color: var(--fg);
  border-radius: 10px;
  border: 1px solid #3a4150;
  transition: all 0.2s;
}

.answer-btn:hover:not(:disabled) {
  background: #3b4357;
  border-color: var(--primary);
}

.answer-btn:disabled {
  opacity: 0.75;
  background: #1e2128;
  color: #aab4c0;
  cursor: not-allowed;
}

.public-answer {
  background: var(--card);
  color: var(--fg);
  font-size: 1.4rem;
  padding: 16px;
  border-radius: 12px;
  margin: 8px 0;
  box-shadow: var(--shadow);
  text-align: center;
}

/* =========================================================
🏆 PODIUM & SCORES FINAUX
========================================================= */
.podium {
  text-align: center;
  padding: 40px;
}

.podium h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  color: var(--primary);
}

.podium h2 {
  font-size: 2rem;
  margin-bottom: 30px;
}

.final-scoreboard {
  max-width: 600px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.final-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: 14px;
  padding: 20px 28px;
  font-size: 1.8rem;
  box-shadow: var(--shadow);
}

.final-card.gold   { background: linear-gradient(135deg, #ffd700, #ffef8a); color: #111; font-weight: bold; }
.final-card.silver { background: linear-gradient(135deg, #c0c0c0, #f2f2f2); color: #111; }
.final-card.bronze { background: linear-gradient(135deg, #cd7f32, #f4b183); color: #111; }

.final-rank   { font-size: 2.2rem; font-weight: bold; }
.final-team   { flex: 1; text-align: left; padding-left: 20px; }
.final-points { font-weight: bold; font-size: 2rem; color: var(--primary); }

/* =========================================================
📷 QR CODES & LIENS
========================================================= */
.qr-container {
  text-align: center;
  margin: 20px 0;
}

.qr-container canvas {
  margin: 10px auto;
  display: block;
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.qr-wrapper { margin-top: 30px; text-align: center; }

#join-qr {
  display: block;
  margin: 0 auto 10px;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.fallback-url {
  font-size: 1.1rem;
  color: var(--fg);
  margin-top: 8px;
}

.fallback-url a {
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.fallback-url a:hover {
  text-decoration: underline;
}

/* =========================================================
📱 RESPONSIVE
========================================================= */
@media (max-width: 600px) {
  body {
    font-size: 15px;
    padding: 0;
  }

  .container {
    max-width: 100%;
    padding: 0 8px;
    padding-top: 140px;
    padding-bottom: 90px;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 12px;
  }

  h2 {
    font-size: 1.2rem;
  }

  #choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
  }

  .answer-btn {
    font-size: 1rem;
    padding: 10px 14px;
    width: 100%;
  }

  #buzzer {
    width: 100%;
    font-size: 1.6rem;
    padding: 18px;
    margin-top: 20px;
  }

  .scoreboard { gap: 8px; }

  .score-card {
    font-size: 1rem;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .final-card {
    font-size: 1.2rem;
    padding: 14px 20px;
  }

  .player-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px;
    min-height: 150px;
  }

  .player-info { margin: 8px 0; text-align: center; }
  .player-avatar { font-size: 2.5rem; }
  .team-name { font-size: 1.6rem; }
  .player-status { font-size: 1.1rem; }
  .player-score { font-size: 1.4rem; margin-top: 6px; }

  #buzzer { display: none; }
  .buzzer-bar { display: block !important; }
}

/* Cache le buzzer même si la MQ mobile force l'affichage */
#buzzer.buzzer-hidden,
.buzzer-bar.buzzer-hidden { display: none !important; }

/* =========================================================
📶 BARRE BUZZER MOBILE
========================================================= */
.buzzer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 17, 21, 0.95);
  padding: 12px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
  display: none;
  z-index: 999;
}

.buzzer-bar button {
  width: 100%;
  font-size: 1.8rem;
  padding: 18px;
}

/* =========================================================
👤 FICHE JOUEUR
========================================================= */
.player-card {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--card);
  margin: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  width: 100%;
  min-height: 110px;
}

.player-avatar {
  font-size: 3rem;
}

.player-info {
  flex: 1;
  margin-left: 16px;
  text-align: left;
}

.team-name {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.player-status {
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 500;
}

.player-score {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

/* =========================================================
🧠 GESTION DES QUESTIONS
========================================================= */

/* 📋 Mise en forme du formulaire de question */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.form-grid label {
  font-weight: 600;
  margin-top: 10px;
}

.form-grid input[type="text"] {
  width: 100%;
  font-size: 1.1rem;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #333;
  background: var(--card);
  color: var(--fg);
}

.drag-handle {
  cursor: grab;
  font-size: 1.4rem;
  text-align: center;
  width: 30px;
  opacity: 0.7;
}

.drag-handle:hover {
  opacity: 1;
}

#sortable tr {
  transition: transform 0.2s ease, background 0.2s ease;
}

#sortable tr.sortable-chosen {
  background: rgba(79, 140, 255, 0.15);
  transform: scale(1.01);
}

#sortable tr.sortable-ghost {
  opacity: 0.4;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .85rem;
}
.badge-buzzer { background: var(--danger);  color: #fff; }
.badge-click  { background: var(--primary); color: #fff; }


.hint {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 10px;
  text-align: left;
}

.pulse-once {
  animation: pulse-once 0.8s ease-out;
}
@keyframes pulse-once {
  0% { transform: scale(1);   }
  30%{ transform: scale(1.04);}
  100%{transform: scale(1);   }
}
