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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Arial', sans-serif;
}

#gameCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(to bottom, #87ceeb, #e0f6ff);
}

#ui {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10;
}

/* Chaque bloc UI a une largeur fixe pour ne jamais se déplacer */
#score    { min-width: 160px; }
#lives    { min-width: 100px; text-align: center; }
#doubleJump { min-width: 60px; text-align: right; }

#score, #lives, #doubleJump {
    padding: 10px 20px;
    border-radius: 10px;
}

#score {
    color: #40E0D0;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.8);
    font-size: 22px;
    letter-spacing: 0.03em;
}

/* Icônes vies */
.heart-icon {
    display: inline-block;
    color: #ff4d79;
    font-size: 26px;
    line-height: 1;
    margin: 0 2px;
    text-shadow: 0 0 10px rgba(255,77,121,0.7), 0 0 20px rgba(255,77,121,0.4);
    animation: heart-beat 1.4s ease-in-out infinite;
}

@keyframes heart-beat {
    0%, 100% { transform: scale(1); }
    14%       { transform: scale(1.18); }
    28%       { transform: scale(1); }
    42%       { transform: scale(1.10); }
    70%       { transform: scale(1); }
}

.icon-skull {
    font-size: 26px;
    filter: drop-shadow(0 0 8px rgba(255,80,80,0.8));
}

/* Icône éclair */
.bolt-icon {
    font-size: 26px;
    line-height: 1;
}

.cooldown-bolt {
    opacity: 0.45;
    filter: grayscale(1);
}

.cooldown-num {
    font-size: 15px;
    font-weight: bold;
    color: #ff6b6b;
    margin-left: 2px;
    vertical-align: middle;
}

#doubleJump {
    font-size: 28px;
    transition: all 0.3s ease;
}

#doubleJump.power-ready {
    animation: pulse-turquoise 1.5s infinite;
}

#doubleJump.cooldown {
    opacity: 0.7;
    animation: none;
    color: #ff6b6b;
}

@keyframes pulse-turquoise {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(64, 224, 208, 0.8));
    }
    50% {
        transform: scale(1.15);
        filter: drop-shadow(0 0 20px rgba(64, 224, 208, 1));
    }
}

#gameOver {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overflow: hidden;
}

#gameOver.hidden {
    display: none;
}

.gameOverContent {
    text-align: center;
    color: white;
    transform: scale(0.7);
    padding: 10px;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#gameOverImage {
    max-width: 250px;
    width: 40%;
    height: auto;
    margin-bottom: 10px;
}

.taunt {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.gameOverContent > p {
    font-size: 20px;
    margin-bottom: 10px;
}

.score-form {
    margin: 10px auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    width: 100%;
}

.score-form input {
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    text-align: center;
}

.score-form input:focus {
    outline: none;
    border-color: #764ba2;
    background: white;
}

.score-form button {
    background: linear-gradient(135deg, #40e0d0 0%, #48d1cc 100%);
    color: white;
    border: none;
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.score-form button:hover {
    transform: scale(1.05);
}

.score-form button:active {
    transform: scale(0.95);
}

.score-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.leaderboard {
    margin: 10px auto;
    width: 50%;
    min-width: 400px;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 15px;
    border: 2px solid #667eea;
    max-height: 50vh;
    overflow-y: auto;
}

.leaderboard h3 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.leaderboard-item.current-player {
    background: rgba(64, 224, 208, 0.3);
    border: 2px solid #40e0d0;
}

.leaderboard-rank {
    font-size: 16px;
    font-weight: bold;
    min-width: 35px;
}

.leaderboard-rank.top1 { color: #ffd700; }
.leaderboard-rank.top2 { color: #c0c0c0; }
.leaderboard-rank.top3 { color: #cd7f32; }

.leaderboard-name {
    flex: 1;
    font-size: 15px;
    text-align: left;
    margin-left: 10px;
}

.leaderboard-score {
    font-size: 16px;
    font-weight: bold;
    color: #40e0d0;
}

.loading {
    color: #999;
    font-style: italic;
    padding: 15px;
    font-size: 14px;
}

.error {
    color: #ff6b6b;
    padding: 15px;
    font-size: 14px;
}

.gameOverContent > button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 10px;
}

.gameOverContent > button:hover {
    transform: scale(1.05);
}


.gameover-logo {
    width: 60px;
    height: auto;
    opacity: 0.6;
    margin-top: 6px;
    filter: brightness(0) invert(1);
}

/* ── Bouton quitter fullscreen (mobile) ── */
#exit-fullscreen-btn {
    display: none;
    position: fixed;
    top: env(safe-area-inset-top, 12px);
    right: 12px;
    z-index: 10000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 16px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

/* ── Mobile portrait : réduire l'UI ── */
@media (max-width: 600px) and (orientation: portrait) {

    #ui {
        top: 10px;
        font-size: 15px;
    }

    #score, #lives, #doubleJump {
        padding: 4px 10px;
    }

    .heart-icon { font-size: 18px; }
    .bolt-icon  { font-size: 18px; }

    .gameOverContent {
        transform: scale(0.82);
        gap: 6px;
    }

    #gameOverImage {
        max-width: 120px;
        width: 30%;
    }

    .taunt {
        font-size: 15px;
        margin-bottom: 4px;
    }

    .gameOverContent > p {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .score-form {
        gap: 6px;
        max-width: 260px;
    }

    .score-form input {
        padding: 7px 10px;
        font-size: 13px;
    }

    .score-form button {
        padding: 7px 16px;
        font-size: 13px;
    }

    .leaderboard {
        width: 90%;
        min-width: unset;
        max-height: 35vh;
        padding: 10px;
    }

    .leaderboard h3 {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .leaderboard-item { padding: 5px 10px; }

    .leaderboard-rank,
    .leaderboard-name,
    .leaderboard-score { font-size: 12px; }

    .gameOverContent > button {
        padding: 8px 20px;
        font-size: 14px;
    }

    .gameover-logo {
        width: 60px;
    }
}
