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

body {
    background: linear-gradient(to bottom, #87CEEB 0%, #E0F6FF 100%);
    overflow: hidden;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#gameContainer {
    position: relative;
    width: 100%;
    max-width: 1200px;
    aspect-ratio: 4 / 3;
    margin: 0 auto;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #87CEEB;
    border: 4px solid #333;
    box-sizing: border-box;
}

#ui {
    position: absolute;
    top: 1%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.5vw 1vw;
    border-radius: 5px;
    font-size: clamp(12px, 1.5vw, 18px);
    display: flex;
    gap: 2vw;
    z-index: 10;
}

#gameOver, #victory {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    font-size: 24px;
    z-index: 100;
}

.hidden {
    display: none !important;
}

#gameOver button, #victory button {
    margin-top: 20px;
    padding: 10px 30px;
    font-size: 18px;
    cursor: pointer;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
}

#gameOver button:hover, #victory button:hover {
    background: #45a049;
}

.stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

#menu, #scoreBoard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: clamp(20px, 4vw, 60px);
    border-radius: 15px;
    text-align: center;
    z-index: 100;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

#scoreBoard {
    display: none;
}

#menu h1, #scoreBoard h1 {
    font-size: clamp(24px, 4vw, 48px);
    margin-bottom: clamp(10px, 2vw, 20px);
    color: #FFD700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

#menu p {
    font-size: clamp(14px, 1.5vw, 18px);
    margin: clamp(8px, 1.5vw, 15px) 0;
    color: #CCC;
}

#menu button, #scoreBoard button {
    margin-top: clamp(15px, 3vw, 30px);
    padding: clamp(10px, 1.5vw, 15px) clamp(20px, 3vw, 40px);
    font-size: clamp(16px, 2vw, 24px);
    cursor: pointer;
    background: #FFD700;
    color: #000;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    transition: transform 0.2s;
}

#menu button:hover, #scoreBoard button:hover {
    background: #FFA500;
    transform: scale(1.1);
}

.controls {
    margin-top: clamp(10px, 2vw, 20px);
    padding: clamp(10px, 2vw, 20px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.controls h3 {
    margin-bottom: clamp(5px, 1vw, 10px);
    color: #FFD700;
    font-size: clamp(14px, 1.8vw, 20px);
}

/* Formulaire de score */
.score-form {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.score-form input {
    padding: 10px;
    margin: 10px 0;
    font-size: 18px;
    width: 80%;
    max-width: 300px;
    border: 2px solid #FFD700;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
}

/* Popup custom pour la confirmation */
#customPopup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: popupAppear 0.3s ease-out;
}

@keyframes popupAppear {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.popup-content h2 {
    color: #FFD700;
    font-size: clamp(24px, 5vw, 36px);
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.popup-content .score-details {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-size: clamp(16px, 3vw, 20px);
}

.popup-content .score-details p {
    margin: 10px 0;
    color: white;
}

.popup-content .score-details .big-points {
    font-size: clamp(32px, 6vw, 48px);
    color: #FFD700;
    font-weight: bold;
    margin: 15px 0;
}

.popup-content button {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: clamp(16px, 3vw, 20px);
    background: #FFD700;
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.popup-content button:hover {
    background: #FFA500;
    transform: scale(1.05);
}

.highlight-row {
    background: rgba(255, 215, 0, 0.3) !important;
    border: 2px solid #FFD700;
}

/* Tableau des scores */
.score-table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.score-table th,
.score-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.score-table th {
    background: rgba(255, 215, 0, 0.3);
    color: #FFD700;
    font-weight: bold;
}

.score-table tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

.difficulty-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.difficulty-tab {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.difficulty-tab:hover {
    background: rgba(255, 255, 255, 0.3);
}

.difficulty-tab.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
}

/* Contrôles tactiles pour mobile */
#mobileControls {
    display: none;
    position: absolute;
    bottom: 2%;
    left: 0;
    right: 0;
    width: 100%;
    height: 25%;
    z-index: 50;
    pointer-events: none;
}

.controlBtn {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 4vw, 36px);
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    user-select: none;
    pointer-events: all;
    touch-action: none;
}

.controlBtn:active {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

#btnLeft {
    left: 5%;
    bottom: 10%;
    width: clamp(50px, 12vw, 80px);
    height: clamp(50px, 12vw, 80px);
}

#btnRight {
    left: calc(5% + clamp(60px, 14vw, 95px));
    bottom: 10%;
    width: clamp(50px, 12vw, 80px);
    height: clamp(50px, 12vw, 80px);
}

#btnJump {
    right: 5%;
    bottom: 10%;
    width: clamp(60px, 14vw, 100px);
    height: clamp(60px, 14vw, 100px);
    background: rgba(255, 215, 0, 0.4);
    border-color: rgba(255, 215, 0, 0.8);
}

#btnJump:active {
    background: rgba(255, 215, 0, 0.6);
}

/* Responsive pour petits écrans */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #gameContainer {
        max-width: 100vw;
        max-height: 100vh;
    }

    #mobileControls {
        display: block;
    }
}

@media (max-width: 480px) {
    #mobileControls {
        height: 30%;
    }
}
