/* ==========================================================================
   Nono-Code : feuille de style (reprend la maquette validée)
   ========================================================================== */

@font-face {
    font-family: 'Nunito';
    src: url("../fonts/nunito-latin-L9yVAfb.woff") format('woff');
    font-weight: 200 1000;
    font-style: normal;
    font-display: swap;
}

:root {
    --cream: #FFF8EC;
    --cream-2: #F3E8D6;
    --cream-shadow: #E4D3B5;
    --navy: #1E2A4A;
    --navy-dark: #0F1830;
    --ink-2: #4A5878;
    --white: #FFFFFF;
    --orange: #FFA62B;
    --orange-light: #FFE7C2;
    --orange-pale: #FFF1DA;
    --orange-dark: #C96A00;
    --orange-text: #9A4F00;
    --eyes: #5EE6FF;

    --c-depart: #FFD93D;  --s-depart: #D9A900;
    --c-mouv: #4D96FF;    --s-mouv: #2F6FD1;
    --c-look: #9B5DE5;    --s-look: #7638C4;
    --c-son: #2EC4B6;     --s-son: #1A9488;
    --c-ctrl: #F15BB5;    --s-ctrl: #C93A8E;    --p-ctrl: #FCD7EC;
    --c-fin: #EF476F;     --s-fin: #C42A50;

    --green: #3BAA2F;
    --grass: #BFE3A8;
    --grass-shadow: #8CC46F;
    --cell: #E6F6DC;
    --rock: #9AA7BD;

    --p-bg: #F6F7FB;
    --p-line: #E3E7EF;
    --p-track: #EEF1F6;

    --radius-l: 28px;
    --radius-m: 20px;
    --blk-w: 88px;
    --blk-h: 100px;
    --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--cream);
    color: var(--navy);
    font-family: var(--font);
    font-size: 18px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body.is-child {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 4px solid var(--navy);
    outline-offset: 3px;
    border-radius: 12px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Écrans enfant : structure commune
   -------------------------------------------------------------------------- */

.screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding: clamp(14px, 2.4vw, 28px) clamp(16px, 4vw, 48px);
    padding-top: max(clamp(14px, 2.4vw, 28px), env(safe-area-inset-top));
    padding-bottom: max(clamp(14px, 2.4vw, 32px), env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2vw, 20px);
    position: relative;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
}

.topbar__title { flex: 1; min-width: 0; }
.topbar__kicker { font-size: 15px; font-weight: 800; color: var(--ink-2); }
.topbar__heading { margin: 0; font-size: clamp(24px, 3vw, 36px); font-weight: 900; line-height: 1.1; }

.btn-round {
    width: 64px;
    height: 64px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 4px 0 var(--cream-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    text-decoration: none;
    transition: transform .12s;
}
.btn-round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cream-shadow); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 20px;
    border: 0;
    border-radius: 28px;
    background: var(--white);
    box-shadow: 0 3px 0 var(--cream-shadow);
    font-size: 18px;
    font-weight: 800;
    color: var(--navy);
    text-decoration: none;
    white-space: nowrap;
}
.chip--muted { color: var(--ink-2); font-size: 17px; }
.chip__avatar {
    width: 44px; height: 44px;
    margin-left: -12px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 28px;
    border: 0;
    border-radius: 26px;
    background: var(--white);
    box-shadow: 0 6px 0 var(--cream-shadow);
    font-size: 24px;
    font-weight: 900;
    color: var(--navy);
    text-decoration: none;
    transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cream-shadow); }
.btn--orange { background: var(--orange); box-shadow: 0 6px 0 var(--orange-dark); }
.btn--orange:active { box-shadow: 0 2px 0 var(--orange-dark); }
.btn--go { background: var(--c-depart); box-shadow: 0 6px 0 var(--s-depart); }
.btn--go:active { box-shadow: 0 2px 0 var(--s-depart); }
.btn--stop { background: var(--c-fin); box-shadow: 0 6px 0 var(--s-fin); color: var(--white); }
.btn--small { min-height: 52px; font-size: 18px; padding: 0 18px; border-radius: 20px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-soft {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 18px;
    border: 0;
    border-radius: 26px;
    background: var(--orange-pale);
    font-size: 17px;
    font-weight: 800;
    color: var(--navy);
}

.card {
    background: var(--white);
    border-radius: var(--radius-l);
    box-shadow: 0 5px 0 var(--cream-shadow);
}

.bubble {
    position: relative;
    background: var(--white);
    border-radius: 26px;
    padding: 16px 24px;
    box-shadow: 0 4px 0 var(--cream-shadow);
    font-size: clamp(20px, 2.4vw, 28px);
    font-weight: 900;
    line-height: 1.2;
}
.bubble--left::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 26px; height: 26px;
    margin-top: -13px;
    background: var(--white);
    border-radius: 4px;
    transform: rotate(45deg);
}
.bubble > * { position: relative; }

.deco-circle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}
.screen > :not(.deco-circle):not(.overlay) { position: relative; z-index: 1; }

.flash-list { display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 14px 20px;
    border-radius: 18px;
    background: var(--white);
    box-shadow: 0 3px 0 var(--cream-shadow);
    font-weight: 800;
}
.flash--success { border-left: 0; background: #E6F6DC; }
.flash--info { background: var(--orange-pale); }
.flash--error { background: #FFE1E8; }

/* Nono ------------------------------------------------------------------- */

.nono { display: block; overflow: visible; }
.nono .nono-body { transition: fill .3s; }

@keyframes nono-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes nono-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8%); } 40%, 80% { transform: translateX(8%); } }
@keyframes nono-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-38%); } }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(255, 166, 43, .7); } 100% { box-shadow: 0 0 0 18px rgba(255, 166, 43, 0); } }
@keyframes hint-blink { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.is-bouncing { animation: nono-bounce 1.6s ease-in-out infinite; }

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

/* --------------------------------------------------------------------------
   Accueil : qui joue ?
   -------------------------------------------------------------------------- */

.home { align-items: center; }
.home__top { width: 100%; display: flex; justify-content: flex-end; }
.wordmark { font-size: clamp(44px, 6vw, 64px); font-weight: 900; line-height: 1; margin: 0; }
.wordmark span { color: var(--orange-dark); }
.home__hello { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.home__hello .bubble { max-width: 380px; }
.profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(24px, 4vw, 48px); margin-top: 12px; }
.profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    border: 0;
    background: none;
    padding: 0;
    text-decoration: none;
    color: var(--navy);
}
.profile__avatar {
    width: clamp(130px, 16vw, 180px);
    height: clamp(130px, 16vw, 180px);
    border-radius: 50%;
    border: 6px solid var(--white);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s;
}
.profile:active .profile__avatar { transform: scale(.95); }
.profile__name { font-size: 28px; font-weight: 900; }
.profile--add .profile__avatar { border: 5px dashed #C8B48F; background: #FFFDF8; }
.profile--add .profile__name { font-size: 22px; font-weight: 800; color: #6B5530; }

/* --------------------------------------------------------------------------
   Menu : Aventures ou Atelier
   -------------------------------------------------------------------------- */

.menu__hello { display: flex; align-items: center; justify-content: center; gap: 18px; }
.menu__cards { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(24px, 5vw, 56px); margin-top: 8px; }
.menu-card {
    width: min(440px, 100%);
    border-radius: 40px;
    background: var(--white);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--navy);
    transition: transform .15s;
}
.menu-card:active { transform: translateY(5px); }
.menu-card--blue { box-shadow: 0 8px 0 var(--s-mouv); }
.menu-card--violet { box-shadow: 0 8px 0 var(--s-look); }
.menu-card__art { height: clamp(200px, 30vh, 290px); display: flex; align-items: center; justify-content: center; }
.menu-card__art svg { width: min(320px, 80%); height: auto; }
.menu-card--blue .menu-card__art { background: var(--c-mouv); }
.menu-card--violet .menu-card__art { background: var(--c-look); }
.menu-card__text { padding: 22px 32px 26px; }
.menu-card__title { font-size: 40px; font-weight: 900; line-height: 1; }
.menu-card__sub { font-size: 20px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }

/* --------------------------------------------------------------------------
   Carte des mondes
   -------------------------------------------------------------------------- */

.worlds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.world-card {
    min-height: 160px;
    border: 4px solid transparent;
    border-radius: var(--radius-l);
    background: var(--white);
    box-shadow: 0 5px 0 var(--cream-shadow);
    padding: 16px 20px;
    display: flex;
    gap: 16px;
    align-items: center;
    text-align: left;
    text-decoration: none;
    color: var(--navy);
}
.world-card.is-selected { border-color: var(--navy); }
.world-card.is-locked { background: #F4F0E8; box-shadow: none; color: var(--ink-2); }
.world-card__badge {
    width: 84px; height: 84px; flex: none;
    border-radius: 50%;
    border: 4px solid var(--navy);
    display: flex; align-items: center; justify-content: center;
}
.world-card.is-locked .world-card__badge { background: #E8ECF2; border: 4px dashed #8A95AB; }
.world-card__body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.world-card__kicker { font-size: 15px; font-weight: 800; color: var(--ink-2); }
.world-card__title { font-size: 24px; font-weight: 900; line-height: 1.1; color: var(--navy); }
.world-card__meta { font-size: 16px; font-weight: 800; }
.world-card__hint { font-size: 15px; font-weight: 700; }

.progress { height: 14px; border-radius: 7px; background: var(--p-track); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 7px; background: var(--s-mouv); }

.trail {
    flex: 1;
    min-height: 300px;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
}
.trail__title { font-size: 24px; font-weight: 900; margin: 0; }
.trail__area { position: relative; flex: 1; aspect-ratio: 1084 / 400; max-height: 460px; width: 100%; margin: auto 0; }
.trail__area > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.trail__stop {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.trail__btn {
    width: clamp(64px, 8vw, 88px);
    height: clamp(64px, 8vw, 88px);
    border-radius: 50%;
    border: 4px solid var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 900;
    color: var(--white);
    background: var(--c-mouv);
    box-shadow: 0 5px 0 var(--s-mouv);
}
.trail__stop.is-current .trail__btn {
    background: var(--orange);
    color: var(--navy);
    border-color: var(--navy);
    box-shadow: 0 5px 0 var(--orange-dark);
    animation: pulse-ring 1.6s ease-out infinite;
}
.trail__stop.is-locked .trail__btn { background: #E8ECF2; box-shadow: 0 5px 0 #C7CEDA; color: var(--ink-2); }
.trail__stars { display: flex; gap: 2px; height: 24px; }
.trail__nono { position: absolute; bottom: calc(100% + 30px); left: 50%; transform: translateX(-50%); pointer-events: none; }

/* --------------------------------------------------------------------------
   Écran de jeu d'un niveau
   -------------------------------------------------------------------------- */

.level { gap: 14px; padding-top: 18px; padding-bottom: 18px; }
.level__main { display: grid; grid-template-columns: minmax(0, 586px) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.level__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.level__guide { flex: 1; padding: 20px 24px; display: flex; gap: 16px; align-items: flex-start; }
.level__guide-text { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 0; }
.level__instruction { font-size: clamp(20px, 2.1vw, 24px); font-weight: 900; line-height: 1.25; margin: 0; }
.level__tip { font-size: 18px; font-weight: 600; color: var(--ink-2); line-height: 1.35; margin: 0; }
.level__actions { display: flex; gap: 16px; }
.level__actions .btn--go { flex: 1; min-height: 104px; font-size: clamp(26px, 3vw, 34px); border-radius: var(--radius-l); }
.level__actions .btn-square { width: 104px; min-height: 104px; flex-direction: column; gap: 2px; font-size: 15px; padding: 0; border-radius: var(--radius-l); }
.level__stars { display: flex; gap: 6px; align-items: center; }

.board {
    width: 100%;
    aspect-ratio: 586 / 398;
    padding: 14px;
    border-radius: var(--radius-l);
    background: var(--grass);
    box-shadow: 0 5px 0 var(--grass-shadow);
    position: relative;
}
.board__grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
    gap: 6px;
}
.board__cell {
    border-radius: 16px;
    background: var(--cell);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.board__cell svg { width: 78%; height: 78%; }
.battery-slot { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1; }
.battery-slot svg { width: 64%; height: 64%; }
.board__actor {
    position: absolute;
    left: 0; top: 0;
    width: calc((100% - (var(--cols, 6) - 1) * 6px) / var(--cols, 6));
    height: calc((100% - (var(--rows, 4) - 1) * 6px) / var(--rows, 4));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .38s cubic-bezier(.4, 1.4, .6, 1);
    pointer-events: none;
    z-index: 3;
}
.board__actor .actor-inner { width: 86%; height: 86%; position: relative; transition: transform .3s; }
.board__actor .nono { width: 100%; height: 100%; }
.actor-dir {
    position: absolute;
    width: 30%;
    height: 30%;
    left: 35%; top: 35%;
    transition: transform .3s;
    pointer-events: none;
}
.actor-dir svg { width: 100%; height: 100%; }
.actor-say {
    position: absolute;
    bottom: 92%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    color: var(--navy);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 18px;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 3px 0 rgba(0, 0, 0, .15);
    animation: pop-in .2s;
    z-index: 4;
}
.is-shaking { animation: nono-shake .45s; }
.is-hopping { animation: nono-hop .4s; }

.program {
    min-height: 140px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.program > [data-program], .scripts > [data-scripts] { flex: 1; min-width: 0; overflow-x: auto; padding-top: 12px; }
.program__label, .palette__label { width: 104px; flex: none; font-size: 18px; font-weight: 900; line-height: 1.2; }
.palette {
    min-height: 136px;
    padding: 12px 20px;
    border-radius: var(--radius-l);
    background: var(--cream-2);
    display: flex;
    align-items: center;
    gap: 16px;
}
.palette__blocks { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

.result-msg {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    z-index: 5;
    background: var(--white);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 4px 0 var(--cream-shadow);
    white-space: nowrap;
    animation: pop-in .2s;
}

/* --------------------------------------------------------------------------
   Blocs de programmation
   -------------------------------------------------------------------------- */

.blk {
    --c: var(--c-mouv);
    --s: var(--s-mouv);
    --i: #FFFFFF;
    width: var(--blk-w);
    height: var(--blk-h);
    flex: none;
    border: 0;
    border-radius: 18px;
    background: var(--c);
    box-shadow: 0 4px 0 var(--s);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px 6px 7px;
    color: var(--navy);
    touch-action: none;
    cursor: grab;
    transition: transform .12s, opacity .12s, box-shadow .12s;
}
.blk__ico { width: 40px; height: 40px; color: var(--i); }
.blk__label {
    width: 100%;
    background: var(--white);
    border-radius: 10px;
    padding: 4px 2px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
}
.blk__badge {
    position: absolute;
    top: -9px;
    right: -9px;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    border-radius: 17px;
    background: var(--white);
    border: 3px solid var(--s);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
    color: var(--navy);
    cursor: pointer;
    z-index: 2;
    white-space: nowrap;
    max-width: 96px;
    overflow: hidden;
}
.blk__badge .swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--navy); }
.blk.is-locked { cursor: default; }
.blk.is-dragging, .blk-c.is-dragging { opacity: .3; }
.blk.is-running, .blk-c.is-running { transform: translateY(-6px) scale(1.06); box-shadow: 0 0 0 4px var(--navy), 0 10px 0 var(--s); }
.blk.is-hint { animation: hint-blink .8s ease-in-out infinite; box-shadow: 0 0 0 5px var(--orange), 0 4px 0 var(--s); }

.blk--depart { --c: var(--c-depart); --s: var(--s-depart); --i: var(--navy); }
.blk--mouv { --c: var(--c-mouv); --s: var(--s-mouv); --i: #FFFFFF; }
.blk--look { --c: var(--c-look); --s: var(--s-look); --i: #FFFFFF; }
.blk--son { --c: var(--c-son); --s: var(--s-son); --i: var(--navy); }
.blk--ctrl { --c: var(--c-ctrl); --s: var(--s-ctrl); --i: var(--navy); }
.blk--fin { --c: var(--c-fin); --s: var(--s-fin); --i: #FFFFFF; }

/* Bloc conteneur (Répète, Répète toujours) */
.blk-c {
    --c: var(--c-ctrl);
    --s: var(--s-ctrl);
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 8px;
    border-radius: 22px;
    background: var(--c);
    box-shadow: 0 4px 0 var(--s);
    position: relative;
    touch-action: none;
    cursor: grab;
    transition: transform .12s, opacity .12s;
}
.blk-c__head { width: 72px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.blk-c__head .blk__ico { color: var(--navy); }
.blk-c__head .blk__badge { right: -16px; top: -18px; }
.blk-c__body {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    min-width: 100px;
    min-height: 112px;
    border-radius: 16px;
    background: var(--p-ctrl);
}

.seq { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.slot {
    width: 12px;
    height: 96px;
    flex: none;
    border-radius: 8px;
    transition: width .12s, background .12s;
}
.slot.is-target { width: 60px; background: rgba(30, 42, 74, .14); outline: 3px dashed var(--navy); outline-offset: -3px; }
.slot--end {
    width: var(--blk-w);
    height: var(--blk-h);
    border: 4px dashed #D8C7A6;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    color: #B49A6C;
}
.slot--end.is-target { width: var(--blk-w); border-color: var(--navy); background: rgba(30, 42, 74, .08); outline: 0; }
.blk-c__body .slot--end { width: 72px; height: 84px; }

.drag-ghost {
    position: fixed;
    left: 0; top: 0;
    z-index: 1000;
    pointer-events: none;
    transform-origin: 20% 20%;
    opacity: .95;
    filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .25));
}
.drop-trash { outline: 4px dashed var(--c-fin); outline-offset: -4px; }

/* Éditeur de paramètres */
.popover {
    position: fixed;
    z-index: 900;
    background: var(--white);
    border-radius: 24px;
    padding: 14px;
    box-shadow: 0 6px 0 var(--cream-shadow), 0 12px 30px rgba(15, 24, 48, .25);
    animation: pop-in .15s;
    max-width: min(420px, 92vw);
}
.popover__title { font-size: 16px; font-weight: 900; margin: 0 4px 10px; }
.popover__grid { display: grid; grid-template-columns: repeat(5, 60px); gap: 8px; }
.popover__grid--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.popover__btn {
    min-height: 60px;
    border: 3px solid var(--p-line);
    border-radius: 18px;
    background: var(--white);
    font-size: 22px;
    font-weight: 900;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 4px 10px;
}
.popover__btn.is-selected { border-color: var(--navy); background: var(--orange-pale); }
.popover__btn--text { font-size: 17px; }
.popover__swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--navy); }
.popover__input { width: 100%; margin-top: 10px; min-height: 52px; border-radius: 16px; border: 3px solid var(--p-line); padding: 0 14px; font-size: 18px; font-weight: 800; }

/* --------------------------------------------------------------------------
   Atelier
   -------------------------------------------------------------------------- */

.workshop { gap: 16px; padding-top: 18px; padding-bottom: 18px; }
.workshop__main { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); gap: 20px; }
.stage {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-l);
    background: var(--navy);
    box-shadow: 0 5px 0 var(--navy-dark);
    position: relative;
    overflow: hidden;
    touch-action: none;
}
.stage__backdrop { position: absolute; inset: 0; }
.stage__backdrop svg { width: 100%; height: 100%; }
.stage__actor {
    position: absolute;
    left: 0; top: 0;
    width: 12.5%;
    aspect-ratio: 200 / 214;
    transition: transform .28s cubic-bezier(.4, 1.3, .6, 1);
    cursor: grab;
    z-index: 3;
}
.stage__actor .actor-inner { width: 100%; height: 100%; position: relative; transition: transform .3s; }
.stage__actor .nono { width: 100%; height: 100%; }
.stage__actor.is-dragging { transition: none; cursor: grabbing; }
.workshop__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.workshop__run { display: flex; gap: 14px; }
.workshop__run .btn--go { flex: 1; min-height: 100px; font-size: 30px; border-radius: 26px; }
.workshop__run .btn--stop { width: 100px; min-height: 100px; padding: 0; border-radius: 26px; }
.backdrops { flex: 1; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.backdrops__title { font-size: 18px; font-weight: 900; margin: 0; }
.backdrops__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.backdrop-btn {
    height: 82px;
    border: 4px solid transparent;
    border-radius: 16px;
    padding: 0 0 6px;
    display: flex; align-items: flex-end; justify-content: center;
    font-size: 15px;
    font-weight: 800;
    position: relative;
    overflow: hidden;
}
.backdrop-btn svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.backdrop-btn span { position: relative; background: rgba(255, 255, 255, .9); color: var(--navy); border-radius: 10px; padding: 1px 8px; }
.backdrop-btn.is-selected { border-color: var(--orange); outline: 3px solid var(--navy); }

.scripts {
    min-height: 136px;
    padding: 14px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-x: auto;
}
.script-row { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.script-row + .script-row { border-top: 3px solid #F0E3CC; padding-top: 12px; }
.script-new {
    min-height: 72px;
    border: 4px dashed #D8C7A6;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    color: #8A6E3E;
    font-weight: 800;
    font-size: 16px;
}
.script-new.is-target { border-color: var(--navy); background: rgba(30, 42, 74, .06); color: var(--navy); }
.tabs { display: grid; grid-template-columns: repeat(3, 46px); gap: 8px; flex: none; }
.tab {
    width: 46px; height: 46px;
    border: 3px solid transparent;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.tab.is-selected { border-color: var(--navy); }
.tab svg { width: 24px; height: 24px; }

/* Galerie des créations */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.creation { overflow: hidden; display: flex; flex-direction: column; }
.creation__thumb { aspect-ratio: 16 / 9; position: relative; text-decoration: none; display: block; }
.creation__thumb svg { width: 100%; height: 100%; }
.creation__thumb .nono { position: absolute; width: 22%; left: 39%; top: 42%; }
.creation__body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.creation__title { font-size: 20px; font-weight: 900; text-decoration: none; color: var(--navy); }
.creation__actions { display: flex; gap: 10px; }
.creation__actions form { display: contents; }
.creation-new {
    min-height: 240px;
    border: 5px dashed #C8B48F;
    border-radius: var(--radius-l);
    background: #FFFDF8;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    font-size: 22px; font-weight: 900; color: #6B5530;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Fenêtres : Bravo, confirmation, Nono dort
   -------------------------------------------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(30, 42, 74, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal {
    width: min(640px, 100%);
    border-radius: 44px;
    background: var(--cream);
    box-shadow: 0 10px 0 var(--navy-dark);
    padding: 32px clamp(24px, 5vw, 48px) 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    animation: pop-in .25s;
}
.modal__title { font-size: clamp(44px, 7vw, 64px); font-weight: 900; line-height: 1; margin: 0; }
.modal__text { font-size: 24px; font-weight: 800; margin: 0; line-height: 1.3; }
.modal__stars { display: flex; gap: 12px; align-items: flex-end; }
.modal__actions { display: flex; gap: 20px; width: 100%; margin-top: 10px; flex-wrap: wrap; }
.modal__actions .btn { flex: 1; min-height: 88px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

dialog.confirm { border: 0; padding: 0; background: transparent; max-width: 92vw; }
dialog.confirm::backdrop { background: rgba(30, 42, 74, .8); }

.sleep { text-align: center; align-items: center; justify-content: center; }
.sleep__title { font-size: clamp(36px, 5vw, 52px); font-weight: 900; margin: 0; }
.sleep__text { font-size: 22px; font-weight: 700; color: var(--ink-2); max-width: 520px; margin: 0; }

.toast {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 950;
    background: var(--navy);
    color: var(--white);
    border-radius: 20px;
    padding: 14px 22px;
    font-weight: 800;
    font-size: 17px;
    animation: pop-in .2s;
    max-width: 92vw;
}

/* --------------------------------------------------------------------------
   Connexion, inscription, porte parentale (pages « adulte » simples)
   -------------------------------------------------------------------------- */

.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth__card {
    width: min(480px, 100%);
    background: var(--white);
    border-radius: 32px;
    box-shadow: 0 6px 0 var(--cream-shadow);
    padding: 32px clamp(20px, 5vw, 40px);
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.auth__head { display: flex; align-items: center; gap: 14px; }
.auth__title { font-size: 30px; font-weight: 900; margin: 0; line-height: 1.1; }
.auth__sub { margin: 0; color: var(--ink-2); font-weight: 600; }
.auth__links { font-size: 16px; font-weight: 700; color: var(--ink-2); text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-size: 16px; font-weight: 800; color: var(--navy); padding: 0; }
.field fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.field input[type=text], .field input[type=email], .field input[type=password] {
    min-height: 52px;
    border: 2px solid var(--p-line);
    border-radius: 14px;
    padding: 0 14px;
    font-size: 17px;
    font-weight: 700;
    background: var(--white);
    width: 100%;
}
.field input:focus { border-color: var(--navy); outline: 0; }
.field__help { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.field__errors { color: #B00030; font-size: 15px; font-weight: 800; margin: 0; padding: 0; list-style: none; }
.field--check { flex-direction: row; align-items: flex-start; gap: 10px; }
.field--check input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--orange-dark); }
.field--check label { font-weight: 700; font-size: 15px; }

.alert { padding: 12px 16px; border-radius: 14px; font-weight: 800; font-size: 15px; }
.alert--error { background: #FFE1E8; color: #8A0026; }
.alert--success { background: #E6F6DC; color: #1E5A17; }
.alert--info { background: var(--orange-pale); color: var(--navy); }

.p-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    background: var(--orange);
    box-shadow: 0 4px 0 var(--orange-dark);
    font-size: 17px;
    font-weight: 900;
    color: var(--navy);
    text-decoration: none;
}
.p-btn--ghost { background: var(--white); border: 2px solid var(--p-line); box-shadow: none; font-weight: 800; }
.p-btn--danger { background: #FFE1E8; box-shadow: none; color: #8A0026; }
.p-btn--block { width: 100%; }

/* --------------------------------------------------------------------------
   Espace parent
   -------------------------------------------------------------------------- */

body.is-parent { background: var(--p-bg); }
.p-layout { min-height: 100vh; min-height: 100dvh; display: flex; flex-wrap: wrap; }
.p-nav {
    width: 248px;
    flex: 1 1 248px;
    max-width: 100%;
    background: var(--white);
    border-right: 1px solid var(--p-line);
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.p-nav__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.p-nav__brand strong { display: block; font-size: 18px; font-weight: 900; }
.p-nav__brand span { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.p-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-2);
}
.p-nav__link.is-active { background: var(--orange-pale); color: var(--navy); font-weight: 800; }
.p-nav__spacer { flex: 1; min-height: 16px; }
.p-nav form { display: contents; }
.p-nav__logout { text-align: center; font-size: 15px; font-weight: 700; color: var(--ink-2); padding: 12px; text-decoration: none; }

.p-main { flex: 999 1 560px; min-width: 0; padding: 32px 40px; display: flex; flex-direction: column; gap: 22px; }
.p-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.p-head h1 { margin: 0; font-size: 30px; font-weight: 900; flex: 1; min-width: 240px; }
.p-cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.p-col-main { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.p-col-side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 20px; }
.p-card { background: var(--white); border: 1px solid var(--p-line); border-radius: 20px; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.p-card h2 { margin: 0; font-size: 20px; font-weight: 900; }
.p-card--dark { background: var(--navy); border: 0; color: var(--white); }
.p-card--dark p { color: #D5DCEA; margin: 0; font-size: 15px; font-weight: 600; }
.p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.p-stat { background: var(--white); border: 1px solid var(--p-line); border-radius: 20px; padding: 16px 18px; }
.p-stat__label { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.p-stat__value { font-size: 34px; font-weight: 900; }
.p-stat__value small { font-size: 18px; color: var(--ink-2); }
.p-world { display: flex; flex-direction: column; gap: 6px; }
.p-world__row { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; font-weight: 800; }
.p-world.is-locked .p-world__row { color: var(--ink-2); }
.p-muted { font-size: 15px; font-weight: 600; color: var(--ink-2); margin: 0; }
.p-list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.p-list li { display: flex; align-items: center; gap: 14px; }
.p-list__thumb { width: 72px; height: 44px; border-radius: 10px; flex: none; overflow: hidden; }
.p-list__thumb svg { width: 100%; height: 100%; }
.p-list__title { flex: 1; font-size: 16px; font-weight: 800; }
.p-switcher { display: flex; gap: 8px; flex-wrap: wrap; }
.p-switcher a {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px 0 6px;
    border: 1px solid var(--p-line); border-radius: 22px; background: var(--white);
    text-decoration: none; font-weight: 800; font-size: 15px;
}
.p-switcher a.is-active { border-color: var(--navy); background: var(--orange-pale); }
.p-dot { width: 32px; height: 32px; border-radius: 50%; display: inline-block; flex: none; }
.p-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.p-child { flex-direction: row; align-items: center; }
.p-child__avatar { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.p-child__info { flex: 1; min-width: 0; }
.p-child__info strong { font-size: 20px; font-weight: 900; display: block; }
.p-child__info span { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.p-form { display: flex; flex-direction: column; gap: 20px; max-width: 560px; }
.p-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.p-actions form { display: contents; }

/* Widgets de formulaire personnalisés */
.color-choices { display: flex; flex-wrap: wrap; gap: 12px; }
.color-choice { position: relative; }
.color-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.color-choice span {
    width: 52px; height: 52px; border-radius: 50%;
    display: block;
    border: 4px solid var(--white);
    box-shadow: 0 0 0 2px var(--p-line);
    cursor: pointer;
}
.color-choice input:checked + span { box-shadow: 0 0 0 4px var(--navy); }
.color-choice input:focus-visible + span { outline: 4px solid var(--orange); outline-offset: 4px; }
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.segmented label {
    position: relative;
    min-height: 48px;
    border: 2px solid var(--p-line);
    border-radius: 14px;
    background: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
    cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { border-color: var(--navy); background: var(--orange); font-weight: 900; }
.segmented label:has(input:focus-visible) { outline: 4px solid var(--navy); outline-offset: 2px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; font-size: 16px; font-weight: 800; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 52px; height: 30px; flex: none; border-radius: 15px; background: #C7CEDA; position: relative; transition: background .15s; }
.switch__track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--white); transition: transform .15s; }
.switch input:checked + .switch__track { background: var(--s-mouv); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { outline: 4px solid var(--navy); outline-offset: 2px; }

.prose { max-width: 760px; }
.prose h2 { font-size: 22px; margin: 24px 0 8px; }
.prose p, .prose li { font-size: 17px; line-height: 1.55; }

/* --------------------------------------------------------------------------
   Adaptations : tablette en portrait, téléphone
   -------------------------------------------------------------------------- */

@media (max-width: 980px) {
    .level__main, .workshop__main { grid-template-columns: 1fr; }
    .worlds { grid-template-columns: 1fr; }
    .world-card { min-height: 110px; }
    .program, .palette { overflow-x: auto; }
    .program > [data-program], .scripts > [data-scripts] { flex: 1; min-width: 0; overflow-x: auto; padding-top: 12px; }
.program__label, .palette__label { width: auto; min-width: 72px; font-size: 15px; }
}

@media (max-width: 640px) {
    :root { --blk-w: 76px; --blk-h: 90px; }
    .blk__ico { width: 32px; height: 32px; }
    .menu-card__title { font-size: 32px; }
    .p-main { padding: 20px 16px; }
    .p-nav { border-right: 0; border-bottom: 1px solid var(--p-line); flex-basis: 100%; }
    .p-nav__spacer { display: none; }
    .level__actions .btn-square { width: 84px; }
}
