/* Macréa Kids — prototype. Paysage, grandes cibles tactiles, aucune ressource externe. */
:root {
  --terre: #7a3b1d;
  --terre-sombre: #3d1d0e;
  --creme: #fff8ec;
  --soleil: #ffb627;
  --or: #ffd34d;
  --vert: #3fa34d;
  --ombre: 0 1.2vmin 3vmin rgba(40, 15, 5, 0.35);
  --rayon: 3vmin;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--terre-sombre); overflow: hidden; }
body { user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.stage { position: fixed; inset: 0; overflow: hidden; background: var(--terre-sombre); }
.stage.fade-in { animation: fade 0.45s ease; }
/* Vidéos et images de l'histoire : affichées EN ENTIER (bandes sombres sur les côtés si l'écran n'est pas
   au format 16:9), pour que rien d'important ne soit coupé (l'oiseau en haut de l'image, par exemple). */
.full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.home-bg { object-fit: cover; }

button { font: inherit; cursor: pointer; border: 0; padding: 0; background: none; color: inherit; }
.icon-btn svg { width: 55%; height: 55%; fill: currentColor; }

/* ---------- démarrage ---------- */
.start-cover { filter: brightness(0.85); }
.big-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 28vmin; height: 28vmin; border-radius: 50%;
  background: var(--soleil); color: var(--creme); box-shadow: var(--ombre), 0 0 0 1.4vmin rgba(255, 248, 236, 0.6);
  display: grid; place-items: center; z-index: 5;
}
.big-play svg { margin-left: 8%; }

/* ---------- accueil : choix de l'épisode (images + numéros, rien à lire) ---------- */
.home-bg { filter: brightness(0.55) blur(3px); transform: scale(1.05); }
/* Prévu pour une dizaine d'épisodes : les cartes passent à la ligne, et défilent si besoin. */
.episode-row {
  position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center;
  gap: 4vmin; padding: 6vmin; overflow-y: auto;
}
.episode-card {
  position: relative; width: clamp(150px, 28vw, 420px); aspect-ratio: 16 / 9; border-radius: 6cqw; overflow: hidden;
  container-type: inline-size;
  background: var(--terre); box-shadow: var(--ombre), 0 0 0 1vmin var(--creme); transition: transform 0.15s ease;
}
.episode-card:active { transform: scale(0.96); }
.episode-card > img { width: 100%; height: 100%; object-fit: cover; }
.episode-num {
  position: absolute; left: 4cqw; top: 4cqw; width: 17cqw; height: 17cqw; border-radius: 50%;
  background: var(--soleil); color: var(--terre-sombre); display: grid; place-items: center; font-size: 11cqw; font-weight: 800; box-shadow: var(--ombre);
}
.episode-done { position: absolute; right: 4cqw; top: 2cqw; font-size: 15cqw; line-height: 1; color: var(--or); text-shadow: 0 0.4vmin 1vmin rgba(0,0,0,0.5); }
.episode-play {
  position: absolute; right: 5cqw; bottom: 5cqw; width: 22cqw; height: 22cqw; border-radius: 50%;
  background: var(--soleil); color: var(--creme); display: grid; place-items: center; box-shadow: var(--ombre);
}
.episode-play svg { width: 55%; height: 55%; fill: currentColor; margin-left: 8%; }
.pulse { animation: pulse 1.8s ease-in-out infinite; }

/* ---------- mini-jeu « collect » ---------- */
.collect { position: absolute; inset: 0; }
.collect-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0.7) saturate(0.95); }

.face {
  position: absolute; top: 3vmin; left: 3vmin; width: 24vmin; height: 24vmin; border-radius: 50%;
  overflow: hidden; border: 1vmin solid var(--creme); box-shadow: var(--ombre); background: var(--creme);
  transition: width 0.5s ease, height 0.5s ease; z-index: 4;
}
.face img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.bounce { animation: bounce 0.6s ease; }

.ear-btn {
  position: absolute; top: 7vmin; left: 30vmin; width: 15vmin; height: 15vmin; border-radius: 50%;
  background: var(--creme); color: var(--terre); box-shadow: var(--ombre); display: grid; place-items: center; z-index: 4;
}

.ear-btn[hidden] { display: none; }
.tray { position: absolute; top: 4vmin; right: 4vmin; display: flex; gap: 2vmin; z-index: 4; }
.slot {
  width: 12vmin; height: 12vmin; border-radius: 50%; background: rgba(255, 248, 236, 0.35);
  border: 0.6vmin solid rgba(255, 248, 236, 0.7); display: grid; place-items: center; padding: 1.6vmin;
}
.slot img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1) brightness(0.15); opacity: 0.45; transition: filter 0.4s, opacity 0.4s; }
.slot.filled { background: var(--creme); border-color: var(--vert); animation: pop 0.5s ease; }
.slot.filled img { filter: none; opacity: 1; }

.board {
  position: absolute; left: 3vmin; right: 36vw; top: 31vmin; bottom: 4vmin;
  display: grid; grid-template-columns: repeat(3, 1fr); align-content: center; justify-items: center; gap: 3vmin;
}
.card {
  width: min(29vmin, 19vw); aspect-ratio: 1; border-radius: var(--rayon); padding: 2vmin;
  background: rgba(255, 248, 236, 0.93); box-shadow: var(--ombre);
  transition: transform 0.15s ease, opacity 0.3s ease;
}
.board[data-count="3"] .card, .board[data-count="2"] .card { width: min(38vmin, 20vw); }
.card img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.card:active { transform: scale(0.95); }
.card.nope { animation: nope 0.5s ease; }
.card.glow { animation: glow 1.2s ease-in-out infinite; }
.card.guide { animation: guide 0.9s ease-in-out infinite; }
.board.guided .card:not(.guide) { opacity: 0.35; }
.card.correct { transform: scale(1.06); box-shadow: 0 0 0 1vmin var(--vert), var(--ombre); }

.bag-zone {
  position: absolute; right: 3vw; bottom: 4vmin; width: 31vw; height: 64vmin;
  display: flex; align-items: flex-end; justify-content: center;
  transition: transform 0.7s cubic-bezier(.3,.7,.4,1);
}
.bag { position: relative; height: 54vmin; }
.bag-img { position: relative; height: 100%; z-index: 2; filter: drop-shadow(0 1.5vmin 2vmin rgba(0,0,0,0.4)); }
/* Les objets rangés dépassent du haut du sac (derrière le rabat). */
.peek { position: absolute; left: 0; right: 0; top: -40%; height: 54%; z-index: 1; }
.peek-item {
  position: absolute; bottom: 0; left: var(--x); width: 46%; margin-left: -23%;
  transform: rotate(var(--tilt)); transform-origin: bottom center; animation: slide-in 0.5s ease;
  filter: drop-shadow(0 0.6vmin 0.8vmin rgba(0,0,0,0.35));
}
.bag.pop { animation: pop 0.5s ease; }
.ghost { position: fixed; z-index: 50; object-fit: contain; pointer-events: none; }

.collect.complete .bag-zone { transform: translateX(-28vw) scale(1.15); }
.collect.complete .bag { animation: celebrate 1.1s ease 2; }
.collect.complete .face { width: 34vmin; height: 34vmin; }

/* ---------- cadre 16:9 du mini-jeu (mêmes proportions que la vidéo, affiché en entier comme elle) ---------- */
.collect-frame { position: absolute; inset: 0; }
.collect-panel .collect-frame {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, 177.78vh); height: min(56.25vw, 100vh);
}
.collect-bg.no-dim, .collect-panel .collect-bg { filter: none; }
/* Même cadre 16:9 posé sur la vidéo, pour placer les mots au même endroit que pendant le jeu. */
.frame-169 {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, 177.78vh); height: min(56.25vw, 100vh);
}
.video-overlay { pointer-events: none; z-index: 4; }
/* Karaoké : paroles en bas de la vidéo, sur un léger dégradé sombre (pas de boîte qui cache l'image). */
.karaoke {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2.5% 6% 1.8%;
  display: flex; flex-direction: column; align-items: center; gap: 0.6vmin; text-align: center;
  background: linear-gradient(to top, rgba(30, 12, 4, 0.6), rgba(30, 12, 4, 0.35) 55%, transparent);
}
.karaoke-line { max-width: 100%; font-weight: 800; line-height: 1.15; letter-spacing: 0.01em; filter: drop-shadow(0 0.4vmin 0.5vmin rgba(0, 0, 0, 0.7)); }
.karaoke-line.empty { visibility: hidden; }
/* La ligne chantée se colore de gauche à droite (--p = avancée du chant). */
.karaoke-now {
  font-size: 6.5vmin; color: transparent; -webkit-background-clip: text; background-clip: text;
  background-image: linear-gradient(90deg, var(--or) var(--p, 0%), var(--creme) var(--p, 0%));
}
.karaoke-now.rise { animation: karaoke-rise 0.35s ease-out; }
.karaoke-next { font-size: 3.8vmin; color: rgba(255, 248, 236, 0.75); }
@keyframes karaoke-rise { from { transform: translateY(60%); opacity: 0.3; } to { transform: none; opacity: 1; } }
.video-word-panel { pointer-events: auto; justify-content: flex-start; animation: fade 0.4s ease; }
.video-word-panel .word-row { flex: 0 0 calc((100% - 3vmin) / 3); animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1); }

/* ---------- présentation « panel » : mots trouvés dans l'espace libre du décor ---------- */
.face-placed { width: var(--face-size); height: auto; aspect-ratio: 1; }
.ear-placed { width: auto; height: auto; aspect-ratio: 1; }
.ear-placed[style*="width"] { height: auto; }
.board-placed {
  right: auto; bottom: auto; grid-template-columns: repeat(2, 1fr); align-content: center; gap: 3vmin 2.5vmin;
}
.board-placed .card, .board-placed[data-count="3"] .card, .board-placed[data-count="2"] .card { width: min(100%, 30vmin); }

.word-panel {
  position: absolute; display: flex; flex-direction: column; justify-content: space-evenly; gap: 1.5vmin;
  padding: 2vmin 2.5vmin; border-radius: calc(var(--rayon) * 1.4);
  background: rgba(255, 248, 236, 0.78); box-shadow: var(--ombre); backdrop-filter: blur(2px);
}
.word-row { display: flex; align-items: center; gap: 2.5vmin; min-height: 0; flex: 1; }
.word-row-pic {
  flex: none; height: 100%; max-height: 12vmin; aspect-ratio: 1; border-radius: 50%; padding: 1.4vmin;
  background: rgba(255, 255, 255, 0.55); border: 0.6vmin dashed rgba(122, 59, 29, 0.35);
}
.word-row-pic img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1) brightness(0.2); opacity: 0.3; transition: filter 0.4s, opacity 0.4s; }
.word-row-text { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 0.6vmin; min-width: 0; color: var(--terre-sombre); line-height: 1.1; }
.word-line { display: flex; align-items: baseline; gap: 1.2vmin; white-space: nowrap; }
.word-line strong { font-size: 5.2vmin; letter-spacing: 0.01em; }
.word-line .word-dash { font-size: 3.6vmin; opacity: 0.5; }
.word-line .word-fr { font-size: 3.6vmin; opacity: 0.85; }
.word-row-text .dev-badge { position: static; transform: none; }
.word-row.found .word-row-pic { background: #fff; border: 0.6vmin solid var(--vert); animation: pop 0.5s ease; }
.word-row.found .word-row-pic img { filter: none; opacity: 1; }
.word-row.found .word-row-text { animation: slide-text 0.5s ease; }
.say-btn {
  flex: none; margin-left: auto; width: 7.5vmin; height: 7.5vmin; border-radius: 50%;
  background: var(--soleil); color: var(--creme); box-shadow: var(--ombre); display: grid; place-items: center;
  animation: pop 0.5s ease;
}
.word-row.saying .word-row-pic, .word-pop.saying { animation: pop 0.6s ease; }
/* Introduction : chaque silhouette s'allume à son tour. */
.word-row.intro-pulse .word-row-pic { animation: target 1s ease 2; border-color: var(--or); }
.word-row.intro-pulse .word-row-pic img { opacity: 0.8; }
/* Manche en cours : l'objet à trouver clignote en silhouette, avec un halo doré. */
.word-row.current .word-row-pic {
  border: 0.6vmin solid var(--or); background: #fff;
  animation: target 1.4s ease-in-out infinite;
}
.word-row.current .word-row-pic img { opacity: 0.75; filter: grayscale(1) brightness(0.35); }
.collect-panel.complete .word-panel { box-shadow: var(--ombre), 0 0 0 1vmin var(--soleil); }
.collect-panel.complete .face { width: calc(var(--face-size) * 1.2); height: auto; }

/* ---------- mini-jeu « find » : toucher dans le décor ---------- */
.find { position: absolute; inset: 0; }
.find-frame { cursor: pointer; }
.find-target { position: absolute; background: transparent; border-radius: 4vmin; z-index: 3; }
.find-ring {
  position: absolute; z-index: 2; border-radius: 4vmin; pointer-events: none;
  border: 1vmin solid transparent; transition: border-color 0.3s, box-shadow 0.4s;
}
.find-ring.hint { border-color: var(--or); animation: glow-ring 1.2s ease-in-out infinite; }
.find.guided .find-ring { box-shadow: 0 0 0 200vmax rgba(20, 8, 2, 0.5); }
.find-ring.found { border-color: var(--vert); box-shadow: 0 0 0 0.6vmin #fff, 0 0 5vmin var(--vert); animation: pop 0.6s ease; }
.find-miss {
  position: absolute; z-index: 4; width: 7vmin; height: 7vmin; margin: -3.5vmin 0 0 -3.5vmin; border-radius: 50%;
  border: 0.8vmin solid rgba(255, 248, 236, 0.9); pointer-events: none; animation: miss 0.7s ease forwards;
}
/* Flèche « touche ici » : la pointe est exactement au point (x, y) donné par l'épisode. */
.find-arrow {
  position: absolute; z-index: 4; width: 12vmin; height: 18.5vmin; pointer-events: none;
  transform: translate(-50%, -100%) rotate(var(--rot, 0deg)); transform-origin: 50% 100%;
  opacity: 0; transition: opacity 0.35s ease;
}
.find-arrow.show { opacity: 1; }
.find-arrow svg {
  width: 100%; height: 100%; overflow: visible;
  fill: var(--soleil); stroke: var(--creme); stroke-width: 4; stroke-linejoin: round;
  filter: drop-shadow(0 0.8vmin 1vmin rgba(40, 15, 5, 0.45));
  animation: arrow-bounce 0.9s ease-in-out infinite;
}
.find .face-placed { z-index: 4; }
.find .ear-btn { z-index: 5; }
.find-word { z-index: 6; }
.find-word.placed { right: auto; }
.find-word { padding: 1.5vmin 2.5vmin 1.5vmin 1.5vmin; gap: 2vmin; }
.find-word .word-pop-img { width: 15vmin; height: 15vmin; border-radius: 2vmin; object-fit: cover; }
.find-word .word-pop-text strong { font-size: 6.5vmin; }
.find-word .word-pop-text .word-dash, .find-word .word-pop-text .word-fr { font-size: 4vmin; }
.find-word .say-btn { margin-left: 1vmin; }

/* ---------- mini-jeu « route » : choisir son chemin sur une carte ---------- */
.route { position: absolute; inset: 0; }
.route-walker, .route-guide { position: absolute; z-index: 3; pointer-events: none; transform: translate(-50%, -100%); }
/* --h = hauteur en fraction de la carte ; la largeur suit les proportions de l'image. */
.route-walker { height: var(--h); aspect-ratio: 138 / 420; }
.route-walker img { display: block; width: 100%; height: 100%; filter: drop-shadow(0 0.6vmin 0.6vmin rgba(0,0,0,0.45)); }
.route-walker.moving img { animation: walk-bob 0.36s ease-in-out infinite; }
.route-guide { height: var(--h); aspect-ratio: 364 / 320; z-index: 4; }
.route-guide img { width: 100%; height: 100%; filter: drop-shadow(0 0.6vmin 0.8vmin rgba(0,0,0,0.4)); }
.route-guide.moving img { animation: flap 0.25s ease-in-out infinite; }
.route-guide.hop { animation: pop 0.6s ease 2; }
.route-zones { position: absolute; inset: 0; z-index: 2; }
.route-zone { position: absolute; border-radius: 3vmin; background: transparent; }
.route-zone.test { border: 0.5vmin dashed rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.14); }
.route-zone.test.good { border-color: #7dff8a; background: rgba(125, 255, 138, 0.16); }
.route-zone-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px;
}
.route-zone.nope { animation: nope 0.5s ease; }
.route-zone.found { box-shadow: 0 0 0 0.8vmin var(--vert), 0 0 5vmin var(--vert); }
.route.guided .route-zone:not(.good) { background: rgba(20, 8, 2, 0.45); }
.route .face-placed { z-index: 5; }
.route .ear-btn { z-index: 6; }
.route .find-word { z-index: 6; }
.route .find-arrow { z-index: 5; }

/* ---------- mot qui apparaît sur la vidéo ---------- */
.word-pop {
  position: absolute; right: 4vmin; top: 9vmin; z-index: 6;
  display: flex; align-items: center; gap: 2.5vmin; padding: 2vmin 4vmin 2vmin 2vmin;
  background: var(--creme); border-radius: var(--rayon); box-shadow: var(--ombre), 0 0 0 0.8vmin var(--soleil);
  animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1);
}
.word-pop.out { animation: word-out 0.45s ease forwards; }
/* Carte descendue en bas (repère `place`), sur les élèves plutôt que sur le tableau ou le personnage. */
.word-pop.at-bottom-right { top: auto; bottom: 4vmin; }
.word-pop.at-bottom-left { top: auto; bottom: 4vmin; right: auto; left: 4vmin; }
.word-pop-img { width: 20vmin; height: 20vmin; object-fit: contain; }
.word-pop-text, .discover-word { display: flex; flex-direction: column; align-items: center; line-height: 1.05; color: var(--terre-sombre); }
.word-pop-text { flex-direction: row; align-items: baseline; }
.word-pop-text strong { font-size: 8vmin; letter-spacing: 0.02em; }
.word-pop-text .word-dash, .word-pop-text .word-fr { font-size: 4.8vmin; }
.word-pop .dev-badge { bottom: -1.6em; }
.word-pop.can-listen { cursor: pointer; }
.say-icon {
  width: 10vmin; height: 10vmin; border-radius: 50%; margin-left: 1vmin;
  background: var(--soleil); color: var(--creme); display: grid; place-items: center; box-shadow: var(--ombre);
}
.say-icon svg { width: 60%; height: 60%; fill: currentColor; }

/* ---------- imagier « discover » ---------- */
.discover-bg { filter: brightness(0.5) saturate(0.9) blur(2px); }
.discover-center { position: absolute; inset: 18vmin 16vw 6vmin; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vmin; }
.discover-card {
  width: min(52vmin, 40vw); aspect-ratio: 1; border-radius: calc(var(--rayon) * 1.5); padding: 4vmin;
  background: var(--creme); box-shadow: var(--ombre), 0 0 0 1vmin rgba(255, 182, 39, 0.8);
}
.discover-card img, .discover-mini img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.discover-card.pop, .discover-mini.pop { animation: pop 0.5s ease; }
.discover-word { position: relative; background: rgba(255, 248, 236, 0.92); border-radius: var(--rayon); padding: 1.2vmin 4vmin; box-shadow: var(--ombre); }
.discover-word strong { font-size: 8vmin; }
.discover-word span { font-size: 3.6vmin; opacity: 0.75; }
.discover-word .dev-badge { bottom: -1.5em; }
.discover-recap { display: flex; gap: 3vmin; align-items: flex-start; }
.discover-mini {
  display: flex; flex-direction: column; align-items: center; gap: 2vmin;
  width: min(30vmin, 19vw); padding: 2vmin; border-radius: var(--rayon); background: rgba(255, 248, 236, 0.18);
}
.discover-mini > img { aspect-ratio: 1; background: var(--creme); border-radius: var(--rayon); padding: 2vmin; box-shadow: var(--ombre); }
.discover-mini .discover-word strong { font-size: 5vmin; }
.discover-mini .discover-word span { font-size: 2.8vmin; }
.discover-next { position: absolute; right: 5vmin; bottom: 6vmin; z-index: 5; }
.discover-next[hidden] { display: none; }
.discover-next svg { margin-left: 8%; }
.pulse-soft { animation: pop 1.6s ease-in-out infinite; }

/* ---------- fin ---------- */
.end-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin;
  background: radial-gradient(circle at 50% 35%, #ffcf70, var(--terre) 75%);
}
.end-face { width: 38vmin; height: 38vmin; border-radius: 50%; object-fit: cover; object-position: center 25%; border: 1.2vmin solid var(--creme); box-shadow: var(--ombre); }
.stickers { display: flex; gap: 3vmin; }
.sticker { position: relative; width: 18vmin; height: 18vmin; border-radius: var(--rayon); background: var(--creme); padding: 1.5vmin; box-shadow: var(--ombre); }
.sticker img { width: 100%; height: 100%; object-fit: contain; }
.stickers { flex-wrap: wrap; justify-content: center; max-width: 92vw; row-gap: 5vmin; padding-bottom: 4vmin; }
.sticker { width: 14vmin; height: 14vmin; }
.sticker-word {
  position: absolute; left: 50%; bottom: -3.4vmin; transform: translateX(-50%); white-space: nowrap;
  font-size: 2.8vmin; font-weight: 700; color: var(--creme); text-shadow: 0 0.3vmin 0.6vmin rgba(0,0,0,0.5);
}
.end-actions { display: flex; gap: 6vmin; }
.big-round { width: 18vmin; height: 18vmin; border-radius: 50%; background: var(--soleil); color: var(--creme); box-shadow: var(--ombre); display: grid; place-items: center; }
.end-home { position: absolute; right: 4vmin; bottom: 4vmin; }
.end-actions { align-items: center; }
.small-round { width: 14vmin; height: 14vmin; opacity: 0.92; }
.next-episode {
  position: relative; width: min(46vmin, 38vw); aspect-ratio: 16 / 9; border-radius: calc(var(--rayon) * 1.4); overflow: hidden;
  box-shadow: var(--ombre), 0 0 0 1vmin var(--creme), 0 0 0 2vmin var(--soleil);
}
.next-episode > img { width: 100%; height: 100%; object-fit: cover; }
.next-episode .episode-play { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: 15vmin; height: 15vmin; }
/* Beaucoup de mots dans le carnet (fin de saison) : tout se resserre pour tenir à l'écran, même sur iPad. */
.end-screen.many { gap: 3vmin; }
.end-screen.many .end-face { width: 24vmin; height: 24vmin; border-width: 0.9vmin; }
.end-screen.many .stickers { gap: 2.4vmin; row-gap: 4.4vmin; padding-bottom: 4vmin; }
.end-screen.many .sticker { width: 10.5vmin; height: 10.5vmin; padding: 1vmin; }
.end-screen.many .sticker-word { font-size: 2.4vmin; bottom: -3vmin; }
.end-screen.many .next-episode { width: min(36vmin, 32vw); }
.end-screen.many .small-round { width: 12vmin; height: 12vmin; }

/* Accueil : épisode pas encore ouvert (le précédent n'est pas terminé), épisode à faire mis en avant. */
.episode-card.locked > img { filter: grayscale(0.85) brightness(0.55); }
.episode-card.locked .episode-play { display: none; }
.episode-lock {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 24cqw; height: 24cqw;
  border-radius: 50%; background: rgba(255, 248, 236, 0.92); display: grid; place-items: center; box-shadow: var(--ombre);
}
.episode-lock svg { width: 55%; height: 55%; fill: var(--terre); }
.episode-card.nope { animation: nope 0.5s ease; }
.episode-card.current .episode-play { animation: pop 1.4s ease-in-out infinite; }
.episode-card.current { box-shadow: var(--ombre), 0 0 0 1vmin var(--creme), 0 0 0 2vmin var(--soleil); }

.error-box { position: absolute; inset: 10vmin; display: grid; place-items: center; color: var(--creme); font-size: 18px; text-align: center; }

/* ---------- mode prototype (relecteurs uniquement) ---------- */
.dev-bar { position: fixed; left: 8px; bottom: 8px; display: flex; gap: 8px; align-items: center; z-index: 100; font-size: 12px; }
/* Pendant le livre et les vidéos avec karaoké, la barre de test monte en haut à gauche pour ne pas cacher le texte
   ou les paroles en bas de l'écran (retours de Codex). */
body:has(.book-page) .dev-bar, body:has(.karaoke-layer) .dev-bar { bottom: auto; top: 8px; }
/* Puzzle : la barre de test passe en bas au milieu, sous le cadre, pour ne cacher aucune pièce. */
body:has(.puzzle) .dev-bar { left: 50%; transform: translateX(-50%); }
.dev-label { background: #c0262d; color: #fff; padding: 4px 8px; border-radius: 4px; font-weight: 700; letter-spacing: 0.02em; }
.dev-btn { background: rgba(0,0,0,0.6); color: #fff; height: 30px; min-width: 30px; border-radius: 4px; display: grid; place-items: center; }
.dev-text { padding: 0 10px; font-size: 12px; }
.dev-caption {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); max-width: 70vw; z-index: 100;
  background: rgba(0,0,0,0.72); color: #ffe08a; font-size: 13px; line-height: 1.35; padding: 6px 12px; border-radius: 0 0 6px 6px; text-align: center;
}
.dev-caption[hidden] { display: none; }
.dev-clock { background: rgba(0,0,0,0.6); color: #ffe08a; padding: 6px 8px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.dev-marks { background: rgba(0,0,0,0.6); color: #fff; padding: 6px 8px; border-radius: 4px; }
.dev-marks:empty, .dev-bar [hidden] { display: none; }
.dev-badge { position: absolute; left: 50%; bottom: -1.2em; transform: translateX(-50%); white-space: nowrap; background: #c0262d; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; }

/* ---------- orientation ---------- */
.rotate { display: none; }
/* Seulement sur écran tactile (téléphone, tablette) : sur ordinateur, une fenêtre étroite ne bloque pas le jeu. */
@media (orientation: portrait) and (max-width: 900px) and (pointer: coarse) {
  .rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 200; background: var(--terre); }
  .rotate svg { width: 40vmin; height: 40vmin; fill: none; stroke: var(--creme); stroke-width: 3; stroke-linecap: round; animation: tilt 2s ease-in-out infinite; }
}

/* ---------- animations ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.07); } }
@keyframes bounce { 0% { transform: scale(1); } 35% { transform: scale(1.12) translateY(-1.5vmin); } 70% { transform: scale(0.97); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes nope { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-2vmin) rotate(-4deg); } 40% { transform: translateX(2vmin) rotate(4deg); } 60% { transform: translateX(-1.2vmin); } 80% { transform: translateX(1.2vmin); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0.8vmin var(--or), var(--ombre); } 50% { box-shadow: 0 0 0 1.4vmin var(--or), 0 0 5vmin var(--or); } }
@keyframes guide { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 1vmin var(--or), var(--ombre); } 50% { transform: scale(1.1); box-shadow: 0 0 0 1.6vmin var(--or), 0 0 6vmin var(--or); } }
@keyframes slide-in { from { transform: translateY(40%) rotate(var(--tilt)); opacity: 0; } to { transform: rotate(var(--tilt)); opacity: 1; } }
@keyframes celebrate { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg) translateY(-2vmin); } 75% { transform: rotate(5deg) translateY(-2vmin); } }
@keyframes glow-ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 211, 77, 0.0), 0 0 3vmin var(--or); } 50% { box-shadow: 0 0 0 1.2vmin rgba(255, 211, 77, 0.5), 0 0 6vmin var(--or); } }
@keyframes walk-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6%) rotate(2deg); } }
@keyframes flap { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.88); } }
@keyframes arrow-bounce { 0%, 100% { transform: translateY(-2.5vmin); } 50% { transform: translateY(0); } }
@keyframes miss { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
@keyframes target { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 211, 77, 0); } 50% { transform: scale(1.15); box-shadow: 0 0 0 1.2vmin rgba(255, 211, 77, 0.55), 0 0 4vmin var(--or); } }
@keyframes slide-text { from { transform: translateX(-3vmin); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes word-in { from { transform: scale(0.5) translateY(-4vmin); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes word-out { to { transform: scale(0.8) translateY(-3vmin); opacity: 0; } }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- mini-jeu « riddle » : écouter → choisir → le décor réagit ---------- */
.riddle { position: absolute; inset: 0; }
.riddle-reveal { opacity: 0; transition: opacity 1.2s ease; }
.riddle-reveal.show { opacity: 1; }
/* Personnage du décor : ses pieds sont au point (x, y) donné par l'épisode. */
.riddle-actor {
  position: absolute; z-index: 2; width: auto; pointer-events: none;
  transform: translate(-50%, -100%); filter: drop-shadow(0 1vmin 1.2vmin rgba(40, 15, 5, 0.4));
}
.riddle-actor.flip { transform: translate(-50%, -100%) scaleX(-1); }
.riddle-actor.walking { animation: actor-bob 0.45s ease-in-out infinite; }
@keyframes actor-bob { 0%, 100% { translate: 0 0; rotate: -2deg; } 50% { translate: 0 -2%; rotate: 2deg; } }
.riddle-clue {
  position: absolute; z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 1vmin;
  padding: 1.8vmin; background: var(--creme); border-radius: var(--rayon);
  box-shadow: var(--ombre), 0 0 0 0.8vmin var(--soleil); animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1);
}
.riddle-clue-img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 2vmin; }
.riddle-clue-q {
  position: absolute; top: -3vmin; right: -3vmin; width: 9vmin; height: 9vmin; border-radius: 50%;
  display: grid; place-items: center; background: var(--soleil); color: var(--creme);
  font-size: 6.5vmin; font-weight: 800; box-shadow: var(--ombre); animation: arrow-bounce 1.2s ease-in-out infinite;
}
.riddle-clue.solved { box-shadow: var(--ombre), 0 0 0 0.8vmin var(--vert); animation: pop 0.6s ease; cursor: pointer; }
.riddle-clue .word-pop-text { flex-direction: column; align-items: center; }
.riddle-clue .word-pop-text .word-dash { display: none; }
.riddle-clue .word-pop-text strong { font-size: 5.5vmin; }
.riddle-clue .word-pop-text .word-dash, .riddle-clue .word-pop-text .word-fr { font-size: 3.4vmin; }
.riddle-board {
  position: absolute; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 4vmin;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.riddle-board.leaving { opacity: 0; transform: translateY(8%); pointer-events: none; }
.riddle-card {
  position: relative; height: 100%; aspect-ratio: 1; border-radius: 50%; padding: 2vmin;
  background: var(--creme); box-shadow: var(--ombre); display: grid; place-items: center;
  transition: transform 0.15s ease, opacity 0.3s ease;
}
.riddle-card[hidden] { display: grid; visibility: hidden; }
.riddle-card.picture { border-radius: var(--rayon); }
.riddle-card.picture img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; border-radius: 2vmin; }
.riddle-sound {
  width: 100%; height: 100%; border-radius: 50%; background: var(--c); color: var(--creme);
  display: grid; place-items: center; box-shadow: inset 0 -1vmin 0 rgba(0, 0, 0, 0.15);
}
.riddle-sound svg { width: 55%; height: 55%; fill: currentColor; pointer-events: none; }
.riddle-card.enter { animation: word-in 0.45s cubic-bezier(.3,1.4,.5,1); }
.riddle-card.speaking { animation: speak 0.5s ease-in-out infinite alternate; }
.riddle-card:active { transform: scale(0.94); }
.riddle-card.nope { animation: nope 0.5s ease; }
.riddle-card.glow { animation: glow 1.2s ease-in-out infinite; }
.riddle-card.guide { animation: guide 0.9s ease-in-out infinite; }
.riddle-board.guided .riddle-card:not(.guide) { opacity: 0.3; }
.riddle-card.correct { transform: scale(1.1); box-shadow: 0 0 0 1vmin var(--vert), var(--ombre); }
@keyframes speak { from { transform: scale(1); } to { transform: scale(1.1); } }
.riddle .ear-btn { z-index: 5; }
.riddle-dev { left: 1vmin; bottom: 1vmin; top: auto; z-index: 7; }

/* Mot écrit sous chaque carte à écouter : l'enfant voit l'orthographe en entendant le mot. */
.riddle-label {
  position: absolute; left: 50%; bottom: -2.2vmin; transform: translateX(-50%);
  padding: 0.6vmin 2.2vmin; border-radius: 99px; background: var(--creme); color: var(--terre-sombre);
  font-size: 4.6vmin; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: 0 0.6vmin 1.2vmin rgba(40, 15, 5, 0.3); pointer-events: none;
}
.riddle-card.correct .riddle-label { background: var(--vert); color: var(--creme); }

/* ---------- mini-jeu « journey » : avancer sur la carte, obstacle après obstacle ---------- */
.journey { position: absolute; inset: 0; }
.journey .face-placed { z-index: 5; }
.journey .riddle-actor { z-index: 3; }
.journey .find-word { z-index: 6; }
/* Petites traces de pas laissées sur le chemin, qui s'effacent doucement. */
.footprint {
  position: absolute; z-index: 2; width: 1%; height: 2.4%; border-radius: 45% 45% 50% 50%;
  background: rgba(80, 32, 10, 0.7); box-shadow: 0 0 0 0.15vmin rgba(255, 230, 200, 0.35); pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--angle, 0deg));
  animation: footprint 6s ease-out forwards;
}
@keyframes footprint { 0% { opacity: 0; } 8% { opacity: 1; } 60% { opacity: 0.8; } 100% { opacity: 0; } }

/* ---------- mini-jeu « cards » : les cartes à cocher (révision) ---------- */
.cards { position: absolute; inset: 0; }
.cards-frame { cursor: pointer; }
.cards .ear-btn { z-index: 6; }
.cards .face-placed { z-index: 5; }
.cards-board {
  position: absolute; z-index: 4; display: grid; gap: 3vmin;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); place-items: center;
}
.review-card {
  position: relative; height: 100%; max-width: 100%; min-height: 0; aspect-ratio: 1; padding: 1.6vmin;
  border-radius: var(--rayon); background: var(--creme); box-shadow: var(--ombre), 0 0 0 0.6vmin var(--soleil);
  transition: transform 0.15s ease, opacity 0.3s ease, box-shadow 0.3s ease;
}
.review-card img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; border-radius: 2vmin; pointer-events: none; }
.cards-board.fit-contain .review-card img { object-fit: contain; background: #fff; }
.review-card:active { transform: scale(0.94); }
.review-card.nope { animation: nope 0.5s ease; }
.review-card.glow { animation: glow 1.2s ease-in-out infinite; }
.review-card.guide { animation: guide 0.9s ease-in-out infinite; }
.cards-board.guided .review-card:not(.guide):not(.checked) { opacity: 0.3; }
.review-card.checked { box-shadow: var(--ombre), 0 0 0 1vmin var(--vert); animation: pop 0.6s ease; }
/* Le mot écrit apparaît sous la carte quand elle est cochée. */
.review-label {
  position: absolute; left: 50%; bottom: -2.4vmin; transform: translateX(-50%) scale(0.6); opacity: 0;
  padding: 0.6vmin 2.2vmin; border-radius: 99px; background: var(--vert); color: var(--creme);
  font-size: 4.4vmin; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; pointer-events: none;
  box-shadow: 0 0.6vmin 1.2vmin rgba(40, 15, 5, 0.3); transition: opacity 0.3s ease, transform 0.4s cubic-bezier(.3,1.4,.5,1);
}
.review-card.checked .review-label { opacity: 1; transform: translateX(-50%) scale(1); }
.review-check {
  position: absolute; top: -2.2vmin; right: -2.2vmin; width: 7vmin; height: 7vmin; border-radius: 50%;
  display: grid; place-items: center; background: var(--vert); color: var(--creme); font-size: 4.6vmin; font-weight: 900;
  border: 0.6vmin solid var(--creme); box-shadow: var(--ombre); transform: scale(0); pointer-events: none;
  transition: transform 0.4s cubic-bezier(.3,1.6,.5,1);
}
.review-card.checked .review-check { transform: scale(1); }
.cards-board.all-done .review-card { animation: celebrate 1.1s ease 2; }

/* ---------- livre animé (étape « page ») ---------- */
/* La page : une feuille de papier crème, l'image qui bouge doucement, la reliure à gauche, le texte en bas. */
.book-page {
  overflow: hidden; border-radius: 0.8vmin 1.6vmin 1.6vmin 0.8vmin; background: #f6e8c9;
  box-shadow: 0 1.5vmin 4vmin rgba(0, 0, 0, 0.55);
}
.book-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.9s ease; transform-origin: center;
}
.book-img.on { opacity: 1; }
.book-img.on.move-in { animation: book-in 18s ease-out forwards; }
.book-img.on.move-left { animation: book-left 18s ease-out forwards; }
.book-img.on.move-right { animation: book-right 18s ease-out forwards; }
@keyframes book-in { from { transform: scale(1); } to { transform: scale(1.09); } }
@keyframes book-left { from { transform: scale(1.08) translateX(2%); } to { transform: scale(1.08) translateX(-2%); } }
@keyframes book-right { from { transform: scale(1.08) translateX(-2%); } to { transform: scale(1.08) translateX(2%); } }
/* Couverture en hauteur : montrée en entier, posée sur un fond chaud. */
.book-cover { background: radial-gradient(circle at 50% 40%, #b4562a, #5a2410 75%); }
.book-cover .book-img { object-fit: contain; padding: 3% 0 4%; }
/* Reliure : ombre du pli à gauche, comme une page de livre ouvert. */
.book-spine {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, rgba(60, 30, 10, 0.45), rgba(60, 30, 10, 0.12) 2.5%, transparent 6%, transparent 97%, rgba(60, 30, 10, 0.15));
}
/* Texte de la page : bandeau de papier en bas, ligne lue qui se colore à l'encre, mot malgache souligné d'or. */
.book-text { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; pointer-events: none; }
.book-text .karaoke {
  position: static; padding: 1.4% 12% 1.5% 7%; gap: 0.4vmin;
  background: linear-gradient(to bottom, rgba(250, 239, 214, 0.9), rgba(246, 230, 196, 0.96));
  border-top: 0.45vmin solid #d8b26c; box-shadow: 0 -0.6vmin 2vmin rgba(60, 30, 10, 0.25);
}
.book-text .karaoke-line { filter: none; font-family: Georgia, "Times New Roman", serif; letter-spacing: 0; }
.book-text .karaoke-now {
  font-size: 4.9vmin; font-weight: 700;
  background-image: linear-gradient(90deg, #6b2f12 var(--p, 0%), #b49470 var(--p, 0%));
}
.book-text .karaoke-next { font-size: 3.2vmin; font-weight: 600; color: rgba(107, 47, 18, 0.5); }
.book-text em.mg {
  font-style: normal; font-weight: 900; text-decoration: underline; text-decoration-color: var(--soleil);
  text-decoration-thickness: 0.55vmin; text-underline-offset: 0.7vmin;
}
.book-note { padding: 2% 12% 2.2% 7%; text-align: center; font-family: Georgia, "Times New Roman", serif; color: #6b2f12;
  background: linear-gradient(to bottom, rgba(250, 239, 214, 0.92), rgba(246, 230, 196, 0.97)); border-top: 0.45vmin solid #d8b26c; }
.book-note-title { font-size: 9vmin; font-weight: 700; font-style: italic; line-height: 1.1; }
.book-note-line { font-size: 3.4vmin; line-height: 1.3; margin-top: 0.8vmin; }
/* Cartes des mots dans le livre : en haut, loin du texte, plus petites (deux cartes peuvent se suivre). */
.book-page .word-pop { top: 5%; right: 3%; gap: 1.8vmin; padding: 1.4vmin 2.6vmin 1.4vmin 1.4vmin; }
.book-page .word-pop-img { width: 13vmin; height: 13vmin; border-radius: 1.5vmin; object-fit: cover; }
.book-page .word-pop-text strong { font-size: 6vmin; }
.book-page .word-pop-text .word-dash, .book-page .word-pop-text .word-fr { font-size: 3.6vmin; }
.book-page .say-icon { width: 8vmin; height: 8vmin; }
.book-page .word-pop.at-top-left { right: auto; left: 4%; }
/* Coin de la page qui se soulève et brille : on le touche pour tourner la page. */
.book-corner {
  position: absolute; right: 0; bottom: 0; z-index: 7; width: 17vmin; height: 17vmin; border: 0; padding: 0;
  background: linear-gradient(135deg, transparent 49%, #fff6dc 50%, #ead09a 78%, #c99c55 100%);
  border-radius: 0 0 1.6vmin 0; cursor: pointer; display: grid; place-items: end; color: #8a4316;
  filter: drop-shadow(-0.6vmin -0.6vmin 1vmin rgba(60, 30, 10, 0.45)); animation: corner-lift 1.6s ease-in-out infinite;
  transform-origin: bottom right;
}
.book-corner svg { width: 7vmin; height: 7vmin; margin: 0 1.6vmin 1.6vmin 0; fill: currentColor; }
@keyframes corner-lift {
  0%, 100% { transform: scale(1); filter: drop-shadow(-0.6vmin -0.6vmin 1vmin rgba(60, 30, 10, 0.45)); }
  50% { transform: scale(1.14); filter: drop-shadow(-0.8vmin -0.8vmin 1.4vmin rgba(60, 30, 10, 0.5)) drop-shadow(0 0 2.5vmin var(--or)); }
}
/* La page lue tourne vers la gauche, autour de la reliure, et découvre la page suivante. */
.book-turn { z-index: 20; pointer-events: none; transform-origin: left center; animation: book-turn 0.95s cubic-bezier(.45,.05,.55,.95) forwards; }
.book-turn::after { content: ""; position: absolute; inset: 0; z-index: 30; background: linear-gradient(90deg, transparent, rgba(40, 20, 5, 0.55)); opacity: 0; animation: book-shade 0.95s ease forwards; }
@keyframes book-turn {
  from { transform: translate(-50%, -50%) perspective(160vmin) rotateY(0deg); }
  to { transform: translate(-50%, -50%) perspective(160vmin) rotateY(-100deg); opacity: 0.2; }
}
@keyframes book-shade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .book-img.on { animation: none !important; }
  .book-turn { animation: fade-out 0.4s ease forwards; }
  .book-corner { animation: none; }
}
@keyframes fade-out { to { opacity: 0; } }
/* Flèche jaune courbée qui pointe sur le coin de la page, et bat doucement vers lui. */
.book-guide {
  position: absolute; right: 4vmin; bottom: 8vmin; z-index: 8; width: 20vmin; height: 20vmin; pointer-events: none;
  animation: guide-point 1.1s ease-in-out infinite;
}
.book-guide svg { width: 100%; height: 100%; overflow: visible; }
.book-guide path {
  fill: none; stroke: var(--or); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 0.4vmin #7a3b1d) drop-shadow(0 0.5vmin 0.8vmin rgba(40, 15, 5, 0.6));
}
.book-guide.again { animation-duration: 0.6s; }
@keyframes guide-point {
  0%, 100% { transform: translate(-1.6vmin, -1.6vmin); }
  50% { transform: translate(0.8vmin, 0.8vmin); }
}
@media (prefers-reduced-motion: reduce) { .book-guide, .book-guide.again { animation: none; } }
/* Page « scène » (`plain`) : pas d'habillage de livre, paroles comme le karaoké des vidéos (or sur fond sombre). */
.book-plain { background: #000; border-radius: 0; }
.book-plain .book-text .karaoke {
  padding: 2.5% 6% 1.8%; border-top: 0; box-shadow: none;
  background: linear-gradient(to top, rgba(30, 12, 4, 0.6), rgba(30, 12, 4, 0.35) 55%, transparent);
}
.book-plain .book-text .karaoke-line { font-family: inherit; filter: drop-shadow(0 0.4vmin 0.5vmin rgba(0, 0, 0, 0.7)); }
.book-plain .book-text .karaoke-now { font-size: 6.5vmin; font-weight: 800; background-image: linear-gradient(90deg, var(--or) var(--p, 0%), var(--creme) var(--p, 0%)); }
.book-plain .book-text .karaoke-next { font-size: 3.8vmin; color: rgba(255, 248, 236, 0.75); }
.book-plain .book-img { transition-duration: 0.35s; }
.book-plain .book-img.on { animation: none; }
/* Étiquettes qui suivent les canetons (« 1 iray ») : petite pastille dorée AU-DESSUS de la tête (sans la cacher,
   demande de Malala), qu'on peut toucher. */
.tag-layer { pointer-events: none; }
.duck-tag {
  position: absolute; transform: translate(-50%, calc(-100% - 1.4vmin)); pointer-events: auto; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 0.6vmin 1.4vmin 0.8vmin; border: 0; border-radius: 2.2vmin;
  background: var(--or); color: var(--terre-sombre); font: 700 3.6vmin/1 system-ui, sans-serif;
  box-shadow: 0 0.4vmin 1vmin rgba(40, 15, 5, 0.35); animation: word-in 0.4s cubic-bezier(.3,1.4,.5,1); cursor: pointer;
}
.duck-tag b { font-size: 4.6vmin; line-height: 1; }
.duck-tag[hidden] { display: none; }
.duck-tag.saying { animation: pop 0.6s ease; }
/* Chanson finale (page « scène ») : les paroles AU-DESSUS des canetons, en grand pour le téléphone (pas en bas). */
.book-plain .book-text { top: 3%; bottom: auto; left: 24%; right: 3%; }
.book-plain .book-text .karaoke {
  padding: 1.4vmin 3vmin 1.6vmin; border-radius: 3vmin; gap: 0.4vmin;
  background: rgba(30, 12, 4, 0.5);
}
.book-plain .book-text .karaoke-now { font-size: 8.5vmin; }
.book-plain .book-text .karaoke-next { font-size: 4.6vmin; }

/* Karaoké « dessin animé » (`lyricsStyle: "cartoon"`) : léger et joyeux, pour les enfants. Pas de fond : des lettres
   rondes blanches cernées de brun chaud, et chaque mot s'allume en jaune soleil (avec un petit saut) quand il est chanté. */
.karaoke-cartoon { --cerne: #8f3a10; }
.karaoke-cartoon .karaoke, .book-plain .book-text.karaoke-cartoon .karaoke {
  background: none; box-shadow: none; border: 0; padding: 1vmin 4%; gap: 0.6vmin;
}
.karaoke-cartoon .karaoke-line {
  font-family: "Baloo 2", "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 900; letter-spacing: 0.02em; filter: none;
}
.karaoke-cartoon .karaoke-now, .book-plain .book-text.karaoke-cartoon .karaoke-now {
  font-size: 7.6vmin; color: #fff; background: none; -webkit-background-clip: border-box; background-clip: border-box;
  text-shadow:
    0.45vmin 0 var(--cerne), -0.45vmin 0 var(--cerne), 0 0.45vmin var(--cerne), 0 -0.45vmin var(--cerne),
    0.32vmin 0.32vmin var(--cerne), -0.32vmin 0.32vmin var(--cerne), 0.32vmin -0.32vmin var(--cerne), -0.32vmin -0.32vmin var(--cerne),
    0 1vmin 0.2vmin rgba(143, 58, 16, 0.35);
}
.karaoke-cartoon .kw { display: inline-block; transition: color 0.15s ease, transform 0.2s cubic-bezier(.3,1.6,.5,1); }
.karaoke-cartoon .kw.mg { font-size: 1.08em; }
.karaoke-cartoon .kw.lit { color: #ffd23f; transform: translateY(-0.8vmin) scale(1.08); }
.karaoke-cartoon .karaoke-next, .book-plain .book-text.karaoke-cartoon .karaoke-next {
  font-size: 4.4vmin; color: #fff;
  text-shadow: 0.3vmin 0 var(--cerne), -0.3vmin 0 var(--cerne), 0 0.3vmin var(--cerne), 0 -0.3vmin var(--cerne);
}
.karaoke-cartoon .karaoke-next em.mg { font-style: normal; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .karaoke-cartoon .kw.lit { transform: none; } }
/* Carte du mot en petit (`cueSize: "small"`) : la chanson des canetons a déjà les pastilles et le karaoké. */
.word-pop.small { top: 3vmin; right: 3vmin; gap: 1.4vmin; padding: 1vmin 2vmin 1vmin 1vmin; border-radius: 2vmin; box-shadow: var(--ombre), 0 0 0 0.5vmin var(--soleil); }
.word-pop.small .word-pop-img { width: 11vmin; height: 11vmin; }
.word-pop.small .word-pop-text strong { font-size: 5vmin; }
.word-pop.small .word-pop-text .word-dash, .word-pop.small .word-pop-text .word-fr { font-size: 3.2vmin; }
.word-pop.small .say-icon { width: 6.5vmin; height: 6.5vmin; }

/* ---------- puzzle (5e jeu) : pièces à glisser dans le cadre ---------- */
.puzzle { position: absolute; inset: 0; touch-action: none; background: radial-gradient(ellipse at 50% 45%, #8a4a26 0%, var(--terre-sombre) 80%); }
.puzzle-board {
  position: absolute; border-radius: 1.2vmin; background: rgba(255, 248, 236, 0.12);
  box-shadow: 0 0 0 0.6vmin rgba(255, 248, 236, 0.55), var(--ombre);
  transition: left 0.9s ease, top 0.9s ease, width 0.9s ease, height 0.9s ease, border-radius 0.9s ease, box-shadow 0.9s ease;
}
.puzzle-ghost { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.puzzle-ghost-img { opacity: 0.22; }
.puzzle-slot { fill: none; stroke: rgba(255, 248, 236, 0.55); stroke-width: 3; stroke-dasharray: 10 9; }
.puzzle-slot.glow { fill: rgba(255, 211, 77, 0.35); stroke: var(--or); stroke-width: 9; stroke-dasharray: none; animation: slot-glow 0.8s ease-in-out infinite alternate; }
@keyframes slot-glow { from { fill-opacity: 0.25; } to { fill-opacity: 0.8; } }
.puzzle-full { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.35s ease; border-radius: inherit; }
.puzzle-piece {
  position: absolute; left: 0; top: 0; z-index: 3; cursor: grab; transform-origin: 50% 50%;
  filter: drop-shadow(0 0.6vmin 0.7vmin rgba(30, 10, 2, 0.55));
}
.puzzle-piece svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.puzzle-edge { fill: none; stroke: rgba(255, 248, 236, 0.85); stroke-width: 4; }
.puzzle-piece.moving { transition: transform 0.45s cubic-bezier(.3,1.25,.5,1); }
.puzzle-piece.lifted { cursor: grabbing; filter: drop-shadow(0 2vmin 2vmin rgba(30, 10, 2, 0.5)); z-index: 50; }
.puzzle-piece.placed { filter: none; cursor: default; pointer-events: none; }
.puzzle-piece.placed .puzzle-edge { stroke: rgba(255, 248, 236, 0.35); stroke-width: 2; }
.puzzle-piece.wiggle svg { animation: piece-wiggle 0.5s ease 3; }
@keyframes piece-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg) scale(1.08); } 75% { transform: rotate(9deg) scale(1.08); } }
.puzzle-ear { top: 2.5vmin; left: 2.5vmin; width: 13vmin; height: 13vmin; z-index: 60; }
/* Puzzle terminé : l'image entière remplace les pièces et grandit jusqu'au plein écran. */
.puzzle.complete .puzzle-full { opacity: 1; }
.puzzle.complete .puzzle-piece { opacity: 0; transition: opacity 0.35s ease 0.3s; }
.puzzle.complete .puzzle-board { border-radius: 0; box-shadow: 0 0 0 0 transparent; }
.puzzle.complete .puzzle-ear { display: none; }

/* ---------- « show » (montrer ce qu'on a trouvé) et « count » (compter en touchant) ---------- */
.show-ring {
  position: absolute; z-index: 3; pointer-events: none; border-radius: 50%;
  border: 0.8vmin solid var(--or); animation: glow-ring 1.2s ease-in-out infinite, fade 0.4s ease;
}
.show-ring.found { border-color: #fff; animation: fade 0.3s ease; box-shadow: 0 0 2.5vmin var(--or); border-width: 0.6vmin; opacity: 0.85; }
.show-ring.out, .show-card.out { animation: word-out 0.45s ease forwards; }
.show-card { z-index: 6; padding: 1.2vmin 2.4vmin 1.2vmin 1.2vmin; gap: 1.6vmin; }
.show-card .word-pop-img { width: 12vmin; height: 12vmin; object-fit: contain; background: #fff; }
.show-card .word-pop-text strong { font-size: 6vmin; }
.show-card .word-pop-text .word-dash, .show-card .word-pop-text .word-fr { font-size: 3.6vmin; }
.show-card.saying { animation: pop 0.6s ease; }
.count-hit { position: absolute; z-index: 4; background: transparent; border-radius: 40%; }
.count-badge {
  position: absolute; z-index: 5; translate: -50% -50%; pointer-events: none; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; padding: 0.5vmin 1.4vmin 0.7vmin; border-radius: 2.2vmin;
  background: var(--or); color: var(--terre-sombre); font: 700 3.4vmin/1 system-ui, sans-serif;
  box-shadow: 0 0 0 0.4vmin var(--terre), 0 0.4vmin 1vmin rgba(40, 15, 5, 0.35); animation: word-in 0.4s cubic-bezier(.3,1.4,.5,1);
}
.count-badge b { font-size: 5vmin; line-height: 1; }
.count-badge.saying { animation: pop 0.6s ease; }

/* ---------- quiz (6e jeu) : une question par écran, 3 grandes réponses, « Le savais-tu ? » ---------- */
.quiz {
  --quiz: #c0392b; --rond: "Baloo 2", "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 2.4vmin; padding: 2.4vmin 3.5vmin 3vmin;
  background:
    radial-gradient(circle at 8% 105%, rgba(255, 255, 255, 0.08) 0 22vmin, transparent 22.2vmin),
    radial-gradient(circle at 96% 92%, rgba(255, 255, 255, 0.08) 0 16vmin, transparent 16.2vmin),
    linear-gradient(160deg, color-mix(in srgb, var(--quiz) 80%, #fff) 0%, var(--quiz) 55%, color-mix(in srgb, var(--quiz) 70%, #000) 100%);
  font-family: var(--rond); color: var(--terre-sombre);
}
.quiz-head { display: flex; align-items: center; gap: 2vmin; min-height: 12vmin; padding-right: 15vmin; }
.quiz-badge {
  width: 12vmin; height: 12vmin; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--creme); box-shadow: var(--ombre), 0 0 0 0.7vmin var(--or);
}
.quiz-badge svg { width: 62%; height: 62%; fill: var(--quiz); }
.quiz-title { display: flex; flex-direction: column; line-height: 1.05; color: #fff; text-shadow: 0 0.4vmin 0 rgba(0, 0, 0, 0.25); }
.quiz-title strong { font-size: 6vmin; letter-spacing: 0.01em; }
.quiz-title span { font-size: 3.6vmin; opacity: 0.92; }
.quiz-dots { margin-left: auto; display: flex; gap: 1.4vmin; }
.quiz-dot { width: 3.4vmin; height: 3.4vmin; border-radius: 50%; background: rgba(255, 255, 255, 0.3); box-shadow: inset 0 0 0 0.5vmin rgba(255, 255, 255, 0.6); transition: background 0.3s; }
.quiz-dot.now { background: var(--creme); animation: pop 0.8s ease infinite alternate; }
.quiz-dot.good { background: var(--or); box-shadow: inset 0 0 0 0.5vmin #fff; }
.quiz-dot.done { background: rgba(255, 248, 236, 0.85); }
.quiz-ear { top: 2.4vmin; left: auto; right: 3.5vmin; width: 12vmin; height: 12vmin; z-index: 6; }
.quiz-body { position: relative; flex: 1; display: flex; flex-direction: column; gap: 2.6vmin; min-height: 0; }
.quiz-question {
  background: var(--creme); border-radius: var(--rayon); padding: 2.6vmin 4vmin; box-shadow: var(--ombre);
  font-size: 5vmin; line-height: 1.22; font-weight: 700; text-align: center;
}
.quiz-question p { margin: 0; }
.quiz-question.enter { animation: word-in 0.45s cubic-bezier(.3,1.4,.5,1) both; }
.quiz-answers { flex: 1; display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 2.6vmin; min-height: 0; }
.quiz-answer {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 1.6vmin; padding: 2vmin 2.6vmin 2vmin 2vmin;
  background: #fff; border-radius: var(--rayon); box-shadow: 0 1vmin 0 rgba(0, 0, 0, 0.18), var(--ombre);
  font-family: var(--rond); font-size: 4.6vmin; line-height: 1.15; font-weight: 700; color: var(--terre-sombre); text-align: left;
  transition: transform 0.15s ease, background 0.3s ease, opacity 0.4s ease;
}
.quiz-answer:active { transform: translateY(0.6vmin); }
.quiz-answer.enter { animation: word-in 0.45s cubic-bezier(.3,1.4,.5,1) both; }
.quiz-letter {
  flex: none; width: 8vmin; height: 8vmin; border-radius: 50%; display: grid; place-items: center;
  background: var(--quiz); color: #fff; font-size: 4.4vmin;
}
.quiz-answer.reading { background: #fff6d6; box-shadow: 0 0 0 0.8vmin var(--or), 0 1vmin 0 rgba(0, 0, 0, 0.18); transform: scale(1.03); }
.quiz-answer.wrong { animation: nope 0.5s ease; background: #f3e6e0; }
.quiz-answer.out { opacity: 0.25; pointer-events: none; }
.quiz-answer.hint { animation: guide 1.1s ease-in-out infinite; }
.quiz-answer.good { background: #e3f6e3; box-shadow: 0 0 0 1vmin var(--vert), 0 1vmin 0 rgba(0, 0, 0, 0.18); animation: pop 0.6s ease; }
.quiz-answer.good .quiz-letter { background: var(--vert); }
/* Bonne réponse trouvée, avec une image (D37) : l'image remplit la carte, la réponse est écrite dans un bandeau en bas. */
.quiz-answer.with-image { position: relative; overflow: hidden; padding: 0; align-items: flex-end; justify-content: stretch; }
.quiz-answer-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade 0.6s ease both; }
.quiz-answer.with-image > b, .quiz-answer.with-image > span { position: relative; z-index: 1; }
.quiz-answer.with-image > span {
  flex: 1; align-self: stretch; margin-top: auto; padding: 1.2vmin 1.6vmin 1.2vmin 11.4vmin; background: rgba(227, 246, 227, 0.95);
  font-size: 3.6vmin; line-height: 1.1; display: flex; align-items: center; min-height: 9vmin;
}
.quiz-answer.with-image > b { position: absolute; left: 1.8vmin; bottom: 1.2vmin; z-index: 2; }
.quiz-answers.solved:has(.with-image) { grid-template-columns: 1.2fr 1.8fr; }
/* Réponse trouvée : la bonne carte à gauche, « Le savais-tu ? » à droite (les mauvaises disparaissent). */
.quiz-answers.solved { grid-template-columns: 1fr 2fr; }
.quiz-answers.solved .quiz-answer.out { display: none; }
.quiz-explain {
  position: relative; z-index: 5; display: flex; flex-direction: column; justify-content: center; gap: 0.8vmin; min-height: 0; overflow: auto;
  padding: 2.4vmin 18vmin 2.6vmin 4vmin; border-radius: var(--rayon); background: var(--creme);
  box-shadow: var(--ombre), 0 0 0 0.8vmin var(--vert); animation: word-in 0.45s cubic-bezier(.3,1.4,.5,1);
}
.quiz-explain strong { font-size: 4.4vmin; color: var(--vert); }
.quiz-explain p { margin: 0; font-size: 4.2vmin; line-height: 1.25; font-weight: 600; }
/* « Suivant » : une flèche et le mot ; il clignote (lumière dorée) quand l'explication est finie. */
.quiz-next {
  position: absolute; right: 2.2vmin; top: 50%; translate: 0 -50%; width: 15vmin; padding: 1.6vmin 0 1.2vmin;
  display: flex; flex-direction: column; align-items: center; gap: 0.6vmin;
  border-radius: 4vmin; background: var(--soleil); color: var(--creme); box-shadow: var(--ombre);
}
.quiz-next svg { width: 8vmin; height: 8vmin; fill: currentColor; }
.quiz-next-label { font-family: var(--rond); font-size: 3.4vmin; font-weight: 800; color: var(--terre-sombre); line-height: 1; }
.quiz-next.ready { animation: next-blink 1.1s ease-in-out infinite; }
.quiz-next.alone { position: relative; top: auto; right: auto; translate: none; align-self: center; justify-self: start; z-index: 5; }
@keyframes next-blink {
  0%, 100% { transform: scale(1); box-shadow: var(--ombre), 0 0 0 0 rgba(255, 211, 77, 0); filter: brightness(1); }
  50% { transform: scale(1.1); box-shadow: var(--ombre), 0 0 0 1.4vmin rgba(255, 211, 77, 0.55), 0 0 5vmin var(--or); filter: brightness(1.12); }
}
.quiz-result { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 2.4vmin; }
.quiz-stars { display: flex; gap: 2vmin; }
.quiz-star { width: 16vmin; height: 16vmin; animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1) both; }
.quiz-star svg { width: 100%; height: 100%; fill: rgba(255, 255, 255, 0.35); stroke: rgba(255, 255, 255, 0.7); stroke-width: 0.8; }
.quiz-star.on svg { fill: var(--or); stroke: #fff; filter: drop-shadow(0 0.6vmin 0.8vmin rgba(0, 0, 0, 0.3)); }
.quiz-score { display: flex; flex-direction: column; align-items: center; color: #fff; text-shadow: 0 0.4vmin 0 rgba(0, 0, 0, 0.25); line-height: 1; }
.quiz-score strong { font-size: 12vmin; }
.quiz-score span { font-size: 4.4vmin; }
.quiz-go { width: 16vmin; height: 16vmin; }
/* Mode test : la barre « PROTOTYPE » reste en bas ; le quiz lui laisse la place. */
body:has(.dev-bar) .quiz { padding-bottom: 44px; }

/* ---------- accueil par paliers (le quiz) : une rangée par palier ---------- */
.level-list {
  --rond: "Baloo 2", "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center;
  gap: 2.2vmin; padding: 3vmin 4vmin 4vmin;
}
.level {
  display: grid; grid-template-columns: 22vmin 1fr; align-items: center; gap: 2vmin;
  padding: 1.6vmin 2vmin; border-radius: 4vmin; background: rgba(255, 248, 236, 0.14);
  box-shadow: inset 0 0 0 0.5vmin rgba(255, 248, 236, 0.25);
}
.level.current { background: rgba(255, 248, 236, 0.22); box-shadow: inset 0 0 0 0.6vmin var(--soleil); }
.level.nope { animation: nope 0.5s ease; }
.level-head { display: flex; flex-direction: column; align-items: center; gap: 0.4vmin; color: #fff; text-align: center; font-family: var(--rond); line-height: 1.05; }
.level-head strong { font-size: 3.3vmin; text-shadow: 0 0.3vmin 0 rgba(0, 0, 0, 0.3); }
.level-stars { font-size: 4.4vmin; color: var(--or); letter-spacing: 0.2vmin; text-shadow: 0 0.3vmin 0 rgba(0, 0, 0, 0.3); }
.level-count { font-size: 2.8vmin; font-weight: 700; opacity: 0.9; }
.level-lock { width: 6vmin; height: 6vmin; border-radius: 50%; background: rgba(255, 248, 236, 0.92); display: grid; place-items: center; box-shadow: var(--ombre); }
.level-lock svg { width: 58%; height: 58%; fill: var(--terre); }
.level-hint { font-size: 2.3vmin; font-weight: 700; opacity: 0.9; }
.level-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2.2vmin; }
.level-card { width: 100%; border-radius: 3.2vmin; box-shadow: var(--ombre), 0 0 0 0.6vmin var(--creme); }
.level-card.current { box-shadow: var(--ombre), 0 0 0 0.6vmin var(--creme), 0 0 0 1.3vmin var(--soleil); }
.level-card .episode-play { width: 20cqw; height: 20cqw; right: 4cqw; bottom: auto; top: 6cqw; }
.level-card-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2.4cqw 3cqw 3cqw; text-align: center;
  font-family: var(--rond); font-weight: 800; font-size: 9cqw; line-height: 1.05; color: var(--terre-sombre);
  background: rgba(255, 248, 236, 0.94);
}
.level-card-done {
  position: absolute; left: 4cqw; top: 5cqw; width: 18cqw; height: 18cqw; border-radius: 50%; display: grid; place-items: center;
  background: var(--vert); color: #fff; font-size: 12cqw; font-weight: 800; box-shadow: var(--ombre);
}
.level.locked .level-card > img { filter: grayscale(0.8) brightness(0.6); }
.level.locked .level-card-label { opacity: 0.75; }

/* ---------- écran d'accueil avec tous les jeux (D36) ---------- */
.games-home {
  --rond: "Baloo 2", "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vmin; padding: 3vmin 5vmin 5vmin;
  background: radial-gradient(ellipse at 50% 0%, #f6b44b 0%, #d9772b 45%, #8a3b17 100%); overflow-y: auto;
}
.games-title { margin: 0; font-family: var(--rond); font-size: 5.6vmin; line-height: 1; color: #fff; text-shadow: 0 0.5vmin 0 rgba(61, 29, 14, 0.45); }
.games-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3vmin 3.4vmin; width: min(100%, 190vmin); }
.game-card {
  position: relative; aspect-ratio: 16 / 9; border-radius: 3.6vmin; overflow: hidden; container-type: inline-size;
  background: var(--terre); box-shadow: var(--ombre), 0 0 0 0.7vmin var(--creme); transition: transform 0.15s ease;
}
.game-card:active { transform: scale(0.96); }
.game-card > img { width: 100%; height: 100%; object-fit: cover; }
.game-card .episode-play { width: 17cqw; height: 17cqw; right: 4cqw; top: 5cqw; bottom: auto; }
.game-card-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2cqw 3cqw 2.6cqw; text-align: center;
  font-family: var(--rond); font-weight: 800; font-size: 7.6cqw; line-height: 1.05; color: var(--terre-sombre); background: rgba(255, 248, 236, 0.94);
}
.game-card-tag {
  position: absolute; left: 4cqw; top: 5cqw; padding: 1.2cqw 3cqw; border-radius: 4cqw; background: var(--vert); color: #fff;
  font-family: var(--rond); font-weight: 800; font-size: 5.6cqw; box-shadow: var(--ombre);
}
/* Safary (D45) : le jeu des grands, avec son étiquette brune. Plus de 6 jeux : 4 cartes par rangée. */
.games-grid.quatre { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, 210vmin); }
.game-card.apart .game-card-tag { background: #7e2c1c; font-size: 4.6cqw; }
.games-back {
  position: absolute; left: 2.4vmin; top: 2.4vmin; z-index: 6; width: 10vmin; height: 10vmin; border-radius: 50%;
  background: var(--soleil); color: var(--creme); display: grid; place-items: center; box-shadow: var(--ombre); opacity: 1;
}
.games-back svg { width: 58%; height: 58%; fill: currentColor; }

/* ---------- maison pour quitter un jeu en cours (en haut à gauche, par-dessus tout) ---------- */
.quit-btn {
  position: fixed; left: 2vmin; top: 2vmin; z-index: 90; width: 9vmin; height: 9vmin; border-radius: 50%;
  background: var(--creme); color: var(--terre); display: grid; place-items: center; box-shadow: var(--ombre); opacity: 0.92;
}
.quit-btn svg { width: 56%; height: 56%; fill: currentColor; }
/* Écran de fin : il a déjà sa propre maison (« Retour à l'accueil »), on n'en montre pas deux. */
body:has(.end-screen) .quit-btn { display: none; }
/* Puzzle : les pièces de départ sont rangées sur les côtés ; la maison passe en haut au milieu, au-dessus du cadre. */
body:has(.puzzle) .quit-btn { left: 50%; top: 1vmin; transform: translateX(-50%); width: 8vmin; height: 8vmin; }
/* Le quiz : sa pastille de thème se décale pour laisser la place à la maison. */
body:has(.quit-btn) .quiz-head { padding-left: 10vmin; }
/* Barre de test montée en haut à gauche (livre, karaoké) : elle passe à droite de la maison. */
body:has(.quit-btn):has(.book-page) .dev-bar, body:has(.quit-btn):has(.karaoke-layer) .dev-bar { left: 13vmin; }
.start:has(.games-back) .level-list, .start:has(.games-back) .episode-row { padding-left: 14vmin; }

/* ---------- album à collectionner (D39, le quiz) ---------- */
.album-open {
  position: absolute; right: 2.4vmin; top: 2.4vmin; z-index: 6; width: 12vmin; height: 12vmin; border-radius: 50%;
  background: var(--soleil); color: var(--creme); display: grid; place-items: center; box-shadow: var(--ombre);
}
.album-open svg { width: 56%; height: 56%; fill: currentColor; }
.album-open-count {
  position: absolute; right: -1vmin; bottom: -1vmin; min-width: 5.6vmin; height: 5.6vmin; padding: 0 1.2vmin; border-radius: 3vmin;
  background: var(--creme); color: var(--terre); font-weight: 800; font-size: 3.4vmin; display: grid; place-items: center;
}
.start:has(.album-open) .level-list { padding-right: 17vmin; }

.album {
  --rond: "Baloo 2", "Fredoka", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  position: absolute; inset: 0; display: flex; flex-direction: column; font-family: var(--rond);
  background: linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.4)), var(--album, var(--terre));
  transition: background-color 0.3s;
}
.album-bar { display: flex; align-items: center; gap: 3vmin; padding: 2.4vmin 4vmin 1vmin; }
.album-back {
  width: 11vmin; height: 11vmin; flex: none; border-radius: 50%; background: var(--creme); color: var(--terre);
  display: grid; place-items: center; box-shadow: var(--ombre);
}
.album-back svg { width: 56%; height: 56%; fill: currentColor; }
.album-tabs { flex: 1; display: flex; justify-content: center; gap: 3.4vmin; }
.album-tab {
  position: relative; width: 13vmin; height: 13vmin; border-radius: 50%; background: var(--creme); opacity: 0.7;
  display: grid; place-items: center; box-shadow: var(--ombre); transition: transform 0.2s, opacity 0.2s;
}
.album-tab.on { opacity: 1; transform: scale(1.1); box-shadow: var(--ombre), 0 0 0 0.8vmin var(--or); }
.album-tab-icon svg { width: 7vmin; height: 7vmin; fill: var(--tab); display: block; }
.album-tab-count {
  position: absolute; left: 50%; bottom: -2vmin; transform: translateX(-50%); white-space: nowrap;
  background: var(--tab); color: #fff; font-weight: 800; font-size: 3vmin; padding: 0.2vmin 1.6vmin; border-radius: 3vmin;
}
.album-total { flex: none; min-width: 11vmin; text-align: right; color: #fff; text-shadow: 0 0.4vmin 0 rgba(0, 0, 0, 0.25); }
.album-total strong { font-size: 6vmin; }
.album-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content; gap: 2.6vmin; padding: 3.4vmin 4vmin 5vmin; align-content: start;
}
.album-card {
  aspect-ratio: 4 / 3; border-radius: 2vmin; overflow: hidden; background: var(--creme); padding: 0.7vmin;
  box-shadow: var(--ombre); display: block;
}
.album-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 1.4vmin; display: block; }
.album-card.empty {
  background: rgba(255, 255, 255, 0.14); box-shadow: none; border: 0.5vmin dashed rgba(255, 255, 255, 0.55);
  display: grid; place-items: center;
}
.album-card.empty span { font-size: 9vmin; font-weight: 800; color: rgba(255, 255, 255, 0.7); line-height: 1; }
.album-zoom {
  position: absolute; inset: 0; z-index: 20; background: rgba(20, 8, 2, 0.88); display: grid; place-items: center;
  animation: fade 0.25s ease;
}
.album-zoom img {
  max-width: 92%; max-height: 90%; border-radius: 2vmin; border: 1vmin solid var(--creme); box-shadow: var(--ombre);
  animation: word-in 0.4s cubic-bezier(.3,1.4,.5,1) both;
}

/* Fin de partie avec de nouvelles images pour l'album. */
.quiz-result.with-prizes { gap: 1.6vmin; }
.quiz-result.with-prizes .quiz-star { width: 12vmin; height: 12vmin; }
.quiz-result.with-prizes .quiz-score strong { font-size: 9vmin; }
.quiz-result.with-prizes .quiz-score span { font-size: 3.8vmin; }
.quiz-result-foot { display: flex; align-items: center; gap: 4vmin; }
.quiz-prizes {
  display: flex; align-items: center; gap: 2vmin; padding: 1.6vmin 2.4vmin; border-radius: var(--rayon);
  background: rgba(255, 255, 255, 0.2);
}
.quiz-prizes-icon svg { width: 9vmin; height: 9vmin; fill: #fff; display: block; }
.quiz-prize {
  height: 15vmin; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 1.6vmin; border: 0.6vmin solid var(--creme);
  box-shadow: var(--ombre); animation: prize-in 0.6s cubic-bezier(.3,1.4,.5,1) both;
}
@keyframes prize-in { from { transform: scale(0) rotate(-14deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .quiz-prize, .album-zoom img { animation: none; } }

/* Annonce du début de partie : thème, « Niveau facile » et étoiles, en grand, pendant la voix d'introduction. */
.quiz-announce {
  margin: auto; display: flex; flex-direction: column; align-items: center; gap: 1.4vmin; padding: 3vmin 8vmin 3.4vmin;
  background: var(--creme); border-radius: var(--rayon); box-shadow: var(--ombre), 0 0 0 0.8vmin var(--or);
  color: var(--quiz); text-align: center; animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1) both;
}
.quiz-announce.out { opacity: 0; transform: scale(0.85) translateY(-6vmin); transition: opacity 0.35s, transform 0.35s; }
.quiz-announce-badge { width: 12vmin; height: 12vmin; border-radius: 50%; background: var(--quiz); display: grid; place-items: center; }
.quiz-announce-badge svg { width: 62%; height: 62%; fill: var(--creme); }
.quiz-announce strong { font-size: 7vmin; line-height: 1.05; }
.quiz-announce-level { font-size: 6vmin; font-weight: 800; color: var(--terre); }
.quiz-announce-stars { display: flex; gap: 1.6vmin; }
.quiz-announce .quiz-star { width: 11vmin; height: 11vmin; }
.quiz-announce .quiz-star svg { fill: rgba(0, 0, 0, 0.1); stroke: rgba(0, 0, 0, 0.18); }
.quiz-announce .quiz-star.on svg { fill: var(--or); stroke: #c98a00; }
@media (prefers-reduced-motion: reduce) { .quiz-announce, .quiz-announce.out { animation: none; transition: none; } }

/* ---------- Abonnement et espace parents (D42, D43) ---------- */
/* Côté enfant : cadenas doré sur un épisode payant (aucun prix, aucun texte). */
.episode-card.paid > img { filter: saturate(0.6) brightness(0.8); }
.episode-lock.paid-lock { background: var(--or); box-shadow: 0 0 0 0.6vmin var(--creme); }
.big-play.paid-big { background: var(--or); }
.ask-adult { position: absolute; inset: 0; display: grid; place-items: center; background: var(--terre-sombre); }
.ask-adult-bg { filter: grayscale(0.5) brightness(0.45); }
.ask-adult-lock {
  position: relative; width: 26vmin; height: 26vmin; border-radius: 50%; background: var(--or); display: grid; place-items: center;
  box-shadow: var(--ombre), 0 0 0 1.2vmin var(--creme); animation: word-in 0.5s cubic-bezier(.3,1.4,.5,1) both;
}
.ask-adult-lock svg { width: 52%; height: 52%; fill: var(--terre); }
.ask-adult-home { position: absolute; left: 4vmin; bottom: 4vmin; width: 16vmin; height: 16vmin; }
/* Petite porte vers l'espace parents (en haut à droite), discrète pour l'enfant. */
.parents-open {
  position: absolute; right: 2.4vmin; top: 2.4vmin; z-index: 6; width: 9vmin; height: 9vmin; border-radius: 50%;
  background: rgba(255, 248, 236, 0.85); color: var(--terre); display: grid; place-items: center; box-shadow: var(--ombre);
}
.parents-open svg { width: 60%; height: 60%; fill: currentColor; }
.games-home:has(.parents-open) .games-title { padding: 0 12vmin; }

/* Barrière parentale */
.gate { position: absolute; inset: 0; display: grid; place-items: center; background: var(--terre-sombre); overflow-y: auto; padding: 3vmin; }
.gate-close { position: absolute; left: 2.4vmin; top: 2.4vmin; width: 10vmin; height: 10vmin; border-radius: 50%; background: var(--creme); color: var(--terre); display: grid; place-items: center; }
.gate-close svg { width: 56%; height: 56%; fill: currentColor; }
.gate-card {
  background: var(--creme); color: #2b1a10; border-radius: var(--rayon); padding: 3vmin 5vmin; box-shadow: var(--ombre);
  display: grid; grid-template-columns: auto auto; grid-template-areas: "t pad" "q pad" "a pad"; gap: 1.5vmin 6vmin; align-items: center;
  font-family: system-ui, "Segoe UI", sans-serif;
}
.gate-card h2 { grid-area: t; margin: 0; font-size: 20px; color: var(--terre); }
.gate-ask { grid-area: q; margin: 0; font-size: 17px; max-width: 16em; }
.gate-answer { grid-area: a; font-size: 34px; font-weight: 700; letter-spacing: 0.06em; color: var(--terre); min-height: 1.2em; }
.gate-answer.nope { animation: nope 0.5s ease; color: #c0392b; }
.gate-pad { grid-area: pad; display: grid; grid-template-columns: repeat(3, 52px); gap: 8px; }
.gate-key { height: 46px; border-radius: 10px; background: #f0e2c8; color: #2b1a10; font-size: 20px; font-weight: 700; }
.gate-key:active { background: var(--or); }
.gate-erase { grid-column: span 2; }

/* Espace parents : une page lisible, qu'on fait défiler (aussi en portrait). */
body:has(.parents) .rotate, body:has(.gate) .rotate { display: none; }
.parents {
  position: absolute; inset: 0; overflow-y: auto; background: #f6eedf; color: #2b1a10;
  font: 16px/1.5 system-ui, "Segoe UI", sans-serif; padding: 0 0 40px;
}
.parents-top { position: sticky; top: 0; z-index: 2; background: var(--terre); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.parents-top h1 { margin: 0; font-size: 19px; }
.parents-back { background: rgba(255, 255, 255, 0.18); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 15px; }
.parents-section { max-width: 720px; margin: 14px auto 0; padding: 14px 18px; background: #fffaf1; border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.parents-section h2 { margin: 0 0 8px; font-size: 18px; color: var(--terre); }
.parents-section p { margin: 6px 0; }
.parents-list { margin: 6px 0; padding-left: 22px; }
.parents-state { background: #efe3cc; border-radius: 8px; padding: 8px 12px; }
.parents-state.on { background: #dcefd6; color: #24561c; font-weight: 600; }
.parents-price strong { font-size: 24px; color: var(--terre); }
.parents-pay, .parents-btn {
  display: inline-block; background: var(--terre); color: #fff; text-decoration: none; border-radius: 10px; padding: 10px 18px;
  font-weight: 700; font-size: 16px; margin: 6px 0;
}
.parents-pay { background: #0070ba; }
.parents-btn.light { background: #efe3cc; color: #2b1a10; }
.parents-btn:disabled { opacity: 0.6; }
.parents-note { font-size: 14px; color: #6b5444; }
.parents-code { display: flex; gap: 8px; flex-wrap: wrap; }
.parents-code input {
  flex: 1; min-width: 200px; font: 600 18px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 0.08em; padding: 10px 12px;
  border: 1.5px solid #cdb895; border-radius: 10px; background: #fff; color: #2b1a10; text-transform: uppercase;
}
.parents-msg { min-height: 1.4em; font-size: 15px; }
.parents-msg.good { color: #24561c; font-weight: 600; }
.parents-msg.bad { color: #b03a2e; }
.parents-todo { font-size: 13px; color: #b03a2e; font-style: italic; }
.parents-links { display: flex; gap: 16px; flex-wrap: wrap; }
.parents-links a { color: var(--terre); }
/* Offres de l'abonnement (D43) */
.parents-state.over { background: #f6dccf; color: #8a2e1c; }
.parents-offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 10px 0; }
.parents-offer { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1.5px solid #e3d2b3; border-radius: 12px; padding: 10px 14px; }
/* Un bouton « S’abonner » dans chaque offre (lien PayPal propre à l’offre). */
.parents-offer-promo { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: #fff3d6; font-size: 13px; line-height: 1.35; color: #5a3a1c; }
.parents-offer-promo span:first-child { font-weight: 700; color: #7e2c1c; }
.parents-offer-promo span:last-child { font-weight: 700; }
/* Offre annoncée mais pas encore ouverte (« Bientôt disponible »). */
.parents-offer.bientot { opacity: .7; }
.parents-offer-bientot { margin-top: 8px; align-self: flex-start; font-size: 13px; font-weight: 700; color: #7e2c1c; background: #f6e7c8; border-radius: 999px; padding: 4px 12px; }
.parents-tva { margin: 4px 0 0; font-size: 12px; color: #8a6a45; }
.parents-pay-offre { margin-top: 8px; align-self: flex-start; padding: 8px 18px; font-size: 15px; }
.parents-offer-label { font-weight: 700; color: var(--terre); }
.parents-offer .parents-price { margin: 2px 0; }
.parents-offer-until { font-size: 13px; color: #6b5444; }
