/* ==========================================================
   Capito — styles
   Pour changer les couleurs, modifie les variables juste dessous.
   ========================================================== */

:root {
  color-scheme: light dark;

  --violet: #6c4df6;
  --violet-fonce: #4b30cf;
  --violet-doux: #ece7ff;
  --rose: #ff6b8b;
  --jaune: #ffc83d;
  --jaune-fonce: #dd9f12;
  --vert: #1db46a;
  --vert-fonce: #12874d;
  --vert-doux: #dcf6e8;
  --vert-texte: #0e7a43;
  --rouge: #ee4b4b;
  --rouge-fonce: #c22f2f;
  --rouge-doux: #fde4e4;
  --rouge-texte: #b42323;

  --fond: #f6f4ff;
  --carte: #ffffff;
  --carte-2: #efecf9;
  --texte: #1e1b2e;
  --texte-doux: #6b6785;
  --bordure: #e2ddf2;
  --gris: #d3cee2;
  --gris-fonce: #b0aac6;
  --etoile-vide: #d9d4e8;

  --ombre: 0 1px 2px rgb(30 27 46 / 6%), 0 6px 18px rgb(30 27 46 / 7%);
  --rayon: 18px;
  --police: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --couleur: var(--violet); /* couleur de la matière en cours */
  --hauteur-pied: 100px;
  /* fondu sombre en bas du chemin */
  --fondu-milieu: rgba(30, 22, 60, 0.16);
  --fondu-fin: rgba(30, 22, 60, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    --violet: #8b73ff;
    --violet-fonce: #5a3fe0;
    --violet-doux: #2b2452;
    --vert: #26c376;
    --vert-fonce: #158a51;
    --vert-doux: #133829;
    --vert-texte: #62e3a3;
    --rouge: #ff5d5d;
    --rouge-fonce: #c43535;
    --rouge-doux: #431b20;
    --rouge-texte: #ff9a9a;

    --fond: #13111b;
    --carte: #1f1c2b;
    --carte-2: #2a2639;
    --texte: #f3f1fa;
    --texte-doux: #aaa5c1;
    --bordure: #353049;
    --gris: #3e3955;
    --gris-fonce: #2a2639;
    --etoile-vide: #4a4463;

    --ombre: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 18px rgb(0 0 0 / 25%);
    --fondu-milieu: rgba(0, 0, 0, 0.3);
    --fondu-fin: rgba(0, 0, 0, 0.82);
  }
}

/* ---------------------------------------------------------- Bases */

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden; /* la page défile dans <body>, voir plus bas */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--fond);
}

body {
  margin: 0;
  height: 100%;
  overflow-y: auto; /* la page défile ici : on peut ainsi masquer la barre de défilement, iPhone compris */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.4;
  overflow-x: hidden;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }
[role="button"] { cursor: pointer; touch-action: manipulation; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

.icone { width: 24px; height: 24px; flex: none; display: block; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding:
    env(safe-area-inset-top, 0px)
    max(16px, env(safe-area-inset-right, 0px))
    calc(40px + env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

.chargement {
  padding-top: 40vh;
  text-align: center;
  color: var(--texte-doux);
  font-weight: 700;
}

.vide {
  color: var(--texte-doux);
  text-align: center;
  padding: 16px;
}

/* ---------------------------------------------------------- Boutons */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn-principal { --b: var(--violet); --o: var(--violet-fonce); }
.btn-vert { --b: var(--vert); --o: var(--vert-fonce); }
.btn-rouge { --b: var(--rouge); --o: var(--rouge-fonce); }

.btn-principal, .btn-vert, .btn-rouge {
  background: var(--b);
  color: #fff;
  box-shadow: 0 4px 0 var(--o);
}

.btn-principal:active:not(:disabled),
.btn-vert:active:not(:disabled),
.btn-rouge:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--o);
}

.btn:disabled {
  background: var(--gris);
  box-shadow: 0 4px 0 var(--gris-fonce);
  color: var(--texte-doux);
}

.btn-secondaire {
  background: var(--carte);
  color: var(--violet);
  box-shadow: inset 0 0 0 2px var(--bordure), 0 4px 0 var(--bordure);
}
.btn-secondaire:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 2px var(--bordure), 0 1px 0 var(--bordure);
}

.btn-icone {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  color: var(--texte-doux);
}
.btn-icone:active { background: var(--carte-2); }
.btn-icone .icone { width: 26px; height: 26px; }

.actions { display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------- Accueil */

.accueil-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.logo img { width: 40px; height: 40px; border-radius: 11px; }

.stats { display: flex; gap: 8px; }

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--carte);
  box-shadow: var(--ombre);
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
}
.pastille.eteinte { filter: grayscale(1); opacity: 0.6; }


.titre-section {
  font-size: 19px;
  font-weight: 800;
  margin: 26px 0 12px;
}

.matiere {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 12px;
  padding: 16px;
  text-align: left;
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  transition: transform 0.12s;
}
.matiere:active { transform: scale(0.98); }

.matiere-emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 30px;
  background: var(--carte-2);
  background: color-mix(in srgb, var(--couleur) 18%, transparent);
}

.matiere-infos { display: block; flex: 1; min-width: 0; }
.matiere-titre { display: block; font-weight: 800; font-size: 18px; line-height: 1.25; }
.matiere-detail { display: block; color: var(--texte-doux); font-size: 14px; margin-top: 2px; }
.matiere-fleche { color: var(--gris-fonce); }

.badge-exemple {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--jaune);
  color: #4a3500;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.pied-page {
  margin-top: 36px;
  text-align: center;
  color: var(--texte-doux);
  font-size: 13px;
}

/* ---------------------------------------------------------- Chemin d'une matière */

.banniere {
  /* Reste visible en haut quand on descend le long chemin des niveaux. */
  position: sticky;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px 12px 8px;
  border-radius: var(--rayon);
  background: var(--couleur);
  color: #fff;
  box-shadow: 0 4px 0 rgb(0 0 0 / 18%);
}
.banniere .btn-icone { color: #fff; }
.banniere .btn-icone:active { background: rgb(255 255 255 / 18%); }
.banniere-emoji { font-size: 32px; }
.banniere-textes { min-width: 0; }
.banniere-titre { font-size: 19px; font-weight: 900; line-height: 1.2; }

.chapitre { margin: 28px 0 4px; text-align: center; }
.chapitre-numero {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--couleur);
}
.chapitre-titre { font-size: 21px; font-weight: 900; margin-top: 2px; }

.chemin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  padding: 44px 0 8px;
}

.noeud-conteneur {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 150px;
  transform: translateX(var(--decalage, 0));
}

.noeud {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 70px;
  border-radius: 50%;
  background: var(--couleur);
  color: #fff;
  box-shadow: 0 6px 0 rgb(0 0 0 / 22%);
  transition: transform 0.1s, box-shadow 0.1s;
}
.noeud .icone { width: 32px; height: 32px; }
.noeud:active { transform: translateY(4px); box-shadow: 0 2px 0 rgb(0 0 0 / 22%); }

.noeud.parfait { background: var(--jaune); color: #6b4a00; }

.noeud.verrouille {
  background: var(--gris);
  color: var(--carte);
  box-shadow: 0 6px 0 var(--gris-fonce);
}
.noeud.verrouille .icone { width: 28px; height: 28px; opacity: 0.9; }

.noeud.actuel::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 4px solid var(--couleur);
  opacity: 0.35;
  animation: pulsation 1.8s ease-out infinite;
}

.bulle {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  z-index: 1;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--carte);
  color: var(--couleur);
  box-shadow: var(--ombre);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: flotte 2s ease-in-out infinite;
}
.bulle::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -7px;
  border: 7px solid transparent;
  border-top-color: var(--carte);
}

.noeud-etoiles { display: flex; gap: 2px; margin-top: 10px; }
.noeud-etoiles .icone { width: 18px; height: 18px; }

.icone.creuse { color: var(--etoile-vide); }
.icone.pleine { color: var(--jaune); }

/* Fondu sombre en bas de l'écran : donne envie de jouer le niveau en cours plutôt que
   de regarder tout ce qui reste. On peut quand même descendre (il laisse passer les touchers). */
#app.ecran-matiere { padding-bottom: calc(30vh + env(safe-area-inset-bottom, 0px)); }
.fondu-bas {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 30vh;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, var(--fondu-milieu) 45%, var(--fondu-fin) 100%);
}

/* ---------------------------------------------------------- Panneaux (feuilles) */

.voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(20 16 40 / 45%);
  animation: fondu 0.2s;
}
.voile.centre { align-items: center; padding: 16px; }
.voile.sortie { animation: fondu 0.18s reverse forwards; }

.feuille {
  width: 100%;
  max-width: 560px;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 26px 26px 0 0;
  background: var(--carte);
  text-align: center;
  animation: monte 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.voile.sortie .feuille { animation: monte 0.18s reverse forwards; }
.feuille.boite { max-width: 400px; padding: 24px 20px; border-radius: 24px; }

.feuille-poignee {
  width: 40px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 99px;
  background: var(--gris);
}
.feuille-sur-titre {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--couleur);
}
.feuille-titre { font-size: 23px; font-weight: 900; margin: 4px 0 10px; }
.feuille-texte { color: var(--texte-doux); margin-bottom: 20px; }

.etoiles-moyennes { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.etoiles-moyennes .icone { width: 32px; height: 32px; }

/* ---------------------------------------------------------- Partie */

#app.ecran-partie {
  padding-bottom: calc(var(--hauteur-pied) + 24px);
}

.partie-entete {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  background: var(--fond);
}

.barre {
  flex: 1;
  height: 16px;
  border-radius: 99px;
  background: var(--carte-2);
  overflow: hidden;
}
.barre > span {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--rose));
  transition: width 0.45s cubic-bezier(0.3, 0.8, 0.4, 1);
}
.barre > span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 99px;
  background: rgb(255 255 255 / 35%);
}

.coeurs { display: flex; gap: 1px; }
.coeur { width: 26px; height: 26px; color: var(--rouge); }
.coeur.perdu { color: var(--gris); animation: perd-coeur 0.6s; }

.partie-corps {
  user-select: none;
  -webkit-user-select: none;
}
.partie-corps.entree { animation: entree 0.35s cubic-bezier(0.2, 0.8, 0.3, 1); }

.consigne {
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--couleur);
}

.enonce {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
}

.enonce-vrai-faux {
  padding: 20px;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
}

.partie-pied {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--fond);
  border-top: 2px solid var(--bordure);
  transition: background-color 0.2s;
}
.partie-pied.juste { background: var(--vert-doux); border-top-color: transparent; }
.partie-pied.faux { background: var(--rouge-doux); border-top-color: transparent; }
.partie-pied-contenu { max-width: 528px; margin: 0 auto; }

.retour:empty { display: none; }
.retour { animation: monte-un-peu 0.25s ease-out; }

.retour-titre {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 900;
}
.retour-titre .icone {
  width: 32px;
  height: 32px;
  padding: 5px;
  border-radius: 50%;
  color: #fff;
}
.juste .retour-titre { color: var(--vert-texte); }
.juste .retour-titre .icone { background: var(--vert); animation: pop 0.4s; }
.faux .retour-titre { color: var(--rouge-texte); }
.faux .retour-titre .icone { background: var(--rouge); animation: secoue 0.4s; }

.retour-defile {
  max-height: 42vh;
  margin-bottom: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.retour-reponse { margin: 4px 0 6px; font-size: 16px; }
.faux .retour-reponse strong { color: var(--rouge-texte); }
.retour-reponse ul, .retour-reponse ol { margin: 4px 0 0; padding-left: 22px; }
.retour-explication { margin: 4px 0; font-size: 16px; }
.retour-source { margin-top: 6px; font-size: 13px; color: var(--texte-doux); }

.aide {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--texte-doux);
}

/* ---------------------------------------------------------- Mini-jeu : choix (QCM, Vrai/Faux) */

.choix-liste { display: flex; flex-direction: column; gap: 10px; }

.choix {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  text-align: left;
  font-size: 17px;
  font-weight: 650;
  background: var(--carte);
  border: 2px solid var(--bordure);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--bordure);
  transition: transform 0.08s, border-color 0.15s, background-color 0.15s, opacity 0.2s;
}
.choix:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--bordure); }
.choix:disabled { color: inherit; opacity: 1; }

.choix[aria-pressed="true"] {
  border-color: var(--violet);
  background: var(--violet-doux);
  box-shadow: 0 3px 0 var(--violet);
}

.choix-case {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 2px solid var(--gris-fonce);
  border-radius: 50%;
  color: transparent;
}
.multiple .choix-case { border-radius: 8px; }
.choix-case .icone { width: 16px; height: 16px; }
.choix[aria-pressed="true"] .choix-case { background: var(--violet); border-color: var(--violet); color: #fff; }

.choix.juste {
  border-color: var(--vert);
  background: var(--vert-doux);
  box-shadow: 0 3px 0 var(--vert);
}
.choix.juste .choix-case { background: var(--vert); border-color: var(--vert); color: #fff; }
.choix.faux {
  border-color: var(--rouge);
  background: var(--rouge-doux);
  box-shadow: 0 3px 0 var(--rouge);
  animation: secoue 0.4s;
}
.choix.faux .choix-case { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.choix.manque { border-color: var(--vert); border-style: dashed; box-shadow: none; }
.corrige .choix:not(.juste):not(.faux):not(.manque) { opacity: 0.5; }

.vf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vf .choix {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 120px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
.vf .choix .icone { width: 38px; height: 38px; }
.vf-vrai .icone { color: var(--vert); }
.vf-faux .icone { color: var(--rouge); }
.vf .choix:disabled:not(.juste):not(.faux) { opacity: 0.5; }

/* ---------------------------------------------------------- Mini-jeu : classer dans des zones */

.zones {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 10px;
}

.zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
  padding: 10px;
  border: 2px dashed var(--gris-fonce);
  border-radius: 16px;
  background: var(--carte);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.zone-titre { font-size: 14px; font-weight: 800; color: var(--texte-doux); line-height: 1.25; }
.zone-contenu { display: flex; flex-wrap: wrap; gap: 6px; }

.choix-en-cours .zone,
.choix-en-cours .reserve { border-color: var(--violet); }
.zone.survol,
.reserve.survol {
  border-color: var(--violet);
  border-style: solid;
  background: var(--violet-doux);
  transform: scale(1.02);
}

.reserve {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 70px;
  margin-top: 14px;
  padding: 12px;
  border: 2px dashed transparent;
  border-radius: 16px;
  background: var(--carte-2);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.reserve:empty::before {
  content: "Tout est rangé ! 👍";
  margin: auto;
  color: var(--texte-doux);
  font-size: 15px;
  font-weight: 700;
}

.etiquette {
  max-width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  background: var(--carte);
  border: 2px solid var(--bordure);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--bordure);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.12s, border-color 0.15s, background-color 0.15s, opacity 0.15s;
}
.zone .etiquette { min-height: 38px; padding: 6px 10px; font-size: 15px; }
.etiquette.choisie {
  border-color: var(--violet);
  background: var(--violet-doux);
  box-shadow: 0 3px 0 var(--violet);
  transform: translateY(-2px);
}
.etiquette.en-deplacement { opacity: 0.3; }
.etiquette.juste { border-color: var(--vert); background: var(--vert-doux); box-shadow: 0 3px 0 var(--vert); }
.etiquette.faux { border-color: var(--rouge); background: var(--rouge-doux); box-shadow: 0 3px 0 var(--rouge); animation: secoue 0.4s; }

.fantome {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 14px 28px rgb(0 0 0 / 22%);
  border-color: var(--violet);
  transition: none;
}

/* ---------------------------------------------------------- Résultat */

.resultat { padding-top: 40px; text-align: center; }
.resultat-emoji { font-size: 76px; line-height: 1; animation: rebond 0.7s; }
.resultat h1 { margin: 14px 0 4px; font-size: 30px; font-weight: 900; }
.resultat-sous-titre { color: var(--texte-doux); }

.etoiles-grandes { display: flex; justify-content: center; gap: 8px; margin: 22px 0 6px; }
.etoiles-grandes .icone { width: 64px; height: 64px; }
.etoiles-grandes .icone.pleine { animation: etoile 0.5s backwards; }
.etoiles-grandes .icone:nth-child(2) { margin-top: -14px; animation-delay: 0.25s; }
.etoiles-grandes .icone:nth-child(3) { animation-delay: 0.5s; }

.cartes-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0 18px;
}
.stat { padding: 14px 6px; border-radius: 16px; background: var(--carte); box-shadow: var(--ombre); }
.stat-valeur { font-size: 22px; font-weight: 900; }
.stat-nom {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--texte-doux);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.resultat-serie { margin-bottom: 18px; font-weight: 700; color: var(--jaune-fonce); }
.resultat .actions { margin-top: 12px; }

/* ---------------------------------------------------------- Message temporaire */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--texte);
  color: var(--fond);
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  animation: toast 2.8s forwards;
}

/* ---------------------------------------------------------- Animations */

@keyframes entree { from { opacity: 0; transform: translateY(14px); } }
@keyframes fondu { from { opacity: 0; } }
@keyframes monte { from { transform: translateY(100%); } }
@keyframes monte-un-peu { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes secoue {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes perd-coeur {
  0% { transform: scale(1); color: var(--rouge); }
  40% { transform: scale(1.4) rotate(-12deg); color: var(--rouge); }
  100% { transform: scale(1); }
}
@keyframes pulsation {
  0% { transform: scale(0.95); opacity: 0.5; }
  100% { transform: scale(1.25); opacity: 0; }
}
@keyframes flotte {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -5px); }
}
@keyframes rebond {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes etoile {
  0% { transform: scale(0) rotate(-45deg); }
  70% { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  8%, 88% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================
   Mini-jeux ajoutés : paires, ordre, texte à trous, trouver l'erreur
   ========================================================== */

/* ---------- Associer des paires */

.paires {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px;
}
.paires-colonne { display: flex; flex-direction: column; gap: 10px; }

.paire {
  --p: var(--violet);
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 56px;
  padding: 10px 12px;
  text-align: left;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.25;
  background: var(--carte);
  border: 2px solid var(--bordure);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--bordure);
  transition: transform 0.1s, border-color 0.15s, background-color 0.15s;
}
.paires-droite .paire { font-weight: 600; }
.paire:disabled { color: inherit; }
.paire.choisie {
  border-color: var(--violet);
  background: var(--violet-doux);
  box-shadow: 0 3px 0 var(--violet);
  transform: translateY(-2px);
}
.paire.liee {
  padding-right: 36px;
  border-color: var(--p);
  background: var(--carte-2);
  background: color-mix(in srgb, var(--p) 14%, var(--carte));
  box-shadow: 0 3px 0 var(--p);
}
.paire.liee::after {
  content: attr(data-numero);
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--p);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  transform: translateY(-50%);
}
.paire[data-couleur="0"] { --p: #6c4df6; }
.paire[data-couleur="1"] { --p: #f0507a; }
.paire[data-couleur="2"] { --p: #0e9fb3; }
.paire[data-couleur="3"] { --p: #e8860c; }
.paire[data-couleur="4"] { --p: #3b7cf6; }
.paire[data-couleur="5"] { --p: #b04ad8; }
.paire.juste { border-color: var(--vert); background: var(--vert-doux); box-shadow: 0 3px 0 var(--vert); }
.paire.faux { border-color: var(--rouge); background: var(--rouge-doux); box-shadow: 0 3px 0 var(--rouge); animation: secoue 0.4s; }

/* ---------- Remettre dans l'ordre */

.ordre-liste { display: flex; flex-direction: column; gap: 8px; }
.ordre-case {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 8px;
  border: 2px dashed var(--gris-fonce);
  border-radius: 14px;
  background: var(--carte);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.ordre-case.remplie { border-style: solid; border-color: transparent; background: transparent; }
.ordre-case.prochaine { border-color: var(--violet); background: var(--violet-doux); }
.ordre-numero {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--carte-2);
  color: var(--texte-doux);
  font-size: 15px;
  font-weight: 900;
}
.ordre-case.remplie .ordre-numero { background: var(--violet); color: #fff; }
.ordre-contenu { display: flex; flex: 1; min-width: 0; }
.ordre-contenu .etiquette { width: 100%; }

/* ---------- Texte à trous */

.texte-trous {
  margin-bottom: 4px;
  font-size: 19px;
  font-weight: 600;
  line-height: 2.6;
}
.trou {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 42px;
  margin: 0 3px;
  padding: 2px;
  vertical-align: middle;
  line-height: 1.2;
  border: 2px dashed var(--gris-fonce);
  border-radius: 12px;
  background: var(--carte);
  transition: border-color 0.15s, background-color 0.15s;
}
.trou.actif { border-color: var(--violet); background: var(--violet-doux); }
.trou.rempli { min-width: 0; margin: 0 1px; padding: 0; border-color: transparent; background: transparent; }
.trou .etiquette { min-height: 38px; padding: 5px 11px; font-size: 17px; }

/* ---------- Trouver l'erreur */

.groupes { display: grid; gap: 10px; }
.groupes.plusieurs { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.groupe { padding: 12px; border-radius: 16px; background: var(--carte); box-shadow: var(--ombre); }
.groupe-titre { margin-bottom: 8px; font-size: 14px; font-weight: 800; color: var(--texte-doux); }
.groupe-elements { display: flex; flex-wrap: wrap; gap: 8px; }
.etiquette.fixe { cursor: pointer; touch-action: manipulation; }
.etiquette:disabled { color: inherit; }
.etiquette.manque { border-color: var(--vert); border-style: dashed; background: var(--vert-doux); box-shadow: none; }

/* Survol pendant un glisser, pour tous les jeux */
.ordre-case.survol,
.trou.survol {
  border-color: var(--violet);
  border-style: solid;
  background: var(--violet-doux);
  transform: scale(1.02);
}

/* ==========================================================
   Révisions, rappels et réglages
   ========================================================== */

.accueil-entete .btn-icone { width: 40px; height: 40px; margin-left: -2px; }
.accueil-entete .stats { align-items: center; gap: 6px; }
.accueil-entete .pastille { padding: 6px 10px; }

.matiere-revisions { display: block; margin-top: 2px; color: var(--couleur); font-weight: 700; }

.carte-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  text-align: left;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
  transition: transform 0.12s;
}
.carte-action:active { transform: scale(0.98); }
.carte-action > .icone { color: var(--gris-fonce); }
.carte-action-icone { font-size: 28px; line-height: 1; }
.carte-action-textes { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.carte-action-textes strong { font-size: 17px; font-weight: 800; }
.carte-action-textes span { font-size: 14px; color: var(--texte-doux); }
.carte-action.rappel {
  background: #fff6d9;
  box-shadow: inset 0 0 0 2px #f6dc8c;
}
@media (prefers-color-scheme: dark) {
  .carte-action.rappel { background: #2e2814; box-shadow: inset 0 0 0 2px #5a4b1c; }
}

.badge-revision {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--carte-2);
  color: var(--couleur);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.entete-simple { display: flex; align-items: center; gap: 6px; padding: 12px 0 4px; margin-left: -8px; }
.entete-simple h1 { font-size: 26px; font-weight: 900; }

.reglage {
  margin-top: 16px;
  padding: 18px 16px;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
}
.reglage h2 { margin-bottom: 8px; font-size: 18px; font-weight: 800; }
.reglage h2 span { margin-right: 4px; }
.reglage p { margin-bottom: 12px; font-size: 15px; color: var(--texte-doux); }
.reglage ol { margin: 0; padding-left: 22px; font-size: 15px; color: var(--texte-doux); }
.reglage li + li { margin-top: 6px; }
.reglage-info { font-weight: 700; }
.reglage .actions { gap: 12px; }

.liens { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 12px; }
.lien {
  min-height: 40px;
  color: var(--violet);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.interrupteur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 6px;
  font-weight: 700;
  cursor: pointer;
}
.interrupteur input { flex: none; width: 26px; height: 26px; margin: 0; accent-color: var(--violet); }

.zone-texte {
  display: block;
  width: 100%;
  min-height: 130px;
  margin-bottom: 16px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  color: var(--texte);
  background: var(--fond);
  border: 2px solid var(--bordure);
  border-radius: 14px;
  resize: vertical;
}

.invisible {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Finitions */

.confettis {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stat.serie-plus .stat-valeur { animation: pop 0.6s 0.5s backwards; }

/* ==========================================================
   Mascotte : Mochi, le chat blanc tout rond
   ========================================================== */

:root {
  --chat-blanc: #ffffff;
  --chat-contour: #d3cbea;
  --chat-rose: #ffb3c6;
  --chat-encre: #2c2442;
}
@media (prefers-color-scheme: dark) {
  :root { --chat-contour: #bfb6dc; }
}

.mascotte { display: block; flex: none; overflow: visible; }
.m-blanc { fill: var(--chat-blanc); stroke: var(--chat-contour); stroke-width: 2.6; stroke-linejoin: round; }
.m-oreille { fill: var(--chat-rose); }
.m-joue { fill: var(--chat-rose); opacity: 0.6; }
.m-nez, .m-langue { fill: #ff8fab; }
.m-encre, .m-bouche { fill: var(--chat-encre); }
.m-reflet { fill: #fff; }
.m-trait, .m-trait-epais { fill: none; stroke: var(--chat-encre); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.m-trait-epais { stroke-width: 3.6; }
.m-etincelle { fill: var(--jaune); }
.m-larme { fill: #7cc8ff; }

/* Il cligne des yeux de temps en temps */
.m-yeux { transform-origin: 60px 66px; animation: chat-cligne 4.5s infinite; }
/* Clin d'œil et petit balancement sur l'accueil */
.mascotte-coucou { transform-origin: 50% 90%; animation: chat-balance 1.6s ease-in-out 0.3s 2; }
/* Il saute de joie */
.mascotte-bravo { animation: chat-saut 0.55s ease-out 0.2s 3; }
.mascotte-bravo .m-etincelle { animation: chat-brille 1.2s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.mascotte-triste { animation: chat-soupir 2.4s ease-in-out infinite; }

@keyframes chat-cligne { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes chat-balance { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-7deg); } 70% { transform: rotate(5deg); } }
@keyframes chat-saut { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
@keyframes chat-brille { from { transform: scale(0.6); opacity: 0.6; } to { transform: scale(1.15); opacity: 1; } }
@keyframes chat-soupir { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px); } }

/* Accueil : le chat et sa bulle */
.bonjour { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; }
.bonjour .mascotte { margin-left: -6px; }
.bulle-chat {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--carte);
  box-shadow: var(--ombre);
}
.bulle-chat::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -9px;
  border: 9px solid transparent;
  border-left: 0;
  border-right-color: var(--carte);
  transform: translateY(-50%);
}
.bulle-chat h1 { font-size: 22px; font-weight: 900; line-height: 1.2; }
.bulle-chat p { margin-top: 3px; color: var(--texte-doux); font-size: 15px; }

/* Correction : le chat passe la tête au-dessus du bandeau */
.retour-titre { position: relative; padding-right: 64px; }
.retour-mascotte { position: absolute; right: -4px; top: -40px; }

/* Résultat */
.resultat-mascotte { margin: 0 auto; }

/* ==========================================================
   Barre de défilement masquée, Mochi sur le chemin, programme d'un niveau
   ========================================================== */

body::-webkit-scrollbar { display: none; width: 0; height: 0; }

.deco-chemin {
  position: absolute;
  top: 50%;
  pointer-events: none;
  transform: translateY(-62%);
}
.deco-chemin.a-gauche { right: calc(100% + 4px); }
.deco-chemin.a-droite { left: calc(100% + 4px); }
.deco-chemin .pose-mochi { animation: chat-flotte 3.4s ease-in-out infinite; }
@keyframes chat-flotte { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Accessoires des poses de Mochi */
.a-violet { fill: var(--violet); }
.a-violet-clair { fill: #b9a8ff; }
.a-jaune { fill: var(--jaune); }
.a-rose { fill: #ff8fab; }
.a-gris { fill: #e9e5f5; }
.a-blanc { fill: #fff; }
.a-encre { fill: var(--chat-encre); }
.a-bord { stroke: var(--chat-contour); stroke-width: 2.6; }
.a-verre { fill: #dff1ff; opacity: 0.85; }
.a-anneau { fill: none; stroke: var(--violet); stroke-width: 6; }
.a-epais-violet { fill: none; stroke: var(--violet); stroke-width: 8; stroke-linecap: round; }
.a-contour { fill: none; stroke: var(--chat-encre); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.a-contour-violet { fill: none; stroke: var(--violet); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.a-contour-jaune { fill: none; stroke: var(--jaune); stroke-width: 3.4; stroke-linecap: round; }
.a-anse { fill: none; stroke: #b9a8ff; stroke-width: 6; stroke-linecap: round; }
.a-trait-blanc { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.a-texte { font: 900 15px var(--police); fill: #fff; text-anchor: middle; }

/* Fenêtre d'un niveau : ce qui est au programme */
.feuille-notions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  text-align: left;
}
.feuille-notions li { display: flex; align-items: center; gap: 8px; font-weight: 700; line-height: 1.3; }
.pastille-nouveau,
.pastille-rappel {
  flex: none;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.pastille-nouveau { background: var(--couleur); color: #fff; }
.pastille-rappel { background: var(--carte-2); color: var(--texte-doux); }

/* ==========================================================
   Accès (demande, attente), administration et classement
   ========================================================== */

.acces { padding: 28px 0 24px; text-align: center; }
.acces-mascotte { margin: 0 auto; }
.acces h1 { margin: 12px 0 6px; font-size: 28px; font-weight: 900; line-height: 1.15; }
.acces-texte { margin: 0 auto 18px; max-width: 420px; color: var(--texte-doux); font-size: 16px; }
.acces-note { margin: -6px auto 18px; max-width: 420px; color: var(--texte-doux); font-size: 14px; font-weight: 700; }
.acces-etapes {
  margin: 0 auto;
  max-width: 420px;
  padding: 16px 16px 16px 36px;
  text-align: left;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
  font-size: 15px;
}
.acces-etapes li + li { margin-top: 8px; }
.acces .actions { margin-bottom: 10px; }

.acces-formulaire { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.acces-champ { display: flex; flex-direction: column; gap: 6px; }
.acces-champ label { font-size: 15px; font-weight: 800; }
.champ {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font: inherit;
  font-size: 17px; /* 16 px minimum : sinon l'iPhone zoome sur le champ */
  color: var(--texte);
  background: var(--carte);
  border: 2px solid var(--bordure);
  border-radius: 14px;
}
.champ:focus { outline: none; border-color: var(--violet); }
.acces-case {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--carte);
  box-shadow: inset 0 0 0 2px var(--bordure);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.acces-case input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--violet); }
.acces-erreur { min-height: 1.3em; color: var(--rouge-texte); font-size: 15px; font-weight: 700; }
.acces-erreur:empty { min-height: 0; }
.acces-rgpd { color: var(--texte-doux); font-size: 14px; }
.acces-rgpd summary { min-height: 40px; padding-top: 8px; color: var(--violet); font-weight: 700; cursor: pointer; }
.acces-rgpd p { margin-top: 8px; }
.acces-lien-admin { margin-top: 18px; color: var(--texte-doux); font-size: 14px; }

.carte-action.alerte { background: var(--violet-doux); box-shadow: inset 0 0 0 2px var(--violet); }
.carte-action.classement { margin-top: 18px; }

.lien-danger { color: var(--rouge-texte); }

.btn-petit {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 15px;
}

.admin-chargement, .admin-vide { padding: 16px 4px; color: var(--texte-doux); }
.admin-section { margin-top: 18px; }
.admin-section h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 19px; font-weight: 900; }
.admin-nombre {
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--carte-2);
  color: var(--texte-doux);
  font-size: 14px;
  font-weight: 800;
}
.admin-joueur {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
}
.admin-infos { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; }
.admin-infos strong { font-size: 17px; font-weight: 800; }
.admin-email { color: var(--texte-doux); font-size: 14px; overflow-wrap: anywhere; }
.admin-date { color: var(--texte-doux); font-size: 13px; font-weight: 700; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-moi { color: var(--texte-doux); font-size: 14px; font-weight: 700; }
.admin-note { margin-top: 20px; color: var(--texte-doux); font-size: 14px; text-align: center; }

.classement-sous-titre { margin-top: 2px; color: var(--texte-doux); font-size: 15px; font-weight: 700; }
.classement-vide { padding-top: 30px; text-align: center; color: var(--texte-doux); }
.classement-vide .mascotte { margin: 0 auto 10px; }
.classement-info {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--rayon);
  background: var(--carte);
  box-shadow: var(--ombre);
}
.classement-info p { margin-bottom: 10px; color: var(--texte-doux); font-size: 15px; }
.classement-liste { margin: 14px 0 0; padding: 0; list-style: none; }
.classement-ligne {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--carte);
  box-shadow: var(--ombre);
}
.classement-ligne.moi { box-shadow: inset 0 0 0 2px var(--violet), var(--ombre); }
.classement-ligne.cache { opacity: 0.7; }
.classement-rang { flex: none; width: 34px; text-align: center; font-size: 18px; font-weight: 900; color: var(--texte-doux); }
.classement-prenom { flex: 1; min-width: 0; font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classement-toi {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--violet-doux);
  color: var(--violet);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  vertical-align: 2px;
}
.classement-serie { flex: none; font-size: 15px; font-weight: 700; color: var(--texte-doux); }
.classement-xp { flex: none; min-width: 64px; text-align: right; font-size: 16px; font-weight: 900; color: var(--violet); }
