:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD6;
    --primary-light: #A29BFE;
    --danger: #FF7675;
    --danger-dark: #E05554;
    --success: #55E6C1;
    --ui-bg: rgba(255, 255, 255, 0.96);
    --shadow-soft: 0 8px 25px rgba(0,0,0,0.12);
    --shadow-strong: 0 12px 35px rgba(0,0,0,0.2);
    --border-radius: 20px;
}
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Fredoka One', cursive;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    background-color: #E6F3FF;
}

/* --- DÉCOR FIXE --- */
#scenery {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0; overflow: hidden; transition: background 1s;
}
.decor-item {
    position: absolute; transition: all 1s;
}
.wind path {
    stroke: rgba(255,255,255,0.4); stroke-width: 4; fill: none;
    stroke-linecap: round; stroke-dasharray: 80 400; animation: blow 12s linear infinite;
}
@keyframes blow {
    0% { stroke-dashoffset: 500; }
    100% { stroke-dashoffset: -500; }
}

/* THEMES V2 — dégradés riches */
.theme-hills { background: linear-gradient(180deg, #D4EFFF 0%, #E6F3FF 40%, #F0F8FF 100%); }
.theme-hills .ground-back { bottom: 0; left: -10%; width: 120%; height: 40vh; background: linear-gradient(180deg, #B5D99C 0%, #8FBF6A 100%); border-radius: 50% 50% 0 0 / 100% 100% 0 0; box-shadow: 0 -5px 20px rgba(143,191,106,0.3); }
.theme-hills .ground-front { bottom: -5vh; left: -20%; width: 150%; height: 35vh; background: linear-gradient(180deg, #A8E6CF 0%, #7DCFA8 100%); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }

.theme-space { background: radial-gradient(ellipse at 30% 20%, #1A1A3E 0%, #0D0D1F 50%, #000000 100%); }
.theme-space .ground-back { bottom: -10vh; left: -10%; width: 120%; height: 30vh; background: linear-gradient(180deg, #666 0%, #444 100%); border-radius: 50% 50% 0 0; box-shadow: inset 0 15px 40px rgba(0,0,0,0.5), 0 -3px 15px rgba(100,100,150,0.2); }
.theme-space .ground-front { bottom: -15vh; left: -20%; width: 150%; height: 30vh; background: linear-gradient(180deg, #444 0%, #222 100%); border-radius: 50% 50% 0 0; }

.theme-ocean { background: linear-gradient(180deg, #74B9FF 0%, #4FACFE 30%, #00D2FF 70%, #00B4D8 100%); }
.theme-ocean .ground-back { bottom: 0; left: -10%; width: 120%; height: 30vh; background: linear-gradient(180deg, #FFEAA7 0%, #FAD390 100%); border-radius: 40% 60% 0 0; box-shadow: 0 -3px 15px rgba(250,211,144,0.3); }
.theme-ocean .ground-front { bottom: -10vh; left: -20%; width: 150%; height: 30vh; background: linear-gradient(180deg, #F0B67F 0%, #E58E26 100%); border-radius: 60% 40% 0 0; }

.theme-desert { background: linear-gradient(180deg, #FDCB6E 0%, #F6D365 30%, #FDA085 100%); }
.theme-desert .ground-back { bottom: 0; left: -10%; width: 120%; height: 45vh; background: linear-gradient(180deg, #F0C040 0%, #D4A020 100%); clip-path: polygon(0% 100%, 20% 0%, 40% 100%, 60% 10%, 80% 100%, 100% 20%, 100% 100%); }
.theme-desert .ground-front { bottom: 0; left: -20%; width: 150%; height: 30vh; background: linear-gradient(180deg, #F8C291 0%, #E0A06A 100%); border-radius: 50% 50% 0 0; }

.theme-candy { background: linear-gradient(180deg, #FFB3BA 0%, #FECFEF 50%, #FFD1DC 100%); }
.theme-candy .ground-back { bottom: 0; left: -10%; width: 120%; height: 40vh; background: linear-gradient(180deg, #FFB8E8 0%, #FF9FF3 100%); border-radius: 50% 50% 0 0; box-shadow: 0 -5px 20px rgba(255,159,243,0.3); }
.theme-candy .ground-front { bottom: -5vh; left: -20%; width: 150%; height: 35vh; background: linear-gradient(180deg, #F89AD7 0%, #E86CC0 100%); border-radius: 50% 50% 0 0; }

.tree { position: absolute; bottom: 30vh; display: flex; flex-direction: column; align-items: center; transform-origin: bottom center; animation: sway 4s ease-in-out infinite alternate; }
.tree.t1 { left: 15%; animation-delay: 0s; transform: scale(0.8); }
.tree.t2 { left: 75%; animation-delay: -2s; transform: scale(1.1); }
.tree.t3 { left: 45%; bottom: 35vh; animation-delay: -1s; transform: scale(0.6); z-index: -1; opacity: 0.8; }
.tree-leaves { width: 80px; height: 80px; background: radial-gradient(circle at 35% 35%, #58D68D 0%, #2DCA73 50%, #1E8449 100%); border-radius: 50%; box-shadow: -8px 8px 0 rgba(0,0,0,0.08) inset, 0 4px 12px rgba(30,132,73,0.2); z-index: 2; }
.tree-trunk { width: 20px; height: 60px; background: linear-gradient(90deg, #6E3B1E 0%, #A0522D 50%, #6E3B1E 100%); margin-top: -10px; border-radius: 5px; box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
@keyframes sway { 0% { transform: rotate(-2deg); } 100% { transform: rotate(2deg); } }
.tree.t1 { animation: sway 4s ease-in-out infinite alternate; }
.tree.t2 { animation: sway 3.5s ease-in-out infinite alternate; animation-delay: -1.5s; }
.tree.t3 { animation: sway 5s ease-in-out infinite alternate; animation-delay: -3s; }

/* === THEME-SPECIFIC VISIBILITY === */
.decor-hills, .decor-space, .decor-ocean, .decor-desert, .decor-candy { display: none; }
.theme-hills .decor-hills, .theme-hills .decor-tree { display: flex; }
.theme-space .decor-space { display: block; }
.theme-ocean .decor-ocean { display: block; }
.theme-desert .decor-desert { display: block; }
.theme-candy .decor-candy { display: block; }
.theme-space .decor-tree, .theme-ocean .decor-tree, .theme-desert .decor-tree, .theme-candy .decor-tree { display: none; }

/* === HILLS — Nuages flottants === */
.cloud-anim {
    position: absolute; border-radius: 50%; pointer-events: none;
    background: rgba(255,255,255,0.7);
    box-shadow: 20px 5px 0 10px rgba(255,255,255,0.6), -15px 3px 0 8px rgba(255,255,255,0.5);
    animation: cloudFloat linear infinite;
}
.cloud-anim.c1 { width: 90px; height: 35px; top: 8%; animation-duration: 35s; animation-delay: 0s; }
.cloud-anim.c2 { width: 70px; height: 28px; top: 15%; animation-duration: 45s; animation-delay: -15s; opacity: 0.6; }
.cloud-anim.c3 { width: 110px; height: 40px; top: 5%; animation-duration: 55s; animation-delay: -30s; opacity: 0.5; }
@keyframes cloudFloat { 0% { left: -15%; } 100% { left: 105%; } }

/* HILLS — Oiseaux */
.bird-anim {
    position: absolute; width: 0; height: 0; pointer-events: none;
    border-left: 6px solid transparent; border-right: 6px solid transparent;
    border-bottom: 4px solid #555;
    animation: birdFly 12s linear infinite;
}
.bird-anim.b1 { top: 12%; animation-delay: 0s; }
.bird-anim.b2 { top: 18%; animation-delay: -6s; opacity: 0.6; }
@keyframes birdFly {
    0% { left: -5%; transform: translateY(0); }
    25% { transform: translateY(-8px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-6px); }
    100% { left: 105%; transform: translateY(0); }
}

/* HILLS — Papillons */
.butterfly-anim {
    position: absolute; width: 10px; height: 10px; pointer-events: none;
    background: #FF9FF3; border-radius: 50% 0 50% 0; opacity: 0.7;
    box-shadow: -6px 0 0 #A29BFE;
    animation: butterflyFloat 8s ease-in-out infinite alternate;
}
.butterfly-anim.bf1 { top: 25%; left: 30%; }
.butterfly-anim.bf2 { top: 20%; left: 65%; background: #FFEAA7; box-shadow: -6px 0 0 #FDCB6E; animation-duration: 10s; animation-delay: -4s; opacity: 0.5; }
@keyframes butterflyFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -15px) rotate(10deg); }
    50% { transform: translate(-20px, -25px) rotate(-5deg); }
    75% { transform: translate(40px, -10px) rotate(8deg); }
    100% { transform: translate(10px, -30px) rotate(-3deg); }
}

/* HILLS — Lucioles */
.firefly {
    position: absolute; width: 4px; height: 4px; border-radius: 50%; pointer-events: none;
    background: #FFEAA7;
    box-shadow: 0 0 6px 3px rgba(255, 234, 167, 0.6), 0 0 12px 6px rgba(255, 234, 167, 0.2);
    animation: fireflyGlow 4s ease-in-out infinite alternate, fireflyDrift 12s ease-in-out infinite;
}
.firefly.ff1 { top: 30%; left: 15%; animation-delay: 0s; }
.firefly.ff2 { top: 22%; left: 45%; animation-delay: -1.5s; animation-duration: 5s; }
.firefly.ff3 { top: 35%; left: 70%; animation-delay: -3s; }
.firefly.ff4 { top: 28%; left: 85%; animation-delay: -2s; animation-duration: 3.5s; }
.firefly.ff5 { top: 40%; left: 35%; animation-delay: -4s; animation-duration: 4.5s; }
@keyframes fireflyGlow { 0% { opacity: 0.1; transform: scale(0.6); } 100% { opacity: 0.9; transform: scale(1.2); } }
@keyframes fireflyDrift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(20px, -15px); }
    50% { transform: translate(-10px, -25px); }
    75% { transform: translate(15px, -5px); }
    100% { transform: translate(0, 0); }
}

/* HILLS — Fleurs au sol */
.flower {
    position: absolute; width: 12px; height: 12px; pointer-events: none; z-index: 0;
    border-radius: 50%; animation: flowerSway 3s ease-in-out infinite alternate;
}
.flower.fl1 { bottom: 32%; left: 8%; background: radial-gradient(circle, #FF6B6B, #E74C3C); box-shadow: 5px 0 0 #FF9FF3, -5px 0 0 #FF9FF3, 0 5px 0 #FF9FF3, 0 -5px 0 #FF9FF3; }
.flower.fl2 { bottom: 30%; left: 35%; width: 10px; height: 10px; background: radial-gradient(circle, #FFEAA7, #FDCB6E); box-shadow: 4px 0 0 #FFD93D, -4px 0 0 #FFD93D, 0 4px 0 #FFD93D, 0 -4px 0 #FFD93D; animation-delay: -1s; }
.flower.fl3 { bottom: 33%; left: 58%; width: 8px; height: 8px; background: radial-gradient(circle, #A29BFE, #6C5CE7); box-shadow: 3px 0 0 #DDA0DD, -3px 0 0 #DDA0DD, 0 3px 0 #DDA0DD, 0 -3px 0 #DDA0DD; animation-delay: -2s; }
.flower.fl4 { bottom: 31%; left: 82%; width: 11px; height: 11px; background: radial-gradient(circle, #81ECEC, #00CEC9); box-shadow: 4px 0 0 #74B9FF, -4px 0 0 #74B9FF, 0 4px 0 #74B9FF, 0 -4px 0 #74B9FF; animation-delay: -0.5s; }
@keyframes flowerSway { 0% { transform: rotate(-5deg); } 100% { transform: rotate(5deg); } }

/* HILLS — Arc-en-ciel subtil */
.rainbow-arc {
    position: absolute; top: 2%; left: 5%; width: 60%; height: 30%; pointer-events: none;
    border-radius: 50% 50% 0 0;
    border: 8px solid transparent;
    border-top: 8px solid rgba(255, 0, 0, 0.08);
    box-shadow:
        0 -3px 0 rgba(255, 127, 0, 0.06),
        0 -6px 0 rgba(255, 255, 0, 0.05),
        0 -9px 0 rgba(0, 255, 0, 0.04),
        0 -12px 0 rgba(0, 0, 255, 0.04),
        0 -15px 0 rgba(75, 0, 130, 0.03);
    opacity: 0;
    animation: rainbowAppear 20s ease-in-out infinite;
}
@keyframes rainbowAppear { 0%, 30% { opacity: 0; } 40%, 60% { opacity: 1; } 70%, 100% { opacity: 0; } }

/* HILLS — Graines de pissenlit */
.dandelion-seed {
    position: absolute; width: 3px; height: 3px; border-radius: 50%; pointer-events: none;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 -4px 0 1px rgba(255, 255, 255, 0.3);
    animation: dandelionFloat linear infinite;
}
.dandelion-seed.ds1 { top: 25%; left: 20%; animation-duration: 15s; }
.dandelion-seed.ds2 { top: 30%; left: 50%; animation-duration: 18s; animation-delay: -6s; opacity: 0.5; }
.dandelion-seed.ds3 { top: 20%; left: 75%; animation-duration: 20s; animation-delay: -12s; opacity: 0.4; }
@keyframes dandelionFloat {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.7; }
    50% { transform: translate(60px, -40px) rotate(180deg); opacity: 0.5; }
    90% { opacity: 0.3; }
    100% { transform: translate(120px, -20px) rotate(360deg); opacity: 0; }
}

/* === SPACE — Étoiles scintillantes === */
.star-twinkle {
    position: absolute; border-radius: 50%; pointer-events: none;
    background: white;
    animation: twinkle ease-in-out infinite alternate;
}
.star-twinkle.s1 { width: 3px; height: 3px; top: 8%; left: 15%; animation-duration: 2s; }
.star-twinkle.s2 { width: 2px; height: 2px; top: 15%; left: 40%; animation-duration: 3s; animation-delay: -1s; }
.star-twinkle.s3 { width: 4px; height: 4px; top: 5%; left: 65%; animation-duration: 2.5s; animation-delay: -0.5s; }
.star-twinkle.s4 { width: 2px; height: 2px; top: 22%; left: 80%; animation-duration: 3.5s; animation-delay: -2s; }
.star-twinkle.s5 { width: 3px; height: 3px; top: 12%; left: 55%; animation-duration: 2.8s; animation-delay: -1.5s; }
.star-twinkle.s6 { width: 2px; height: 2px; top: 28%; left: 25%; animation-duration: 4s; animation-delay: -3s; }
.star-twinkle.s7 { width: 3px; height: 3px; top: 18%; left: 90%; animation-duration: 2.2s; animation-delay: -0.8s; }
.star-twinkle.s8 { width: 2px; height: 2px; top: 35%; left: 10%; animation-duration: 3.2s; animation-delay: -2.5s; }
.star-twinkle.s9 { width: 3px; height: 3px; top: 40%; left: 45%; animation-duration: 2.6s; animation-delay: -1.2s; }
.star-twinkle.s10 { width: 2px; height: 2px; top: 32%; left: 72%; animation-duration: 3.8s; animation-delay: -0.3s; }
@keyframes twinkle { 0% { opacity: 0.2; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1.3); box-shadow: 0 0 6px 2px rgba(255,255,255,0.5); } }

/* SPACE — Nébuleuse colorée */
.nebula {
    position: absolute; top: 15%; left: 20%; width: 40%; height: 35%; pointer-events: none;
    background: radial-gradient(ellipse at 40% 50%,
        rgba(155, 89, 182, 0.08) 0%,
        rgba(52, 152, 219, 0.05) 30%,
        rgba(231, 76, 60, 0.03) 60%,
        transparent 80%);
    border-radius: 50%;
    animation: nebulaPulse 10s ease-in-out infinite alternate;
}
@keyframes nebulaPulse {
    0% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    100% { transform: scale(1.1) rotate(5deg); opacity: 0.9; }
}

/* SPACE — Satellite */
.satellite-anim {
    position: absolute; width: 8px; height: 4px; pointer-events: none;
    background: #BDC3C7;
    box-shadow: -6px 0 0 2px #3498DB, 6px 0 0 2px #3498DB;
    animation: satelliteOrbit 25s linear infinite;
}
@keyframes satelliteOrbit {
    0% { top: 30%; left: -5%; transform: rotate(0deg); }
    50% { top: 15%; left: 105%; transform: rotate(180deg); }
    100% { top: 30%; left: -5%; transform: rotate(360deg); }
}

/* SPACE — Étoiles filantes */
.shooting-star {
    position: absolute; width: 2px; height: 2px; border-radius: 50%; pointer-events: none;
    background: white;
    animation: shootingStar 6s linear infinite;
}
.shooting-star.sh1 { top: 10%; left: 80%; animation-delay: 0s; }
.shooting-star.sh2 { top: 20%; left: 60%; animation-delay: -3s; animation-duration: 8s; }
.shooting-star::after {
    content: ''; position: absolute; top: -1px; left: 2px; width: 30px; height: 1px;
    background: linear-gradient(to right, white, transparent);
    transform-origin: left center; transform: rotate(-37deg);
}
@keyframes shootingStar {
    0%, 40% { opacity: 0; transform: translate(0, 0); }
    45% { opacity: 1; }
    55% { opacity: 1; }
    60% { opacity: 0; transform: translate(-80px, 60px); }
    100% { opacity: 0; transform: translate(-80px, 60px); }
}

/* SPACE — 2ème comète */
.comet-anim.comet2 { animation-delay: -4s; animation-duration: 12s; }

/* SPACE — Planète */
.planet-anim {
    position: absolute; width: 50px; height: 50px; border-radius: 50%; pointer-events: none;
    top: 10%; right: 12%;
    background: radial-gradient(circle at 35% 35%, #F39C12 0%, #E67E22 50%, #D35400 100%);
    box-shadow: -4px 4px 0 rgba(0,0,0,0.2) inset, 0 0 20px rgba(243,156,18,0.3);
    animation: planetBob 6s ease-in-out infinite alternate;
}
.planet-anim::after {
    content: ''; position: absolute; top: 50%; left: -15px; right: -15px; height: 8px;
    border: 2px solid rgba(255,255,255,0.3); border-radius: 50%;
    transform: rotate(-15deg);
}
@keyframes planetBob { 0% { transform: translateY(0); } 100% { transform: translateY(-10px); } }

/* SPACE — Comète */
.comet-anim {
    position: absolute; width: 6px; height: 6px; border-radius: 50%; pointer-events: none;
    background: white; box-shadow: 0 0 8px 3px rgba(255,255,255,0.6);
    animation: cometFly 8s linear infinite;
}
@keyframes cometFly {
    0% { top: 5%; left: 110%; opacity: 1; }
    60% { top: 40%; left: -10%; opacity: 1; }
    61% { opacity: 0; }
    100% { top: 5%; left: 110%; opacity: 0; }
}
.comet-anim::after {
    content: ''; position: absolute; top: -1px; left: 6px; width: 40px; height: 2px;
    background: linear-gradient(to right, white, rgba(255,255,255,0));
    transform: rotate(-17deg); transform-origin: left center;
}

/* === OCEAN — Bulles === */
.bubble-anim {
    position: absolute; border-radius: 50%; pointer-events: none;
    border: 2px solid rgba(255,255,255,0.5);
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3), transparent);
    animation: bubbleRise linear infinite;
}
.bubble-anim.bu1 { width: 12px; height: 12px; left: 20%; animation-duration: 6s; }
.bubble-anim.bu2 { width: 8px; height: 8px; left: 50%; animation-duration: 8s; animation-delay: -3s; }
.bubble-anim.bu3 { width: 15px; height: 15px; left: 70%; animation-duration: 7s; animation-delay: -5s; }
.bubble-anim.bu4 { width: 6px; height: 6px; left: 35%; animation-duration: 5s; animation-delay: -1s; }
@keyframes bubbleRise {
    0% { bottom: -5%; opacity: 0.8; transform: translateX(0) scale(0.8); }
    50% { opacity: 0.6; transform: translateX(15px) scale(1); }
    100% { bottom: 70%; opacity: 0; transform: translateX(-10px) scale(1.2); }
}

/* OCEAN — Poissons */
.fish-anim {
    position: absolute; pointer-events: none;
    width: 20px; height: 12px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: fishSwim 10s linear infinite;
}
.fish-anim.f1 { background: #F39C12; bottom: 45%; animation-delay: 0s; }
.fish-anim.f2 { background: #E74C3C; bottom: 55%; animation-duration: 14s; animation-delay: -7s; }
.fish-anim::after {
    content: ''; position: absolute; right: -8px; top: 2px;
    border-left: 8px solid inherit; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
@keyframes fishSwim {
    0% { left: -5%; transform: translateY(0) scaleX(1); }
    25% { transform: translateY(-8px) scaleX(1); }
    49% { transform: translateY(5px) scaleX(1); }
    50% { left: 105%; transform: translateY(5px) scaleX(-1); }
    75% { transform: translateY(-10px) scaleX(-1); }
    100% { left: -5%; transform: translateY(0) scaleX(-1); }
}

/* OCEAN — Vague */
.wave-line {
    position: absolute; bottom: 28vh; left: 0; width: 200%; height: 15px; pointer-events: none;
    background: repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(255,255,255,0.15) 40px, rgba(255,255,255,0.15) 80px);
    border-radius: 50%; animation: waveMove 4s linear infinite;
}
.bubble-anim.bu5 { width: 10px; height: 10px; left: 85%; animation-duration: 5.5s; animation-delay: -2s; }
.bubble-anim.bu6 { width: 7px; height: 7px; left: 10%; animation-duration: 7.5s; animation-delay: -4s; }
.fish-anim.f3 { background: #2ECC71; bottom: 40%; animation-duration: 18s; animation-delay: -4s; width: 15px; height: 9px; }
.wave-line.w2 { bottom: 35vh; animation-duration: 5s; opacity: 0.5; }
@keyframes waveMove { 0% { transform: translateX(0); } 100% { transform: translateX(-80px); } }

/* OCEAN — Méduses */
.jellyfish {
    position: absolute; pointer-events: none;
    width: 20px; height: 14px; border-radius: 50% 50% 30% 30%;
    animation: jellyPulse 3s ease-in-out infinite, jellyFloat 10s ease-in-out infinite;
}
.jellyfish.jf1 { left: 25%; bottom: 50%; background: radial-gradient(circle at 50% 30%, rgba(155, 89, 182, 0.6), rgba(155, 89, 182, 0.2)); }
.jellyfish.jf2 { left: 70%; bottom: 45%; width: 15px; height: 10px; background: radial-gradient(circle at 50% 30%, rgba(52, 152, 219, 0.5), rgba(52, 152, 219, 0.15)); animation-delay: -2s; }
.jellyfish::after {
    content: ''; position: absolute; bottom: -8px; left: 20%; width: 60%; height: 8px;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
    border-right: 2px solid rgba(255, 255, 255, 0.2);
    border-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.2) 0px, rgba(255,255,255,0.2) 2px, transparent 2px, transparent 4px) 1;
}
@keyframes jellyPulse { 0%, 100% { transform: scaleX(1) scaleY(1); } 50% { transform: scaleX(1.1) scaleY(0.9); } }
@keyframes jellyFloat {
    0% { transform: translate(0, 0); }
    25% { transform: translate(10px, -20px); }
    50% { transform: translate(-5px, -35px); }
    75% { transform: translate(15px, -15px); }
    100% { transform: translate(0, 0); }
}

/* OCEAN — Rayons de lumière */
.light-ray {
    position: absolute; top: 0; pointer-events: none;
    width: 40px; height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 70%);
    transform: skewX(-15deg);
    animation: lightRayShimmer 6s ease-in-out infinite alternate;
}
.light-ray.lr1 { left: 15%; animation-delay: 0s; }
.light-ray.lr2 { left: 45%; width: 30px; animation-delay: -2s; animation-duration: 8s; }
.light-ray.lr3 { left: 75%; width: 35px; animation-delay: -4s; animation-duration: 7s; }
@keyframes lightRayShimmer { 0% { opacity: 0.3; } 100% { opacity: 0.7; } }

/* OCEAN — Algues */
.seaweed {
    position: absolute; bottom: 0; pointer-events: none; z-index: 0;
    width: 6px; height: 50px;
    background: linear-gradient(to top, #27AE60, #2ECC71);
    border-radius: 3px 3px 0 0;
    transform-origin: bottom center;
    animation: seaweedSway 4s ease-in-out infinite alternate;
}
.seaweed.sw1 { left: 10%; height: 45px; animation-delay: 0s; }
.seaweed.sw2 { left: 50%; height: 55px; animation-delay: -1.5s; }
.seaweed.sw3 { left: 85%; height: 40px; animation-delay: -3s; animation-duration: 5s; }
@keyframes seaweedSway { 0% { transform: rotate(-10deg); } 100% { transform: rotate(10deg); } }

/* === DESERT — Sable === */
.sand-drift {
    position: absolute; bottom: 25vh; height: 2px; pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(210,180,100,0.4), transparent);
    animation: sandBlow linear infinite;
}
.sand-drift.sd1 { width: 80px; left: 20%; animation-duration: 4s; }
.sand-drift.sd2 { width: 60px; left: 60%; animation-duration: 6s; animation-delay: -2s; bottom: 30vh; }
@keyframes sandBlow { 0% { transform: translateX(-50px); opacity: 0; } 50% { opacity: 0.6; } 100% { transform: translateX(100px); opacity: 0; } }

/* DESERT — Soleil */
.sun-anim {
    position: absolute; top: 8%; right: 10%; width: 60px; height: 60px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle at 40% 40%, #FFF9C4 0%, #F1C40F 40%, #F39C12 100%);
    box-shadow: 0 0 40px 15px rgba(241,196,15,0.3), 0 0 80px 30px rgba(241,196,15,0.1);
    animation: sunPulse 4s ease-in-out infinite alternate;
}
.sand-drift.sd3 { width: 50px; left: 80%; animation-duration: 5s; animation-delay: -3s; bottom: 28vh; }
@keyframes sunPulse { 0% { box-shadow: 0 0 40px 15px rgba(241,196,15,0.3); } 100% { box-shadow: 0 0 50px 20px rgba(241,196,15,0.4), 0 0 100px 40px rgba(241,196,15,0.15); } }

/* DESERT — Rayons du soleil */
.sun-rays {
    position: absolute; top: 0; right: 0; width: 50%; height: 60%; pointer-events: none;
    background: radial-gradient(ellipse at top right, rgba(241, 196, 15, 0.08), transparent 70%);
    animation: sunRayPulse 5s ease-in-out infinite alternate;
}
@keyframes sunRayPulse { 0% { opacity: 0.5; } 100% { opacity: 0.9; } }

/* DESERT — Cactus déco (non interactifs) */
.cactus-deco {
    position: absolute; bottom: 26vh; pointer-events: none; z-index: 0;
    width: 10px; height: 35px;
    background: #27AE60; border-radius: 5px 5px 0 0;
    animation: cactusSway 6s ease-in-out infinite alternate;
}
.cactus-deco::before {
    content: ''; position: absolute; top: 8px; left: -8px;
    width: 8px; height: 15px; background: #27AE60; border-radius: 5px 0 0 5px;
}
.cactus-deco::after {
    content: ''; position: absolute; top: 12px; right: -8px;
    width: 8px; height: 12px; background: #2ECC71; border-radius: 0 5px 5px 0;
}
.cactus-deco.cd1 { left: 12%; height: 40px; }
.cactus-deco.cd2 { left: 78%; height: 30px; animation-delay: -3s; }
@keyframes cactusSway { 0% { transform: rotate(-1deg); } 100% { transform: rotate(1deg); } }

/* DESERT — Mirage */
.mirage {
    position: absolute; bottom: 22vh; left: 10%; width: 80%; height: 15px; pointer-events: none;
    background: linear-gradient(to bottom, rgba(79, 172, 254, 0.15), transparent);
    border-radius: 50%;
    animation: mirageShimmer 3s ease-in-out infinite;
}
@keyframes mirageShimmer {
    0%, 100% { opacity: 0.3; transform: scaleY(1); }
    50% { opacity: 0.6; transform: scaleY(1.5); }
}

/* DESERT — Vautour */
.vulture {
    position: absolute; width: 0; height: 0; pointer-events: none;
    border-left: 10px solid transparent; border-right: 10px solid transparent;
    border-bottom: 5px solid #333;
    animation: vultureCircle 20s linear infinite;
}
@keyframes vultureCircle {
    0% { top: 12%; left: 30%; transform: rotate(0deg); }
    25% { top: 8%; left: 60%; transform: rotate(5deg); }
    50% { top: 15%; left: 50%; transform: rotate(-3deg); }
    75% { top: 10%; left: 35%; transform: rotate(4deg); }
    100% { top: 12%; left: 30%; transform: rotate(0deg); }
}

/* DESERT — Tumbleweed */
.tumbleweed {
    position: absolute; bottom: 26vh; width: 18px; height: 18px; border-radius: 50%; pointer-events: none;
    border: 2px solid #8B7355;
    background: radial-gradient(circle, transparent 30%, rgba(139, 115, 85, 0.3));
    animation: tumbleRoll 8s linear infinite;
}
.tumbleweed.tw1 { animation-delay: -2s; }
@keyframes tumbleRoll {
    0% { left: -5%; transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(180deg) translateY(-15px); }
    50% { transform: rotate(360deg) translateY(0); }
    75% { transform: rotate(540deg) translateY(-10px); }
    100% { left: 105%; transform: rotate(720deg) translateY(0); }
}

/* === CANDY — Bonbons flottants === */
.candy-float {
    position: absolute; border-radius: 50%; pointer-events: none;
    animation: candyBounce ease-in-out infinite alternate;
}
.candy-float.cf1 { width: 18px; height: 18px; top: 10%; left: 20%; background: radial-gradient(circle at 35% 35%, #FF9FF3, #F368E0); animation-duration: 3s; }
.candy-float.cf2 { width: 14px; height: 14px; top: 18%; left: 65%; background: radial-gradient(circle at 35% 35%, #81ECEC, #00CEC9); animation-duration: 4s; animation-delay: -1.5s; }
.candy-float.cf3 { width: 22px; height: 22px; top: 8%; left: 45%; background: radial-gradient(circle at 35% 35%, #FFE66D, #FDCB6E); animation-duration: 3.5s; animation-delay: -2s; }
@keyframes candyBounce { 0% { transform: translateY(0) rotate(0deg); } 100% { transform: translateY(-15px) rotate(10deg); } }

/* CANDY — Sparkles */
.sparkle-candy {
    position: absolute; width: 6px; height: 6px; pointer-events: none;
    background: white; border-radius: 50%;
    animation: sparkleCandy ease-in-out infinite;
}
.sparkle-candy.sp1 { top: 15%; left: 30%; animation-duration: 2s; }
.sparkle-candy.sp2 { top: 25%; left: 70%; animation-duration: 2.5s; animation-delay: -1s; }
.sparkle-candy.sp3 { top: 10%; left: 85%; animation-duration: 3s; animation-delay: -2s; }
.candy-float.cf4 { width: 16px; height: 16px; top: 22%; left: 80%; background: radial-gradient(circle at 35% 35%, #74B9FF, #0984E3); animation-duration: 2.8s; animation-delay: -1s; }
.sparkle-candy.sp4 { top: 8%; left: 50%; animation-duration: 2.2s; animation-delay: -0.5s; }
@keyframes sparkleCandy {
    0%, 100% { opacity: 0; transform: scale(0.3) rotate(0deg); }
    50% { opacity: 0.8; transform: scale(1.2) rotate(180deg); box-shadow: 0 0 8px 3px rgba(255,255,255,0.5); }
}

/* CANDY — Arc-en-ciel */
.candy-rainbow {
    position: absolute; top: 5%; left: 10%; width: 80%; height: 25%; pointer-events: none;
    border-radius: 50% 50% 0 0;
    background: linear-gradient(180deg,
        rgba(255, 0, 0, 0.08),
        rgba(255, 127, 0, 0.08),
        rgba(255, 255, 0, 0.08),
        rgba(0, 255, 0, 0.08),
        rgba(0, 0, 255, 0.08),
        rgba(75, 0, 130, 0.08));
    animation: candyRainbow 8s ease-in-out infinite alternate;
}
@keyframes candyRainbow { 0% { opacity: 0.4; transform: scaleY(0.9); } 100% { opacity: 0.8; transform: scaleY(1.1); } }

/* CANDY — Sucettes */
.lollipop {
    position: absolute; pointer-events: none; z-index: 0;
    width: 16px; height: 16px; border-radius: 50%;
    animation: lollipopSpin 4s linear infinite;
}
.lollipop::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    width: 3px; height: 20px; background: #FFF;
    border-radius: 0 0 2px 2px;
}
.lollipop.lp1 {
    bottom: 28%; left: 15%;
    background: conic-gradient(#FF6B6B, #FFD93D, #6BCB77, #4D96FF, #FF6B6B);
}
.lollipop.lp2 {
    bottom: 30%; left: 80%; width: 13px; height: 13px;
    background: conic-gradient(#FF9FF3, #FFF, #FF9FF3, #FFF);
    animation-direction: reverse; animation-delay: -2s;
}
@keyframes lollipopSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* CANDY — Confettis */
.confetti-rain {
    position: absolute; width: 6px; height: 6px; pointer-events: none;
    border-radius: 1px; animation: confettiFall linear infinite;
}
.confetti-rain.cr1 { left: 10%; background: #FF6B6B; animation-duration: 5s; animation-delay: 0s; }
.confetti-rain.cr2 { left: 25%; background: #FFD93D; width: 4px; height: 8px; animation-duration: 6s; animation-delay: -1s; }
.confetti-rain.cr3 { left: 45%; background: #6BCB77; animation-duration: 4.5s; animation-delay: -2.5s; border-radius: 50%; }
.confetti-rain.cr4 { left: 60%; background: #4D96FF; width: 8px; height: 4px; animation-duration: 5.5s; animation-delay: -3s; }
.confetti-rain.cr5 { left: 75%; background: #FF9FF3; animation-duration: 7s; animation-delay: -4s; }
.confetti-rain.cr6 { left: 90%; background: #A29BFE; width: 5px; height: 5px; animation-duration: 4s; animation-delay: -1.5s; border-radius: 50%; }
@keyframes confettiFall {
    0% { top: -5%; transform: rotate(0deg) translateX(0); opacity: 0.8; }
    25% { transform: rotate(90deg) translateX(10px); }
    50% { transform: rotate(180deg) translateX(-10px); opacity: 0.6; }
    75% { transform: rotate(270deg) translateX(5px); }
    100% { top: 75%; transform: rotate(360deg) translateX(0); opacity: 0; }
}

/* --- UI & CANVAS --- */
canvas { position: absolute; top: 0; left: 0; z-index: 1; }
.ui-layer { position: absolute; width: 100%; height: 100%; pointer-events: none; z-index: 10; display: flex; flex-direction: column; justify-content: flex-end; }

/* TOAST MESSAGE */
#toast {
    position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
    background: var(--success); color: #333; padding: 12px 25px; border-radius: 30px;
    font-weight: bold; font-size: 1.2rem; z-index: 1000;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); border: 3px solid #fff; pointer-events: none;
}
#toast.show { top: 20px; }

/* ÉCRAN DE PAUSE GÉANT */
#pause-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    z-index: 9999; cursor: pointer; pointer-events: auto;
}
#big-play-btn {
    width: 150px; height: 150px; display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 15px 35px rgba(0,0,0,0.3));
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#big-play-btn svg { width: 150px; height: 150px; }
#big-play-btn:hover { transform: scale(1.1); }

/* Actions Flottantes */
.top-right-actions {
    position: absolute; top: 20px; right: 20px; pointer-events: auto;
    display: flex; gap: 15px; flex-wrap: wrap; justify-content: flex-end;
}
.bubble-btn {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 40%, var(--primary-dark) 100%);
    color: white; border: 3px solid rgba(255,255,255,0.6);
    padding: 12px 20px; border-radius: 30px; font-size: 1.1rem; cursor: pointer;
    box-shadow: 0 6px 18px rgba(108,92,231,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
    font-family: inherit; font-weight: bold;
    transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform: scale(0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.bubble-btn:hover { transform: scale(1.05); box-shadow: 0 8px 25px rgba(108,92,231,0.45); }
.bubble-btn:active { transform: scale(0.95); box-shadow: 0 3px 10px rgba(108,92,231,0.3); }
#edit-bubble { display: none; }
#respawn-btn { background: linear-gradient(180deg, #C39BD3 0%, #9B59B6 40%, #7D3C98 100%); box-shadow: 0 6px 18px rgba(155,89,182,0.35); }
#map-bubble { background: linear-gradient(180deg, #FEE08E 0%, #FDCB6E 40%, #E5B655 100%); color: #333; box-shadow: 0 6px 18px rgba(253,203,110,0.4); text-shadow: none; }
#pickup-btn { background: linear-gradient(180deg, #F78FB3 0%, #E84393 40%, #C73578 100%); box-shadow: 0 6px 18px rgba(232,67,147,0.35); }
#pause-btn { background: linear-gradient(180deg, #F19066 0%, #E17055 40%, #C75B42 100%); width: 55px; padding: 10px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(225,112,85,0.35); }
#reset-btn { background: linear-gradient(180deg, #FF9B9B 0%, var(--danger) 40%, var(--danger-dark) 100%); width: 55px; padding: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; box-shadow: 0 6px 18px rgba(255,118,117,0.35); }

#fab-add {
    position: absolute; bottom: 30px; right: 20px; pointer-events: auto;
    width: 70px; height: 70px; border-radius: 50%;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 50%, var(--primary-dark) 100%);
    color: white; font-size: 40px; border: 3px solid rgba(255,255,255,0.6);
    box-shadow: 0 8px 25px rgba(108,92,231,0.4), inset 0 2px 0 rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 20; transform: scale(0.9); padding: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2); line-height: 1;
}
#fab-add:hover { transform: scale(1.05); box-shadow: 0 12px 35px rgba(108,92,231,0.5); }
#fab-add.active { transform: scale(0.9) rotate(45deg); background: var(--danger); }

/* Barre d'outils */
.toolbar-container {
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(200px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: auto;
    display: flex; z-index: 15; max-width: 85vw;
}
.toolbar-container.visible { transform: translateX(-50%) translateY(0); }
.toolbar {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(245,245,250,0.96) 100%);
    padding: 10px 20px; border-radius: 50px;
    display: flex; gap: 8px; box-shadow: 0 8px 30px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
    border: 3px solid rgba(255,255,255,0.7); align-items: center; overflow-x: auto; scrollbar-width: none;
    backdrop-filter: blur(10px);
}
.toolbar::-webkit-scrollbar { display: none; }
.tool-btn {
    min-width: 50px; height: 50px; border-radius: 15px; border: none; cursor: pointer;
    background: linear-gradient(180deg, #FAFAFA 0%, #ECECEC 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0; transform: scale(0.85);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}
.tool-btn:hover { transform: scale(1.05); background: #fff; box-shadow: 0 6px 15px rgba(0,0,0,0.12); }
.tool-btn:active { transform: scale(0.92); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.lib-btn { background: #FFE66D; }
.struct-btn { background: #9B59B6; color: white; border: 3px solid #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2); }
.monster-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4) !important;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(0.85); }
    50% { transform: scale(0.95); }
}
.separator { width: 4px; height: 40px; background: #ddd; border-radius: 2px; margin: 0 5px; flex-shrink: 0; }

/* --- MODALES DRAGGABLES FIXES --- */
.modal {
    pointer-events: auto; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,248,252,0.97) 100%);
    padding: 0; border-radius: 28px; border: 3px solid rgba(108,92,231,0.3);
    box-shadow: 0 20px 60px rgba(108,92,231,0.15), 0 8px 25px rgba(0,0,0,0.1);
    display: none; flex-direction: column;
    min-width: 320px; max-width: 420px; max-height: 90vh; z-index: 100; animation: fadeIn 0.25s ease-out;
    backdrop-filter: blur(12px);
}
.modal.visible { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* === ENCYCLOPÉDIE (full-screen overlay) === */
.encyclopedia-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(20, 15, 40, 0.75);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 200; display: none; align-items: center; justify-content: center;
    animation: encFadeIn 0.3s ease-out;
}
.encyclopedia-overlay.visible { display: flex; }
@keyframes encFadeIn { from { opacity: 0; } to { opacity: 1; } }

.encyclopedia-container {
    width: 92vw; max-width: 900px; max-height: 88vh;
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,248,252,0.97) 100%);
    border-radius: 28px; border: 3px solid rgba(108,92,231,0.3);
    box-shadow: 0 20px 60px rgba(108,92,231,0.25), 0 8px 25px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; overflow: hidden;
    animation: encSlideIn 0.3s ease-out;
}
@keyframes encSlideIn { from { opacity: 0; transform: scale(0.92) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.encyclopedia-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px 10px; flex-shrink: 0;
}
.encyclopedia-title {
    margin: 0; font-size: 1.6rem; color: var(--primary-dark);
    font-family: 'Fredoka One', cursive;
}
.encyclopedia-close {
    width: 40px; height: 40px; border: none; background: rgba(108,92,231,0.1);
    border-radius: 50%; font-size: 1.2rem; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; color: #666;
}
.encyclopedia-close:hover { background: var(--danger); color: white; transform: scale(1.1); }

.encyclopedia-overlay .encyclopedia-tabs {
    display: flex; gap: 8px; padding: 0 24px; margin-bottom: 12px; flex-shrink: 0;
}
.enc-tab {
    flex: 1; padding: 12px 8px; border: 3px solid rgba(108,92,231,0.2); border-radius: 16px;
    background: white; font-size: 1.05rem; font-weight: bold; cursor: pointer; transition: all 0.2s;
    text-align: center; font-family: 'Fredoka One', cursive;
}
.enc-tab:hover { border-color: var(--primary); background: rgba(108,92,231,0.06); transform: translateY(-1px); }
.enc-tab.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 12px rgba(108,92,231,0.3); }

.encyclopedia-overlay .encyclopedia-search { padding: 0 24px; margin-bottom: 12px; flex-shrink: 0; }
.encyclopedia-search input {
    width: 100%; padding: 12px 16px; border: 2px solid #E0E0E0; border-radius: 16px;
    font-size: 1.1rem; outline: none; box-sizing: border-box;
    transition: border 0.2s; font-family: 'Fredoka One', cursive;
}
.encyclopedia-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.1); }

.encyclopedia-grid {
    flex: 1; overflow-y: auto; padding: 0 24px 20px;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px; align-content: start;
}
.encyclopedia-grid::-webkit-scrollbar { width: 8px; }
.encyclopedia-grid::-webkit-scrollbar-track { background: transparent; }
.encyclopedia-grid::-webkit-scrollbar-thumb { background: rgba(108,92,231,0.2); border-radius: 4px; }

.enc-card {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 16px 12px; background: rgba(248,248,252,0.9); border-radius: 20px;
    border: 2px solid transparent; transition: all 0.2s; cursor: default;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.enc-card:hover {
    border-color: var(--primary-light); background: white;
    box-shadow: 0 6px 20px rgba(108,92,231,0.15); transform: translateY(-3px);
}
.enc-card .enc-icon { font-size: 2.4rem; margin-bottom: 8px; }
.enc-card .enc-info { width: 100%; }
.enc-card .enc-name { font-weight: bold; font-size: 1.05rem; color: #333; margin-bottom: 4px; }
.enc-card .enc-desc { font-size: 0.85rem; color: #777; line-height: 1.3; }
.enc-card .enc-components { font-size: 0.8rem; color: var(--primary); margin-top: 6px; font-weight: bold; }

.enc-card.enc-pickup { border-bottom: 4px solid #3498DB; }
.enc-card.enc-fusion { border-bottom: 4px solid #9B59B6; }

/* === HUD TOGGLE (espace) === */
.hud-hidden .ui-layer,
.hud-hidden #fab-add,
.hud-hidden #toolbar-container,
.hud-hidden .top-bar,
.hud-hidden #edit-bubble,
.hud-hidden #toast,
.hud-hidden .modal { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.hud-visible .ui-layer,
.hud-visible #fab-add,
.hud-visible .top-bar { transition: opacity 0.3s; }

.modal-header {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 60%, var(--primary-dark) 100%);
    color: white; padding: 15px 20px;
    border-radius: 24px 24px 0 0; cursor: grab; display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 10px rgba(108,92,231,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.modal-header:active { cursor: grabbing; }
.panel-title { margin: 0; font-size: 1.3rem; pointer-events: none; }
.close-btn { background: none; border: none; font-size: 28px; cursor: pointer; color: white; line-height: 1; margin-top:-5px;}
.modal-content { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }

input[type="text"] {
    font-family: inherit; font-size: 1.2rem; padding: 10px; border-radius: 15px;
    border: 3px solid #ddd; text-align: center; width: 85%; margin: 0 auto; outline: none;
}
.section-title { font-size: 0.9rem; color: #777; margin: 10px 0 0 0; text-transform: uppercase; font-weight: bold; text-align: center;}
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.btn-opt {
    border: 3px solid #ddd; border-radius: 12px; cursor: pointer; background: white;
    padding: 8px 12px; font-weight: bold; font-family: inherit; color: #555;
    transition: 0.2s; font-size: 14px;
}
.btn-opt.selected { border-color: var(--primary); background: #eee; transform: scale(1.1); color: var(--primary); }
.color-btn { width: 35px; height: 35px; border-radius: 50%; border: 3px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.2); cursor: pointer; transition: 0.1s; }
.color-btn.selected { border-color: #333; transform: scale(1.2); }
.size-btn { width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; border: 3px solid #ddd; border-radius: 12px; background: white; cursor: pointer; transition: 0.1s; }
.size-btn.selected { border-color: var(--primary); transform: scale(1.1); }

.action-btns { display: flex; gap: 15px; margin-top: 15px; }
.btn-main { flex: 1; padding: 15px; border-radius: 15px; border: none; font-family: inherit; font-weight: bold; cursor: pointer; color: white; font-size: 1.1rem; transition: 0.2s; }
.btn-main:hover { opacity: 0.9; transform: scale(1.02); }

/* CREATOR MODAL */
.creator-preview-box {
    text-align: center; margin: 8px auto; padding: 8px;
    width: 130px; height: 130px;
    background: linear-gradient(135deg, #f0f0ff 0%, #e8f4f8 100%);
    border-radius: 20px; border: 3px solid #e0e0e0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.06);
}
.creator-preview-box canvas {
    position: static !important; z-index: auto !important;
    width: 120px; height: 120px; border-radius: 14px;
}

.creator-mode-toggle {
    display: flex; justify-content: center; gap: 8px; margin-bottom: 8px;
}
.creator-mode-btn {
    padding: 8px 24px; border-radius: 20px; border: 3px solid #ddd;
    background: white; font-size: 20px; cursor: pointer; transition: 0.2s;
}
.creator-mode-btn.selected {
    border-color: var(--primary); background: var(--primary);
    transform: scale(1.05); box-shadow: 0 3px 10px rgba(108,92,231,0.3);
}

.creator-tabs {
    display: flex; justify-content: center; gap: 6px; margin: 8px 0;
}
.creator-tab {
    width: 48px; height: 48px; border-radius: 14px; border: 3px solid #ddd;
    background: white; font-size: 22px; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.creator-tab.selected {
    border-color: var(--primary); background: #F0EDFF;
    transform: scale(1.1); box-shadow: 0 3px 8px rgba(108,92,231,0.2);
}
.creator-tab:hover { transform: scale(1.05); }

.creator-tab-content {
    max-height: 200px; overflow-y: auto; padding: 4px 0;
    scrollbar-width: thin;
}

.creator-option-grid {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 4px 0;
}
.creator-option-btn {
    width: 52px; height: 52px; border-radius: 14px; border: 3px solid #e0e0e0;
    background: white; cursor: pointer; transition: 0.2s; padding: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.creator-option-btn:hover { transform: scale(1.08); border-color: #bbb; }
.creator-option-btn.selected {
    border-color: var(--primary); background: #F0EDFF;
    transform: scale(1.12); box-shadow: 0 3px 8px rgba(108,92,231,0.25);
}
.creator-option-btn canvas { pointer-events: none; position: static !important; z-index: auto !important; }

.section-title-mini {
    font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 1px;
    margin: 8px 0 4px; text-align: center; font-weight: 600;
}

#creator-shapes .shape-btn, #creator-pro-shapes .shape-btn {
    width: 50px; height: 50px; border: 3px solid #ddd; border-radius: 12px;
    background: white; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
#creator-shapes .shape-btn.selected, #creator-pro-shapes .shape-btn.selected {
    border-color: var(--primary); background: #eee; transform: scale(1.15);
}

/* BIBLIOTHÈQUE */
#sidebar {
    position: absolute; top: 0; left: 0; width: 320px; height: 100%;
    background: var(--ui-bg); pointer-events: auto; transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 5px 0 20px rgba(0,0,0,0.1); z-index: 100; display: flex; flex-direction: column; border-right: 5px solid var(--primary);
}
#sidebar.open { transform: translateX(0); }
.sidebar-header { padding: 25px; background: var(--primary); color: white; display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { margin: 0; font-size: 1.4rem; }
.close-sidebar { background: none; border: none; color: white; font-size: 30px; cursor: pointer; }
.char-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.char-item { background: white; border-radius: 15px; padding: 15px; display: flex; align-items: center; gap: 15px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); cursor: pointer; transition: 0.2s; border: 3px solid transparent; }
.char-item:hover { transform: translateY(-5px); border-color: var(--primary); }

/* Secrets / Easter Eggs List */
.ee-item { font-size: 1.1rem; padding: 5px 0; border-bottom: 1px dashed #ddd; color: #555; }
.ee-item b { color: var(--primary); font-size: 1.2rem; }

/* Volume sliders */
.volume-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.vol-icon { font-size: 22px; width: 32px; text-align: center; }
.volume-slider { -webkit-appearance: none; appearance: none; flex: 1; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #dfe6e9, #74b9ff); outline: none; cursor: pointer; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #6c5ce7, #a29bfe); border: 3px solid white; box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: pointer; transition: transform 0.15s; }
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.volume-slider::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #6c5ce7, #a29bfe); border: 3px solid white; box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: pointer; }

/* Recording buttons */
.record-row { display: flex; gap: 8px; justify-content: center; }
.btn-rec { padding: 8px 16px; border: 2px solid #ddd; border-radius: 12px; background: white; font-size: 14px; cursor: pointer; transition: all 0.2s; font-family: 'Fredoka One', cursive; }
.btn-rec:hover { border-color: #E74C3C; background: #FFF5F5; }
.btn-rec.recording { border-color: #E74C3C; background: #E74C3C; color: white; animation: pulse-rec 1s infinite; }
@keyframes pulse-rec { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Flèches de scroll pour modales */
.modal-scroll-arrow {
    position: absolute; left: 50%; transform: translateX(-50%);
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(108, 92, 231, 0.85); color: white;
    border: 3px solid white; box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    font-size: 22px; cursor: pointer; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, opacity 0.2s;
    opacity: 0; pointer-events: none;
}
.modal-scroll-arrow.visible { opacity: 1; pointer-events: auto; }
.modal-scroll-arrow:hover { transform: translateX(-50%) scale(1.15); }
.modal-scroll-arrow.up { top: 45px; }
.modal-scroll-arrow.down { bottom: 8px; }
