/* ============================================================
   BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --c: #2563eb;            /* couleur de la matière / aventure, redéfinie par vue */
  --texte: #1e293b;
  --doux: #64748b;
  --fond: #f0f7ff;
  --or: #f59e0b;
  --vert: #16a34a;
  --rouge: #dc2626;
  --rayon: 20px;
  --ombre: 0 4px 0 rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

body {
  font-family: ui-rounded, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(circle at 20% 0%, #fff7ed 0, transparent 40%), radial-gradient(circle at 100% 30%, #ecfdf5 0, transparent 40%), var(--fond);
  background-attachment: fixed;
  color: var(--texte);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
button:disabled { cursor: default; }
h1, h2, h3 { line-height: 1.2; }

.chargement, .vide { text-align: center; color: var(--doux); padding: 60px 0; }
.page { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }
.carte { background: white; border-radius: var(--rayon); box-shadow: var(--ombre); padding: 24px; }
.etiquette { font-weight: 700; margin: 18px 0 8px; display: block; }
.indice { color: var(--doux); font-size: 15px; }
.lien { display: block; margin: 28px auto 0; color: var(--doux); text-decoration: underline; }
.etoile-or { color: var(--or); font-weight: 700; }
.etoiles { color: var(--or); letter-spacing: 2px; }
.etoiles .vide { color: #e2e8f0; padding: 0; }
.erreur-demarrage { text-align: center; color: var(--rouge); margin-top: 60px; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 20px;
  border: 3px solid #e2e8f0;
  border-radius: 14px;
  outline: none;
  background: white;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--c); }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--c);
  color: white;
  font-weight: 800;
  padding: 12px 22px;
  border-radius: 14px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c), black 25%);
  transition: transform .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c), black 25%); }
.btn:disabled { background: #cbd5e1; box-shadow: 0 4px 0 #94a3b8; }
.btn.secondaire { background: white; color: var(--texte); box-shadow: 0 4px 0 #cbd5e1, inset 0 0 0 2px #e2e8f0; }
.btn.danger { --c: var(--rouge); }
.btn.gros { font-size: 19px; padding: 14px 32px; min-width: 200px; }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ============================================================
   BARRE DU HAUT
   ============================================================ */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
}
.logo { font-size: 30px; width: 44px; height: 44px; display: grid; place-items: center; }
/* Boutons-icônes à droite : 🎵 🗺️ 🎒 et l'avatar (mon profil) ; .ici = la page ouverte */
.barre-icones { display: flex; align-items: center; gap: 8px; }
.icone-barre, .bouton-musique {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #f1f5f9; font-size: 22px;
  cursor: pointer; display: grid; place-items: center; touch-action: manipulation;
}
.icone-barre:hover { background: #e2e8f0; }
.icone-barre.ici { background: white; box-shadow: 0 0 0 3px var(--c); }
.avatar-barre { background: white; box-shadow: 0 0 0 2px #e2e8f0; font-size: 26px; }
.bouton-musique[aria-pressed="false"] { opacity: .6; }
.badge-retour { text-decoration: none; }
.classe { font-size: 13px; color: var(--doux); font-weight: 600; }

/* ============================================================
   PROFILS
   ============================================================ */
.page-profils { text-align: center; padding-top: 60px; }
.titre-app { font-size: 34px; margin-bottom: 8px; }
.page-profils h2 { color: var(--doux); font-weight: 600; margin-bottom: 32px; }
.grille-profils { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.carte-profil { position: relative; }
.profil-choix {
  width: 150px; padding: 20px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: white; border-radius: var(--rayon); box-shadow: var(--ombre);
  transition: transform .15s;
}
.profil-choix:hover { transform: translateY(-4px); }
.carte-profil.actif .profil-choix { outline: 3px solid var(--c); }
.carte-profil .avatar { font-size: 56px; }
.carte-profil .pseudo { font-weight: 800; }
.carte-profil.nouveau .profil-choix { background: transparent; box-shadow: none; border: 3px dashed #cbd5e1; color: var(--doux); }
.profil-suppr { position: absolute; top: -10px; right: -10px; background: white; border-radius: 50%; width: 44px; height: 44px; box-shadow: var(--ombre); }
.profil-modif { position: absolute; top: -10px; left: -10px; background: white; border-radius: 50%; width: 44px; height: 44px; box-shadow: var(--ombre); }

.form-profil { max-width: 560px; margin: 0 auto; text-align: left; }

/* 🔐 Connexion (hors mode test) : identifiant + mot de passe */
.form-connexion { max-width: 420px; margin: 0 auto; text-align: left; }
.form-connexion .actions { margin-top: 22px; }
.form-connexion .btn { width: 100%; }
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 60px; }
.voir-mdp { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
.aide-champ { font-size: 14px; color: var(--doux); margin-top: 6px; }
.ou-bien { margin: 26px 0 10px; color: var(--doux); }
.connecte-comme { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.connecte-comme .avatar { font-size: 40px; }
.identifiant-actuel { font-weight: 700; }
.grille-avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-choix { font-size: 30px; aspect-ratio: 1; border-radius: 14px; background: #f1f5f9; transition: transform .1s; }
.avatar-choix:hover { transform: scale(1.1); }
.grille-classes { display: flex; flex-wrap: wrap; gap: 8px; }
.classe-choix { padding: 8px 16px; border-radius: 12px; background: #f1f5f9; font-weight: 700; }
.avatar-choix.choisi, .classe-choix.choisi { background: var(--c); color: white; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c), white 60%); }

/* ============================================================
   ACCUEIL
   ============================================================ */
.bienvenue { margin: 16px 0 28px; }
.bienvenue h1 { font-size: 32px; }
.bienvenue p { color: var(--doux); font-size: 19px; }

.grille-matieres { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.carte-matiere {
  position: relative; overflow: hidden;
  background: white; border-radius: var(--rayon); padding: 28px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c), white 55%), var(--ombre);
  border: 3px solid color-mix(in srgb, var(--c), white 75%);
  transition: transform .15s;
}
.carte-matiere:hover { transform: translateY(-4px); }
.carte-matiere::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
  background: color-mix(in srgb, var(--c), white 88%);
}
.matiere-emoji { font-size: 52px; position: relative; z-index: 1; }
.carte-matiere h2 { color: var(--c); font-size: 26px; margin: 8px 0 4px; }
.carte-matiere p { color: var(--doux); }
.matiere-stats { display: flex; justify-content: space-between; margin-top: 18px; font-weight: 700; font-size: 15px; }

.carnet-intro { color: var(--doux); margin: -14px 0 20px; }
.carnet h2 { margin-bottom: 14px; }
.tresors { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.tresor {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 18px 10px; border-radius: 16px; background: rgba(255, 255, 255, .6); border: 2px dashed #cbd5e1;
  font-size: 14px; color: var(--doux);
}
.tresor-emoji { font-size: 40px; filter: grayscale(1); opacity: .5; }
.tresor.obtenu { background: linear-gradient(160deg, #fffbeb, #fef3c7); border: 2px solid #fcd34d; color: var(--texte); font-weight: 700; }
.tresor.obtenu .tresor-emoji { filter: none; opacity: 1; }

/* ============================================================
   AMIS (#/amis, #/ami/<id>)
   ============================================================ */
.liste-amis { display: flex; flex-direction: column; gap: 12px; }
.carte-ami {
  display: flex; align-items: center; gap: 14px; background: white; border-radius: var(--rayon);
  padding: 14px 16px; box-shadow: var(--ombre); transition: transform .15s;
}
.carte-ami:hover { transform: translateX(4px); }
.ami-avatar {
  flex-shrink: 0; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  font-size: 34px; background: #f1f5f9; box-shadow: 0 0 0 3px white, 0 0 0 5px #e2e8f0;
}
.ami-corps { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ami-nom { font-weight: 800; font-size: 19px; }
.ami-stats { display: flex; gap: 14px; font-weight: 700; font-size: 15px; }
.ami-derniere { color: var(--doux); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ami-fleche { font-size: 30px; color: #cbd5e1; }
.amis-vide { margin: 0 0 8px; }

.ajout-amis { margin-top: 32px; }
.ajout-amis h2, .sous-titre { font-size: 21px; margin: 28px 0 12px; }
.ajout-amis h2 { margin-top: 0; }
/* Mon code d'explorateur et la saisie du code d'un copain */
.code-carte { padding: 18px 20px; }
.mon-code { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 12px;
  border-radius: 16px; background: color-mix(in srgb, var(--c), white 92%); border: 2px dashed color-mix(in srgb, var(--c), white 60%); }
.mon-code .code { font-family: ui-monospace, Consolas, monospace; font-size: 34px; font-weight: 800; letter-spacing: 4px; color: var(--c); user-select: all; }
.saisie-code { display: flex; gap: 10px; }
.saisie-code input {
  flex: 1; min-width: 0; font: inherit; font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: 3px;
  text-transform: uppercase; padding: 10px 14px; border-radius: 14px; border: 2px solid #e2e8f0;
}
.saisie-code input:focus { outline: none; border-color: var(--c); }

/* Invitations reçues (en haut) et envoyées (en attente) */
.invitations { margin-bottom: 24px; }
.invitations .sous-titre { margin-top: 0; }
.carte-invitation {
  display: flex; align-items: center; gap: 12px; background: white; border-radius: var(--rayon); padding: 12px 14px;
  box-shadow: var(--ombre); margin-bottom: 10px;
}
.invitations .carte-invitation { box-shadow: 0 0 0 3px #fcd34d, var(--ombre); }
.invitation-boutons { display: flex; gap: 6px; flex-shrink: 0; }
.attente-titre { font-size: 17px; color: var(--doux); margin: 20px 0 10px; }
.carte-invitation .ami-avatar { width: 48px; height: 48px; font-size: 28px; }

/* 👫 de la barre : nombre d'invitations reçues ; bandeau sur l'accueil */
.icone-barre { position: relative; }
.pastille {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--rouge); color: white; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px white;
}
.bandeau-invitation {
  display: flex; align-items: center; gap: 10px; margin: -6px 0 20px; padding: 12px 16px; border-radius: 16px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7); border: 2px solid #fcd34d; font-size: 16px;
}
.bandeau-invitation > span:first-of-type { flex: 1; }

.entete-ami { display: flex; align-items: center; gap: 16px; margin: 14px 0 20px; }
.entete-ami .ami-avatar { width: 76px; height: 76px; font-size: 44px; }
.entete-ami h1 { font-size: 28px; }

/* Tableau « l'ami / toi » : le meilleur des deux de chaque ligne en vert */
.duel { padding: 8px 18px; }
.duel-ligne { display: grid; grid-template-columns: 1fr 88px 88px; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid #f1f5f9; }
.duel-ligne > span:not(:first-child) { text-align: center; font-weight: 800; font-size: 18px; border-radius: 10px; padding: 2px 0; }
.duel-ligne .devant { background: #dcfce7; color: #15803d; }
.duel-ligne.matiere > span:not(:first-child) { font-size: 16px; }
.duel-tete { border-top: 0; color: var(--doux); }
.duel-tete > span:not(:first-child) { font-size: 14px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aventure-ami .progres-ligne { margin-top: 6px; }
.progres-ligne .qui { font-size: 20px; width: 26px; text-align: center; }

/* ============================================================
   MATIÈRE : LISTE DES AVENTURES
   ============================================================ */
.titre-page { font-size: 32px; color: var(--c); margin: 8px 0 24px; }
.liste-aventures { display: flex; flex-direction: column; gap: 18px; }
/* Filtre par niveau (CM1, CM2, 5e…) au-dessus des aventures d'une matière ; défile de côté sur téléphone */
.filtre-niveaux { display: flex; gap: 8px; margin: -10px 0 20px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.filtre-niveaux::-webkit-scrollbar { display: none; }
.filtre-niveau {
  flex: 0 0 auto; min-width: 56px; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 2px solid #e2e8f0;
  background: #fff; font: inherit; font-size: 16px; font-weight: 800; color: var(--doux); cursor: pointer; touch-action: manipulation;
}
.filtre-niveau.choisi { border-color: var(--c); background: var(--c); color: #fff; }
.carte-aventure {
  display: grid; grid-template-columns: 96px 1fr 64px; gap: 20px; align-items: center;
  background: white; border-radius: var(--rayon); padding: 20px; box-shadow: var(--ombre);
  border-left: 8px solid var(--c);
  transition: transform .15s;
}
.carte-aventure:hover { transform: translateX(4px); }
.aventure-emoji {
  font-size: 52px; width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px;
  background: color-mix(in srgb, var(--c), white 85%);
}
.carte-aventure h3 { font-size: 22px; margin: 6px 0 4px; }
.carte-aventure p { color: var(--doux); font-size: 15px; }
.aventure-tresor { font-size: 40px; text-align: center; filter: grayscale(.8); opacity: .6; }
.aventure-tresor.obtenu { filter: none; opacity: 1; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: #f1f5f9; color: var(--doux); }
.badge.theme { background: color-mix(in srgb, var(--c), white 85%); color: color-mix(in srgb, var(--c), black 30%); }
.badge.reco { background: #dcfce7; color: #15803d; }

.progres-ligne { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 15px; }
.jauge { flex: 1; height: 12px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.jauge > div { height: 100%; background: var(--c); border-radius: 99px; transition: width .4s; }

/* ============================================================
   AVENTURE : CHEMIN
   ============================================================ */
.entete-aventure {
  display: flex; gap: 22px; align-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c), white 80%), white);
  border-radius: var(--rayon); padding: 24px; box-shadow: var(--ombre);
}
.entete-emoji { font-size: 72px; }
.entete-aventure h1 { font-size: 28px; margin: 8px 0; }
.entete-aventure p { color: var(--doux); }

.chemin { display: flex; flex-direction: column; align-items: center; padding: 40px 0 20px; }
.pas { display: flex; flex-direction: column; align-items: center; transform: translateX(var(--x)); text-align: center; }
.noeud {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; font-size: 40px;
  background: color-mix(in srgb, var(--c), white 70%);
  box-shadow: 0 7px 0 color-mix(in srgb, var(--c), white 40%);
  transition: transform .1s;
}
a.noeud:hover { transform: scale(1.06); }
.noeud.reussi { background: var(--c); box-shadow: 0 7px 0 color-mix(in srgb, var(--c), black 25%); }
.noeud.actuel { background: var(--c); box-shadow: 0 7px 0 color-mix(in srgb, var(--c), black 25%), 0 0 0 8px color-mix(in srgb, var(--c), white 75%); animation: pulse 1.6s infinite; }
.noeud.verrouille { background: #e2e8f0; box-shadow: 0 7px 0 #cbd5e1; font-size: 30px; }
.noeud.tresor { background: #fef3c7; box-shadow: 0 7px 0 #fcd34d; filter: grayscale(.6); }
.noeud.tresor.obtenu { filter: none; animation: brille 2s infinite; }
.pas-info { margin-top: 14px; max-width: 220px; }
.pas-num { font-size: 13px; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: 1px; }
.pas-titre { font-weight: 800; }
.pointilles { height: 56px; border-left: 5px dotted #cbd5e1; transform: translateX(var(--x)); margin: 8px 0; }

@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes brille { 50% { box-shadow: 0 7px 0 #fcd34d, 0 0 30px #fcd34d; } }

/* ============================================================
   JEU
   ============================================================ */
.jeu { min-height: 100vh; display: flex; flex-direction: column; background: white; }
.jeu-haut { display: flex; align-items: center; gap: 18px; max-width: 920px; width: 100%; margin: 0 auto; padding: 22px 20px; }
.jeu-haut .jauge { height: 16px; }
.fermer { font-size: 22px; color: #94a3b8; }
.fermer:hover { color: var(--texte); }
.compteur { font-weight: 800; color: var(--doux); min-width: 48px; text-align: right; }
.jeu-corps { flex: 1; max-width: 720px; width: 100%; margin: 0 auto; padding: 20px; }

.jeu-bas {
  border-top: 2px solid #e2e8f0;
  padding: 20px max(20px, calc((100% - 720px) / 2));
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  min-height: 110px;
}
.jeu-bas:has(> .btn:only-child) { justify-content: center; }
.jeu-bas.juste { background: #dcfce7; border-color: #bbf7d0; --c: var(--vert); }
/* Juste à un accent près (hors français) : jaune, avec la bonne écriture et les lettres fautives surlignées */
.jeu-bas.presque { background: #fef9c3; border-color: #fde68a; --c: #a16207; }
.zone-saisie.presque input { border-color: #eab308; background: #fefce8; }
.bonne-ecriture { font-size: 1.15em; letter-spacing: .02em; }
.bonne-ecriture mark { background: #fde047; color: inherit; border-radius: 4px; padding: 0 2px; box-shadow: inset 0 -3px 0 #ca8a04; }
.bonne-ecriture-sous { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: #fefce8; border: 2px solid #fde68a; font-size: 17px; }
.jeu-bas.faux { background: #fee2e2; border-color: #fecaca; --c: var(--rouge); }
.retour-reponse { font-size: 16px; }
.retour-titre { font-size: 22px; font-weight: 800; color: var(--c); }
.pourquoi {
  margin-top: 16px; padding: 14px 16px; border-radius: 20px; background: white; box-shadow: var(--ombre);
  border-left: 6px solid var(--vert); animation: monte .25s; font-size: 17px; line-height: 1.5;
}
.pourquoi.faux { border-left-color: #f59e0b; }
.pourquoi > * + * { margin-top: 10px; }
.pourquoi-titre { font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .5px; color: #a16207; }
.pourquoi.juste .pourquoi-titre { color: #15803d; }
.pourquoi strong { color: #0f172a; }

.recit { text-align: center; padding-top: 20px; }
.lecons-defi { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; text-align: left; }
.lecon-defi {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; border-radius: 14px;
  background: #f1f5f9; font-weight: 700; touch-action: manipulation;
}
.lecon-defi span { font-size: 24px; }
.lecon-defi:hover { background: #e2e8f0; }
.recit-emoji { font-size: 90px; }
.recit h1 { font-size: 30px; margin: 4px 0 20px; }
.parchemin {
  text-align: left; font-size: 19px; line-height: 1.6;
  background: #fffbeb; border: 2px solid #fde68a; border-radius: var(--rayon); padding: 24px 28px;
}

.question h2 { font-size: 24px; margin: 10px 0 28px; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choix-btn {
  padding: 18px; font-size: 19px; font-weight: 700; text-align: center;
  border: 3px solid #e2e8f0; border-radius: 16px; box-shadow: 0 4px 0 #e2e8f0;
  transition: transform .08s;
}
.choix-btn:hover:not(:disabled) { border-color: var(--c); background: color-mix(in srgb, var(--c), white 92%); }
.choix-btn:active:not(:disabled) { transform: translateY(3px); }
.choix-btn.bon { border-color: var(--vert); background: #dcfce7; box-shadow: 0 4px 0 #86efac; }
.choix-btn.mauvais { border-color: var(--rouge); background: #fee2e2; box-shadow: 0 4px 0 #fca5a5; animation: secoue .4s; }
.choix-btn.eteint { opacity: .45; }

.zone-saisie { display: flex; align-items: center; gap: 12px; max-width: 420px; }
.unite { font-size: 20px; font-weight: 700; color: var(--doux); }

.ligne-reponse {
  min-height: 70px; padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  border-bottom: 3px solid #e2e8f0; margin-bottom: 28px;
}
.ligne-reponse.mauvais { animation: secoue .4s; }
.reserve { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 56px; }
.tuile {
  padding: 10px 18px; font-size: 19px; font-weight: 700; border: 3px solid #e2e8f0; border-radius: 14px;
  box-shadow: 0 4px 0 #e2e8f0; background: white;
}
.tuile:hover:not(:disabled) { border-color: var(--c); }

@keyframes secoue { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Fin d'étape */
.fin { text-align: center; padding-top: 10px; }
.grandes-etoiles { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.grande-etoile { font-size: 70px; color: #e2e8f0; }
.grande-etoile.pleine { color: var(--or); animation: apparait .5s backwards; text-shadow: 0 4px 0 #d97706; }
.fin h1 { font-size: 32px; }
.score { color: var(--doux); font-size: 19px; margin-top: 4px; }
.conseil { margin-top: 12px; color: #b45309; }
.tresor-gagne {
  display: flex; align-items: center; gap: 18px; text-align: left; margin: 24px auto 0; max-width: 480px;
  background: linear-gradient(135deg, #fef3c7, #fffbeb); border: 3px solid #fcd34d; border-radius: var(--rayon); padding: 18px 24px;
  animation: apparait .6s .7s backwards;
}
.tresor-gagne-emoji { font-size: 60px; }
.decouverte {
  text-align: left; margin-top: 28px; padding: 22px 26px; border-radius: var(--rayon);
  background: #f0fdf4; border: 2px solid #bbf7d0;
}
.decouverte-titre { font-weight: 800; color: #15803d; margin-bottom: 6px; }
.bilan-etape { margin-top: 16px; padding: 16px; border-radius: 20px; background: white; box-shadow: var(--ombre); text-align: left; }
.bilan-etape .decouverte-titre { color: #9a3412; }
.bilan-etape > * + * { margin-top: 10px; }
.carte-legende { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 14px; color: var(--doux); }
.carte-legende span { display: inline-flex; align-items: center; gap: 6px; }
.carte-legende i { width: 16px; height: 16px; border-radius: 4px; background: var(--z); opacity: .75; }
.decouverte-titre span { font-weight: 600; color: #4d7c0f; }
.decouverte h3 { font-size: 20px; margin-bottom: 6px; }

@keyframes apparait { from { transform: scale(0) rotate(-30deg); opacity: 0; } }

/* ============================================================
   TOASTS & MODALE
   ============================================================ */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--texte); color: white; padding: 12px 20px; border-radius: 12px; font-weight: 600; box-shadow: var(--ombre); animation: monte .25s; }
.toast.erreur { background: var(--rouge); }
@keyframes monte { from { transform: translateY(20px); opacity: 0; } }

.modal-fond { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); display: grid; place-items: center; z-index: 50; }
.modal { background: white; border-radius: var(--rayon); padding: 28px; max-width: 420px; text-align: center; font-size: 18px; box-shadow: var(--ombre); }

/* ============================================================
   PETITS ÉCRANS
   ============================================================ */
@media (max-width: 640px) {
  .choix { grid-template-columns: 1fr; }
  .carte-aventure { grid-template-columns: 64px 1fr; }
  .aventure-emoji { width: 64px; height: 64px; font-size: 36px; }
  .aventure-tresor { display: none; }
  .grille-avatars { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .avatar-choix { font-size: 26px; }
  .jeu-bas { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   DROITE GRADUÉE
   ============================================================ */
.droite { width: 100%; max-width: 680px; display: block; margin: 10px auto 0; overflow: visible; }
.droite .axe { stroke: #334155; stroke-width: 3; }
.droite marker path { fill: #334155; }
.droite .graduation { stroke: #334155; stroke-width: 2; }
.droite .graduation.zero { stroke-width: 4; }
.droite .nombre { font-size: 18px; font-weight: 700; fill: #334155; text-anchor: middle; }
.droite .zone-clic { fill: transparent; cursor: pointer; }
.droite .zone-clic:hover { fill: color-mix(in srgb, var(--c), transparent 85%); }
.droite .marque path { fill: var(--c); }
.droite .marque text { font-size: 20px; font-weight: 800; text-anchor: middle; fill: var(--c); }
.droite .marque.bon path, .droite .marque.bon text { fill: var(--vert); }
.droite .marque.mauvais path, .droite .marque.mauvais text { fill: var(--rouge); opacity: .7; }
.indice.centre { text-align: center; margin-top: 10px; }

/* ============================================================
   INVENTIONS (trésors physique / techno)
   ============================================================ */
button.tresor { font: inherit; cursor: pointer; }
.tresor-type { font-size: 12px; font-weight: 700; color: #7c3aed; background: #f3e8ff; border-radius: 99px; padding: 1px 8px; }
.invention {
  text-align: left; margin: 18px auto 0; max-width: 620px; padding: 22px 26px; border-radius: var(--rayon);
  background: linear-gradient(160deg, #faf5ff, #f5f3ff); border: 2px solid #ddd6fe;
}
.invention .decouverte-titre { color: #6d28d9; }
.invention .decouverte-titre span { color: #7c3aed; }
.invention h3 { font-size: 21px; margin-bottom: 6px; }
.invention-emoji { font-size: 44px; float: right; margin-left: 12px; }
.modal.fiche { max-width: 620px; text-align: left; padding: 10px 24px 24px; }
.modal.fiche .invention { border: none; background: none; padding: 14px 0 0; margin: 0; }

/* ============================================================
   CARTE ILLUSTRÉE D'AVENTURE (décors de public/decors.js)
   ============================================================ */
/* La carte est grande (on s'y déplace) : sur téléphone elle dépasse l'écran en largeur et défile au doigt dans .carte-zone */
.carte-zone {
  max-width: 600px; margin: 0 auto; border-radius: 28px; overflow: hidden;
  box-shadow: var(--ombre), inset 0 0 0 4px white; scrollbar-width: none; overscroll-behavior-x: contain;
}
.carte-zone::-webkit-scrollbar { display: none; }
.carte-map { position: relative; width: 100%; aspect-ratio: 400 / 720; overflow: hidden; }
/* Carte chargée (7 nœuds ou plus, défi compris) sur téléphone : bulles réduites au titre (les séries se lisent sur l'anneau) */
@media (max-width: 640px) {
  .carte-map.serree .bulle .pas-num, .carte-map.serree .bulle .progres-etape { display: none; }
  .carte-map.serree .bulle { padding: 4px 8px; }
  .carte-map.serree .bulle .pas-titre { font-size: 12px; line-height: 1.2; }
}
.carte-astuce { text-align: center; color: var(--doux, #64748b); font-size: 14px; margin: 22px 0 10px; }

/* Lieux de la carte : une pastille ✨ qui ouvre une bulle d'info */
.repere {
  position: absolute; transform: translate(-50%, -50%); z-index: 2; width: 44px; height: 44px; padding: 0;
  border: none; background: none; display: grid; place-items: center; cursor: pointer; touch-action: manipulation;
}
.repere span {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 17px;
  background: rgba(255, 255, 255, .9); box-shadow: 0 0 0 3px rgba(250, 204, 21, .9), 0 3px 8px rgba(0, 0, 0, .25);
  animation: repere-pulse 2.4s ease-in-out infinite;
}
.repere.ouvert span { box-shadow: 0 0 0 4px #f59e0b, 0 3px 8px rgba(0, 0, 0, .3); animation: none; transform: scale(1.12); }
@keyframes repere-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(250, 204, 21, .9), 0 3px 8px rgba(0, 0, 0, .25); } 50% { box-shadow: 0 0 0 7px rgba(250, 204, 21, .35), 0 3px 8px rgba(0, 0, 0, .25); } }
.repere-info {
  position: absolute; z-index: 6; width: min(260px, 80%); background: white; border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3); font-size: 14px; line-height: 1.45; animation: monte .25s;
}
.repere-info > strong { display: block; font-size: 15px; margin-bottom: 4px; }
.repere-info p { margin: 0; text-align: left; }
.carte-map > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-bord { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 16; stroke-linecap: round; }
.route-base { fill: none; stroke: rgba(68, 64, 60, .45); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 12; }
.route-progres { fill: none; stroke: var(--c); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 0 100000; transition: stroke-dasharray .8s; }

.etape-carte { position: absolute; transform: translate(-50%, -50%); z-index: 1; }
.etape-carte .noeud { width: 62px; height: 62px; font-size: 28px; border: 4px solid white; }
.etape-carte .noeud.verrouille { font-size: 22px; }
.etape-carte .noeud.actuel { box-shadow: 0 6px 0 color-mix(in srgb, var(--c), black 25%), 0 0 0 7px rgba(255, 255, 255, .6); }
.noeud-depart { font-size: 26px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.bulle {
  position: absolute; top: 50%; left: calc(100% + 10px); transform: translateY(-50%);
  width: max-content; max-width: 150px; padding: 5px 10px; border-radius: 12px;
  background: rgba(255, 255, 255, .94); box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
  font-size: 13px; line-height: 1.25;
}
.bulle .pas-num { font-size: 10px; }
.etape-carte.gauche .bulle { left: auto; right: calc(100% + 10px); text-align: right; }
.moi {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%);
  font-size: 26px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); animation: sautille 1.2s infinite; pointer-events: none;
}
@keyframes sautille { 50% { transform: translateX(-50%) translateY(-6px); } }

@media (max-width: 640px) {
  .etape-carte .noeud { width: 52px; height: 52px; font-size: 24px; }
  .bulle { max-width: 110px; font-size: 12px; }
}

/* ============================================================
   TÉLÉPHONE (prioritaire : les élèves jouent surtout sur mobile)
   ============================================================ */
html { -webkit-text-size-adjust: 100%; }
a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Le jeu tient dans l'écran visible (barres du navigateur mobile comprises) ; le bouton du bas reste accessible */
.jeu { min-height: 100dvh; }
.jeu-bas { position: sticky; bottom: 0; background: white; z-index: 5; }
/* ⭐ Réponse juste : « Continuer » en bas de page (pas collé), pour lire le « Le savais-tu ? » avant de passer */
.jeu-bas.en-bas { position: static; }

/* ============================================================
   GÉOMÉTRIE : cadre de dessin (règle, compas) et démonstrations
   ============================================================ */
.btn.petit { padding: 8px 12px; font-size: 14px; min-height: 40px; }
.geo { display: flex; flex-direction: column; gap: 8px; }
.geo-outils { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.geo-outil {
  min-height: 52px; padding: 4px 2px; border-radius: 12px; background: white; border: 2px solid #e2e8f0; box-shadow: 0 3px 0 #cbd5e1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--texte);
}
.geo-outil span { font-size: 20px; line-height: 1; }
.geo-outil.actif { border-color: var(--c); background: color-mix(in srgb, var(--c), white 85%); box-shadow: 0 3px 0 var(--c); }
.geo-outil:disabled { opacity: .4; }
.geo-compas { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.geo-compas input { width: 70px; font-size: 18px; padding: 8px; border: 2px solid #cbd5e1; border-radius: 10px; text-align: center; }
.geo-aide { margin: 0; font-size: 14px; color: var(--doux); min-height: 2.6em; }
.geo-cadre { width: 100%; height: auto; display: block; background: white; border-radius: 12px; box-shadow: inset 0 0 0 2px #e2e8f0; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.geo-cadre.interactif { cursor: crosshair; }
.geo-fond { fill: white; }
.geo-carreau { stroke: #bfdbfe; stroke-width: 1; }
.geo-donne { stroke: #1e293b; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.geo-eleve { stroke: #2563eb; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.geo-cercle { stroke-width: 1.5; }
.geo-solution { stroke: #16a34a; stroke-width: 3; stroke-dasharray: 8 6; fill: none; opacity: .8; }
.geo-point { stroke: #1e293b; stroke-width: 2.5; fill: none; }
.geo-point-eleve { stroke: #2563eb; }
.geo-solution-point { stroke: #16a34a; stroke-width: 3; fill: none; }
.geo-nom { font: 800 17px system-ui, sans-serif; fill: #1e293b; text-anchor: middle; paint-order: stroke; stroke: white; stroke-width: 4px; }
.geo-nom-eleve { fill: #2563eb; }
.geo-nom-solution { fill: #16a34a; }
.geo-mesure { font: 700 12px system-ui, sans-serif; fill: #2563eb; text-anchor: middle; paint-order: stroke; stroke: white; stroke-width: 3px; }
.geo-selection { fill: color-mix(in srgb, #f59e0b, transparent 70%); stroke: #f59e0b; stroke-width: 2; }
.geo-legende { margin: 0; font-size: 15px; }
.geo-manque { display: block; color: var(--rouge); font-weight: 700; }
.geo-vert { color: #16a34a; font-weight: 800; }
.bloc-figure { margin: 0 0 8px; }
/* Dessin d'aide sous une question qui parle d'une figure (pas noté) */
.geo-aide-dessin { margin: 0 0 14px; padding: 8px 10px 10px; border-radius: 16px; background: #f8fafc; border: 2px dashed #cbd5e1; }
.geo-aide-dessin summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; gap: 6px; list-style: none; }
.geo-aide-dessin summary::-webkit-details-marker { display: none; }
.geo-aide-dessin summary::after { content: '▾'; color: var(--doux); }
.geo-aide-dessin:not([open]) summary::after { content: '▸'; }
.geo-aide-titre { flex: 1; }
.geo-aide-dessin .pas-note { font-weight: 700; font-size: 12px; color: var(--doux); background: #e2e8f0; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.geo-aide-dessin .geo-cadre { max-height: 46vh; }
.bloc-figure .geo-cadre { max-width: 420px; margin: 0 auto; }

.demo { display: flex; flex-direction: column; gap: 12px; }
.demo-donnees, .demo-but { background: #f8fafc; border-radius: 14px; padding: 10px 12px; }
.demo-titre { font-weight: 800; margin-bottom: 6px; }
.demo-titre span { font-weight: 600; font-size: 13px; color: var(--doux); }
.demo-but { background: color-mix(in srgb, var(--c), white 88%); }
.demo-puces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.demo-puce { min-height: 40px; padding: 6px 12px; border-radius: 99px; background: white; border: 2px solid color-mix(in srgb, var(--c), white 50%); font-weight: 700; font-size: 14px; text-align: left; }
.demo-etape { border: 2px solid #e2e8f0; border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: white; }
.demo-etape.juste { border-color: #22c55e; background: #f0fdf4; }
.demo-etape.faux { border-color: #ef4444; background: #fef2f2; }
.demo-tete { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.demo-retirer { width: 44px; height: 44px; border-radius: 12px; background: #f1f5f9; font-size: 16px; }
.demo-mot { font-weight: 800; color: var(--c); margin-top: 4px; }
.demo-champ { width: 100%; font: inherit; font-size: 16px; padding: 10px; border: 2px solid #cbd5e1; border-radius: 12px; resize: vertical; background: white; }
.demo-champ:focus { outline: none; border-color: var(--c); }
.demo-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.demo-suggestion { text-align: left; padding: 8px 10px; border-radius: 12px; background: #f8fafc; border: 2px solid #e2e8f0; display: flex; flex-direction: column; gap: 2px; min-height: 44px; }
.demo-suggestion strong { font-size: 14px; }
.demo-suggestion span { font-size: 13px; color: var(--doux); }
.demo-toutes summary { cursor: pointer; font-weight: 700; padding: 8px 0; min-height: 44px; display: flex; align-items: center; }
.demo-toutes .demo-suggestion { margin-bottom: 6px; width: 100%; }
.demo-propriete { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--c), white 90%); }
.demo-propriete div { display: flex; flex-direction: column; gap: 2px; }
.demo-propriete strong { font-size: 14px; }
.demo-propriete span { font-size: 13px; }
.demo-touches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.demo-touche { min-width: 44px; min-height: 44px; border-radius: 10px; background: #f1f5f9; font-weight: 800; font-size: 17px; }
.demo-message { margin: 4px 0 0; color: var(--rouge); font-weight: 700; font-size: 14px; }
.demo-ajouter { align-self: flex-start; }
.demo-modele { background: white; border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.demo-modele p { margin: 6px 0; line-height: 1.45; }
.demo-modele b { color: var(--c); }

.droite-reglage { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.droite-reglage .indice { text-align: center; flex: 1; }
.reglage {
  width: 52px; height: 52px; border-radius: 14px; font-size: 20px; color: var(--c);
  background: white; border: 3px solid #e2e8f0; box-shadow: 0 4px 0 #e2e8f0;
}
.reglage:active { transform: translateY(3px); box-shadow: 0 1px 0 #e2e8f0; }

.etape-carte.tresor-pos .bulle { top: auto; bottom: calc(100% + 6px); left: 50%; right: auto; transform: translateX(-50%); text-align: center; }

@media (max-width: 640px) {
  .page { padding: 16px 14px 40px; }
  .barre { padding: 10px 14px; }
  .bienvenue { margin: 6px 0 18px; }
  .bienvenue h1, .titre-page { font-size: 26px; }
  .carte-matiere { padding: 20px; }
  .tresors { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .carte-ami { padding: 12px; gap: 12px; }
  .ami-avatar { width: 50px; height: 50px; font-size: 28px; }
  .mon-code .code { font-size: 30px; }
  .carte-invitation { padding: 10px 12px; gap: 10px; }
  .entete-ami .ami-avatar { width: 64px; height: 64px; font-size: 36px; }
  .entete-ami h1 { font-size: 23px; }
  .duel { padding: 6px 12px; }
  .duel-ligne { grid-template-columns: 1fr 72px 72px; font-size: 15px; }

  .carte-aventure { grid-template-columns: 56px 1fr; gap: 12px; padding: 14px; border-left-width: 6px; }
  .aventure-emoji { width: 56px; height: 56px; font-size: 30px; border-radius: 16px; align-self: start; }
  .carte-aventure h3 { font-size: 19px; }
  .carte-aventure p, .entete-aventure .intro:not(.deplie) {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .carte-aventure p { font-size: 14px; }

  .entete-aventure { padding: 14px 16px; gap: 12px; align-items: flex-start; }
  .entete-emoji { font-size: 40px; }
  .entete-aventure h1 { font-size: 22px; margin: 6px 0 4px; }
  .entete-aventure .intro { font-size: 14px; cursor: pointer; }
  .carte-zone { width: 100vw; margin-left: calc(50% - 50vw); border-radius: 0; box-shadow: none; }
  .carte-astuce { margin: 14px 8px 8px; font-size: 13px; }

  .jeu-haut { padding: 14px 16px; gap: 12px; }
  .jeu-corps { padding: 12px 16px; }
  .jeu-bas { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); min-height: 0; gap: 12px; }
  .btn.gros { min-width: 0; width: 100%; }
  .question h2 { font-size: 21px; margin: 6px 0 20px; }
  .choix { gap: 10px; }
  .choix-btn { padding: 14px; font-size: 18px; }
  .recit-emoji { font-size: 64px; }
  .recit h1 { font-size: 24px; margin-bottom: 14px; }
  .parchemin { font-size: 17px; padding: 18px 20px; }
  .tuile { padding: 10px 14px; font-size: 18px; }
  .droite .nombre { font-size: 17px; }

  .grande-etoile { font-size: 54px; }
  .fin h1 { font-size: 26px; }
  .fin .actions .btn { flex: 1; }
  .decouverte, .invention { padding: 18px; }
  .modal { margin: 16px; max-height: 85dvh; overflow: auto; }
  .toasts { width: calc(100% - 32px); }
  .toast { text-align: center; }
}

/* Écran tactile : pas d'effet de survol qui reste « collé » après un toucher */
@media (hover: none) {
  .profil-choix:hover, .carte-matiere:hover, .carte-aventure:hover, a.noeud:hover, .avatar-choix:hover { transform: none; }
  .choix-btn:hover:not(:disabled) { border-color: #e2e8f0; background: white; }
  .tuile:hover:not(:disabled) { border-color: #e2e8f0; }
  .droite .zone-clic:hover { fill: transparent; }
  .btn:hover:not(:disabled) { filter: none; }
}

/* ============================================================
   SÉRIES D'UNE ÉTAPE
   ============================================================ */
/* Anneau doré autour du nœud : part des séries réussies (--avance, posé par noeudEtape).
   @property permet d'animer sa croissance quand on revient sur la carte après une série réussie */
@property --avance { syntax: '<percentage>'; inherits: true; initial-value: 0%; }
.noeud { transition: --avance 1.2s ease-out .3s, transform .1s; }
.noeud.en-fete { animation: fete-noeud 1.4s ease-out .3s; z-index: 3; }
@keyframes fete-noeud { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18); } }
.bravo-bulle {
  position: absolute; left: 50%; bottom: calc(100% + 14px); transform: translateX(-50%); white-space: nowrap;
  background: #facc15; color: #713f12; font-weight: 800; font-size: 15px; padding: 6px 12px; border-radius: 99px;
  box-shadow: var(--ombre); animation: monte .4s; pointer-events: none;
}
.modal.fete { max-width: 440px; width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal.fete > * + * { margin-top: 12px; }
.fete-titre { font-size: 22px; font-weight: 800; color: #15803d; }
.modal.fete .invention { text-align: left; border: none; padding: 0; margin: 0; }
.puzzle { width: 64px; height: 64px; display: block; margin: 0 auto; }
.puzzle.grand { width: 190px; height: 190px; }
.morceau-nouveau { animation: morceau 1s ease-out; transform-origin: 100px 100px; }
@keyframes morceau { 0% { transform: scale(1.5); opacity: 0; } 60% { transform: scale(.95); opacity: 1; } 100% { transform: scale(1); } }
.plan-montage {
  border-radius: 16px; padding: 14px; color: #e0f2fe; text-align: left;
  background: #1e3a8a linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px) 0 0 / 16px 16px;
  background-color: #1e3a8a;
}
.plan-titre { font-weight: 800; letter-spacing: .5px; }
.plan-dessin { font-size: 90px; text-align: center; filter: grayscale(1) brightness(1.8); opacity: .85; margin: 6px 0; }
.plan-montage ol { margin: 0; padding-left: 22px; line-height: 1.6; }

/* Anneau autour du nœud, découpé en un morceau par série (--n) : les séries réussies en or (--avance, posé par noeudEtape) */
.noeud { position: relative; cursor: pointer; }
.noeud.verrouille, .noeud.tresor:not(button) { cursor: default; }
.noeud[style*="--avance"]::after {
  content: ''; position: absolute; inset: -11px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(#facc15 var(--avance), rgba(255, 255, 255, .8) 0);
  --morceau: calc(360deg / var(--n, 4));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px)),
    repeating-conic-gradient(from 8deg, #000 0 calc(var(--morceau) - 16deg), transparent 0 var(--morceau));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px)),
    repeating-conic-gradient(from 8deg, #000 0 calc(var(--morceau) - 16deg), transparent 0 var(--morceau));
  -webkit-mask-composite: source-in; mask-composite: intersect;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}
@media (hover: hover) { button.noeud:hover { transform: scale(1.06); } }

.progres-etape { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; white-space: nowrap; }
.points-series { display: inline-flex; gap: 3px; }
.points-series i { width: 8px; height: 8px; border-radius: 50%; background: #e2e8f0; display: block; }
.points-series i.fait { background: #f59e0b; }
.points-series.grand { justify-content: center; gap: 8px; margin: 14px 0 4px; display: flex; }
.points-series.grand i { width: 14px; height: 14px; }
.points-series.grand i.ici { box-shadow: 0 0 0 3px white, 0 0 0 5px var(--c); }
.pas-info .progres-etape { justify-content: center; }

.titre-serie { font-size: 20px; color: var(--c); margin: 6px 0 16px; }
.etape-gagnee {
  display: inline-block; margin-top: 14px; padding: 8px 18px; border-radius: 99px;
  background: color-mix(in srgb, var(--c), white 85%); color: color-mix(in srgb, var(--c), black 25%); font-weight: 800;
}

/* Panneau des séries : glisse depuis le bas sur téléphone, centré sur ordinateur */
.panneau {
  position: relative; width: 100%; max-width: 480px; max-height: 90dvh; overflow: auto;
  background: white; border-radius: 24px; padding: 22px 20px 20px; box-shadow: var(--ombre);
  animation: monte .25s;
}
.panneau-fermer { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; color: #94a3b8; font-size: 18px; }
.panneau-entete { display: flex; align-items: center; gap: 14px; padding-right: 40px; margin-bottom: 16px; }
.panneau-emoji {
  font-size: 34px; width: 60px; height: 60px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--c), white 80%);
}
.panneau-entete h2 { font-size: 20px; }
.panneau .btn.gros { width: 100%; margin-top: 16px; }
.series-liste { display: flex; flex-direction: column; gap: 8px; }
.serie-ligne {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px;
  border-radius: 14px; border: 2px solid #e2e8f0; background: white;
}
.serie-ligne.actuelle { border-color: var(--c); background: color-mix(in srgb, var(--c), white 92%); }
.serie-ligne.verrouillee { opacity: .55; }
.serie-num {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: #f1f5f9; color: var(--doux);
}
.serie-ligne.faite .serie-num { background: #f59e0b; color: white; }
.serie-ligne.actuelle .serie-num { background: var(--c); color: white; }
.serie-texte { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.serie-texte span { font-size: 14px; color: var(--doux); }
.serie-etat { font-size: 15px; }

@media (max-width: 640px) {
  .panneau-fond { align-items: end; }
  .panneau-fond .panneau {
    max-width: none; border-radius: 24px 24px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .etape-carte .noeud[style*="--avance"]::after { inset: -10px; }
}
@media (max-width: 640px) {
  .fin .actions { flex-wrap: nowrap; }
  .fin .actions .btn { padding: 12px 14px; white-space: nowrap; font-size: 16px; }
}

/* ============================================================
   LEÇON (fiches illustrées avant la première série)
   ============================================================ */
.lecon { padding-top: 4px; }
.pas-num.centre { text-align: center; }
.fiche-lecon {
  background: white; border-radius: 24px; padding: 22px 20px; margin-top: 12px; box-shadow: var(--ombre);
  border-top: 6px solid var(--c); animation: monte .25s;
}
.fiche-emoji {
  font-size: 44px; width: 76px; height: 76px; margin: -60px auto 6px; display: grid; place-items: center;
  border-radius: 50%; background: white; box-shadow: 0 0 0 5px color-mix(in srgb, var(--c), white 75%);
}
.fiche-lecon h2 { text-align: center; font-size: 23px; color: color-mix(in srgb, var(--c), black 20%); margin-bottom: 14px; }
.fiche-lecon > * + * { margin-top: 14px; }
.fiche-lecon strong { color: color-mix(in srgb, var(--c), black 25%); }
.bloc-texte { font-size: 17px; line-height: 1.55; }
.ligne-idee + .ligne-idee { margin-top: 8px; }
.bloc-exemple .suite { padding-left: 1.2em; }
.bloc-exemple .suite + div:not(.suite) { margin-top: 10px; }
.bloc-titre { font-weight: 800; margin-bottom: 6px; }
.bloc-retenir {
  background: #fef9c3; border: 2px solid #fde047; border-radius: 16px; padding: 12px 14px; font-size: 17px; line-height: 1.5;
}
.bloc-retenir .bloc-titre { color: #a16207; text-transform: uppercase; font-size: 13px; letter-spacing: 1px; }
.bloc-astuce {
  display: flex; gap: 10px; align-items: flex-start; background: #e0f2fe; border-radius: 16px; padding: 12px 14px; font-size: 16px; line-height: 1.5;
}
.astuce-emoji { font-size: 22px; line-height: 1.2; }
.bloc-exemple {
  background: color-mix(in srgb, var(--c), white 93%); border-left: 5px solid var(--c); border-radius: 0 14px 14px 0;
  padding: 12px 14px; font-size: 18px; font-weight: 600; line-height: 1.7; font-variant-numeric: tabular-nums;
}
.bloc-exemple .bloc-titre { font-size: 15px; color: var(--doux); font-weight: 700; line-height: 1.4; }
.bloc-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.vignette {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding: 12px 8px;
  border-radius: 16px; background: color-mix(in srgb, var(--c), white 92%); line-height: 1.3;
}
.vignette-emoji { font-size: 34px; margin-bottom: 2px; }
.vignette strong { font-size: 16px; }
.vignette span:last-child:not(.vignette-emoji) { font-size: 14px; color: var(--doux); }
.bloc-tableau { overflow-x: auto; border-radius: 14px; border: 2px solid #e2e8f0; }
.bloc-tableau table { border-collapse: collapse; width: 100%; font-size: 16px; }
.bloc-tableau th { background: color-mix(in srgb, var(--c), white 85%); font-weight: 800; }
.bloc-tableau th, .bloc-tableau td { padding: 8px 10px; text-align: center; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.bloc-tableau.tableau-texte th, .bloc-tableau.tableau-texte td { white-space: normal; font-size: 15px; line-height: 1.3; }
.bloc-tableau tr:last-child td { border-bottom: 0; }
.bloc-tableau tbody tr:nth-child(even) { background: #f8fafc; }
.bloc-chaine { list-style: none; display: flex; flex-direction: column; align-items: stretch; gap: 22px; }
.bloc-chaine li {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--c), white 92%); font-size: 16px; font-weight: 600; line-height: 1.35;
}
.bloc-chaine li:not(:last-child)::after {
  content: '⬇'; position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); color: var(--c); font-size: 16px;
}
.chaine-emoji { font-size: 26px; }
.bloc-frise { list-style: none; position: relative; padding-left: 4px; }
.bloc-frise::before { content: ''; position: absolute; left: 49px; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--c), white 60%); }
.bloc-frise li { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 6px 0; }
.frise-date {
  position: relative; z-index: 1; flex-shrink: 0; min-width: 92px; padding: 4px 8px; border-radius: 99px; text-align: center;
  background: var(--c); color: white; font-weight: 800; font-size: 14px;
}
.frise-texte { font-size: 16px; line-height: 1.4; padding-top: 3px; }
.bloc-frise li:has(.frise-date) { margin-left: 0; }
.frise-illustree li { align-items: center; }
.frise-illustree .frise-texte { flex: 1; font-size: 15px; padding-top: 0; }
.frise-image {
  flex-shrink: 0; width: 84px; height: 48px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c), white 88%);
}
.frise-image svg { width: 100%; height: 100%; display: block; }
.frise-emoji { font-size: 28px; }
.droite-lecon { margin-top: 6px; }
.bloc-fractions { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; }
.bloc-fractions figure { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.disque { width: 84px; height: 84px; }
.bloc-fractions figcaption { font-weight: 800; font-size: 19px; color: color-mix(in srgb, var(--c), black 25%); }
.bloc-phrase { display: flex; flex-wrap: wrap; gap: 8px 6px; justify-content: center; padding: 6px 0; }
.segment { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.segment-mots { font-size: 19px; font-weight: 700; padding: 4px 8px; border-radius: 10px; }
.segment-role { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.role-sujet .segment-mots { background: #dbeafe; color: #1d4ed8; } .role-sujet .segment-role { color: #1d4ed8; }
.role-verbe .segment-mots { background: #fee2e2; color: #b91c1c; } .role-verbe .segment-role { color: #b91c1c; }
.role-complement .segment-mots { background: #dcfce7; color: #15803d; } .role-complement .segment-role { color: #15803d; }
.role-nom .segment-mots { background: #ede9fe; color: #6d28d9; } .role-nom .segment-role { color: #6d28d9; }
.role-adjectif .segment-mots { background: #ffedd5; color: #c2410c; } .role-adjectif .segment-role { color: #c2410c; }
.role-determinant .segment-mots { background: #f1f5f9; color: #475569; } .role-determinant .segment-role { color: #475569; }
/* Leçon racontée (histoire) : date et lieu du chapitre, cartes et scènes dessinées (public/illustrations.js) */
.fiche-quand { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 6px; }
.fiche-quand span { padding: 4px 12px; border-radius: 99px; font-weight: 800; font-size: 15px; }
.fiche-quand .quand { background: var(--c); color: white; }
.fiche-quand .ou { background: color-mix(in srgb, var(--c), white 88%); color: color-mix(in srgb, var(--c), black 35%); }
/* Dessin d'un calcul (bloc « operation ») : groupes d'objets, partage, tas qu'on ajoute ou dont on enlève */
.bloc-operation { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.operation-ligne { margin: 0; padding: 10px; border-radius: 14px; background: #fffbeb; border: 2px solid #fde68a; }
.operation-ligne figcaption { margin-top: 8px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.groupes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.groupe { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; border-radius: 10px; background: #fff; border: 1.5px solid #fcd34d; }
.porteur { font-size: 22px; line-height: 1; }
.groupe.compact { flex-direction: row; gap: 4px; padding: 3px 6px; }
.groupe.compact .porteur { font-size: 18px; }
.quantite { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 1px; max-width: 108px; }
.operation-ligne > .quantite { display: flex; max-width: 240px; margin: 0 auto; }
.objet { font-size: 15px; line-height: 1.15; }
.paquet { display: inline-flex; align-items: center; gap: 1px; padding: 1px 5px; border-radius: 8px; background: #fef3c7; border: 1.5px solid #f59e0b; font-size: 14px; }
.paquet b { font-size: 13px; color: #92400e; }
.points-suite { font-size: 22px; font-weight: 800; color: var(--doux); }
.egal-dessin { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 6px; font-weight: 800; color: #92400e; }
.quantite.resultat { max-width: 240px; padding: 3px 6px; border-radius: 10px; background: #dcfce7; border: 1.5px solid #86efac; }
.tas { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.tas .quantite { max-width: 150px; padding: 3px 6px; border-radius: 10px; background: #fff; border: 1.5px solid #fcd34d; }
.tas .quantite.resultat { background: #dcfce7; border-color: #86efac; }
.tas .quantite.enleve { position: relative; background: #fee2e2; border-color: #fca5a5; }
.quantite.enleve > * { opacity: .5; }
.quantite.enleve::after { content: ''; position: absolute; left: 2px; right: 2px; top: 50%; border-top: 3px solid #dc2626; transform: rotate(-14deg); }
.signe { font-size: 22px; font-weight: 800; color: #92400e; }
.bloc-illustration { margin-left: 0; margin-right: 0; }
.bloc-illustration svg { display: block; width: 100%; height: auto; border-radius: 16px; }
.bloc-illustration figcaption { text-align: center; font-size: 14px; color: var(--doux); margin-top: 6px; }
.scene-lecon .scene-nom { font-size: 13px; font-weight: 800; fill: #1e293b; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; stroke-linejoin: round; }
.carte-lecon text { paint-order: stroke; stroke-linejoin: round; }
.carte-lecon .mer { fill: #a9d8f0; }
.carte-lecon .terre { fill: #f3e2b8; stroke: #cdae72; stroke-width: 1; }
.carte-lecon .zone { fill: var(--z); fill-opacity: .3; stroke: var(--z); stroke-width: 1.5; stroke-dasharray: 4 3; }
.carte-lecon .fleuve { fill: none; stroke: #5aaee0; stroke-width: 2; stroke-linecap: round; }
.carte-lecon .fleuve-nom { font-size: 10px; font-style: italic; fill: #2b6f99; stroke: #f3e2b8; stroke-width: 3px; }
.carte-lecon .region { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; fill: #9a6b2f; stroke: #f3e2b8; stroke-width: 3px; }
.carte-lecon .mer-nom { font-size: 11px; font-style: italic; font-weight: 600; fill: #2b6f99; stroke: #a9d8f0; stroke-width: 3px; }
.carte-lecon .deco { font-size: 15px; }
.carte-lecon .lieu-nom { font-size: 13px; font-weight: 800; fill: #1e293b; stroke: white; stroke-width: 3.5px; }
.carte-lecon .lieu-emoji { font-size: 16px; }
.carte-lecon .point { fill: #1e293b; stroke: white; stroke-width: 2; }
.carte-lecon .actif .point { fill: var(--c); }
.carte-lecon .actif .lieu-nom { fill: color-mix(in srgb, var(--c), black 30%); }
.carte-lecon .halo { fill: var(--c); opacity: .35; transform-box: fill-box; transform-origin: center; animation: halo-lieu 1.6s ease-out infinite; }
.carte-lecon .trajet { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 7 5; animation: trajet-defile 1s linear infinite; }
.carte-lecon .trajet-nom { font-size: 12px; font-weight: 800; stroke: white; stroke-width: 3.5px; }
@keyframes trajet-defile { to { stroke-dashoffset: -12; } }
@keyframes halo-lieu { from { transform: scale(.6); opacity: .6; } to { transform: scale(2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .carte-lecon .trajet, .carte-lecon .halo { animation: none; } }
.bloc-icones { display: flex; flex-direction: column; gap: 8px; }
.icone { border-radius: 16px; background: color-mix(in srgb, var(--c), white 90%); }
.icone summary {
  list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px 6px 10px;
  cursor: pointer; font-weight: 700; font-size: 16px; line-height: 1.25; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.icone summary::-webkit-details-marker { display: none; }
.icone-emoji { font-size: 24px; }
.icone-texte { flex: 1; }
.icone-plus {
  flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--c); color: white; font-weight: 800; font-size: 18px; transition: transform .2s;
}
.icone[open] .icone-plus { transform: rotate(45deg); }
.icone[open] { background: color-mix(in srgb, var(--c), white 84%); }
.icone-scene { margin: 0 12px 12px; animation: monte .2s; }
.icone-scene svg { display: block; width: 100%; height: auto; border-radius: 12px; }
.icone-info { padding: 0 14px 12px 46px; font-size: 15px; line-height: 1.45; color: var(--texte); animation: monte .2s; }
.lecon .points-series.grand { margin-top: 16px; }
.glisser-indice { font-size: 14px; }
.jauge-lecon div { background: #38bdf8; }
.lien-lecon { width: 100%; margin-top: 10px; }
.jeu-bas .btn.secondaire:not(.gros) { padding-left: 18px; padding-right: 18px; }

@media (max-width: 640px) {
  .fiche-lecon { padding: 18px 14px; border-radius: 20px; }
  .fiche-lecon h2 { font-size: 21px; }
  .bloc-cartes { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bloc-texte, .bloc-retenir { font-size: 16px; }
  .bloc-exemple { font-size: 17px; }
  .bloc-tableau table { font-size: 15px; }
  .bloc-tableau th, .bloc-tableau td { padding: 7px 6px; }
  .frise-date { min-width: 80px; font-size: 13px; }
  .bloc-frise::before { left: 43px; }
  .frise-image { width: 70px; height: 42px; }
  .frise-illustree li { gap: 10px; }
  .lecon + * { margin-top: 0; }
  .jeu-bas .btn.gros { min-width: 0; flex: 1; }
}
/* Leçon et intro de série : boutons côte à côte, même sur téléphone (◀ étroit, bouton principal large) */
.jeu-bas.bas-ligne { flex-direction: row; align-items: center; }
.jeu-bas.bas-ligne > div:empty { display: none; }
.fiche-lecon { margin-top: 50px; }

/* Boutons de la leçon sous la fiche (pas de barre collée en bas : on lit la fiche jusqu'au bout avant de tourner) */
.lecon { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.lecon-nav { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.lecon-nav .btn.gros { flex: 0 1 380px; }
.lecon-nav .btn.secondaire { padding-left: 18px; padding-right: 18px; }
@media (max-width: 640px) {
  .lecon-nav .btn.gros { flex: 1; min-width: 0; }
}

/* Grand écran : la leçon prend la largeur ; les dessins à droite du texte, sans dépasser la hauteur de l'écran */
.jeu-corps:has(> .lecon-large) { max-width: 1140px; }
.lecon-large .fiche-lecon { padding: 26px 32px; }
.lecon-large .fiche-lecon:not(:has(.fiche-colonnes)) { max-width: 800px; margin-left: auto; margin-right: auto; }
.lecon-large .bloc-illustration svg { max-height: max(300px, calc(100dvh - 470px)); }
.lecon-large .fiche-lecon { margin-top: 44px; }
.lecon-large .fiche-lecon h2 { margin-bottom: 4px; }
.fiche-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 32px; align-items: start; }
.fiche-texte > * + *, .fiche-visuels > * + * { margin-top: 14px; }
.fiche-visuels { position: sticky; top: 16px; }

/* Textes en justifié (leçons, récits, explications) ; la césure évite les grands blancs sur téléphone */
.bloc-texte, .bloc-retenir, .bloc-astuce > div, .icone-info, .parchemin, .decouverte p, .pourquoi p, .bilan-etape p, .invention p {
  text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}

/* Frise verticale à trous (exercices « ordre » d'histoire / géographie) */
.frise-ordre { list-style: none; margin: 6px 0 18px; padding: 0 0 0 52px; position: relative; display: flex; flex-direction: column; gap: 12px; }
.frise-ordre::before { content: ''; position: absolute; left: 20px; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: var(--c); opacity: .45; }
.frise-ordre.mauvais { animation: secoue .4s; }
.case-frise { position: relative; display: flex; align-items: center; min-height: 56px; }
.case-num {
  position: absolute; left: -30px; transform: translateX(-50%); min-width: 30px; height: 30px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; background: var(--c); color: white; font-weight: 800; font-size: 14px; box-shadow: 0 0 0 4px white;
}
.case-num.date { font-size: 12px; min-width: 44px; }
.case-vide {
  flex: 1; min-height: 52px; border: 3px dashed #cbd5e1; border-radius: 14px; display: grid; place-items: center;
  color: #94a3b8; font-weight: 800; font-size: 18px; background: #f8fafc;
}
.case-frise .tuile { flex: 1; text-align: left; }
.case-frise.survol .case-vide, .case-frise.survol .tuile { border-color: var(--c); background: color-mix(in srgb, var(--c), white 88%); }
.case-frise.juste .tuile { border-color: #22c55e; box-shadow: 0 4px 0 #86efac; background: #f0fdf4; }
.case-frise.faux .tuile { border-color: #ef4444; box-shadow: 0 4px 0 #fca5a5; background: #fef2f2; }
.case-frise.juste .case-num { background: #16a34a; }
.case-frise.faux .case-num { background: #dc2626; }
.tuile-frise { touch-action: none; user-select: none; -webkit-user-select: none; font-size: 16px; padding: 10px 14px; line-height: 1.3; }
.reserve-frise { min-height: 0; margin-bottom: 8px; }
/* « Dater » : chaque événement est écrit, sa date va dans le trou à droite (pas de ligne : ils sont dans le désordre) */
.frise-ordre.dater { padding-left: 0; gap: 10px; }
.frise-ordre.dater::before { display: none; }
.case-dater { gap: 10px; align-items: stretch; }
.evenement-dater {
  flex: 1; display: flex; align-items: center; padding: 8px 12px; border-radius: 14px; font-weight: 700; font-size: 15px; line-height: 1.3;
  background: color-mix(in srgb, var(--c), white 88%); border-left: 5px solid var(--c);
}
.trou-date { width: 118px; flex: none; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.trou-date .case-vide, .trou-date .tuile { width: 100%; text-align: center; }
.trou-date .tuile-frise { padding: 10px 6px; font-weight: 800; }
.date-juste { text-align: center; font-size: 13px; font-weight: 800; color: #16a34a; }
.case-dater.juste .evenement-dater { border-left-color: #16a34a; }
.case-dater.faux .evenement-dater { border-left-color: #dc2626; }
.case-dater.faux .tuile { text-decoration: line-through; }
.tuile.en-cours { opacity: .3; }
.tuile-fantome { position: fixed; z-index: 100; pointer-events: none; margin: 0; transform: rotate(-2deg) scale(1.04); box-shadow: 0 12px 24px rgba(0, 0, 0, .25); border-color: var(--c); }

/* 📄 Analyse de document : le texte, ses passages à toucher, le passage qui répond surligné à la correction */
.document {
  text-align: left; margin: 12px 0 16px; padding: 16px 18px; border-radius: 16px; background: #fffbeb;
  border: 2px solid #fde68a; box-shadow: 0 3px 0 #fcd34d;
}
.document-titre { font-weight: 800; color: #92400e; margin-bottom: 8px; }
.document-texte p { margin: 0 0 10px; font-size: 17px; line-height: 1.75; color: #1e293b; }
.document-source { font-size: 13px; font-style: italic; color: #78716c; border-top: 1px dashed #fcd34d; padding-top: 8px; }
.passage, .passage-fixe { border-radius: 6px; padding: 2px 1px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.passage { cursor: pointer; border-bottom: 2px dotted #d6b45c; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.passage.choisi { background: color-mix(in srgb, var(--c), white 70%); border-bottom: 2px solid var(--c); }
.passage-fixe.bon, .passage.bon { background: #fde047; box-shadow: 0 0 0 2px #fde047; font-weight: 600; }
.passage-fixe.mauvais { background: #fecaca; text-decoration: line-through; text-decoration-color: #dc2626; }
.passage-fixe.trouve { background: #bbf7d0; box-shadow: 0 0 0 2px #bbf7d0; font-weight: 600; }
.passage-fixe.manque { background: #fecaca; box-shadow: 0 0 0 2px #fecaca; font-weight: 600; }
.legende-passages { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 14px; margin: 4px 0 0; }
.legende-passages span { padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.legende-passages .trouve { background: #bbf7d0; }
.legende-passages .manque { background: #fecaca; }
.legende-passages .mauvais { background: #fecaca; text-decoration: line-through; text-decoration-color: #dc2626; }
.consigne-document { font-weight: 700; color: #475569; margin: 18px 0 0; }
.defi-document { margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; background: #fef3c7; color: #92400e; }
.document-repli { margin-top: 16px; }
.document-repli > summary {
  cursor: pointer; font-weight: 700; color: #92400e; padding: 10px 14px; border-radius: 12px; background: #fffbeb;
  border: 2px solid #fde68a; list-style-position: inside; min-height: 44px; box-sizing: border-box;
}
.document-repli[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.document-repli .document { margin-top: 0; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
@media (hover: hover) { .passage:not(.choisi):hover { background: #fef3c7; } }

/* 🧮 Brouillon de calcul (maths) : lignes posées sur une feuille quadrillée, nombres de l'énoncé, clavier à l'écran */
.brouillon {
  margin: 8px 0 12px; padding: 8px; border-radius: 14px; border: 2px solid #cbd5e1;
  background-color: #fff; background-image: linear-gradient(#e0f2fe 1px, transparent 1px), linear-gradient(90deg, #e0f2fe 1px, transparent 1px);
  background-size: 16px 16px;
}
.ligne-calcul {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 48px; padding: 6px 10px; margin: 2px 0;
  border: 2px solid transparent; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
  font: inherit; font-size: 22px; font-weight: 700; color: var(--texte); font-variant-numeric: tabular-nums;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ligne-calcul.donnee { cursor: default; color: #334155; }
.ligne-calcul.active { border-color: var(--c); background: color-mix(in srgb, var(--c), white 92%); }
.ligne-calcul.juste { background: #dcfce7; }
.ligne-calcul.fausse { background: #fee2e2; color: #991b1b; }
.ligne-calcul:disabled { cursor: default; opacity: 1; }
.ligne-calcul .egal { flex: 0 0 20px; color: var(--doux); }
.ligne-texte { flex: 1; overflow-wrap: anywhere; }
.ligne-marque { font-size: 20px; }
.ligne-calcul.juste .ligne-marque { color: #16a34a; }
.ligne-calcul.fausse .ligne-marque { color: #dc2626; }
.ligne-vide { font-size: 15px; font-weight: 400; font-style: italic; color: #94a3b8; }
.curseur { display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -3px; background: var(--c); animation: clignote 1s steps(1) infinite; }
@keyframes clignote { 50% { opacity: 0; } }
.brouillon-unite { padding: 4px 10px 2px; font-size: 15px; color: var(--doux); }
.brouillon-remarque { color: #b45309; font-weight: 700; }
.jetons { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 0 auto 10px; max-width: 420px; }
.jetons-titre { font-size: 14px; font-weight: 700; color: var(--doux); }
.jeton {
  min-width: 52px; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c), white 88%); font: inherit; font-size: 19px; font-weight: 800; color: var(--texte); cursor: pointer;
  touch-action: manipulation;
}
.pave { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 420px; margin: 0 auto; }
.touche {
  min-height: 50px; border-radius: 12px; border: 0; background: #f1f5f9; box-shadow: 0 3px 0 #cbd5e1;
  font: inherit; font-size: 22px; font-weight: 800; color: var(--texte); cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.touche:active { transform: translateY(2px); box-shadow: 0 1px 0 #cbd5e1; }
.touche.operation { background: color-mix(in srgb, var(--c), white 85%); }
.touche.effacer { background: #fee2e2; }
.touche.nouvelle-ligne { grid-column: auto / -1; background: var(--c); color: #fff; font-size: 15px; white-space: nowrap; box-shadow: 0 3px 0 color-mix(in srgb, var(--c), black 25%); }
/* Solution d'un calcul : une ligne par calcul, l'une sous l'autre */
.calcul-solution { margin-top: 8px; padding: 8px 12px; border-left: 4px solid var(--c); border-radius: 8px; background: #f8fafc; }
.calcul-solution div { font-size: 19px; line-height: 1.7; font-variant-numeric: tabular-nums; }

/* 🧪 Mode test (MODE_TEST=1) : boutons de réinitialisation / validation */
.zone-test {
  margin: 20px auto 0; max-width: 600px; padding: 12px 14px; border: 2px dashed #f59e0b; border-radius: 16px;
  background: #fffbeb; display: flex; flex-direction: column; gap: 8px;
}
.zone-test-titre { font-weight: 800; color: #b45309; font-size: 14px; }
.zone-test .btn { width: 100%; }
.zone-test .indice { margin: 0; font-size: 13px; }
/* Leçons : une idée par ligne, alignée à gauche (justifiée, une ligne courte laisse de grands trous) */
.ligne-idee:not(:only-child) { text-align: left; hyphens: none; }

/* « Ce qu'on attend de toi » (maths), au-dessus du brouillon */
.attendu { background: #eff6ff; border: 2px solid #bfdbfe; border-radius: 14px; padding: 4px 14px; margin: 0 0 12px; font-size: 15px; text-align: left; }
.attendu summary { cursor: pointer; font-weight: 800; color: #1d4ed8; min-height: 40px; display: flex; align-items: center; touch-action: manipulation; }
.attendu ol { margin: 2px 0 10px; padding-left: 22px; }
.attendu li { margin: 4px 0; }
.attendu-exemple { background: #fff; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.attendu-exemple span { display: block; font-size: 12px; font-weight: 800; color: var(--doux); text-transform: uppercase; }
.attendu-regle { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #b45309; }
