/* Utilise les tokens définis dans css/style.css (--nuit, --or, --parchemin, etc.) */

/* ---------- Carte des niveaux (chapitres) ---------- */
.carte-body { padding: 0; background: var(--parchemin); min-height: 100vh; }
.carte-intro { padding: 36px 24px 8px; text-align: center; }
.mde-bandeau-invite {
  background: var(--or-clair); color: #16233a; text-align: center;
  padding: 10px 20px; font-size: 13px; font-weight: 600;
}
.mde-bandeau-invite a { color: var(--nuit); text-decoration: underline; margin-left: 6px; }

.niveau-selecteur {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 20px 24px 0;
}
.niveau-label { font-weight: 600; color: var(--encre-douce); font-size: 14px; }
.niveau-select {
  font-family: var(--police-texte); font-weight: 700; font-size: 15px; color: var(--nuit);
  padding: 9px 16px; border-radius: 20px; border: 1px solid var(--bordure); background: #fff;
  cursor: pointer; min-width: 220px;
}
.niveau-select:hover { border-color: var(--bleu-mde); }
.niveau-select:focus { outline: none; border-color: var(--bleu-mde); }
.carte-titre {
  font-size: 30px; color: var(--nuit); margin: 0 0 4px;
}
.carte-souligne {
  width: 64px; height: 3px; background: var(--or); margin: 10px auto 0; border-radius: 2px;
}
.carte-grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 22px;
  max-width: 980px;
  margin: 28px auto 60px;
  padding: 0 24px;
}
.carte-ile {
  --couleur: #2f6fed;
  text-decoration: none;
  color: var(--encre);
  background: #fff;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(0,42,96,0.07);
  border: 1px solid var(--bordure);
  border-top: 4px solid var(--couleur);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.carte-ile:hover { transform: translateY(-5px); box-shadow: 0 14px 28px rgba(0,42,96,0.13); }
.carte-ile-icone {
  font-size: 30px; width: 52px; height: 52px; border-radius: 12px;
  background: color-mix(in srgb, var(--couleur) 12%, white);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.carte-ile-titre { font-family: var(--police-titre); font-weight: 600; font-size: 17px; margin-bottom: 14px; line-height: 1.3; }
.carte-ile-barre { background: var(--parchemin-fonce); border-radius: 8px; height: 8px; overflow: hidden; }
.carte-ile-barre-remplie { background: var(--couleur); height: 100%; transition: width 0.5s ease; border-radius: 8px; }
.carte-ile-pct { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--encre-douce); }
.carte-ile-pct.termine { color: var(--sauge); }
.carte-ile-etoiles { font-size: 20px; letter-spacing: 2px; margin-top: 4px; }

/* ---------- En-tête du parcours ---------- */
.jeu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--bordure);
  position: sticky; top: 0; z-index: 10;
}
.jeu-retour { text-decoration: none; color: var(--bleu-mde); font-weight: 600; font-size: 14px; }
.jeu-titre-chapitre { font-family: var(--police-titre); font-weight: 600; font-size: 18px; color: var(--nuit); }
.jeu-progres-texte {
  font-weight: 700; color: var(--nuit); font-size: 13px;
  background: var(--or-clair); padding: 5px 12px; border-radius: 20px;
}

/* ---------- Parcours / chemin ---------- */
.jeu-conteneur {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 1400px;
  background:
    radial-gradient(circle at 15% 10%, rgba(127,179,255,0.08) 0, transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(47,111,237,0.06) 0, transparent 45%),
    var(--parchemin);
}
.jeu-chargement { text-align: center; padding: 60px 20px; color: var(--encre-douce); }

.chemin-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.chemin-trait { fill: none; stroke: var(--parchemin-fonce); stroke-width: 22; stroke-linecap: round; }
.chemin-trait-interieur { fill: none; stroke: var(--or); stroke-opacity: 0.55; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1 20; }

.noeud-etape {
  position: absolute;
  width: 60px; height: 60px;
  margin-left: -30px; margin-top: -30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px;
  font-family: var(--police-titre);
  border: 4px solid #fff;
  box-shadow: 0 5px 0 rgba(0,42,96,0.15), 0 8px 16px rgba(0,42,96,0.1);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: #fff;
  background: #b7bcc4;
}
.noeud-etape:hover { transform: scale(1.09) translateY(-2px); }
.noeud-etape.reussi { background: var(--sauge); }
.noeud-etape.reussi::after { content: '★'; }
.noeud-etape.reussi { font-size: 22px; }
.noeud-etape.debloque { background: var(--or); box-shadow: 0 5px 0 #2f6fb0, 0 0 0 6px rgba(127,179,255,0.18); animation: respire 2.2s ease-in-out infinite; }
.noeud-etape.verrouille { background: #c7ccd3; cursor: not-allowed; opacity: 0.8; box-shadow: 0 4px 0 rgba(0,42,96,0.1); }
.noeud-etape.verrouille:hover { transform: none; }
@keyframes respire {
  0%, 100% { box-shadow: 0 5px 0 #2f6fb0, 0 0 0 6px rgba(127,179,255,0.18); }
  50% { box-shadow: 0 5px 0 #2f6fb0, 0 0 0 10px rgba(127,179,255,0.08); }
}

.avatar-perso {
  position: absolute;
  width: 50px; height: 50px;
  margin-left: -25px; margin-top: -78px;
  font-size: 40px;
  transition: left 0.7s cubic-bezier(.4,0,.2,1), top 0.7s cubic-bezier(.4,0,.2,1);
  z-index: 5;
  filter: drop-shadow(0 6px 4px rgba(0,42,96,0.3));
}

/* ---------- Modales ---------- */
.modale-fond[hidden] { display: none; }
.modale-fond {
  position: fixed; inset: 0;
  background: rgba(18, 35, 61, 0.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modale-boite {
  background: #fff; border-radius: 20px; padding: 30px 26px;
  max-width: 440px; width: 100%; position: relative;
  box-shadow: 0 24px 50px rgba(0,42,96,0.3);
  border-top: 5px solid var(--bleu-mde);
}
.modale-numero {
  font-weight: 700; color: var(--bleu-mde); margin-bottom: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
}
.modale-question { font-size: 18px; margin-bottom: 18px; line-height: 1.55; color: var(--encre); }
.modale-choix { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.choix-bouton {
  padding: 13px 15px; border-radius: 12px; border: 2px solid var(--bordure);
  background: var(--parchemin); cursor: pointer; text-align: left; font-size: 15px;
  font-family: var(--police-texte); transition: border-color 0.15s ease, background 0.15s ease;
}
.choix-bouton:hover { border-color: var(--bleu-mde); }
.choix-bouton.selectionne { border-color: var(--bleu-mde); background: #eaf0fe; }
.modale-reponse-libre {
  width: 100%; padding: 13px; border-radius: 12px; border: 2px solid var(--bordure);
  font-size: 15px; margin-bottom: 14px; font-family: var(--police-texte); background: var(--parchemin);
}
.modale-reponse-libre:focus { outline: none; border-color: var(--bleu-mde); }
.modale-feedback { padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.modale-feedback.correct { background: #e8f5ec; color: var(--sauge); }
.modale-feedback.incorrect { background: #fdedec; color: var(--corail); }
.modale-indice-texte { background: var(--or-clair); border-radius: 10px; padding: 11px 13px; margin-bottom: 14px; font-size: 14px; color: #6b4f0e; }
.modale-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.btn { border: none; border-radius: 10px; padding: 11px 18px; font-weight: 700; cursor: pointer; text-decoration: none; font-size: 14px; font-family: var(--police-texte); transition: transform 0.1s ease, background 0.15s ease; }
.btn:active { transform: scale(0.97); }
.btn-indice { background: var(--or-clair); color: #6b4f0e; margin-right: auto; }
.btn-indice:hover { background: #f6dd9c; }
.btn-valider { background: var(--bleu-mde); color: #fff; }
.btn-valider:hover { background: #2258c4; }
.btn-continuer { background: var(--sauge); color: #fff; }
.btn-continuer:hover { background: #347550; }
.modale-fermer {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 16px; cursor: pointer; color: var(--encre-douce); width: 28px; height: 28px; border-radius: 50%;
}
.modale-fermer:hover { background: var(--parchemin); }

/* ---------- Écran de victoire ---------- */
.victoire-boite { text-align: center; border-top-color: var(--or); }
.trophee { font-size: 60px; animation: rebond 0.6s ease; }
@keyframes rebond {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.victoire-boite h2 { color: var(--nuit); margin: 6px 0 4px; font-size: 24px; }
.victoire-boite p { color: var(--encre-douce); }
.victoire-etoiles { font-size: 30px; margin: 12px 0; color: var(--or); }

@media (max-width: 480px) {
  .jeu-conteneur { max-width: 100%; }
}

/* ---------- Paysage mathématique décoratif (sur les côtés, écrans larges) ---------- */
@media (min-width: 900px) {
  body.jeu-body {
    background-image:
      url('../../../img/paysage-math.svg'),
      url('../../../img/paysage-math.svg');
    background-repeat: repeat-y, repeat-y;
    background-position: left top, right top;
    background-size: 340px auto, 340px auto;
    animation: derive-paysage 50s linear infinite;
  }
}
@keyframes derive-paysage {
  from { background-position: 0% 0px, 100% 0px; }
  to   { background-position: 0% -700px, 100% -700px; }
}
