/* Mise en page des écrans. Tout tient dans la fenêtre : jamais de scroll côté enfant. */
#app { position: fixed; inset: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow: hidden; display: grid; }
.screen.fade-in { animation: fadein 300ms ease; }
@keyframes fadein { from { opacity: 0; transform: scale(1.02); } }

/* ---- Accueil & monde : le chemin ---- */
.path-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.path-svg path { fill: none; stroke: #fff; stroke-width: 14; stroke-linecap: round; stroke-dasharray: 1 24; opacity: .9; }
.home .step { width: clamp(96px, 15vmin, 150px); }
.home .step > svg { width: 66%; height: 66%; }
.hero { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: flex; align-items: flex-end; gap: 12px; max-width: 46%; z-index: 3; }
.hero .bubble { font-size: clamp(1.2rem, 3vmin, 2rem); padding: 14px 20px; }
.play-btn { position: absolute; right: max(24px, env(safe-area-inset-right, 0px)); bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 3; width: clamp(110px, 20vmin, 170px); height: clamp(110px, 20vmin, 170px); font-size: clamp(2.6rem, 8vmin, 5rem); }
.sun { position: absolute; top: 5%; right: 8%; width: clamp(70px, 12vmin, 120px); height: auto; }
.world-title { position: absolute; top: max(16px, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); font-size: clamp(1.4rem, 4vmin, 2.6rem); font-weight: 700; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.18); white-space: nowrap; z-index: 4; }
.tree { position: absolute; width: clamp(60px, 10vmin, 110px); height: auto; pointer-events: none; }

/* ---- Activité ---- */
.activity { grid-template-rows: auto 1fr auto; padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); gap: 8px; }
.activity .ask { display: flex; align-items: center; gap: 14px; padding-top: 64px; min-height: 0; }
.activity .ask .mascot { width: clamp(80px, 14vmin, 150px); flex: none; }
.activity .ask .bubble { font-size: clamp(1.3rem, 3.4vmin, 2.2rem); padding: 12px 20px; }
.activity .stage { display: grid; place-items: center; min-height: 0; }
.activity .stage .tiles { width: min(100%, 980px); }
.activity .stage .tile { min-height: clamp(130px, 30vmin, 240px); }
.activity .stage .tile > svg { width: clamp(90px, 22vmin, 190px); height: clamp(90px, 22vmin, 190px); }
.activity .foot { display: flex; justify-content: center; align-items: center; min-height: 64px; }
.dots { position: absolute; top: max(20px, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 4; }
.dots i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.dots i.on { background: var(--star); }
.btn-back { position: absolute; top: max(12px, env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); z-index: 6; width: 64px; height: 64px; min-width: 0; min-height: 0; font-size: 1.6rem; }
.btn-say { position: absolute; bottom: max(14px, env(safe-area-inset-bottom, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); z-index: 6; }
.btn-parent { width: 64px; height: 64px; min-width: 0; min-height: 0; font-size: 1.6rem; }

/* stage spécifiques */
.seq { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.seq .cell { width: clamp(56px, 11vmin, 96px); height: clamp(56px, 11vmin, 96px); display: grid; place-items: center; background: var(--paper); border-radius: var(--r-m); box-shadow: var(--float); font-size: 2.6rem; font-weight: 700; color: var(--ink-soft); }
.seq .cell svg { width: 70%; height: 70%; }
.hole { width: clamp(100px, 18vmin, 160px); height: clamp(100px, 18vmin, 160px); color: #cbb58a; filter: drop-shadow(inset 0 0 0 #000); }
.hole svg { width: 100%; height: 100%; }
.groupe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.groupe svg { width: clamp(34px, 6vmin, 56px); height: clamp(34px, 6vmin, 56px); }
.count-field { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 620px; margin-bottom: 10px; }
.count-field button { width: clamp(64px, 11vmin, 96px); height: clamp(64px, 11vmin, 96px); position: relative; transition: transform var(--t-fast) var(--ease-pop); }
.count-field button svg { width: 100%; height: 100%; }
.count-field button.counted { transform: scale(1.1); }
.count-field button.counted::after { content: attr(data-n); position: absolute; right: -4px; top: -6px; background: var(--star); color: var(--ink); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-weight: 700; box-shadow: 0 2px 0 var(--star-dark); }
.memory { display: grid; gap: clamp(8px, 2vmin, 18px); grid-template-columns: repeat(3, 1fr); width: min(100%, 560px); }
.memory .card { aspect-ratio: 1; perspective: 800px; }
.memory .card .in { position: relative; width: 100%; height: 100%; transition: transform 380ms var(--ease-pop); transform-style: preserve-3d; }
.memory .card.open .in, .memory .card.found .in { transform: rotateY(180deg); }
.memory .face { position: absolute; inset: 0; border-radius: var(--r-m); backface-visibility: hidden; display: grid; place-items: center; box-shadow: var(--pop); font-size: clamp(2rem, 7vmin, 4rem); font-weight: 700; }
.memory .face.back { background: var(--w-logique); color: #fff; }
.memory .face.back svg { width: 40%; height: 40%; opacity: .8; }
.memory .face.front { background: var(--paper); transform: rotateY(180deg); }
.memory .face.front svg { width: 70%; height: 70%; }
.memory .card.found .face.front { outline: 6px solid var(--ok); }
.memory .swatch { width: 60%; }

/* traçage */
.trace-wrap { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; width: min(100%, 900px); height: 100%; }
.trace-box { position: relative; height: min(100%, 60vmin); aspect-ratio: 1; margin: 0 auto; background: var(--paper); border-radius: var(--r-l); box-shadow: var(--float); touch-action: none; }
.trace-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: var(--r-l); }
.trace-side { display: grid; gap: 12px; justify-items: center; text-align: center; font-size: clamp(1.1rem, 2.6vmin, 1.6rem); font-weight: 600; }
.trace-side .word { background: var(--sand); border-radius: var(--r-m); padding: 10px 16px; display: grid; justify-items: center; gap: 6px; }
.trace-side .word svg { width: clamp(60px, 12vmin, 110px); height: clamp(60px, 12vmin, 110px); }
.name-row { display: flex; gap: 8px; font-size: clamp(2rem, 6vmin, 3.5rem); font-weight: 700; }
.name-row span { width: 1.2em; text-align: center; color: var(--ink-faint); }
.name-row span.done { color: var(--w-lettres); }
.name-row span.now { color: var(--sun); animation: pulse 1s infinite; }

/* ---- Résultat ---- */
.result { place-items: center; text-align: center; }
.result .box { display: grid; justify-items: center; gap: 18px; }
.result .mascot { width: clamp(140px, 26vmin, 240px); }
.result .big-stars { display: flex; gap: 14px; font-size: clamp(3rem, 9vmin, 5.5rem); }
.result .big-stars svg { width: 1em; height: 1em; color: rgba(255,255,255,.7); transform: scale(0); animation: popin 500ms var(--ease-pop) forwards; }
.result .big-stars svg.on { color: var(--star); filter: drop-shadow(0 4px 0 var(--star-dark)); }
.result .big-stars svg:nth-child(2) { animation-delay: 250ms; } .result .big-stars svg:nth-child(3) { animation-delay: 500ms; }
@keyframes popin { to { transform: scale(1); } }
.result .row { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.result .bubble::before { display: none; }
.result .bubble { font-size: clamp(1.3rem, 3.6vmin, 2.2rem); }

/* ---- Coin parents ---- */
.gate { place-items: center; background: var(--paper); }
.gate .box { display: grid; gap: 16px; justify-items: center; text-align: center; font-family: var(--font-text); }
.gate .q { font-family: var(--font-ui); font-size: 2rem; font-weight: 600; }
.gate .pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.gate .pad .btn { min-width: 64px; min-height: 64px; font-size: 1.5rem; padding: 0; }
.parent-screen { overflow: auto; display: block; padding: 24px max(20px, env(safe-area-inset-right, 0px)) 60px max(20px, env(safe-area-inset-left, 0px)); }
.parent-screen .inner { max-width: 900px; margin: 0 auto; }
.parent-screen .head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.parent-screen .settings { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.parent-screen .set { background: #fff; border: 1px solid var(--ink-faint); border-radius: var(--r-m); padding: 14px 16px; display: grid; gap: 8px; }
.parent-screen .set label { font-weight: 700; }
.parent-screen .set .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.parent-screen .prog { display: grid; gap: 12px; }
.parent-screen .monde { border-radius: var(--r-m); overflow: hidden; border: 1px solid var(--ink-faint); background: #fff; }
.parent-screen .monde header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: #fff; font-family: var(--font-ui); font-weight: 600; font-size: 1.2rem; }
.parent-screen .monde header svg { width: 36px; height: 36px; }
.parent-screen .monde header small { font-weight: 400; font-size: .85rem; opacity: .9; margin-left: auto; text-align: right; font-family: var(--font-text); }
.parent-screen .monde table { width: 100%; }
.parent-screen .monde td .stars { font-size: 1.1rem; }
.parent-screen .monde td .stars .off { color: var(--ink-faint); }
.parent-screen .tablewrap { overflow-x: auto; }
.parent-screen .danger { color: #b3261e; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; }

/* ---- Confettis ---- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---- Portrait / petit écran ---- */
@media (orientation: portrait) {
  .hero { max-width: 62%; bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
  .hero .mascot { width: clamp(70px, 18vmin, 110px); }
  .hero .bubble { font-size: clamp(1rem, 4.2vmin, 1.5rem); padding: 10px 14px; }
  .home .step { width: clamp(84px, 20vmin, 120px); }
  .step .label { font-size: .85rem; }
  .play-btn { width: clamp(90px, 24vmin, 130px); height: clamp(90px, 24vmin, 130px); }
  .sun { top: 2%; right: 4%; width: 14vmin; }
  .tree { display: none; }
  .activity .ask { padding-top: 70px; }
  .trace-wrap { grid-template-columns: 1fr; }
  .trace-box { height: auto; width: min(100%, 70vmin); }
}
@media (max-width: 640px) {
  .activity .stage .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
  .activity .stage .tile { min-height: 120px; }
  .activity .stage .tile > svg { width: clamp(70px, 18vmin, 120px); height: clamp(70px, 18vmin, 120px); }
  .tiles { gap: 12px; }
  .memory { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Décor ---- */
.cloud.drift { animation: drift 60s linear infinite; }
.cloud.drift.slow { animation-duration: 90s; }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(110vw); } }
.hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 26%; pointer-events: none; }
.deco { position: absolute; opacity: .35; pointer-events: none; height: auto; aspect-ratio: 1; }
.tree.small { width: clamp(40px, 7vmin, 80px); }
.row-btns { display: flex; gap: 10px; }
.bubble-count { position: absolute; top: -6px; right: -6px; background: var(--sun); color: #fff; font-style: normal; font-size: .85rem; font-weight: 700; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; box-shadow: 0 2px 0 var(--sun-dark); }
.btn-parent { position: relative; }
.step .n { font-size: 2.4rem; }
.night { background: linear-gradient(180deg, #1b2a5a 0%, #3a4f8f 70%, #2c6b3f 70.2%, #1f4d2d 100%); }
.night .bubble { color: var(--ink); }
.moon { width: clamp(80px, 14vmin, 140px); height: auto; }

/* ---- Variantes de manches ---- */
.seq.days .cell { font-size: 1rem; }
.seq.days .cell.now { background: var(--star); }
.seq.days .cell.ask { color: var(--sun); }
.tile .word { font-size: clamp(1.4rem, 4vmin, 2.4rem); }
.weather { display: grid; place-items: center; margin-bottom: 10px; }
.weather svg { width: clamp(80px, 16vmin, 150px); height: clamp(80px, 16vmin, 150px); }
.seq.manque .cell { width: clamp(70px, 14vmin, 120px); height: clamp(70px, 14vmin, 120px); position: relative; transition: background var(--t-med); }
.seq.manque .cell.cover svg { visibility: hidden; }
.seq.manque .cell.cover { background: var(--w-logique); }
.seq.manque .cell.cover::after { content: "?"; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; font-weight: 700; }
.seq.manque .cell.gone svg { visibility: hidden; }
.seq.manque .cell.gone { border: 4px dashed var(--ink-faint); background: transparent; box-shadow: none; }
.tiles.emo .tile > svg { width: clamp(100px, 24vmin, 200px); height: clamp(100px, 24vmin, 200px); }

/* ---- Le corps ---- */
.body-wrap { height: 100%; display: grid; place-items: center; }
.bonhomme { height: min(100%, 60vmin); width: auto; max-width: 100%; filter: drop-shadow(0 8px 10px rgba(0,0,0,.15)); }
.bonhomme [data-part] { cursor: pointer; transition: filter var(--t-fast); }
.bonhomme [data-part].hit { filter: drop-shadow(0 0 6px var(--sun)) drop-shadow(0 0 14px var(--sun)); animation: wiggle 500ms ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

/* ---- Abécédaire ---- */
.abc-wrap, .activity .stage:has(.abc) { }
.activity .stage:has(.abc) { grid-template-columns: 1fr auto; gap: 16px; align-items: center; justify-items: stretch; }
.abc { display: grid; grid-template-columns: repeat(7, 1fr); gap: clamp(6px, 1.2vmin, 12px); width: 100%; max-width: 760px; }
.abc-l { aspect-ratio: 1; border-radius: var(--r-m); background: var(--paper); font-size: clamp(1.4rem, 4.2vmin, 2.6rem); font-weight: 700; box-shadow: var(--pop-pressed); transition: transform var(--t-fast) var(--ease-pop); }
.abc-l:active { transform: scale(.92); }
.abc-l.on { background: var(--w-lettres); color: #fff; box-shadow: 0 4px 0 var(--w-lettres-dark); }
.abc-side { display: grid; place-items: center; min-width: 180px; }
.abc-side .word-card { min-width: 180px; }
.abc-side .word-card .fox.mini { width: 70px; }

/* ---- Le panier ---- */
.panier-wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: end; width: min(100%, 900px); height: 100%; }
.tree-apples { position: relative; height: min(100%, 52vmin); aspect-ratio: 1.2; margin: 0 auto; }
.tree-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tree-apples .apple { position: absolute; width: clamp(48px, 9vmin, 80px); height: clamp(48px, 9vmin, 80px); transition: transform var(--t-fast) var(--ease-pop); filter: drop-shadow(0 3px 3px rgba(0,0,0,.2)); }
.tree-apples .apple svg, .in-basket .apple svg { width: 100%; height: 100%; }
.basket { position: relative; height: min(70%, 36vmin); aspect-ratio: 1.2; margin: 0 auto; }
.basket-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.in-basket { position: absolute; left: 14%; right: 14%; top: 26%; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.in-basket .apple { width: clamp(36px, 7vmin, 60px); height: clamp(36px, 7vmin, 60px); animation: popin 300ms var(--ease-pop); }

/* ---- Puzzle ---- */
.puzzle-wrap { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; width: min(100%, 900px); height: 100%; }
.model { display: grid; justify-items: center; gap: 6px; font-weight: 600; color: var(--ink-soft); }
.model svg { width: clamp(110px, 22vmin, 220px); border-radius: var(--r-s); box-shadow: var(--float); }
.pz { display: grid; gap: 6px; width: min(100%, 60vmin); margin: 0 auto; background: var(--paper); padding: 6px; border-radius: var(--r-m); box-shadow: var(--pop); }
.pz-cell { border-radius: 8px; overflow: hidden; border: 4px solid transparent; transition: transform var(--t-fast) var(--ease-pop); line-height: 0; }
.pz-cell svg { width: 100%; height: 100%; display: block; }
.pz-cell.sel { border-color: var(--sun); transform: scale(.93); }
.pz-cell.ok { border-color: rgba(45,198,83,.6); }

/* ---- Atelier peinture ---- */
.paint-wrap { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; width: min(100%, 940px); height: 100%; }
.paint-page { background: #fff; border-radius: var(--r-l); box-shadow: var(--pop); padding: 10px; height: min(100%, 58vmin); display: grid; place-items: center; }
.coloriage { height: 100%; width: auto; max-width: 100%; }
.coloriage .zone { fill: #fff; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; cursor: pointer; transition: fill var(--t-fast); }
.coloriage .zone:hover { fill: #f3f6fb; }
.palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pot { width: clamp(52px, 9vmin, 72px); height: clamp(52px, 9vmin, 72px); border-radius: 50%; border: 5px solid #fff; box-shadow: var(--pop-pressed); transition: transform var(--t-fast) var(--ease-pop); }
.pot.on { transform: scale(1.18); box-shadow: 0 0 0 4px var(--ink), var(--pop); }
.btn-erase { position: absolute; top: 8px; right: 8px; width: 52px; height: 52px; min-width: 0; min-height: 0; font-size: 1.3rem; z-index: 2; }

/* ---- Album ---- */
.album-wrap { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; padding: 76px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); height: 100%; }
.album-count { justify-self: center; background: rgba(255,255,255,.9); border-radius: var(--r-pill); padding: 6px 18px; font-weight: 700; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; box-shadow: var(--float); }
.album-count svg { width: 1.4em; height: 1.4em; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(84px, 11vmin, 120px), 1fr)); gap: 12px; align-content: center; overflow: auto; padding: 4px; }
.sticker { aspect-ratio: 1; border-radius: var(--r-m); background: rgba(255,255,255,.55); display: grid; place-items: center; border: 4px dashed rgba(255,255,255,.9); }
.sticker svg { width: 66%; height: 66%; filter: grayscale(1) opacity(.25); }
.sticker.on { background: var(--paper); border: 4px solid var(--w); box-shadow: var(--pop); }
.sticker.on svg { filter: none; }
.sticker.bounce { animation: bounce 600ms var(--ease-pop); }
.album-screen .hero { position: static; max-width: none; justify-self: start; }
.album-screen .hero .fox { width: clamp(70px, 12vmin, 110px); }
.sticker-reveal { width: clamp(90px, 18vmin, 160px); aspect-ratio: 1; background: var(--paper); border-radius: var(--r-m); display: grid; place-items: center; box-shadow: var(--pop); animation: popin 600ms var(--ease-pop) both; animation-delay: 700ms; transform: scale(0); }
.sticker-reveal svg { width: 70%; height: 70%; }

/* ---- Parents ---- */
.parent-screen textarea { width: 100%; font: inherit; font-size: .85rem; border-radius: var(--r-s); border: 2px solid var(--ink-faint); padding: 8px; }
.monde-foot { padding: 8px 14px; }

@media (orientation: portrait) {
  .activity .stage:has(.abc) { grid-template-columns: 1fr; }
  .abc { grid-template-columns: repeat(6, 1fr); }
  .panier-wrap { grid-template-columns: 1fr; grid-template-rows: 1fr auto; align-items: center; }
  .tree-apples { height: auto; width: min(100%, 70vmin); }
  .basket { height: 24vmin; }
  .puzzle-wrap { grid-template-columns: 1fr; height: auto; align-content: center; gap: 12px; }
  .model svg { width: 24vmin; }
  .panier-wrap, .paint-wrap, .trace-wrap { height: auto; }
  .paint-wrap { grid-template-columns: 1fr; }
  .paint-page { height: auto; }
  .palette { grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .pot { width: 40px; height: 40px; }
}
