/* =====================================================================
   MON CAHIER — feuille de style commune à toutes les pages
   Un ciel animé (ballons, oiseaux, nuages) derrière une feuille de
   cahier Seyès ; une colonne centrée, un écran à la fois.

   Sommaire :
     1. Couleurs (thème clair et thème sombre)
     2. Page, en-tête, feuille de cahier
     3. Accueil : cartes des niveaux et des jeux
     4. Réglages : puces, « Je retiens »
     5. Exercice : question, réponses, correction, pavé numérique
     6. Dessins des questions (objets, frises, horloge, phrases…)
     7. La course du T-Rex
     8. Le jeu des ballons
     9. Bilan
    10. Les jeux sur leur propre page (serpent, ninja, route)
    11. L'aventure
    12. Téléphones et petits écrans : version plus compacte
   ===================================================================== */


/* Les polices sont hébergées avec le site (dossier fonts/) : aucun appel
   à Google, donc pas de cookie ni de bandeau. Licence libre SIL OFL. */
@font-face { font-family: "Andika"; font-weight: 400; font-display: swap; src: url("../fonts/andika-400.woff2") format("woff2"); }
@font-face { font-family: "Andika"; font-weight: 700; font-display: swap; src: url("../fonts/andika-700.woff2") format("woff2"); }
@font-face { font-family: "Playwrite FR Moderne"; font-weight: 400; font-display: swap; src: url("../fonts/playwrite-fr-moderne.woff2") format("woff2"); }


/* ---------------------------------------------------------------------
   1. COULEURS
   Chaque jeu a sa couleur (data-couleur="orange", "violet"…) : elle
   remplit les variables --theme et --theme-soft.
   --------------------------------------------------------------------- */

:root {
  --sky-top: #7CC8FF; --sky-bottom: #E9F7FF; --grass: #7CCB68; --grass-dark: #5AAE47;
  --rex: #3E9E4C; --rex-dark: #2B7537; --rex-belly: #CDEBA6; --skin: #D9A06F;
  --cloud: rgba(255,255,255,.92); --bird: #2B3460;
  --paper: #FFFFFF; --line: #D6DEF5; --line-thin: #EEF2FB; --margin: #F07A8A;
  --ink: #23308F; --text: #1C2035; --muted: #566080;
  --card: #FFFFFF; --chip: #EEF1FB; --chip-on-text: #FFFFFF;
  --orange: #E2580C; --orange-soft: #FFEFE2;
  --violet: #6C4BEF; --violet-soft: #F0ECFF;
  --vert: #1F8A4C; --vert-soft: #E3F5E9;
  --rose: #D6336C; --rose-soft: #FCE7EF;
  --bleu: #1F6FD1; --bleu-soft: #E5F0FD;
  --turquoise: #0B8A94; --turquoise-soft: #DDF4F5;
  --ok: #17804F; --okbg: #E2F4EA; --ko: #B8430F; --kobg: #FCECE2; --hl: #FFE96B; --hl-text: #1C2035;
  --font-display: "Playwrite FR Moderne", "Segoe Script", "Comic Sans MS", cursive;
  --font-body: "Andika", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --r: 18px;
}

/* Thème sombre (réglage de l'appareil) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-top: #121842; --sky-bottom: #3A3472; --grass: #2F6B3A; --grass-dark: #245530;
    --rex: #4DB35B; --rex-dark: #2E8040; --rex-belly: #B8DD94; --skin: #C98F5F;
    --cloud: rgba(200,210,255,.16); --bird: #D3DBFF;
    --paper: #1D2337; --line: #2C3555; --line-thin: #232A44; --margin: #B4475A;
    --ink: #B3C3FF; --text: #E7EAF6; --muted: #A0A8C6;
    --card: #1D2337; --chip: #283050; --chip-on-text: #13182A;
    --orange: #FF9C5B; --orange-soft: #3A2618;
    --violet: #AE9BFF; --violet-soft: #2A2450;
    --vert: #5ED39B; --vert-soft: #16301F;
    --rose: #FF8FB3; --rose-soft: #3A1E2A;
    --bleu: #8CB8FF; --bleu-soft: #1C2A48;
    --turquoise: #5FD6DD; --turquoise-soft: #14313A;
    --ok: #5ED39B; --okbg: #16301F; --ko: #FF9C70; --kobg: #36211A; --hl: #6E5F10; --hl-text: #FFF6C9;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --sky-top: #121842; --sky-bottom: #3A3472; --grass: #2F6B3A; --grass-dark: #245530;
  --rex: #4DB35B; --rex-dark: #2E8040; --rex-belly: #B8DD94; --skin: #C98F5F;
  --cloud: rgba(200,210,255,.16); --bird: #D3DBFF;
  --paper: #1D2337; --line: #2C3555; --line-thin: #232A44; --margin: #B4475A;
  --ink: #B3C3FF; --text: #E7EAF6; --muted: #A0A8C6;
  --card: #1D2337; --chip: #283050; --chip-on-text: #13182A;
  --orange: #FF9C5B; --orange-soft: #3A2618;
  --violet: #AE9BFF; --violet-soft: #2A2450;
  --vert: #5ED39B; --vert-soft: #16301F;
  --rose: #FF8FB3; --rose-soft: #3A1E2A;
  --bleu: #8CB8FF; --bleu-soft: #1C2A48;
  --turquoise: #5FD6DD; --turquoise-soft: #14313A;
  --ok: #5ED39B; --okbg: #16301F; --ko: #FF9C70; --kobg: #36211A; --hl: #6E5F10; --hl-text: #FFF6C9;
  color-scheme: dark;
}

/* Couleur du jeu en cours */
body { --theme: var(--ink); --theme-soft: var(--chip); }
[data-couleur="orange"] { --theme: var(--orange); --theme-soft: var(--orange-soft); }
[data-couleur="violet"] { --theme: var(--violet); --theme-soft: var(--violet-soft); }
[data-couleur="vert"] { --theme: var(--vert); --theme-soft: var(--vert-soft); }
[data-couleur="rose"] { --theme: var(--rose); --theme-soft: var(--rose-soft); }
[data-couleur="bleu"] { --theme: var(--bleu); --theme-soft: var(--bleu-soft); }
[data-couleur="turquoise"] { --theme: var(--turquoise); --theme-soft: var(--turquoise-soft); }


/* ---------------------------------------------------------------------
   2. PAGE, EN-TÊTE, FEUILLE DE CAHIER
   --------------------------------------------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }

body {
  margin: 0;
  background-color: var(--sky-bottom);
  background-image: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body); font-size: 18px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  min-height: 100%;
}

/* Ciel animé : #sky derrière la feuille, #fx devant (ballons de félicitations) */
#sky, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#sky { z-index: 0; }
#fx { z-index: 5; }

.wrap {
  max-width: 760px; margin: 0 auto; padding-block: 20px 56px;
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 22px;
}

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand a { color: inherit; text-decoration: none; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(26px, 6vw, 36px); color: var(--ink); margin: 0; line-height: 1.6; }
.tag { font-weight: 700; font-size: 14px; letter-spacing: .08em; color: #fff; background: var(--margin); border-radius: 6px; padding: 1px 8px; }
.hright { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stars { font-weight: 700; color: var(--ink); background: var(--card); border-radius: 999px; padding: 5px 14px; font-variant-numeric: tabular-nums; box-shadow: 0 2px 0 var(--line); }
.motion { all: unset; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--ink); background: var(--card); border-radius: 999px; padding: 5px 12px; box-shadow: 0 2px 0 var(--line); }
.motion:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; color: var(--ink); margin: 0; line-height: 1.7; text-wrap: balance; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
p { margin: 0; }
.lead { color: var(--muted); }

/* Feuille de cahier : lignes Seyès discrètes, bandeau de la couleur du jeu */
.sheet {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--line-thin) 31px 32px);
  border-top: 8px solid var(--theme);
  border-radius: var(--r); padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 10px 30px rgba(20,40,90,.18);
}
section[data-couleur] h2 { color: var(--theme); }


/* ---------------------------------------------------------------------
   3. ACCUEIL : cartes des niveaux et des jeux
   --------------------------------------------------------------------- */

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.choice {
  all: unset; cursor: pointer; background: var(--theme-soft); border: 2px solid var(--theme);
  border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .2s;
}
.choice:hover { transform: translateY(-4px) rotate(-1deg); }
.choice:focus-visible { outline: 3px solid var(--theme); outline-offset: 3px; }
/* Sur téléphone : la tuile qu'on vient de lire (1er toucher) ; le 2e toucher l'ouvre */
.choice.lue { position: relative; outline: 4px solid var(--theme); outline-offset: 3px; }
.choice.lue::after {
  content: "👆 Touche encore pour ouvrir"; position: absolute; right: 10px; bottom: -14px;
  background: var(--theme); color: var(--chip-on-text); font-size: 13px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; animation: pop .35s ease-out;
}
.choice .big { font-family: var(--font-display); font-size: 30px; color: var(--theme); line-height: 1.6; }
.choice .big b { color: var(--margin); font-weight: 400; }
.choice strong { font-size: 21px; color: var(--text); }
.choice span { color: var(--muted); font-size: 16px; }
.choice .mini-stars { font-weight: 700; color: var(--ink); margin-top: 4px; }

/* Le choix des jeux en deux colonnes : les nombres et les calculs, les lettres et les mots */
.matieres { display: grid; gap: 22px; }
.matiere { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.matiere-titre { font-size: 17px; letter-spacing: .04em; color: var(--ink); background: var(--chip); border-radius: 12px; padding: 8px 14px; text-transform: none; }
.matiere .choices { grid-template-columns: 1fr; }
@media (min-width: 700px) { .matieres { grid-template-columns: 1fr 1fr; align-items: start; } }
.matiere.anglais { grid-column: 1 / -1; }
.matiere.anglais .choices { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
/* La liste des mots anglais dans « Je retiens » */
.vocabulaire { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.mot-anglais { all: unset; cursor: pointer; background: var(--theme-soft); border-radius: 8px; padding: 2px 8px; color: var(--muted); box-shadow: 0 2px 0 var(--line); }
.mot-anglais:hover { box-shadow: 0 0 0 2px var(--theme); }
.mot-anglais:active { transform: translateY(2px); }
.mot-anglais:focus-visible { outline: 2px solid var(--theme); }
.vocabulaire b { color: var(--text); }

/* Grands écrans : 2 cartes par ligne dans chaque colonne (la page s'élargit seulement sur le choix des jeux) */
@media (min-width: 1100px) {
  .wrap:has(#home:not([hidden]) #games) { max-width: 1180px; }
  #games .choices { grid-template-columns: 1fr 1fr; }
  #games .matiere.anglais .choices { grid-template-columns: repeat(4, 1fr); }     /* toute la largeur : 4 par ligne */
  #games .choice { padding: 18px; }
  #games .choice .big { font-size: 26px; }
  #games .choice strong { font-size: 19px; }
  #games .choice span { font-size: 15px; }
}

/* Grands écrans : les réglages à gauche, « Je retiens » à droite (tout tient sans défiler) */
@media (min-width: 1100px) {
  .wrap:has(#setup:not([hidden]) .retiens:not([hidden])) { max-width: 1180px; }
  #setup .sheet:has(> .retiens:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: repeat(7, auto) 1fr; column-gap: 32px; align-items: start; }
  #setup .sheet > * { grid-column: 1; }
  #setup .sheet > .retiens { grid-column: 2; grid-row: 1 / -1; }      /* la dernière ligne (1fr) absorbe la hauteur en trop */
}

/* Cartes des niveaux (page d'accueil) : un peu plus grandes */
/* Le grand titre (GS, CP, CE1 · CE2) rapetisse avec sa carte pour tenir sur une ligne */
.niveau { container-type: inline-size; }
.niveau .big { font-size: min(40px, 17cqi); white-space: nowrap; }
/* Les 3 classes (GS, CP, CE) côte à côte dès que la place le permet, sinon l'une sous l'autre */
.choices:has(> .niveau) { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }


/* ---------------------------------------------------------------------
   4. RÉGLAGES : puces, « Je retiens »
   --------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  all: unset; cursor: pointer; background: var(--theme-soft); color: var(--text);
  border-radius: 999px; padding: 7px 16px; font-weight: 700; font-size: 17px;
  border: 2px solid transparent; font-variant-numeric: tabular-nums; transition: transform .12s;
}
.chip:hover { border-color: var(--theme); }
.chip[aria-pressed="true"] { background: var(--theme); color: var(--chip-on-text); transform: scale(1.05); }
.chip:focus-visible { outline: 3px solid var(--margin); outline-offset: 2px; }
.group { display: flex; flex-direction: column; gap: 10px; }
.groups { display: flex; flex-direction: column; gap: 18px; }

/* « Plus d'options » : seulement sur téléphone (voir optionsRepliables dans commun.js) */
.plus-options { display: none; }
@media (max-width: 600px) {
  .groups.repliable:not(.ouvert) > .en-plus { display: none; }
  .plus-options {
    all: unset; display: block; align-self: flex-start; cursor: pointer;
    padding: 7px 16px; border-radius: 999px; border: 2px dashed var(--theme);
    color: var(--theme); font-weight: 700; font-size: 16px;
  }
}

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  all: unset; cursor: pointer; background: var(--theme); color: var(--chip-on-text);
  font-weight: 700; font-size: 19px; border-radius: 14px; padding: 12px 26px; text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .1s;
}
/* « C'est parti ! » : vert, bien visible juste sous les choix */
.btn.partir { background: var(--vert); font-size: 21px; padding: 14px 34px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn.counting { position: relative; overflow: hidden; }
.btn .timer { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: rgba(255,255,255,.75); transform-origin: left; animation: countdown 5s linear forwards; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.btn.ghost { background: transparent; color: var(--theme); border: 2px solid var(--theme); box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--margin); outline-offset: 3px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* « ← Retour aux jeux », « ← Changer de classe », « ← Arrêter » : de vrais boutons, bien visibles */
.back {
  all: unset; cursor: pointer; align-self: flex-start; justify-self: start; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 17px; color: var(--theme); background: var(--theme-soft);
  border: 2px solid var(--theme); border-radius: 999px; padding: 7px 18px; box-shadow: 0 3px 0 var(--line); transition: transform .1s;
}
.back:hover { background: var(--theme); color: var(--chip-on-text); }
.back:active { transform: translateY(2px); box-shadow: none; }
.back:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.qtop .back { font-size: 15px; padding: 5px 14px; }
.warn { color: var(--ko); font-weight: 700; font-size: 16px; }

/* Je retiens */
.retiens { border: 2px dashed var(--margin); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.retiens h3 { color: var(--margin); }
.retiens-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.titre-jeu { display: flex; align-items: center; gap: 12px; }
.chip.hasard { border-style: dashed; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px 16px; font-variant-numeric: tabular-nums; }
.tables div { display: flex; flex-direction: column; }
.tables b { color: var(--ink); }
.rules { display: grid; gap: 6px; margin: 0; padding-left: 20px; }
.end { color: var(--margin); font-weight: 700; }


/* ---------------------------------------------------------------------
   5. EXERCICE
   --------------------------------------------------------------------- */

.qtop { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.qtop .bar { flex: 1 1 120px; }
.restart { all: unset; cursor: pointer; font-weight: 700; font-size: 16px; color: var(--theme); background: var(--theme-soft); border-radius: 999px; padding: 4px 12px; }
.restart:focus-visible { outline: 2px solid var(--theme); outline-offset: 2px; }
.confirm { background: var(--card); border: 2px solid var(--ko); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.confirm p { font-weight: 700; }
.confirm .btn:not(.ghost) { background: var(--ko); }
.toast { background: var(--okbg); color: var(--ok); font-weight: 700; border-radius: 12px; padding: 10px 16px; }
/* Note pour les parents, en bas de l'accueil */
.note-parents { position: relative; max-width: 640px; margin: 14px auto 0; padding: 8px 14px; border-radius: 12px; background: var(--card); color: var(--muted); font-size: 13px; text-align: center; opacity: .9; }
.bar { flex: 1; height: 12px; background: var(--theme-soft); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--theme) 0 10px, color-mix(in srgb, var(--theme) 75%, #fff) 10px 20px); border-radius: 999px; transition: width .4s; }
.count { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 16px; }

/* Consigne, avec le bouton pour l'écouter */
.consigne { display: flex; align-items: center; gap: 10px; }
.qlabel { font-size: 18px; color: var(--muted); }
.dire { all: unset; cursor: pointer; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--theme-soft); text-align: center; line-height: 40px; font-size: 20px; }
.dire:focus-visible { outline: 3px solid var(--theme); outline-offset: 2px; }
.verb { font-family: var(--font-display); color: var(--theme); font-size: 24px; }

/* Ligne de la question (calcul, conjugaison…) */
.qline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: clamp(30px, 8vw, 44px); font-weight: 700; font-variant-numeric: tabular-nums; }
.qline.texte { font-size: clamp(24px, 6vw, 32px); }
.answer { font: inherit; color: var(--theme); background: transparent; border: none; border-bottom: 3px solid var(--theme); width: 3.2ch; padding: 0 4px; text-align: center; border-radius: 0; }
.answer.chiffres4 { width: 4.2ch; }
/* Précision « (plusieurs) » à côté de ils / elles */
.nombre-pers { font-size: .5em; font-weight: 700; color: var(--theme); background: var(--theme-soft); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.answer.wide { width: min(11ch, 100%); text-align: left; flex: 1 1 180px; min-width: 0; }
.answer:focus { outline: none; background: var(--theme-soft); }
.answer.good { border-color: var(--ok); color: var(--ok); }
.answer.bad { border-color: var(--ko); color: var(--ko); text-decoration: line-through; }

/* Opération posée (en colonnes) */
.qline.posee { justify-content: center; cursor: pointer; }
.pose { display: inline-grid; grid-template-columns: repeat(var(--colonnes), 1.1em); justify-items: center; line-height: 1.3; font-variant-numeric: tabular-nums; }
.pose .op-signe { color: var(--theme); }
.pose .trait { grid-column: 1 / -1; justify-self: stretch; border-top: 4px solid var(--ink); margin: 4px 0 6px; }
.pose .case { width: .95em; height: 1.2em; border: 2px dashed var(--line); border-radius: 8px; color: var(--theme); display: grid; place-items: center; }
.pose .case.active { border: 3px solid var(--theme); background: var(--theme-soft); }
.pose .case.juste { border-color: transparent; color: var(--ok); animation: pop .35s ease-out; }   /* le résultat écrit après la réponse */
.pose .retenue { font-size: .45em; color: var(--ko); align-self: end; }
.posee.juste .case { border-color: var(--ok); color: var(--ok); }
.posee.faux .case { border-color: var(--ko); color: var(--ko); text-decoration: line-through; }
.posee.juste .case.active, .posee.faux .case.active { background: none; border: 2px dashed var(--line); }
.answer.cache { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pose.petite { font-size: 26px; font-weight: 700; margin: 4px 0 8px; }
.pose.petite .case { border: none; color: var(--ok); }
.accents { display: flex; gap: 6px; flex-wrap: wrap; }
.accents button { all: unset; cursor: pointer; background: var(--theme-soft); border-radius: 8px; min-width: 40px; text-align: center; padding: 4px 6px; font-size: 20px; font-weight: 700; }
.accents button:focus-visible { outline: 2px solid var(--ink); }

/* Réponses à toucher (choix) */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.option {
  all: unset; cursor: pointer; position: relative;
  background: var(--theme-soft); color: var(--text); border: 3px solid transparent;
  border-radius: 16px; padding: 14px 10px; text-align: center;
  font-size: clamp(24px, 6vw, 32px); font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 0 var(--line); transition: transform .1s;
}
.option:hover { border-color: var(--theme); }
.option:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.option:focus-visible { outline: 3px solid var(--margin); outline-offset: 2px; }
.option.grand { font-size: clamp(44px, 12vw, 60px); line-height: 1.2; }
/* Réponses longues (« Déterminant ») : texte plus petit pour rester dans la tuile */
.option.long { font-size: clamp(17px, 4.4vw, 24px); overflow-wrap: anywhere; }
.option.good { background: var(--okbg); border-color: var(--ok); color: var(--ok); }
.option.bad { background: var(--kobg); border-color: var(--ko); color: var(--ko); }
.option.right { border-color: var(--ok); box-shadow: 0 0 0 4px var(--okbg); }
.option:disabled { cursor: default; }
.option .key { position: absolute; top: 4px; right: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
@media (hover: none) { .option .key { display: none; } }

/* Correction */
.fb { border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.fb.ok { background: var(--okbg); color: var(--ok); }
.fb.ko { background: var(--kobg); color: var(--ko); }
.fb .msg { font-weight: 700; font-size: 21px; }
.fb .detail { color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.fb mark { background: var(--hl); color: var(--hl-text); padding: 0 4px; border-radius: 4px; }
.fb mark.juste { background: none; color: var(--ok); font-size: 24px; font-weight: 700; padding: 0; }
.helptab { display: grid; gap: 2px; color: var(--text); font-variant-numeric: tabular-nums; }
.helptab .row { padding: 2px 8px; border-radius: 6px; }
.helptab .row.hit { background: var(--hl); color: var(--hl-text); font-weight: 700; }
.petit { font-size: 15px; color: var(--muted); }
.remarque { font-weight: 700; }
/* Sur grand écran, l'aide (tables, conjugaison) tient sur deux colonnes : moins haute */
@media (min-width: 601px) {
  .helptab { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .helptab > :not(.row), .helptab > .large { grid-column: 1 / -1; }
}

/* Pavé numérique (tablette) */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; width: 100%; align-self: center; }
.keypad button { all: unset; cursor: pointer; background: var(--theme-soft); box-shadow: 0 3px 0 var(--line); border-radius: 12px; padding: 12px 0; text-align: center; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.keypad button:active { transform: scale(.96); }
.keypad button:focus-visible { outline: 3px solid var(--ink); }
.keypad .ok { background: var(--theme); color: var(--chip-on-text); font-size: 20px; }


/* ---------------------------------------------------------------------
   6. DESSINS DES QUESTIONS
   --------------------------------------------------------------------- */

.visuel { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Objets à compter, rangés par paquets de 5 */
.objets { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; font-size: clamp(30px, 8vw, 42px); line-height: 1.2; }
.paquet { display: flex; gap: 4px; }
.objets .barre { position: relative; opacity: .35; }
/* « Compte avec moi » : l'objet qu'on est en train de compter, puis ceux déjà comptés */
.objets .compte { position: relative; }
.objets .compte::after { content: attr(data-n); position: absolute; left: 50%; bottom: -.55em; transform: translateX(-50%); font-size: .42em; font-weight: 700; color: var(--theme); }
.objets .compte-ici { transform: scale(1.25); filter: drop-shadow(0 0 8px var(--theme)); transition: transform .15s; }
.objets .compte-ici::before { content: ""; position: absolute; left: 10%; right: 10%; bottom: -.08em; height: 4px; border-radius: 2px; background: var(--theme); }
.objets .barre::after { content: "✖"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ko); font-size: .8em; opacity: 1; }
/* Petits problèmes : l'histoire et la scène animée */
.histoire { font-size: clamp(19px, 4.8vw, 23px); font-weight: 700; line-height: 1.5; text-align: center; color: var(--text); text-wrap: balance; }
/* Boîtes de 10 (Faire 10) */
.boites { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.boite-dix { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px; border: 3px solid var(--theme); border-radius: 10px; background: var(--card); }
.boite-dix span { width: clamp(26px, 7vw, 38px); aspect-ratio: 1; border-radius: 50%; border: 2px dashed var(--line); }
.boite-dix .plein { background: var(--theme); border: none; }
.boite-dix .ajout { background: var(--hl); border: 2px solid var(--ok); }

/* Syllabes */
.grand-mot .sep { color: var(--muted); padding: 0 .15em; }
.syllabes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.syllabes span { background: var(--theme-soft); color: var(--text); font-weight: 700; font-size: 22px; border-radius: 10px; padding: 4px 12px; }
.syllabes span.hit { background: var(--hl); color: var(--hl-text); }

/* Monnaie : pièces et billets dessinés en CSS */
.argent { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.piece, .billet { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #3A2A05; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.piece { width: 58px; height: 58px; border-radius: 50%; font-size: 15px; }
.piece b { font-size: 24px; }
.piece.e1 { background: radial-gradient(circle, #DADDE3 0 55%, #E9B949 56%); border: 3px solid #C99A2E; }
.piece.e2 { background: radial-gradient(circle, #E9B949 0 55%, #DADDE3 56%); border: 3px solid #A9AEB8; }
.billet { min-width: 92px; height: 52px; border-radius: 6px; font-size: 16px; padding: 0 8px; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.5); }
.billet b { font-size: 26px; }
.billet.b5 { background: linear-gradient(135deg, #8E9AAF, #6B778D); }
.billet.b10 { background: linear-gradient(135deg, #D9534F, #B23B37); }
.billet.b20 { background: linear-gradient(135deg, #3E7CC9, #2B5C9E); }
.billet.b50 { background: linear-gradient(135deg, #E88A2E, #C46B12); }

/* La marchande : l'étiquette de prix, et les porte-monnaie dans les réponses */
.etiquette { display: flex; align-items: center; gap: 14px; }
.etiquette .article { font-size: clamp(64px, 16vw, 90px); line-height: 1; }
.etiquette .prix { font-size: 30px; font-weight: 700; color: #1C2035; background: #FFD36A; border-radius: 10px 24px 24px 10px; padding: 6px 18px 6px 14px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.argent.petit { gap: 4px; }
.argent.petit .piece { width: 40px; height: 40px; font-size: 11px; }
.argent.petit .piece b { font-size: 17px; }

/* Les lettres en désordre : une case par lettre */
.qline.ordre { justify-content: center; gap: 8px; }
.case-lettre { all: unset; cursor: pointer; width: 1.3em; height: 1.5em; display: grid; place-items: center; border-bottom: 4px solid var(--theme); background: var(--theme-soft); border-radius: 8px 8px 0 0; color: var(--text); }
.qline.ordre.juste .case-lettre { border-color: var(--ok); color: var(--ok); }
.qline.ordre.faux .case-lettre { border-color: var(--ko); color: var(--ko); }
.option.utilisee { opacity: .25; }
.case-lettre.apercu { color: var(--theme); background: var(--card); }
.option.attente { visibility: hidden; }
.revoir { align-self: center; }

/* Nature des mots : le mot à reconnaître */
.phrase .cible { color: var(--theme); text-decoration-thickness: 3px; text-underline-offset: 5px; }

/* La cuisine : le plat, le saladier qui se remplit, les ingrédients cochés */
.recette { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.recette .plat { font-size: clamp(64px, 16vw, 90px); line-height: 1; }
.bol {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 2px;
  width: min(280px, 80%); min-height: 64px; padding: 6px 14px 10px; font-size: 30px;
  background: linear-gradient(to bottom, transparent 0 20%, #F4E3C3 20%); border: 4px solid #C9A46A; border-top: none;
  border-radius: 0 0 140px 140px / 0 0 64px 64px;
}
.bol span { animation: tombe .35s ease-out; }
@keyframes tombe { from { transform: translateY(-40px); opacity: 0; } }
.options.grille { grid-template-columns: repeat(var(--colonnes, 3), minmax(0, 1fr)); }
.option.panier { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px;
  font-size: clamp(16px, 4vw, 22px); line-height: 1.15; overflow-wrap: anywhere; }
.option.panier .ing-image { font-size: clamp(30px, 8vw, 40px); line-height: 1.1; }
.option.panier[aria-pressed="true"] { border-color: var(--theme); background: var(--theme-soft); box-shadow: 0 0 0 3px var(--theme); }
.option.panier[aria-pressed="true"]::after { content: "✔"; position: absolute; left: 8px; top: 4px; font-size: 16px; color: var(--theme); }

.dans-ma-tete { font-weight: 700; font-size: 19px; color: var(--theme); background: var(--theme-soft); border-radius: 999px; padding: 6px 16px; }
.scene { display: flex; align-items: center; justify-content: center; gap: 10px 22px; flex-wrap: wrap; }
.scene .acteur { font-size: clamp(48px, 12vw, 64px); line-height: 1; animation: arriver 1s ease-out .3s backwards, sautille .5s ease-in-out 1.3s 4 alternate; }
/* état final (sans animation) : les objets partis sont barrés, les nouveaux brillent */
.scene .part { position: relative; opacity: .35; animation: partir .7s ease-in backwards; animation-delay: calc(1.4s + var(--i) * .45s); }
.scene .part::after { content: "✖"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ko); font-size: .8em; animation: apparaitre .3s backwards; animation-delay: calc(2s + var(--i) * .45s); }
.scene .arrive { filter: drop-shadow(0 0 6px var(--theme)); animation: venir .6s ease-out backwards; animation-delay: calc(1.4s + var(--i) * .45s); }
@keyframes arriver { from { transform: translateX(120px); opacity: 0; } 70% { transform: translateX(-8px) translateY(-16px); opacity: 1; } }
@keyframes sautille { to { transform: translateY(-10px); } }
@keyframes partir { from { opacity: 1; transform: none; } 45% { opacity: 1; transform: translateY(-18px) scale(1.25); } }
@keyframes apparaitre { from { opacity: 0; transform: scale(2); } }
@keyframes venir { from { opacity: 0; transform: translateX(90px) scale(.3); } }
.sans-animation .scene *, .sans-animation .scene *::after { animation: none !important; }

.operation { display: flex; align-items: center; justify-content: center; gap: 10px 16px; flex-wrap: wrap; }
.operation .signe { font-size: 36px; font-weight: 700; color: var(--theme); }

/* Frise de nombres */
.frise { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.frise span { min-width: 58px; padding: 10px 8px; border: 2px solid var(--theme); border-radius: 12px; text-align: center; font-size: 26px; font-weight: 700; background: var(--card); font-variant-numeric: tabular-nums; }
.frise .trou { background: var(--theme-soft); color: var(--theme); border-style: dashed; }
.frise.petite span { min-width: 40px; padding: 4px 6px; font-size: 18px; }
.frise .hit { background: var(--hl); color: var(--hl-text); }

/* Grande image, grand mot, grand nombre, grande lettre */
.image { font-size: clamp(80px, 22vw, 120px); line-height: 1.1; text-align: center; }
.grand-mot { font-size: clamp(36px, 10vw, 54px); font-weight: 700; letter-spacing: .06em; color: var(--text); text-align: center; }
.grand-mot .manque { color: var(--theme); border-bottom: 4px solid var(--theme); padding: 0 .1em; }
.grande-lettre { font-size: clamp(80px, 22vw, 120px); font-weight: 700; color: var(--theme); line-height: 1.1; }
.grand-nombre { font-size: clamp(56px, 16vw, 84px); font-weight: 700; color: var(--theme); letter-spacing: .08em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.en-lettres { font-family: var(--font-display); font-size: clamp(22px, 5.5vw, 30px); color: var(--theme); text-align: center; line-height: 1.8; }

/* Phrase à compléter */
.phrase { font-size: clamp(22px, 5.5vw, 28px); font-weight: 700; line-height: 1.6; text-align: center; }
.phrase .blanc { display: inline-block; min-width: 3ch; border-bottom: 3px solid var(--theme); color: var(--theme); text-align: center; }

/* Comparaison avec un signe à trouver */
.comparaison { font-size: clamp(40px, 11vw, 60px); font-weight: 700; display: flex; gap: 20px; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.comparaison .blanc { min-width: 1.4em; text-align: center; color: var(--theme); border-bottom: 4px solid var(--theme); }

/* Tableau centaines / dizaines / unités */
.cdu { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cdu th, .cdu td { border: 2px solid var(--line); padding: 4px 14px; text-align: center; }
.cdu th { font-size: 14px; color: var(--muted); }
.cdu td { font-size: 24px; font-weight: 700; }
.cdu .hit { background: var(--hl); color: var(--hl-text); }

/* Horloge */
.horloge { width: min(230px, 62vw); height: auto; display: block; }
.horloge .cadran { fill: var(--card); stroke: var(--theme); stroke-width: 6; }
.horloge .trait { stroke: var(--muted); stroke-width: 1.5; }
.horloge .trait.fort { stroke: var(--text); stroke-width: 3; }
.horloge text { fill: var(--text); font-family: var(--font-body); font-size: 17px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.horloge .heures { stroke: var(--text); stroke-width: 8; stroke-linecap: round; }
.horloge .minutes { stroke: var(--theme); stroke-width: 5; stroke-linecap: round; }
.horloge .centre { fill: var(--text); }


/* ---------------------------------------------------------------------
   7. LA COURSE DU T-REX
   Il avance d'un pas à chaque erreur, recule à chaque bonne réponse.
   --------------------------------------------------------------------- */

.chase { position: relative; height: 152px; border-radius: 14px; background: var(--theme-soft); }
.ground { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; background: var(--grass); border-top: 3px solid var(--grass-dark); border-radius: 0 0 14px 14px; }
.rex { position: absolute; bottom: 12px; left: calc(6px + var(--p, 0) * (100% - 196px)); width: 112px; transition: left 1.3s ease-in-out; }
.kid { position: absolute; bottom: 12px; right: 14px; width: 54px; }
.rex svg, .kid svg { display: block; width: 100%; height: auto; overflow: visible; }
.rex .leg { transform-box: fill-box; transform-origin: 50% 0; }
.rex.walk svg { animation: bob .32s ease-in-out infinite alternate; }
.rex.walk .leg1 { animation: step .32s ease-in-out infinite alternate; }
.rex.walk .leg2 { animation: step .32s ease-in-out infinite alternate-reverse; }
.rex .arm { transform-box: fill-box; transform-origin: 0 50%; transition: transform .3s; }
.rex.hug .arm { transform: rotate(-35deg); animation: wiggle .25s ease-in-out infinite alternate; }
.kid .mouth-o { display: none; }
.kid.scared .mouth-o { display: inline; }
.kid.scared .mouth-ok { display: none; }
.kid.scared svg { animation: shake .18s linear infinite alternate; }
.kid.jump svg { animation: jump .5s ease-out; }
.bubble { position: absolute; bottom: 100%; margin-bottom: -6px; background: var(--card); color: var(--text); font-weight: 700; font-size: 14px; line-height: 1.25; padding: 5px 10px; border-radius: 12px; box-shadow: 0 2px 0 var(--line); white-space: nowrap; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; pointer-events: none; }
.rex .bubble { left: 40px; }
.kid .bubble { right: 0; }
.bubble.show { opacity: 1; transform: none; }
.bubble.long { white-space: normal; width: min(220px, 58vw); }
.rex .bubble.long { left: auto; right: -6px; }
@keyframes bob { to { transform: translateY(-4px); } }
@keyframes step { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
@keyframes wiggle { from { transform: rotate(-25deg); } to { transform: rotate(-50deg); } }
@keyframes shake { from { transform: translateX(-1.5px); } to { transform: translateX(1.5px); } }
@keyframes jump { 40% { transform: translateY(-18px); } 100% { transform: none; } }


/* ---------------------------------------------------------------------
   8. LE JEU DES BALLONS : on éclate le bon ballon avec une fléchette
   --------------------------------------------------------------------- */

:root {
  --dart-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cpath d='M2 2 L11 6 L6 11 Z' fill='%23C9CED8' stroke='%23fff' stroke-width='1.2'/%3E%3Cline x1='8' y1='8' x2='26' y2='26' stroke='%23fff' stroke-width='5' stroke-linecap='round'/%3E%3Cline x1='8' y1='8' x2='26' y2='26' stroke='%233A3F55' stroke-width='3' stroke-linecap='round'/%3E%3Crect x='12.5' y='12.5' width='6' height='6' transform='rotate(45 15.5 15.5)' fill='%23E2580C'/%3E%3Cpath d='M24 24 L35 25 L29 29 Z' fill='%23E83E6C' stroke='%23fff' stroke-width='1'/%3E%3Cpath d='M24 24 L25 35 L29 29 Z' fill='%232F80ED' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E");
  --dart: var(--dart-img) 2 2, crosshair;
}
.arena { position: relative; height: 340px; border-radius: 14px; overflow: hidden; background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom)); cursor: var(--dart); touch-action: manipulation; --bw: clamp(60px, 17vw, 80px); }
.arena * { cursor: var(--dart); }
.arena::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 16px; background: var(--grass); border-top: 3px solid var(--grass-dark); }
.pballoon { all: unset; position: absolute; top: 0; width: var(--bw); height: calc(var(--bw) * 1.45); will-change: transform; -webkit-tap-highlight-color: transparent; }
.pballoon .shape {
  position: absolute; left: 0; top: 0; width: 100%; height: calc(var(--bw) * 1.16);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 30% 26%, rgba(255,255,255,.6) 0 9%, transparent 10%), var(--c);
  box-shadow: inset -6px -9px 0 rgba(0,0,0,.14);
  color: #fff; font-size: calc(var(--bw) * .38); font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.28); font-variant-numeric: tabular-nums;
}
.pballoon .shape::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-bottom-color: var(--c); border-top: 0; }
.pballoon::after { content: ""; position: absolute; left: 50%; top: calc(var(--bw) * 1.16 + 4px); width: 2px; height: calc(var(--bw) * .28); background: var(--bird); opacity: .5; }
.pballoon .key { position: absolute; right: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--card); color: var(--text); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 0 var(--line); }
.pballoon:focus-visible .shape { outline: 4px solid var(--card); outline-offset: 3px; }
.pballoon.popped .shape { animation: popb .28s ease-out forwards; }
.pballoon.popped::after, .pballoon.popped .key { opacity: 0; }
.pballoon.fly { transition: transform 1.1s ease-in, opacity 1.1s ease-in; opacity: 0; }
.pballoon.right .shape { box-shadow: 0 0 0 5px #fff, 0 0 0 10px var(--ok); animation: pulse .55s ease-in-out infinite alternate; }
.dartstuck { position: absolute; width: 36px; height: 36px; background: var(--dart-img) no-repeat; pointer-events: none; animation: throw .16s ease-out; }
.confetti { position: absolute; width: 9px; height: 9px; border-radius: 2px; background: var(--c); pointer-events: none; animation: burst .6s ease-out forwards; }
@keyframes popb { 0% { transform: scale(1); } 50% { transform: scale(1.3); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes pulse { to { transform: scale(1.08); } }
@keyframes throw { from { transform: translate(70px, 90px) rotate(10deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }


/* ---------------------------------------------------------------------
   9. BILAN
   --------------------------------------------------------------------- */

.result-stars { font-size: 52px; letter-spacing: 6px; line-height: 1.2; }
.result-stars .off { opacity: .2; }
.score { font-size: 22px; font-weight: 700; }
.mistakes { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.mistakes li { background: var(--theme-soft); border-radius: 8px; padding: 6px 12px; }
.mistakes li b { color: var(--ok); }

@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
.pop { animation: pop .35s ease-out; }

/* ---------------------------------------------------------------------
   10. LES JEUX SUR LEUR PROPRE PAGE : le serpent, le ninja, la route
   --------------------------------------------------------------------- */

/* Le serpent des tables (snake.html) */
.vies { font-size: 20px; letter-spacing: 2px; }
.snake-tete { display: flex; align-items: center; gap: 10px; }
.snake-question { flex: 1; text-align: center; font-size: clamp(30px, 8vw, 44px); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.snake-question b { color: var(--theme); }
.snake-question b.juste { color: var(--ok); }
.snake-zone { position: relative; width: 100%; display: flex; justify-content: center; }
#terrain { display: block; width: min(100%, 560px, max(240px, calc(100svh - 330px))); aspect-ratio: 1; border-radius: 14px; border: 3px solid var(--theme); touch-action: none; }
.snake-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; max-width: 90%; text-align: center;
  background: var(--card); color: var(--text); font-weight: 700; font-size: 22px; border-radius: 14px; padding: 12px 18px; box-shadow: 0 4px 0 var(--line); }
.fleches { display: grid; grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(2, 60px); gap: 8px; justify-content: center; }
.fleches button { all: unset; cursor: pointer; display: grid; place-items: center; background: var(--theme-soft); color: var(--theme); border-radius: 14px; font-size: 24px; box-shadow: 0 3px 0 var(--line); -webkit-tap-highlight-color: transparent; }
.fleches button:active { transform: translateY(3px); box-shadow: none; }
.fleches [data-dir="haut"] { grid-column: 2; grid-row: 1; }
.fleches [data-dir="gauche"] { grid-column: 1; grid-row: 2; }
.fleches [data-dir="bas"] { grid-column: 2; grid-row: 2; }
.fleches [data-dir="droite"] { grid-column: 3; grid-row: 2; }
/* Ordinateur avec souris : on joue au clavier, les flèches à l'écran ne servent pas */
@media (hover: hover) and (pointer: fine) { .fleches { display: none; } }

/* Le ninja des toits (ninja.html) */
.ninja-scene {
  position: relative; height: clamp(230px, 34vh, 300px); overflow: hidden; border-radius: 14px;
  background:
    radial-gradient(circle at 82% 22%, #FFF6D5 0 22px, rgba(255,246,213,.25) 23px 30px, transparent 31px),   /* la lune */
    linear-gradient(to bottom, #141A3E, #3A3472 75%, #5B4C8C);
}
.ninja-scene::before {        /* la ville au loin */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%; opacity: .5;
  background: linear-gradient(to top, #232A52 30%, transparent 30%),
    repeating-linear-gradient(90deg, #232A52 0 40px, transparent 40px 52px, #232A52 52px 80px, transparent 80px 96px);
  -webkit-mask: linear-gradient(to top, #000 60%, transparent); mask: linear-gradient(to top, #000 60%, transparent);
}
.ninja-monde { position: absolute; left: 0; top: 0; bottom: 0; }
.toit {
  position: absolute; bottom: 0; border-radius: 6px 6px 0 0; border-top: 5px solid #6E7BB8;
  background: conic-gradient(from 90deg at 14px 14px, rgba(255, 211, 106, .55) 25%, transparent 0) 0 6px / 22px 24px, #2E3558;
}
.toit.arrivee { border-top-color: #FFD36A; }
.drapeau { position: absolute; left: 50%; bottom: 100%; transform: translateX(-30%); font-size: 40px; line-height: 1; }
.ninja { position: absolute; width: 56px; z-index: 2; }
.ninja svg { display: block; width: 100%; height: auto; }
.ninja.grappin::before { content: ""; position: absolute; left: 60%; bottom: 70%; width: 2px; height: 600px; background: rgba(255,255,255,.85); }
.ninja-bulle {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); margin: 0; z-index: 3;
  background: var(--card); color: var(--text); font-weight: 700; font-size: 22px; border-radius: 14px; padding: 8px 16px; box-shadow: 0 4px 0 var(--line);
}
.ninja-choix { grid-template-columns: 1fr 1fr; }
/* Niveau « course » : le long toit, les trous et les murs */
.sol { position: absolute; left: 0; bottom: 0; border-top: 5px solid #6E7BB8;
  background: conic-gradient(from 90deg at 14px 14px, rgba(255, 211, 106, .45) 25%, transparent 0) 0 6px / 26px 24px, #2E3558; }
.trou { position: absolute; bottom: 0; background: linear-gradient(to bottom, #141A3E, #07091A); border-radius: 0 0 6px 6px; z-index: 1; }
.mur { position: absolute; height: 62px; border-radius: 4px 4px 0 0; z-index: 1;
  background: repeating-linear-gradient(0deg, #B5543A 0 14px, #8E3F2B 14px 16px), #B5543A; box-shadow: inset 0 0 0 2px #8E3F2B; }
.trou.ok, .mur.ok { box-shadow: 0 0 0 3px #5ED39B, 0 0 16px #5ED39B; }
.ninja.court svg { animation: course .26s ease-in-out infinite alternate; filter: drop-shadow(0 0 calc(var(--halo, 0) * 14px) rgba(255, 232, 140, .95)); }
@keyframes course { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-4px) rotate(3deg); } }

/* La route des tables (route.html) */
.route { position: relative; height: clamp(230px, 36vh, 320px); overflow: hidden; border-radius: 14px; background: #4A4F63; cursor: pointer; touch-action: manipulation; --defile: 0px; }
.route-herbe { position: absolute; left: 0; right: 0; height: 12%; background: repeating-linear-gradient(90deg, #5DB24B 0 40px, #4E9E3F 40px 80px); background-position-x: var(--defile); }
.route-herbe.haut { top: 0; border-bottom: 4px solid #E9EDF5; }
.route-herbe.bas { bottom: 0; border-top: 4px solid #E9EDF5; }
.route-ligne { position: absolute; left: 0; right: 0; height: 4px; margin-top: -2px; opacity: .8; background: repeating-linear-gradient(90deg, #fff 0 34px, transparent 34px 68px); background-position-x: var(--defile); }
.porte { position: absolute; left: 0; top: 0; bottom: 0; width: 0; z-index: 1; }
.panneau {
  position: absolute; left: 0; transform: translateY(-50%); min-width: 58px; padding: 2px 10px; text-align: center;
  font-weight: 700; font-size: clamp(22px, 5vw, 30px); color: #1C2035; background: #FFD36A; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.panneau.bon { background: #5ED39B; }
.panneau.parti { opacity: 0; transition: opacity .3s; }
.panneau.plot { background: none; border: none; box-shadow: none; font-size: 40px; }
.vehicule { position: absolute; left: 5%; top: 50%; width: clamp(80px, 16vw, 120px); transform: translateY(-50%); transition: top .35s ease-in-out; z-index: 2; }
.vehicule svg { display: block; width: 100%; height: auto; overflow: visible; position: relative;
  filter: drop-shadow(0 0 calc(var(--halo, 0) * 16px) rgba(255, 232, 140, .95)); }
/* Le halo de vitesse : une traînée de lumière derrière le véhicule (--halo va de 0 à 1) */
.vehicule::before, .ninja.court::after {      /* (::after pour le ninja : ::before est déjà la corde du grappin) */
  content: ""; position: absolute; top: 50%; right: 70%; height: 55%; width: calc(var(--halo, 0) * 150px);
  transform: translateY(-50%); border-radius: 999px; pointer-events: none;
  background: linear-gradient(to left, rgba(255, 236, 160, calc(var(--halo, 0) * .9)), transparent);
  filter: blur(3px);
}
.vehicule .roue { transform-box: fill-box; transform-origin: center; animation: tourne .45s linear infinite; }
.vehicule.monte svg { animation: penche .4s ease-in-out; --angle: -12deg; }
.vehicule.descend svg { animation: penche .4s ease-in-out; --angle: 12deg; }
.vehicule.choc svg { animation: shake .1s linear 6 alternate; }
.vehicule.choc .roue { animation-play-state: paused; }
@keyframes tourne { to { transform: rotate(360deg); } }
@keyframes penche { 50% { transform: rotate(var(--angle)); } }
.route-choix { grid-template-columns: repeat(3, 1fr); }
.route-choix .option.voie { border-color: var(--theme); box-shadow: 0 0 0 4px var(--theme-soft); }
.route-choix .option.parti { opacity: .4; }
.route-choix .key { font-size: 11px; }


/* ---------------------------------------------------------------------
   11. L'AVENTURE : le bandeau sur la page des jeux, et la carte
   --------------------------------------------------------------------- */

/* L'aventure : le bandeau sur la page des jeux, et la carte (aventure.html) */
.matieres > .banniere { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 18px; flex-wrap: wrap; }
.matieres > .banniere .big { font-size: 40px; }
.aventure-total { font-weight: 700; color: var(--theme); }
.carte { position: relative; width: 100%; max-width: 620px; margin: 0 auto; }
.chemin { position: absolute; inset: 0; width: 100%; height: 100%; }
.chemin polyline { fill: none; stroke: var(--line); stroke-width: 10; stroke-dasharray: 2 16; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.etape { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: 150px; text-align: center; text-decoration: none; color: var(--text); }
.etape-rond {
  position: relative; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 34px;
  background: var(--theme-soft); border: 4px solid var(--theme); box-shadow: 0 5px 0 var(--line); transition: transform .15s;
}
a.etape:hover .etape-rond { transform: scale(1.08); }
.etape.finie .etape-rond { border-color: var(--ok); }
.etape.fermee { color: var(--muted); }
.etape.fermee .etape-rond { background: var(--chip); border-color: var(--line); filter: grayscale(1); opacity: .7; }
.etape.ici .etape-rond { animation: pulse .7s ease-in-out infinite alternate; }
.etape-num { position: absolute; right: -6px; top: -6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; background: var(--theme); color: var(--chip-on-text); }
.etape-texte { display: flex; flex-direction: column; font-size: 15px; line-height: 1.25; background: var(--card); border-radius: 10px; padding: 4px 8px; box-shadow: 0 2px 0 var(--line); }
.etape-etoiles { font-size: 15px; letter-spacing: 1px; color: #F5B700; }
.etape.lue .etape-rond { outline: 4px solid var(--theme); outline-offset: 3px; }   /* lue au 1er toucher (téléphone) */
.etape.lue:not(.fermee) .etape-texte::after { content: "👆 Touche encore"; font-size: 12px; font-weight: 700; color: var(--theme); }
.etape-moi { position: absolute; top: -34px; font-size: 30px; animation: sautille .5s ease-in-out infinite alternate; }
.chateau { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.chateau-dessin { font-size: 72px; line-height: 1; filter: grayscale(1); opacity: .5; }
.chateau.ouvert { color: var(--text); }
.chateau.ouvert .chateau-dessin { filter: none; opacity: 1; animation: pulse .8s ease-in-out infinite alternate; }


/* ---------------------------------------------------------------------
   12. TÉLÉPHONES : tout est un peu plus compact, pour que la question,
   les réponses et la correction tiennent mieux sur l'écran
   --------------------------------------------------------------------- */

@media (max-width: 600px) {
  .wrap { padding-block: 10px 28px; gap: 12px; }
  .sheet { padding: 14px; gap: 12px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .hright { gap: 6px; }
  .motion, .stars { font-size: 13px; padding: 3px 10px; }

  .qtop { gap: 6px 10px; flex-wrap: nowrap; }
  .qtop .restart .mot { display: none; }          /* « ↻ » seul : la barre du haut tient sur une ligne */
  .qtop .restart { padding: 5px 12px; font-size: 18px; }
  .qtop .back, .qtop .count { white-space: nowrap; }
  .qtop .bar { flex: 1 1 40px; min-width: 40px; }
  .chase { height: 96px; }
  .rex { width: 72px; left: calc(6px + var(--p, 0) * (100% - 130px)); }
  .kid { width: 34px; right: 10px; }
  .bubble { font-size: 12px; padding: 3px 8px; }

  .qlabel { font-size: 16px; }
  .dire { width: 34px; height: 34px; line-height: 34px; font-size: 17px; }
  .qline { font-size: clamp(26px, 8vw, 36px); }
  .qline.texte { font-size: clamp(20px, 6vw, 26px); }

  .image, .grande-lettre { font-size: 70px; }
  .grand-mot { font-size: 34px; }
  .grand-nombre { font-size: 52px; }
  .objets { font-size: 28px; gap: 6px 14px; }
  .frise span { min-width: 46px; padding: 6px; font-size: 21px; }
  .horloge { width: min(170px, 48vw); }
  .phrase { font-size: 20px; }
  .comparaison { font-size: 40px; }

  .options { gap: 8px; }
  .option { padding: 8px 6px; font-size: 24px; }
  .recette .plat { font-size: 52px; }
  .bol { min-height: 48px; font-size: 24px; }
  .option.grand { font-size: 38px; }
  /* Les ballons restent en bas de l'écran, toujours visibles, sans avoir à faire défiler ;
     la page garde de la place en dessous pour que la question ne soit pas cachée */
  .arena {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 5;
    height: min(240px, 36svh); box-shadow: 0 -6px 24px rgba(0,0,0,.35);
  }
  body:has(#arena:not([hidden])) .wrap { padding-bottom: calc(min(240px, 36svh) + 24px); }
  body:has(#arena:not([hidden])) .chase { height: 74px; }        /* un peu plus de place pour la question */
  body:has(#arena:not([hidden])) .rex { width: 58px; }
  body:has(#arena:not([hidden])) .objets { font-size: 22px; gap: 4px 10px; }   /* dessins et calcul plus petits */
  body:has(#arena:not([hidden])) .qline.posee { font-size: 28px; }
  body:has(#arena:not([hidden])) .qlabel { font-size: 15px; }
  .keypad { gap: 6px; }
  .keypad button { padding: 8px 0; font-size: 22px; }

  .fb { padding: 10px 12px; gap: 6px; }
  .fb .msg { font-size: 18px; }
  .btn { font-size: 17px; padding: 10px 20px; }
}

/* Écrans peu hauts (ordinateurs portables) : on resserre pour éviter de faire défiler */
@media (min-width: 601px) and (max-height: 900px) {
  .wrap { padding-block: 8px 28px; gap: 12px; }
  .sheet { padding: 16px 20px; gap: 12px; }
  h1 { font-size: 28px; line-height: 1.3; }
  .chase { height: 112px; }
  .rex { width: 84px; left: calc(6px + var(--p, 0) * (100% - 154px)); }
  .kid { width: 42px; }
  .qline { font-size: 38px; }
  .arena { height: 280px; }
  .fb { padding: 10px 14px; gap: 6px; }
  .fb .detail { gap: 4px; }
  .helptab .row { padding: 0 8px; }
}

/* Moins de mouvement si l'appareil le demande */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
