* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0; font-family: "Baloo 2", system-ui, sans-serif; color: #1d2b3a;
  /* Ciel étoilé en fond des menus : quelques points lumineux sur un dégradé nuit. */
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 42%, #ffe082 50%, transparent 51%),
    radial-gradient(1px 1px at 32% 64%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 86%, #b3e5fc 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 80%, #fff 50%, transparent 51%),
    radial-gradient(ellipse at 80% 0%, #6a1b9a55, transparent 60%),
    linear-gradient(160deg, #0b1233, #26184d 60%, #45195a);
  background-attachment: fixed;
}
h1 { margin: .1em 0; color: #1a237e; font-weight: 800; letter-spacing: .01em; }
h1, h2, button, .option span, .gain-xp { font-family: "Baloo 2", system-ui, sans-serif; }
h2 { font-size: 1.1rem; margin: 1.2em 0 .5em; color: #52606d; }

/* ---------- Écrans et cartes ---------- */
.ecran { position: fixed; inset: 0; overflow-y: auto; padding: 16px; display: flex; justify-content: center; align-items: flex-start; }
.carte { width: 100%; max-width: 680px; background: rgba(255, 255, 255, .96); border-radius: 22px; padding: 16px 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .6); }
.centre { text-align: center; justify-content: center; }
.entete { display: flex; gap: 12px; align-items: center; }
.actions { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-top: 18px; }
.aide { color: #607d8b; }
.erreur { color: #d32f2f; font-weight: 600; }

/* ---------- Contrôles ---------- */
button { font: inherit; font-size: 1.3rem; font-weight: 700; padding: 10px 16px; border: 0; border-radius: 14px; background: linear-gradient(180deg, #42a5f5, #1565c0); color: #fff; cursor: pointer; box-shadow: 0 4px 0 #0d3c78; }
.bouton-jouer { background: linear-gradient(180deg, #66bb6a, #2e7d32); box-shadow: 0 4px 0 #1b5e20; padding-inline: 28px; }
button.gris { background: linear-gradient(180deg, #90a4ae, #607d8b); box-shadow: 0 4px 0 #455a64; }
button.danger { background: linear-gradient(180deg, #ef5350, #c62828); box-shadow: 0 4px 0 #8e0000; }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
button:disabled { opacity: .5; cursor: default; }
select, input, textarea { font: inherit; font-size: 1.2rem; padding: 8px 10px; border: 2px solid #90a4ae; border-radius: 10px; width: 100%; }
.reglage { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-weight: 600; }
h3 { font-size: 1rem; margin: 1em 0 .4em; color: #52606d; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { position: relative; }
.puce input { position: absolute; opacity: 0; width: auto; }
.puce span { display: inline-block; min-width: 3rem; text-align: center; padding: 8px 12px; border: 3px solid #cfd8dc; border-radius: 999px; background: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.puce input:checked + span { border-color: #1976d2; background: #1976d2; color: #fff; }
.puce input:focus-visible + span { outline: 3px solid #90caf9; }
.puces.tables .puce span { min-width: 3.2rem; }
.actions-tables { display: flex; gap: 8px; margin-top: 8px; }
.actions-tables button { font-size: 1rem; padding: 6px 12px; }
.compte { font-weight: 700; }
.interrupteur { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #e3f2fd; font-weight: 700; cursor: pointer; }
.interrupteur input { width: auto; flex: none; margin-top: 2px; transform: scale(1.4); }
.interrupteur small { display: block; font-weight: 400; color: #546e7a; }
.etapes-photo { margin-top: 14px; padding: 10px 12px; background: #e8f5e9; border-radius: 12px; }
.etapes-photo summary { font-weight: 600; cursor: pointer; }
.etapes-photo ol, .etapes-photo ul { margin: 8px 0 0; padding-left: 1.3em; line-height: 1.5; }
.etapes-photo.indices { background: #fff8e1; }
.etapes-photo code { padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .08); font-size: .95em; }
.etapes-photo button { margin-top: 10px; font-size: 1.1rem; }

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; width: auto; }
.option span { display: block; height: 100%; padding: 12px; border: 3px solid #cfd8dc; border-radius: 12px; font-size: 1.2rem; font-weight: 600; background: #fff; cursor: pointer; }
.option small { display: block; font-size: .9rem; font-weight: 400; color: #78909c; }
.option input:checked + span { border-color: #1976d2; background: #e3f2fd; }
.option input:focus-visible + span { outline: 3px solid #90caf9; }
.option .barre-niveau { height: 8px; }
.grille.petite { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.grille.petite .option span { font-size: 1.05rem; padding: 8px 10px; }
.option.verrouille span { opacity: .55; filter: grayscale(1); cursor: not-allowed; background: #eceff1; }
.apercu { height: 190px; margin-bottom: 10px; border-radius: 16px; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #283593, #0b1233 70%); }
.apercu canvas { display: block; }
.volumes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="range"] { padding: 0; border: 0; accent-color: #1976d2; }

/* ---------- Parcours ---------- */
#ecran-parcours { position: relative; min-height: 100dvh; }
.entete-parcours { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(11, 18, 51, .88); backdrop-filter: blur(6px); color: #fff; }
.entete-parcours > div { min-width: 0; }
.titre-parcours { display: block; font-size: 1.25rem; }
.entete-parcours small { display: block; color: #ffe082; font-weight: 700; }
.entete-parcours .liste-du-moment { color: #b3e5fc; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boutons-entete { display: flex; gap: 8px; flex: none; }
.profil-carte { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; border: 3px solid #cfd8dc; border-radius: 16px; background: #fff; color: #1d2b3a; font-size: 1.1rem; box-shadow: 0 4px 0 #b0bec5; }
.profil-carte .profil-avatar { font-size: 2.4rem; }
.profil-carte small { color: #78909c; font-weight: 600; }
.champ-code { font-size: 2rem; letter-spacing: .5em; text-align: center; }
.vaisseau-carte { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 3px solid #cfd8dc; border-radius: 14px; background: #fff; }
.vaisseau-carte.choisi { border-color: #2e7d32; background: #e8f5e9; }
.vaisseau-carte.verrouille { background: #eceff1; }
.vaisseau-carte small { color: #607d8b; }
.vaisseau-carte .etat-vaisseau { font-weight: 700; color: #ef6c00; }
.vaisseau-carte button { margin-top: 6px; font-size: 1.05rem; }
#apercu-hangar { height: 200px; }
.icone-parent { flex: none; font-size: 1.4rem; padding: 6px 10px; background: rgba(255, 255, 255, .15); box-shadow: none; }
.carte-parcours { position: relative; width: 100%; max-width: 560px; margin: 0 auto; overflow: hidden; }
.bande-chapitre { position: absolute; left: 0; right: 0; }
.banniere-chapitre { position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%); z-index: 1; padding: 3px 14px; border-radius: 999px; background: rgba(0, 0, 0, .4); color: #fff; font-weight: 800; font-size: .9rem; white-space: nowrap; }
.bande-chapitre:first-child .banniere-chapitre { bottom: 14px; transform: translateX(-50%); }
.chemin { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.chemin-a-venir { fill: none; stroke: rgba(255, 255, 255, .28); stroke-width: 14; stroke-linecap: round; }
.chemin-parcouru { fill: none; stroke: #ffca28; stroke-width: 14; stroke-linecap: round; filter: drop-shadow(0 0 6px #ff9800); }

.etape { position: absolute; z-index: 2; transform: translate(-50%, -50%); width: 76px; height: 76px; padding: 0; display: flex; align-items: center; justify-content: center; border: 4px solid #fff; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #90caf9, #1565c0); box-shadow: 0 6px 0 #0d3c78, 0 10px 20px rgba(0, 0, 0, .45); }
.etape:active { transform: translate(-50%, -46%); }
.etape-icone { font-size: 2rem; line-height: 1; }
.etape-numero { position: absolute; top: -8px; right: -8px; min-width: 28px; height: 28px; padding: 0 4px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; border-radius: 14px; background: #ffca28; color: #3e2723; font-size: .95rem; font-weight: 800; }
.etape-titre { position: absolute; top: 100%; left: 50%; width: 150px; margin-top: 12px; transform: translateX(-50%); color: #fff; font-size: .85rem; font-weight: 700; line-height: 1.1; text-shadow: 0 2px 4px rgba(0, 0, 0, .9); }
.etape-faite { background: radial-gradient(circle at 35% 30%, #fff59d, #f9a825); box-shadow: 0 6px 0 #c17900, 0 10px 20px rgba(0, 0, 0, .45); }
.etape-verrouillee { background: radial-gradient(circle at 35% 30%, #b0bec5, #546e7a); box-shadow: 0 6px 0 #37474f, 0 10px 20px rgba(0, 0, 0, .45); }
.etape-verrouillee .etape-titre { opacity: .6; }
.etape-actuelle { z-index: 3; width: 96px; height: 96px; background: radial-gradient(circle at 35% 30%, #a5d6a7, #2e7d32); box-shadow: 0 6px 0 #1b5e20, 0 0 0 8px rgba(255, 235, 59, .35), 0 0 40px 12px rgba(255, 235, 59, .5); animation: rebond 1.4s ease-in-out infinite; }
.etape-actuelle .etape-icone { font-size: 2.6rem; }
.etape-avatar { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 2px; font-size: 2.2rem; animation: flotte 2s ease-in-out infinite; }
.decor { position: absolute; z-index: 1; transform: translate(-50%, -50%); font-size: 2.2rem; opacity: .85; pointer-events: none; animation: flotte 3s ease-in-out infinite; }
.tremble { animation: tremble .5s; }
@keyframes rebond { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -58%) scale(1.06); } }
@keyframes flotte { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes tremble { 0%, 100% { transform: translate(-50%, -50%); } 20%, 60% { transform: translate(-62%, -50%); } 40%, 80% { transform: translate(-38%, -50%); } }

#choix-tables-jeu { z-index: 21; }
.fenetre { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .6); }
.fiche { max-height: 92dvh; overflow-y: auto; }
.fiche-entete { display: flex; align-items: center; gap: 12px; }
.fiche-entete h2 { margin: 0; color: #1a237e; font-size: 1.4rem; }
.fiche-icone { font-size: 2.6rem; }
.fiche .apercu { height: 160px; margin: 10px 0 0; }
.fiche .histoire { font-style: italic; color: #5d4037; line-height: 1.35; }
.fiche .objectif { font-weight: 700; color: #bf360c; margin: 6px 0; }
.fiche-jeu { margin: 6px 0; color: #37474f; font-weight: 700; }

/* ---------- Progression ---------- */
.profil { margin-top: 8px; padding: 10px 12px; border-radius: 14px; background: linear-gradient(135deg, #fff8e1, #ffe0b2); }
.profil-ligne { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.profil small { display: block; margin-top: 4px; color: #6d4c41; }
.barre-niveau { height: 14px; margin-top: 6px; border-radius: 7px; background: rgba(0, 0, 0, .12); overflow: hidden; }
.barre-niveau > div { height: 100%; width: 0; border-radius: 7px; background: linear-gradient(90deg, #ffca28, #ff7043); }
.resume-partie { margin-top: 14px; font-weight: 700; color: #37474f; }
.exemples { font-weight: 600; color: #37474f; }
.gain-xp { font-size: 1.6rem; font-weight: 700; color: #ef6c00; margin: .3em 0; }
.carte-mission { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .75); border: 2px solid #ffcc80; text-align: left; }
.carte-mission .histoire { margin: .3em 0; font-style: italic; color: #5d4037; line-height: 1.35; }
.carte-mission .objectif { font-weight: 700; color: #bf360c; }
#ecran-fin .carte-mission { background: #fff8e1; }
.grille.quatre { grid-template-columns: repeat(4, 1fr); }
.grille.quatre .option span { text-align: center; }
.zone-parent { margin-top: 24px; padding: 10px 12px; border-radius: 12px; background: #eceff1; }
.zone-parent summary { font-weight: 700; cursor: pointer; }
.recompenses { margin-top: 10px; padding: 8px 12px; border-radius: 12px; background: #e8f5e9; font-weight: 600; color: #2e7d32; }
.recompenses p { margin: .3em 0; }

.tableau { list-style: none; padding: 0; }
.tableau li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #eceff1; }
.tableau li span { flex: 1; font-size: 1.2rem; }
.tableau li small { display: block; font-size: .9rem; color: #78909c; }
.tableau button { font-size: 1.1rem; padding: 6px 10px; }


/* ---------- Jeu ----------
   L'écran suit la zone visible (au-dessus du clavier virtuel) : bandeau d'infos en haut,
   jeu 3D au milieu, champ de réponse en bas, collé au clavier. */
#ecran-jeu { position: fixed; left: 0; right: 0; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; }
.bandeau-jeu { width: 100%; max-width: 680px; margin: 0 auto; background: rgba(255, 255, 255, .95); border-radius: 14px; padding: 6px 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
#zone-3d { position: relative; flex: 1; min-height: 0; border-radius: 14px; overflow: hidden; }
#zone-3d canvas { position: absolute; inset: 0; }
.hud { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .95rem; }
#statut-jeu { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud button.icone { font-size: 1.05rem; padding: 2px 8px; border-radius: 10px; background: linear-gradient(180deg, #eceff1, #cfd8dc); box-shadow: 0 2px 0 #90a4ae; }
.hud button.icone.coupe { opacity: .45; filter: grayscale(1); }
#saisie::placeholder { color: #90a4ae; font-size: 1.1rem; }
.barre { height: 6px; background: #e3e8ee; border-radius: 3px; overflow: hidden; margin-top: 4px; }
#barre-temps { height: 100%; width: 100%; background: #4caf50; }
#barre-temps.urgent { background: #e53935; }
.mot { font-size: 1.7rem; font-weight: 700; letter-spacing: .08em; margin-top: 2px; overflow-wrap: anywhere; white-space: pre-wrap; }
.mot:empty { display: none; }
.juste { color: #2e7d32; }
.faux { color: #d32f2f; text-decoration: underline; }
.ligne { display: flex; gap: 6px; }
.ligne input { flex: 1; min-width: 0; font-size: 1.5rem; padding: 6px 10px; }
.ligne button { padding: 6px 14px; }
#celebration { position: absolute; top: 35%; left: 0; right: 0; z-index: 1; text-align: center; font-size: 3.5rem; pointer-events: none; opacity: 0; transition: opacity .3s; }
#celebration.annonce { font-size: 2rem; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .8), 0 0 18px #ff9800; }

/* Fin de partie : le jeu reste visible en fond, sans son bandeau ni le champ de réponse. */
#ecran-jeu.termine .bandeau-jeu { display: none; }
#ecran-fin { align-items: flex-end; }
#ecran-fin .carte { max-height: 70dvh; overflow-y: auto; background: rgba(255, 255, 255, .92); }

table { margin: 10px auto; border-collapse: collapse; font-size: 1.2rem; }
td { padding: 4px 12px; border-bottom: 1px solid #e3e8ee; text-align: left; }

/* ---------- Fête de fin de chapitre et grande finale ---------- */
#fete { position: fixed; inset: 0; z-index: 50; background: rgba(6, 8, 24, .82); display: flex; align-items: center; justify-content: center; cursor: pointer; }
#fete-feu { position: absolute; inset: 0; width: 100%; height: 100%; }
.fete-texte { position: relative; text-align: center; color: #fff; padding: 24px; max-width: 520px; animation: fete-arrivee .5s ease-out both; }
.fete-icone { display: block; font-size: 4.5rem; line-height: 1; filter: drop-shadow(0 6px 18px #000a); animation: fete-danse 1.6s ease-in-out infinite; }
.fete-texte h1 { color: #ffe082; font-size: 2.1rem; margin: .2em 0; text-shadow: 0 3px 14px #000c; }
.fete-texte strong { display: block; font-size: 1.25rem; color: #b3e5fc; }
.fete-texte p { color: #e8eaf6; line-height: 1.45; }
.fete-texte small { color: #ffffff99; }
#fete.finale .fete-icone { font-size: 6rem; }
#fete.finale .fete-texte h1 { color: #ffd54f; font-size: 2.6rem; }
@keyframes fete-arrivee { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes fete-danse { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  .fete-texte, .fete-icone { animation: none; }
}

/* Deux réglages côte à côte (questions / secondes) */
.deux-reglages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
