@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800&display=swap');

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

body {
    font-family: 'Poppins', sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Accents bleus décoratifs */
body::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(76, 110, 245, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    bottom: -150px;
    left: -150px;
    pointer-events: none;
}

.container {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    animation: fadeIn 1s ease-out;
}

.logo img {
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

h1 {
    font-size: 38px;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 8px;
    animation: fadeIn 1.2s ease-out;
    letter-spacing: -1px;
}

.subtitle {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 30px;
    font-weight: 400;
    animation: fadeIn 1.4s ease-out;
}

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

.game-container {
    background: #ffffff;
    padding: 25px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.15);
    border: 2px solid #e0f2fe;
    animation: fadeIn 1.6s ease-out;
}

.game-title {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 15px;
}

#gameCanvas {
    background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.2);
    cursor: pointer;
    display: block;
    margin: 0 auto 15px;
    transition: transform 0.2s;
    border: 2px solid #e0f2fe;
}

#gameCanvas:hover {
    transform: scale(1.02);
}

.score-display {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.score-label {
    font-size: 13px;
    font-weight: 400;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.instructions {
    margin-top: 12px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
}

/* Leaderboard / Classement */
.leaderboard-container {
    margin-top: 40px;
    background: #ffffff;
    padding: 30px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.15);
    border: 2px solid #e0f2fe;
    animation: fadeIn 1.8s ease-out;
}

.leaderboard-title {
    font-size: 26px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

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

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 15px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.leaderboard-item:hover {
    background: #eff6ff;
    transform: translateX(5px);
    border-color: #bae6fd;
}

.leaderboard-item.top-1 {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fbbf24;
}

.leaderboard-item.top-2 {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    border-color: #9ca3af;
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    border-color: #f97316;
}

.rank {
    font-size: 22px;
    font-weight: 700;
    min-width: 45px;
    text-align: center;
    color: #667eea;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.avatar {
    width: 50px;
    height: 70px;
    border-radius: 8px;
    border: 2px solid #e0f2fe;
    background: #ffffff;
    object-fit: cover;
    image-rendering: pixelated;
}

.pseudo {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    text-align: left;
}

.player-score {
    font-size: 22px;
    font-weight: 700;
    color: #667eea;
    min-width: 60px;
    text-align: right;
}

.loading, .empty, .error {
    text-align: center;
    padding: 30px;
    color: #6b7280;
    font-size: 15px;
}

.error {
    color: #ef4444;
}

/* Game Over Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    padding: 50px;
    border-radius: 30px;
    box-shadow: 0 30px 80px rgba(102, 126, 234, 0.3);
    text-align: center;
    max-width: 450px;
    width: 90%;
    border: 3px solid #e0f2fe;
}

.modal h2 {
    font-size: 42px;
    color: #667eea;
    margin-bottom: 15px;
}

.modal p {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 10px;
}

.final-score {
    font-size: 64px;
    font-weight: 800;
    color: #667eea;
    margin: 20px 0 30px;
}

/* Formulaire d'enregistrement du score */
.save-score-form {
    margin-top: 20px;
}

.form-instruction {
    font-size: 16px;
    color: #1a1a2e;
    font-weight: 600;
    margin-bottom: 15px;
}

#pseudoInput {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #e0f2fe;
    border-radius: 15px;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s;
    margin-bottom: 15px;
}

#pseudoInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.form-buttons button {
    flex: 1;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s;
}

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #4c6ef5 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.btn-skip {
    background: #f1f5f9;
    color: #64748b;
}

.btn-skip:hover {
    background: #e2e8f0;
}

.form-message {
    font-size: 14px;
    padding: 10px;
    border-radius: 10px;
    margin-top: 10px;
}

.form-message.success {
    background: #d1fae5;
    color: #065f46;
}

.form-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.modal button#restartBtn {
    background: linear-gradient(135deg, #667eea 0%, #4c6ef5 100%);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal button#restartBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.modal button#restartBtn:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    h1 {
        font-size: 32px;
    }

    .subtitle {
        font-size: 16px;
    }

    .logo {
        width: 60px;
        height: 60px;
    }

    .game-container {
        padding: 20px;
    }

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

    #gameCanvas {
        max-width: 100%;
        height: auto;
    }

    .leaderboard-container {
        padding: 20px;
        margin-top: 30px;
    }

    .leaderboard-title {
        font-size: 22px;
    }

    .leaderboard-item {
        padding: 12px;
        gap: 10px;
    }

    .rank {
        font-size: 18px;
        min-width: 35px;
    }

    .avatar {
        width: 40px;
        height: 56px;
    }

    .pseudo {
        font-size: 14px;
    }

    .player-score {
        font-size: 18px;
    }

    .modal-content {
        padding: 30px 20px;
    }

    .modal h2 {
        font-size: 32px;
    }

    .final-score {
        font-size: 48px;
    }

    .form-buttons {
        flex-direction: column;
    }
}

@media (max-height: 800px) {
    body {
        padding: 20px;
    }

    .subtitle {
        margin-bottom: 20px;
    }
}
