:root {
  --bg: #081120;
  --panel: #0f172a;
  --panel2: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --good: #22c55e;
  --bad: #ef4444;
  --active: #f59e0b;
  --primary: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* 100dvh = hauteur réelle visible : évite que le bas soit caché
     derrière la barre d'outils du navigateur (iPad / iPhone Safari) */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
header {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #020617;
  border-bottom: 1px solid var(--border);
}

.title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.new-game-btn {
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.new-game-btn:hover {
  transform: translateY(-1px);
  background: #3b82f6;
}

/* Pendant une partie, le bouton est poussé tout en bas du panneau.
   Sur l'écran d'accueil (pas de classe "playing"), il reste centré
   juste sous la carte. */
.playing .panel-center {
  justify-content: flex-start;
}

.playing .new-game-btn {
  margin-top: auto;
}

/* ---------- Stats bar (en haut du panneau de gauche) ---------- */
/* Encadré façon "carte" qui regroupe toutes les stats de la partie */
#statsBar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  color: var(--muted);
}

.stat b {
  color: var(--text);
  font-size: 15px;
}

.stat .good {
  color: var(--good);
}
.stat .bad {
  color: var(--bad);
}

.progress {
  /* toujours seule sur sa ligne, sur toute la largeur du panneau */
  flex: 1 0 100%;
  height: 8px;
  background: #020617;
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: 0.3s;
}

/* ---------- Layout ---------- */
#layout {
  flex: 1;
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Centre verticalement la carte question (et le bouton) dans le panneau */
.panel-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 0;
}

.card {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
}

/* Texte de l'écran d'accueil (avant le démarrage d'une partie) */
.welcome-text {
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
  margin: 0;
}

.badge {
  display: block;
  width: fit-content;
  margin: 0 auto 18px;
  padding: 14px 26px;
  border-radius: 18px;
  background: #020617;
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 44px;
  letter-spacing: 1px;
}

.question {
  font-size: 19px;
  text-align: center;
  margin-bottom: 22px;
  font-weight: 600;
  color: var(--text);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

select,
button {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #111827;
  color: white;
  font-size: 15px;
}

#inputs select {
  margin-bottom: 12px;
}

.action-btn {
  background: var(--primary);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: 0.15s;
  margin-top: 6px;
}

.action-btn:hover {
  transform: translateY(-1px);
  background: #3b82f6;
}

#map {
  height: 100%;
  width: 100%;
}

.timer {
  text-align: center;
  margin-top: 14px;
  font-size: 15px;
  color: var(--muted);
}

.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.stat-line span:first-child {
  color: var(--muted);
}

.stat-line span:last-child {
  font-weight: 600;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: fade 0.18s ease;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  width: 420px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  animation: pop 0.22s ease;
}

.modal h2 {
  margin: 0 0 20px;
  font-size: 22px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-head h2 {
  margin: 0;
}

.close-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #020617;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text);
  border-color: #334155;
}

.modal label {
  margin-top: 14px;
}

.modal label:first-of-type {
  margin-top: 0;
}

/* Groupe de boutons de choix (réglages à 2 options) */
.choice-group {
  display: flex;
  gap: 8px;
}

.choice {
  flex: 1;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #111827;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.choice:hover {
  border-color: #475569;
  color: var(--text);
}

/* Le bouton sélectionné est mis en évidence en bleu */
.choice.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* feedback modal */
.feedback-modal {
  text-align: center;
  width: 380px;
}

.feedback-modal.correct {
  border-color: var(--good);
}
.feedback-modal.wrong {
  border-color: var(--bad);
}

.feedback-icon {
  font-size: 54px;
  line-height: 1;
  margin-bottom: 10px;
}

.feedback-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 18px;
}

.feedback-title.good {
  color: var(--good);
}
.feedback-title.bad {
  color: var(--bad);
}

.answer-block {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 16px;
  margin-bottom: 20px;
  text-align: left;
}

.answer-line {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.answer-line:last-child {
  border-bottom: none;
}

.answer-line span:first-child {
  color: var(--muted);
}

.answer-line span:last-child {
  font-weight: 700;
}

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

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================
   RESPONSIVE — écrans étroits (tablette en portrait, téléphone)
   En dessous de 820px de large, la grille "panneau + carte" côte
   à côte devient illisible (panneau vide, carte écrasée).
   On empile alors : la carte question en haut, la carte de
   France en dessous, et la page peut défiler.
   ============================================================ */
@media (max-width: 820px) {
  body {
    /* on autorise le défilement vertical sur petit écran */
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: auto;
  }

  /* Empilé verticalement au lieu de deux colonnes */
  #layout {
    display: flex;
    flex-direction: column;
  }

  /* Le panneau prend juste la hauteur de son contenu */
  .panel {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Plus besoin de centrer verticalement : le contenu est compact */
  .panel-center {
    flex: 0 0 auto;
  }

  /* La carte de France reçoit une hauteur fixe et confortable */
  #map {
    flex: 0 0 auto;
    height: 60vh;
    height: 60dvh;
    min-height: 340px;
  }

  header {
    flex: 0 0 52px;
    padding: 0 16px;
  }

  .panel {
    padding: 16px;
  }
}
