* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(to bottom, #000428, #004e92);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: white;
    touch-action: none; /* Empêche le zoom et scroll sur mobile */
    -webkit-user-select: none; /* Empêche la sélection de texte */
    user-select: none;
}

#game-container {
    position: relative;
    max-width: 800px;
    width: 100%;
    background: #0a0a1a;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(135, 206, 250, 0.3);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    background: linear-gradient(to bottom, #000000, #1a1a2e, #2a2a3e);
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

#score, #lives, #difficulty {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid #87ceeb;
}

#scoreValue, #livesValue {
    color: #87ceeb;
}

#difficultyValue {
    color: #ff6b6b;
    font-weight: bold;
}

.hidden {
    display: none !important;
}

#start-screen, #game-over, #name-input-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid #87ceeb;
    box-shadow: 0 0 40px rgba(135, 206, 250, 0.5);
    z-index: 100;
    max-height: 80vh;
    overflow-y: auto;
}

#start-screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #87ceeb;
    text-shadow: 0 0 10px rgba(135, 206, 250, 0.8);
}

#start-screen p, #game-over p {
    font-size: 18px;
    margin: 10px 0;
    color: #b0c4de;
}

button {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

button:active {
    transform: translateY(0);
}

#game-over h2 {
    color: #ff6b6b;
    font-size: 36px;
    margin-bottom: 15px;
}

#instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid #87ceeb;
    font-size: 14px;
    z-index: 10;
}

.info-box p {
    margin: 5px 0;
    color: #b0c4de;
}

.music-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #87ceeb;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(135, 206, 250, 0.3);
}

.music-btn:hover {
    background: rgba(135, 206, 250, 0.2);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(135, 206, 250, 0.5);
}

.music-btn:active {
    transform: scale(0.95);
}

.music-btn.muted {
    opacity: 0.5;
}

/* Écran de saisie du nom */
#name-input-screen h2 {
    color: #ffd700;
    font-size: 32px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

#playerName {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    margin: 20px auto;
    font-size: 18px;
    border: 2px solid #87ceeb;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#playerName:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#playerName::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Section des highscores */
#highscores-section {
    margin: 30px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid #87ceeb;
}

#highscores-section h3 {
    color: #ffd700;
    font-size: 24px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

#highscores-list {
    max-height: 400px;
    overflow-y: auto;
}

.highscore-item {
    display: grid;
    grid-template-columns: 50px 1fr 100px 80px;
    gap: 10px;
    padding: 10px;
    margin: 5px 0;
    background: rgba(135, 206, 250, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(135, 206, 250, 0.3);
    align-items: center;
    transition: all 0.2s;
}

.highscore-item:hover {
    background: rgba(135, 206, 250, 0.2);
    transform: translateX(5px);
}

.highscore-item .rank {
    color: #ffd700;
    font-weight: bold;
    font-size: 20px;
}

.highscore-item .name {
    color: #87ceeb;
    font-weight: bold;
    text-align: left;
}

.highscore-item .score {
    color: #ffffff;
    font-weight: bold;
}

.highscore-item .level {
    color: #ff6b6b;
    font-size: 14px;
}

/* Affichage conditionnel selon le device */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    body {
        padding: 0;
        margin: 0;
    }

    #game-container {
        border-radius: 0;
        max-width: 100vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    canvas {
        height: 100%;
        width: 100%;
        object-fit: contain;
    }

    #ui {
        top: 10px;
        left: 10px;
        right: 10px;
        font-size: 14px;
        flex-wrap: wrap;
        gap: 5px;
    }

    #score, #lives, #difficulty {
        padding: 5px 10px;
        font-size: 12px;
    }

    #start-screen, #game-over, #name-input-screen {
        width: 90%;
        max-width: 90vw;
        padding: 20px;
        max-height: 85vh;
    }

    #start-screen h1 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    #start-screen p, #game-over p {
        font-size: 14px;
        margin: 5px 0;
    }

    #game-over h2 {
        font-size: 28px;
    }

    button {
        padding: 12px 30px;
        font-size: 16px;
        margin-top: 15px;
    }

    .music-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    #instructions {
        bottom: 70px;
        font-size: 12px;
        padding: 8px 15px;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        max-width: 80%;
    }

    .info-box p {
        margin: 3px 0;
        font-size: 11px;
    }

    #highscores-section {
        padding: 15px;
        margin: 20px 0;
    }

    #highscores-section h3 {
        font-size: 20px;
    }

    .highscore-item {
        grid-template-columns: 35px 1fr 70px 60px;
        gap: 5px;
        padding: 8px;
        font-size: 12px;
    }

    .highscore-item .rank {
        font-size: 16px;
    }

    .highscore-item .level {
        font-size: 11px;
    }

    #playerName {
        width: 90%;
        max-width: none;
        font-size: 16px;
        padding: 12px;
    }

    #name-input-screen h2 {
        font-size: 24px;
    }
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    #ui {
        font-size: 12px;
    }

    #score, #lives, #difficulty {
        padding: 4px 8px;
        font-size: 11px;
    }

    #start-screen h1 {
        font-size: 24px;
    }

    #start-screen p, #game-over p {
        font-size: 13px;
    }

    button {
        padding: 10px 25px;
        font-size: 14px;
    }

    .music-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        bottom: 10px;
        right: 10px;
    }

    .highscore-item {
        grid-template-columns: 30px 1fr 60px 50px;
        gap: 3px;
        padding: 6px;
        font-size: 11px;
    }
}
