/* ============================================================
   L'AVENTURE DE LÉO - STYLES v3.0
   Design UX/UI Premium - WOW Effect
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

:root {
    /* Couleurs principales */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;

    /* Gradients */
    --gradient-main: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --gradient-warm: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-cool: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-sunset: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --gradient-nature: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);

    /* Spacing */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 20px;
    --space-lg: 32px;
    --space-xl: 48px;

    /* Border radius */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 30px;
    --radius-full: 50%;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: #1a1a2e;
    overflow: hidden;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== ANIMATED BACKGROUND ===== */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-main);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    z-index: -1;
}

.animated-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Floating particles effect */
.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    animation: float 20s infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===== CANVAS ===== */
canvas {
    display: block;
    margin: 0 auto;
    cursor: pointer;
}

/* ===== UI LAYER ===== */
#ui-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

/* ===== HUD - Modern Glass Design ===== */
#hud {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 220ms ease, opacity 220ms ease, background-color 220ms ease;
}

body.is-playing #hud {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1;
    transform: none;
}

body.is-playing #hud:hover {
    opacity: 1;
    transform: none;
    background: transparent;
}

body.is-paused #hud {
    opacity: 1;
    transform: translateY(0);
}

body.is-playing #menu-button {
    background: rgba(0, 0, 0, 0.55);
    border-color: rgba(255, 255, 255, 0.22);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

@media (max-width: 1024px) and (pointer: coarse) {
    #hud {
        padding: 8px 10px;
        gap: 10px;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

#level-display {
    font-family: 'Fredoka One', cursive;
    font-size: 26px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}

@media (max-width: 1024px) and (pointer: coarse) {
    #level-display {
        font-size: 18px;
        letter-spacing: 0.5px;
    }
}

#hearts {
    font-size: 26px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@media (max-width: 1024px) and (pointer: coarse) {
    #hearts {
        font-size: 18px;
    }
}

#key-display {
    font-size: 24px;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255,215,0,0.6);
    display: none;
    animation: keyPulse 0.8s infinite alternate;
}

@keyframes keyPulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.15); filter: brightness(1.3); }
}

#coins-display, #stars-display {
    font-size: 22px;
    color: #ffd700;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-weight: 700;
}

@media (max-width: 1024px) and (pointer: coarse) {
    #coins-display, #stars-display {
        font-size: 16px;
        text-shadow: 0 2px 6px rgba(0,0,0,0.35);
    }
}

/* ===== MENU BUTTON (in-game) ===== */
#menu-button {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-family: 'Nunito', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--glass-shadow);
}

@media (max-width: 1024px) and (pointer: coarse) {
    #menu-button {
        padding: 8px 10px;
        font-size: 13px;
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.22);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

#menu-button:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

#menu-button:active {
    transform: translateY(0) scale(0.95);
}

/* ===== FULLSCREEN OPTION ===== */
#fullscreen-option {
    display: none;
}

@media (min-width: 800px) and (pointer: fine) {
    #fullscreen-option {
        display: flex;
    }
}

/* ===== SCREENS ===== */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: auto;
    text-align: center;
    padding: var(--space-md);
    overflow-y: auto;
}

/* ===== START SCREEN - WOW DESIGN ===== */
#start-screen {
    position: relative;
    background: #0b0f2a;
    gap: var(--space-sm);
    padding-top: clamp(8px, 2vh, 20px);
    padding-bottom: clamp(18px, 4vh, 44px);
    min-height: 100dvh;
    justify-content: space-between;
    height: 100dvh;
    overflow: hidden;
}

#start-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../assets/leo-heroes.jpg') center 15%/cover no-repeat;
    filter: saturate(1.08) brightness(0.9);
    transform: scale(1.03);
    z-index: 0;
}

.start-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    z-index: 0;
    opacity: 1;
    pointer-events: none;
    filter: saturate(1.08) brightness(0.9);
    transition: opacity 250ms ease;
}

.start-bg-video.is-active {
    opacity: 1;
}

.start-bg-video.is-fading {
    opacity: 0;
}

#start-screen .difficulty-container {
    margin-top: var(--space-sm);
}

#start-screen .menu-bar {
    margin-top: var(--space-sm);
}

.start-header {
    width: 100%;
    max-width: 720px;
    padding-top: 0;
    margin-top: 0;
}

.start-footer {
    width: 100%;
    max-width: 720px;
    padding-bottom: clamp(6px, 1.5vh, 14px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .start-header,
    .start-footer {
        max-width: 640px;
    }
}

@media (max-width: 600px) {
    #start-screen {
        padding-top: 16px;
        padding-bottom: 16px;
        gap: var(--space-xs);
    }

    .start-header,
    .start-footer {
        max-width: 520px;
    }
}

#start-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(4, 8, 20, 0.70) 0%, rgba(10, 20, 40, 0.55) 55%, rgba(12, 8, 30, 0.75) 100%);
    z-index: 1;
}

#start-screen > * {
    position: relative;
    z-index: 2;
}

#start-screen > .start-bg-video {
    position: absolute;
    z-index: 0;
}

/* Mascot container */
.mascot-container {
    position: relative;
    margin-bottom: var(--space-sm);
}

.mascot {
    font-size: 100px;
    animation: mascotBounce 2s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

@keyframes mascotBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

/* Game Title */
.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(36px, 8vw, 72px);
    color: white;
    text-shadow:
        0 4px 0 rgba(0,0,0,0.2),
        0 10px 30px rgba(0,0,0,0.45);
    margin: 0;
    animation: titleFloat 3s ease-in-out infinite;
    letter-spacing: 2px;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.subtitle {
    font-size: clamp(16px, 3vw, 22px);
    color: rgba(255,255,255,0.9);
    margin: 0;
    font-weight: 600;
}

#start-screen .game-title {
    margin-top: 0;
}

#start-screen .subtitle {
    margin-top: 0;
}

/* ===== SAVED GAME BANNER ===== */
#saved-game {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: white;
    animation: slideDown 0.5s ease-out;
    box-shadow: var(--glass-shadow);
    width: min(520px, 92vw);
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#saved-game p {
    margin: var(--space-xs) 0;
    font-weight: 600;
}

@media (max-height: 760px) {
    #start-screen {
        gap: var(--space-xs);
        padding-top: 12px;
        padding-bottom: 16px;
    }

    .game-title {
        font-size: clamp(30px, 7vw, 56px);
    }

    #saved-game {
        padding: var(--space-xs) var(--space-sm);
    }

    #saved-game p {
        margin: 6px 0;
    }

    .difficulty-card {
        min-height: 132px;
        padding: var(--space-sm);
    }
}

/* ===== DIFFICULTY CARDS ===== */
.difficulty-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-sm);
    width: 100%;
    max-width: 700px;
    margin-top: var(--space-md);
}

.difficulty-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 150px;
}

.difficulty-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.difficulty-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.difficulty-card:hover::before {
    opacity: 1;
}

.difficulty-card:active {
    transform: translateY(-4px) scale(0.98);
}

.difficulty-icon {
    font-size: clamp(34px, 4vw, 48px);
    margin-bottom: var(--space-xs);
    display: block;
}

.difficulty-label {
    font-family: 'Fredoka One', cursive;
    font-size: 18px;
    color: white;
    margin-bottom: 4px;
}

.difficulty-desc {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    line-height: 1.3;
}

/* Difficulty card colors */
.difficulty-card.very-easy {
    background: linear-gradient(135deg, rgba(236,72,153,0.3) 0%, rgba(251,146,60,0.3) 100%);
    border-color: rgba(236,72,153,0.5);
}

.difficulty-card.easy {
    background: linear-gradient(135deg, rgba(34,197,94,0.3) 0%, rgba(16,185,129,0.3) 100%);
    border-color: rgba(34,197,94,0.5);
}

.difficulty-card.medium {
    background: linear-gradient(135deg, rgba(245,158,11,0.3) 0%, rgba(251,146,60,0.3) 100%);
    border-color: rgba(245,158,11,0.5);
}

.difficulty-card.hard {
    background: linear-gradient(135deg, rgba(239,68,68,0.3) 0%, rgba(220,38,38,0.3) 100%);
    border-color: rgba(239,68,68,0.5);
}

/* ===== BOTTOM MENU BAR ===== */
.menu-bar {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--space-md);
}

.menu-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: white;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.menu-btn:active {
    transform: translateY(0) scale(0.95);
}

.menu-btn-icon {
    font-size: 22px;
}

/* ===== SETTINGS BUTTON (Floating) ===== */
.settings-fab {
    position: fixed;
    top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
    right: calc(var(--space-md) + env(safe-area-inset-right, 0px));
    width: 56px;
    height: 56px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--glass-shadow);
    z-index: 50;
}

.settings-fab:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg) scale(1.1);
}

/* ===== SETTINGS PANEL ===== */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: min(400px, 90vw);
    height: 100%;
    background: rgba(20, 20, 40, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    padding: var(--space-xl) var(--space-lg);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}

.settings-panel.open {
    right: 0;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.settings-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.settings-title {
    font-family: 'Fredoka One', cursive;
    font-size: 28px;
    color: white;
    margin: 0;
}

.settings-close {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-close:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

.settings-group {
    margin-bottom: var(--space-lg);
}

.settings-group-title {
    font-size: 14px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: var(--space-sm);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.settings-label-icon {
    font-size: 22px;
}

/* Modern Toggle Switch */
.toggle-switch {
    width: 56px;
    height: 30px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: var(--success);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.toggle-switch.active::after {
    left: 29px;
}

/* ===== BIG BUTTONS ===== */
.big-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 3px solid var(--glass-border);
    padding: var(--space-md) var(--space-lg);
    font-family: 'Fredoka One', cursive;
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.big-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.big-btn:hover::before {
    left: 100%;
}

.big-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.6);
}

.big-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.btn-easy { background: linear-gradient(135deg, var(--success) 0%, #059669 100%); }
.btn-medium { background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%); }
.btn-hard { background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%); }
.btn-continue { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }
.btn-pause { background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%); }
.btn-very-easy {
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 50%, #fb923c 100%);
    animation: rainbowPulse 3s ease-in-out infinite;
}

@keyframes rainbowPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(236,72,153,0.5); }
    50% { box-shadow: 0 0 40px rgba(251,146,60,0.6); }
}

/* ===== OPTIONS ===== */
.options {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.option-button {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: 2px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.option-button:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}

.option-button.off {
    background: rgba(100,100,100,0.3);
    border-color: rgba(150,150,150,0.3);
}

/* ===== PAUSE SCREEN ===== */
#pause-screen {
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: none;
    gap: var(--space-md);
}

#pause-screen h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(40px, 8vw, 60px);
    color: white;
    margin: 0;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* ===== TRANSITION SCREEN ===== */
#transition-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: none;
    opacity: 0;
    transition: opacity 0.5s;
}

#transition-text {
    font-family: 'Fredoka One', cursive;
    animation: transitionPop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes transitionPop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== CUSTOMIZATION SCREEN ===== */
#customization-screen {
    background: var(--gradient-nature);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    gap: var(--space-md);
}

#customization-screen h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(32px, 6vw, 48px);
    color: white;
    margin: 0;
}

/* Color Buttons */
.color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    max-width: 500px;
}

.color-btn {
    width: 70px;
    height: 70px;
    border: 4px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-md);
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.color-btn:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.color-btn.selected {
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255,215,0,0.6);
    transform: scale(1.1);
}

/* Companion Buttons */
.companion-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    max-width: 600px;
}

.companion-btn {
    padding: var(--space-sm) var(--space-md);
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.companion-btn:hover {
    transform: translateY(-4px) scale(1.05);
    background: rgba(255,255,255,0.3);
}

.companion-btn.selected {
    background: rgba(255,255,255,0.9);
    color: #333;
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255,215,0,0.5);
}

/* Preview Card */
#customization-preview {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
}

#customization-preview p {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* ===== BADGES SCREEN ===== */
#badges-screen {
    background: var(--gradient-warm);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    gap: var(--space-md);
}

#badges-screen h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(32px, 6vw, 48px);
    color: white;
    margin: 0;
}

#badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-sm);
    max-width: 600px;
    width: 100%;
}

.badge-item {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    transition: all 0.3s;
}

.badge-item:hover {
    transform: translateY(-5px);
}

.badge-item.unlocked {
    background: rgba(255,255,255,0.95);
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255,215,0,0.4);
}

.badge-item.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.badge-icon {
    font-size: 44px;
    margin-bottom: var(--space-xs);
}

.badge-title {
    font-size: 13px;
    font-weight: 800;
    color: #333;
}

.badge-desc {
    font-size: 11px;
    color: #666;
}

/* ===== STATS SCREEN ===== */
#stats-screen {
    background: var(--gradient-cool);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    gap: var(--space-md);
}

#stats-screen h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(32px, 6vw, 48px);
    color: white;
    margin: 0;
}

#stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    max-width: 500px;
    width: 100%;
}

.stat-item {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-icon { font-size: 32px; }
.stat-value {
    font-family: 'Fredoka One', cursive;
    font-size: 28px;
    color: var(--primary);
}
.stat-label {
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

/* ===== COMPANION BUBBLE ===== */
#companion-bubble {
    animation: companionFloat 3s ease-in-out infinite;
    border: 4px solid var(--primary);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

@keyframes companionFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

#companion-icon {
    animation: companionWiggle 2s ease-in-out infinite;
}

@keyframes companionWiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* ===== MATH GAME ===== */
#math-game {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    gap: var(--space-md);
}

#math-game h2 {
    font-family: 'Fredoka One', cursive;
    color: #333;
}

#math-question {
    font-family: 'Fredoka One', cursive;
}

#math-answers button {
    font-family: 'Fredoka One', cursive !important;
    font-size: 26px !important;
    min-width: 90px !important;
    padding: 18px 28px !important;
    border-radius: var(--radius-md) !important;
}

/* ===== PROGRESS BAR ===== */
#progress-bar {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    transition: all 0.3s;
}

.progress-dot.completed {
    background: var(--success);
    border-color: #059669;
    box-shadow: 0 0 10px rgba(16,185,129,0.5);
}

.progress-dot.current {
    background: var(--accent);
    border-color: #d97706;
    animation: currentDotPulse 1s infinite;
    box-shadow: 0 0 15px rgba(245,158,11,0.6);
}

@keyframes currentDotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===== JUMP INDICATOR ===== */
#jump-indicator {
    position: absolute;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}

.jump-dot {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    transition: all 0.2s;
}

.jump-dot.available {
    background: var(--success);
    border-color: #059669;
    box-shadow: 0 0 12px rgba(16,185,129,0.6);
}

/* ===== TIMER ===== */
#timer-display {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Fredoka One', cursive;
    font-size: 22px;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: none;
}

/* ===== TUTORIAL ===== */
#tutorial {
    position: absolute;
    top: 50%;
    left: 80px;
    transform: translateY(-50%);
    background: white;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 4px solid var(--primary);
    max-width: 280px;
    display: none;
    pointer-events: auto;
    z-index: 25;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
}

#tutorial h3 {
    font-family: 'Fredoka One', cursive;
    margin: 0 0 var(--space-sm) 0;
    color: var(--primary);
    font-size: 22px;
}

#tutorial p {
    margin: 6px 0;
    font-size: 15px;
    font-weight: 600;
}

#tutorial button {
    margin-top: var(--space-sm);
    padding: 12px 24px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Fredoka One', cursive;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

#tutorial button:hover {
    background: #059669;
    transform: scale(1.05);
}

.tutorial-step {
    display: none;
    animation: tutorialFadeIn 0.4s ease-out;
}

.tutorial-step.active {
    display: block;
}

@keyframes tutorialFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-arrow {
    font-size: 36px;
    animation: arrowPulse 0.6s ease-in-out infinite alternate;
    margin: 0;
}

@keyframes arrowPulse {
    from { transform: translateX(0); }
    to { transform: translateX(12px); }
}

/* Tutoriel adaptatif : Desktop par défaut, Mobile caché */
.tutorial-desktop { display: block; }
.tutorial-mobile { display: none; }

@media (max-width: 1024px) and (pointer: coarse) {
    /* Sur mobile : afficher mobile, cacher desktop */
    .tutorial-desktop { display: none; }
    .tutorial-mobile { display: block; }

    #tutorial {
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        max-width: 320px;
    }

    #tutorial p {
        font-size: 16px;
        line-height: 1.5;
    }

    #tutorial button {
        width: 100%;
        padding: 16px 24px;
        font-size: 18px;
    }
}

/* ===== MESSAGE BOX ===== */
#message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: var(--space-xl);
    border: 6px solid var(--primary);
    border-radius: var(--radius-lg);
    text-align: center;
    display: none;
    pointer-events: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
    z-index: 30;
    min-width: 340px;
    animation: messagePopIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes messagePopIn {
    0% { transform: translate(-50%, -50%) scale(0); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

#msg-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(36px, 6vw, 50px);
    color: var(--primary);
    margin: 0 0 var(--space-sm) 0;
}

#msg-text {
    font-size: 22px;
    color: #333;
    margin: var(--space-sm) 0;
}

#msg-coins {
    font-size: 20px;
    color: #ffa500;
    font-weight: 700;
}

.space-hint {
    font-size: 14px;
    color: #999;
    margin-top: var(--space-sm);
}

/* ===== HALL OF FAME ===== */
#hall-of-fame {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    gap: var(--space-md);
}

#hall-of-fame h2 {
    font-family: 'Fredoka One', cursive;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255,215,0,0.5);
}

#hall-list {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: 2px solid var(--glass-border);
}

#hall-name {
    padding: 12px 20px;
    font-size: 20px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: 3px solid var(--primary);
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#hall-name:focus {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245,158,11,0.4);
}

/* ===== MOBILE CONTROLS - JOYSTICK + JUMP BUTTON ===== */
#controls {
    pointer-events: none;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 15px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 50;
}

#btn-pause-mobile {
    display: none;
}

@media (max-width: 1024px) and (pointer: coarse) {
    #controls {
        display: flex;
    }
    #btn-pause-mobile {
        display: flex;
        position: absolute;
        top: 12px;
        right: 15px;
        width: 56px;
        height: 56px;
        font-size: 26px;
        pointer-events: auto;
        z-index: 100;
    }
    #menu-button {
        display: none;
    }
}

/* ===== JOYSTICK VIRTUEL ===== */
#joystick-zone {
    pointer-events: auto;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

#joystick-base {
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.2),
        0 4px 20px rgba(0,0,0,0.3);
}

#joystick-thumb {
    width: 70px;
    height: 70px;
    background: linear-gradient(145deg, rgba(59,130,246,0.95) 0%, rgba(37,99,235,0.95) 100%);
    border: 4px solid rgba(255,255,255,0.6);
    border-radius: 50%;
    position: absolute;
    box-shadow:
        0 4px 15px rgba(37,99,235,0.5),
        inset 0 2px 10px rgba(255,255,255,0.3);
    transition: transform 0.05s ease-out, box-shadow 0.1s;
    will-change: transform;
}

#joystick-thumb.active {
    background: linear-gradient(145deg, rgba(79,150,255,1) 0%, rgba(57,119,255,1) 100%);
    box-shadow:
        0 0 25px rgba(59,130,246,0.8),
        inset 0 2px 10px rgba(255,255,255,0.4);
}

/* Indicateurs directionnels sur le joystick */
#joystick-base::before {
    content: "⬆️";
    position: absolute;
    top: 8px;
    font-size: 16px;
    opacity: 0.4;
}
#joystick-base::after {
    content: "⬇️";
    position: absolute;
    bottom: 8px;
    font-size: 16px;
    opacity: 0.4;
}

/* ===== ZONE SAUT ===== */
#jump-zone {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.btn {
    background: rgba(255, 255, 255, 0.9);
    border: 4px solid rgba(100, 100, 100, 0.3);
    border-radius: var(--radius-full);
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    color: #333;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    transition: all 0.08s ease-out;
    touch-action: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    background: rgba(255, 255, 255, 1);
    transform: scale(0.92);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* BOUTON SAUT GÉANT - Optimisé pour enfants */
#btn-jump {
    width: 150px;
    height: 150px;
    background: linear-gradient(145deg, rgba(16,185,129,0.95) 0%, rgba(5,150,105,0.95) 100%);
    font-size: 65px;
    border: 5px solid rgba(255,255,255,0.5);
    box-shadow:
        0 8px 30px rgba(16,185,129,0.5),
        inset 0 3px 15px rgba(255,255,255,0.3);
    animation: jumpButtonPulse 2s ease-in-out infinite;
}

#btn-jump:active {
    background: linear-gradient(145deg, rgba(20,200,140,1) 0%, rgba(10,170,115,1) 100%);
    transform: scale(0.9);
    box-shadow:
        0 0 40px rgba(16,185,129,0.8),
        inset 0 3px 15px rgba(255,255,255,0.4);
    animation: none;
}

@keyframes jumpButtonPulse {
    0%, 100% {
        box-shadow:
            0 8px 30px rgba(16,185,129,0.5),
            inset 0 3px 15px rgba(255,255,255,0.3);
    }
    50% {
        box-shadow:
            0 8px 40px rgba(16,185,129,0.7),
            inset 0 3px 15px rgba(255,255,255,0.3);
    }
}

/* ===== STREAK INDICATOR ===== */
#streak-indicator {
    position: absolute;
    top: 100px;
    right: var(--space-md);
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    display: none;
    animation: streakPulse 1.5s infinite;
    box-shadow: 0 4px 20px rgba(249,115,22,0.4);
}

@keyframes streakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== ENCOURAGEMENT POPUP ===== */
.encouragement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-lg);
    border: 5px solid #ffd700;
    font-family: 'Fredoka One', cursive;
    font-size: 26px;
    text-align: center;
    z-index: 100;
    animation: encouragementPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

@keyframes encouragementPop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-15deg); }
    60% { transform: translate(-50%, -50%) scale(1.15) rotate(5deg); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .game-title { font-size: 36px; }
    .subtitle { font-size: 15px; }
    #saved-game { width: min(92vw, 420px); }
    .big-btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 18px;
    }
    .btn { width: 70px; height: 70px; font-size: 30px; }

    /* Joystick responsive pour petits écrans */
    #joystick-zone {
        width: 130px;
        height: 130px;
    }
    #joystick-base {
        width: 110px;
        height: 110px;
    }
    #joystick-thumb {
        width: 55px;
        height: 55px;
    }
    #joystick-base::before,
    #joystick-base::after {
        font-size: 12px;
    }

    #btn-jump {
        width: 120px;
        height: 120px;
        font-size: 50px;
    }

    .difficulty-container {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xs);
    }

    .difficulty-card {
        padding: var(--space-sm);
        min-height: 130px;
    }

    .difficulty-icon {
        font-size: 36px;
    }

    .difficulty-label {
        font-size: 15px;
    }

    .difficulty-desc {
        font-size: 11px;
        line-height: 1.25;
    }

    .color-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }

    .companion-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    .menu-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 13px;
    }

    .settings-fab {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    #math-answers button {
        min-width: 70px !important;
        padding: 14px 20px !important;
        font-size: 22px !important;
    }

    .mascot {
        font-size: 70px;
    }
}

@media (max-height: 600px) {
    .screen {
        padding: var(--space-sm);
        gap: var(--space-xs);
    }

    .mascot {
        font-size: 50px;
    }

    .game-title {
        font-size: 32px;
    }

    .difficulty-container {
        margin-top: var(--space-xs);
    }

    .difficulty-card {
        padding: var(--space-xs);
    }

    .difficulty-icon {
        font-size: 30px;
        margin-bottom: 0;
    }
}

/* ===== ANIMATIONS UTILITIES ===== */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.celebrate {
    animation: celebrateBounce 0.6s ease-in-out 3;
}

@keyframes celebrateBounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

.shake {
    animation: shakeAnim 0.15s linear 3;
}

@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}
