* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #0e1628; 
    font-family: 'Fredoka One', cursive, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #f3f4f6;
}

.game-container {
    background: #1a2238;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.main-title {
    font-size: 36px;
    color: #f8db02; 
    text-shadow: 0 0 10px rgba(248, 219, 2, 0.7);
}

.stats-board {
    font-size: 20px;
    background: #1a2238;
    padding: 8px 15px;
    border-radius: 10px;
    border: 3px solid #14b8a6; 
}

.stats-board .label { color: #14b8a6; }
.stats-board .value { color: #f8db02; }

.game-area {
    position: relative;
    width: 700px;
    height: 700px;
}

/* Le Canvas principal du jeu */
#gameCanvas {
    background-color: #0e1628;
    border: 4px solid #111;
    border-radius: 15px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    transition: box-shadow 0.3s ease;
}

#gameCanvas.speed-boost {
    box-shadow: inset 0 0 30px rgba(20, 184, 166, 0.6);
    border-color: #14b8a6;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 34, 56, 0.95); 
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10;
    overflow: hidden; /* Empêche les objets physiques de déborder */
}

.overlay.hidden { display: none; }

/* --- ÉCRAN TITRE & PHYSIQUE --- */
#titleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Derrière le texte */
    opacity: 0.5; /* Légèrement transparent pour ne pas gêner la lecture */
}

.title-content {
    z-index: 1; /* Au dessus du canvas de fond */
}

.animated-game-title {
    font-size: 65px;
    color: #f8db02;
    margin-bottom: 10px;
    animation: float-pulse 3s ease-in-out infinite;
}

.subtitle {
    font-size: 24px;
    color: #14b8a6;
    margin-bottom: 40px;
}

@keyframes float-pulse {
    0%, 100% { 
        transform: translateY(0) scale(1) rotate(-2deg); 
        text-shadow: 0 0 15px rgba(248, 219, 2, 0.5);
    }
    50% { 
        transform: translateY(-15px) scale(1.05) rotate(2deg); 
        text-shadow: 0 0 30px rgba(248, 219, 2, 0.9), 0 0 10px #fff;
    }
}

.overlay h2 {
    font-size: 40px;
    margin-bottom: 20px;
    color: #f3f4f6;
}

#gameOverScreen h2 { color: #ef4444; }
#levelCompleteScreen h2 { color: #14b8a6; }

/* --- BOUTONS --- */
.btn-group {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

button {
    font-family: 'Fredoka One', cursive;
    font-size: 24px;
    background-color: #111827; 
    color: #f3f4f6;
    border: 4px solid #111;
    padding: 15px 35px;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.2s;
    box-shadow: 0 6px 0 #111;
}

button:hover { background-color: #1f2937; }
button:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #111;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 16px;
    padding: 10px 20px;
    background-color: #374151;
    border-color: #111;
}

/* Grille des niveaux */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.level-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    padding: 0;
}

.level-btn:not(.locked) {
    background-color: #f8db02;
    color: #1a2530;
    border: 4px solid #111;
    box-shadow: 0 6px 0 #111;
}

.level-btn.locked {
    background-color: #374151; 
    color: #9ca3af;
    box-shadow: 0 6px 0 #111;
    cursor: not-allowed;
    border-color: #222;
}