/* Mise en page des écrans. Uniquement des jetons (tokens.css). */
html, body { height: 100%; }
body { overscroll-behavior: none; user-select: none; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: var(--l-max-width); margin: 0 auto; padding: var(--sp-4) var(--l-gutter) calc(var(--sp-5) + env(safe-area-inset-bottom)); gap: var(--sp-5); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--l-topbar); }
.topbar .grow { flex: 1; }
.center { text-align: center; }
.stack { display: grid; gap: var(--sp-4); justify-items: center; }
.push { margin-top: auto; }

/* S01 accueil */
.home { justify-content: center; align-items: center; text-align: center; background: linear-gradient(var(--c-sky) 0 55%, var(--c-grass) 55%); max-width: none; }
.home-train { width: min(70vw, 320px); height: auto; animation: chug 1.4s var(--m-ease) infinite; }
.home-title { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: 700; }
.home .corner { position: absolute; top: calc(var(--sp-4) + env(safe-area-inset-top)); right: var(--l-gutter); }
@keyframes chug { 50% { transform: translateY(-4px); } }

/* S04 carte */
.map-screen { background: linear-gradient(var(--c-sky) 0 var(--sp-8), var(--c-grass) var(--sp-8)); max-width: none; padding-top: var(--sp-3); }
.map-screen > * { width: 100%; max-width: var(--l-max-width); margin-left: auto; margin-right: auto; }
.line-name { font-weight: 700; font-size: var(--fs-lg); text-align: center; }
.track { position: relative; flex: 1; min-height: 520px; }
.track svg.rails { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.track .station { position: absolute; transform: translate(-50%, -50%); }
.track .station-name { position: absolute; transform: translate(-50%, 0); font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: 600; white-space: nowrap; background: var(--c-surface); padding: 0 var(--sp-2); border-radius: var(--r-sm); }
.track .train { position: absolute; width: 84px; height: 63px; transform: translate(-50%, -100%); transition: left var(--m-slow) var(--m-ease), top var(--m-slow) var(--m-ease); pointer-events: none; }
.station .mini-stars { left: 50%; transform: translateX(-50%); }

/* S05 / S06 jeu */
.game { gap: var(--sp-6); }
.game .progress { flex: 1; }
.prompt { font-size: var(--fs-lg); line-height: var(--lh-lg); text-align: center; }
.game .slots { flex-wrap: nowrap; gap: var(--sp-2); }
.game .slot { min-width: 0; flex: 0 1 var(--l-tile-min); }
.game .slot .tile, .game .tiles .tile { font-size: clamp(var(--fs-lg), 7vw, var(--fs-word)); padding: 0 var(--sp-3); }
.game .slot .tile { width: 100%; min-width: 0; height: 100%; }
.game .tiles { min-height: calc(var(--l-tile-min) * 2 + var(--sp-4)); align-content: flex-start; }
.word-reveal { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 600; text-align: center; min-height: var(--lh-display); color: var(--c-success); }
.intro-card { display: grid; gap: var(--sp-5); justify-items: center; text-align: center; }
.demo { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); align-items: center; font-family: var(--font-read); font-size: var(--fs-lg); }
.demo span { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--c-surface); border: 2px solid var(--c-border); }

/* Jeux G02 / G04 / G08 */
.word-card { background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: var(--sp-6) var(--sp-4); text-align: center; font-size: clamp(var(--fs-xl), 11vw, var(--fs-display)); line-height: var(--lh-display); font-weight: 500; overflow-wrap: anywhere; }
.syl-0 { color: var(--c-accent); }
.syl-1 { color: var(--c-rail); }
.syl + .syl { margin-left: var(--sp-2); }
.choice { display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: center; margin-top: auto; }
.choice-btn { flex: 1 1 140px; }
.choice-btn .sym { font-size: var(--fs-xl); }
.choice-btn.is-right { background: var(--c-success); color: var(--c-on-accent); box-shadow: none; }
.choice-btn.is-wrong { background: var(--c-danger-bg); color: var(--c-danger); box-shadow: none; animation: shake var(--m-slow) var(--m-ease); }
.choice-btn:disabled:not(.is-right):not(.is-wrong) { opacity: .6; }
.ears { display: flex; gap: var(--sp-5); justify-content: center; }
.ear { width: 120px; height: 120px; border-radius: var(--r-lg); background: var(--c-surface); border: 3px solid var(--c-border); display: grid; place-items: center; align-content: center; gap: var(--sp-1); font-weight: 700; font-size: var(--fs-lg); transition: transform var(--m-base) var(--m-bounce), background var(--m-base); }
.ear.is-on { background: var(--c-accent-soft); border-color: var(--c-accent); transform: scale(1.08); }
.ear-icon { width: 40px; height: 40px; }
.drum { width: 160px; height: 160px; border-radius: 50%; border: 0; background: var(--c-surface-2); display: grid; place-items: center; margin: 0 auto; cursor: pointer; box-shadow: var(--sh-card); }
.drum svg { width: 120px; height: 120px; }
.drum:active:not(:disabled) { transform: scale(.93); }
.drum:disabled { opacity: .55; }
.tap-dots { display: flex; gap: var(--sp-3); justify-content: center; min-height: 28px; }
.tap-dots span { width: 28px; height: 28px; border-radius: 50%; border: 3px dashed var(--c-border-input); }
.tap-dots span.is-on { background: var(--c-reward); border: 3px solid var(--c-rail); }

/* S07 / S08 */
.overlay .star { width: 56px; height: 56px; }
.gain { font-weight: 700; font-size: var(--fs-lg); }
.big-train { width: 160px; height: 120px; }

/* Jalon 3 ------------------------------------------------------------- */
/* Réglages de lecture */
:root[data-font="systeme"] { --font-read: system-ui, Roboto, "Segoe UI", sans-serif; }
:root[data-spacing="normal"] { --read-letter-spacing: 0.01em; --read-word-spacing: 0.05em; }
.track { min-height: 700px; }
.coins--btn { font: inherit; font-weight: 700; color: var(--c-text); cursor: pointer; }
.notice .grow { flex: 1; }

/* G01 rythme */
.rhythm { display: flex; align-items: center; justify-content: center; min-height: 56px; }
.rhythm .beat { width: 36px; height: 36px; border-radius: 50%; background: var(--c-surface-2); border: 3px solid var(--c-rail); transition: background var(--m-fast), transform var(--m-fast) var(--m-bounce); }
.rhythm .beat.is-on { background: var(--c-reward); transform: scale(1.2); }
.rhythm .gap--c { width: var(--sp-3); }
.rhythm .gap--l { width: var(--sp-8); border-bottom: 3px dotted var(--c-border-input); align-self: center; }
.rhythm--hidden { font-size: var(--fs-xl); font-weight: 700; color: var(--c-text-muted); }
.drum.is-hit { animation: pop var(--m-base) var(--m-bounce); }

/* G03 sons */
.sound-card { display: grid; justify-items: center; gap: var(--sp-1); }
.sound-show { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 600; color: var(--c-accent); text-align: center; }
.word-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.word-tile { width: 100%; min-width: 0; font-size: clamp(var(--fs-lg), 7vw, var(--fs-xl)); }
.tile.is-missed { border: 3px dashed var(--c-success); }

/* G06 lettres */
.slots--letters .slot .tile, .game .tiles .tile:only-child { padding: 0; }
.slots--letters .slot { flex-basis: 64px; }

/* Voix du parent */
.rec-grid { display: grid; gap: var(--sp-2); }
.rec-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: var(--sp-2); align-items: center; padding: var(--sp-1) 0; border-bottom: 1px solid var(--c-border); }
.rec-row.is-done .rec-text::after { content: " ✓"; color: var(--c-success); }
.rec-text { font-size: var(--fs-lg); }
.rec-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--c-danger); }
.rec-btn.is-recording { animation: pulse 1s infinite; border-color: var(--c-danger); }
.rec-btn.is-recording .rec-dot { border-radius: 3px; }

/* S10 trophées */
.trophy-grid { display: grid; gap: var(--sp-3); }
.trophy { display: flex; gap: var(--sp-4); align-items: center; }
.trophy-icon { width: 56px; height: 56px; display: grid; place-items: center; font-size: var(--fs-xl); border-radius: var(--r-md); background: var(--c-surface-2); color: var(--c-locked); flex: none; }
.trophy.is-won .trophy-icon { background: var(--c-reward); }

/* Jalon 4 ------------------------------------------------------------- */
/* Train personnalisable */
.train-wrap { display: inline-block; position: relative; line-height: 1; }
.train-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.train-deco { position: absolute; top: -18%; right: 14%; font-size: 1em; }
.home-train { width: min(70vw, 320px); font-size: clamp(32px, 10vw, 56px); }
.big-train { width: 160px; font-size: 26px; }
.track .train { font-size: 16px; }
.track .train svg { width: 84px; }
.home .corner--left { left: var(--l-gutter); right: auto; }

/* S09 boutique */
.shop-preview { display: grid; place-items: center; min-height: 150px; background: linear-gradient(var(--c-sky) 0 70%, var(--c-grass) 70%); border-radius: var(--r-lg); padding: var(--sp-4); }
.shop-big { width: 200px; font-size: 34px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: var(--sp-3); }
.shop-item { display: grid; justify-items: center; gap: var(--sp-1); padding: var(--sp-3) var(--sp-2); border-radius: var(--r-md); border: 2px solid var(--c-border); background: var(--c-surface); box-shadow: var(--sh-card); font: inherit; color: var(--c-text); cursor: pointer; min-height: 120px; }
.shop-item.is-worn { border: 3px solid var(--c-accent); background: var(--c-accent-soft); }
.shop-item.is-expensive { opacity: .7; }
.shop-train { width: 72px; font-size: 12px; }
.shop-emoji { font-size: var(--fs-xl); line-height: 1.6; min-height: 40px; }
.shop-name { font-size: var(--fs-sm); font-weight: 600; text-align: center; line-height: 1.2; }
.shop-price { font-size: var(--fs-sm); color: var(--c-text-muted); }

/* G07 flash / G10 phrase-image : images */
.flash-zone { min-height: 140px; display: grid; place-items: center; }
.flash-zone .word-card { width: 100%; }
.flash-hidden { color: var(--c-text-muted); }
.pic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.pic-grid--3 .pic:last-child { grid-column: span 2; }
.pic { width: 100%; min-height: 110px; font-size: 56px; line-height: 1; }
.pic-list { display: grid; gap: var(--sp-3); }
.pic--wide { min-height: 96px; font-size: 44px; letter-spacing: .1em; }
.sentence { font-size: var(--fs-xl); line-height: 1.5; text-align: center; padding: var(--sp-5); }

/* G09 lettres miroirs */
.letter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.letter-tile { width: 100%; min-width: 0; font-size: clamp(var(--fs-xl), 12vw, var(--fs-display)); }
.letter-grid--words .letter-tile { font-size: clamp(var(--fs-base), 5.5vw, var(--fs-xl)); padding: 0 var(--sp-1); }
.map-screen #go { position: sticky; bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); z-index: 2; box-shadow: var(--sh-press), var(--sh-pop); }
.fold summary { cursor: pointer; min-height: var(--l-touch-min); display: flex; align-items: center; font-weight: 600; color: var(--c-accent); }
.fold[open] summary { margin-bottom: var(--sp-2); }
/* Boutons : le texte peut passer à la ligne sans déborder */
.btn { text-align: center; line-height: 1.2; padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
/* Espace parent : boutons plus sobres, l'écran est fait pour lire */
.parent-screen .btn { font-size: var(--fs-base); min-height: var(--l-touch-min); }
.parent-screen .btn--lg { font-size: var(--fs-lg); }
.parent-screen h1 { font-size: var(--fs-lg); line-height: var(--lh-lg); }
.game-row { display: grid; gap: var(--sp-1); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); }
.game-row small { font-size: var(--fs-sm); }
.game-stats { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-sm); }
.game-stats .lvl { font-weight: 700; color: var(--c-accent); }

/* Marge basse sous les boutons fixés en bas (88px si un hébergeur ajoute un bandeau).
   Rien d'important ne doit passer dessous. */
:root { --bottom-reserve: 16px; }
.screen { padding-bottom: calc(var(--bottom-reserve) + env(safe-area-inset-bottom)); }
.map-screen #go { bottom: calc(var(--bottom-reserve) + env(safe-area-inset-bottom)); }
.overlay { padding-bottom: calc(var(--bottom-reserve) + env(safe-area-inset-bottom)); }
.game #start { position: sticky; bottom: calc(var(--bottom-reserve) + env(safe-area-inset-bottom)); z-index: 2; box-shadow: var(--sh-press), var(--sh-pop); }
