/* --- RESET & ANTI-FLASH BLANC --- */
:root {
    --main-bg: #0f0f12; 
    --card-bg: #1a1a1f;
    --text-main: #ffffff;
    --accent: #a24fff;
    --accent-gradient: linear-gradient(135deg, #a24fff, #602080);
    --border: rgba(255, 255, 255, 0.1);
    --input-bg: #25252b;
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; }

html, body { 
    margin: 0; 
    padding: 0;
    background-color: #0f0f12 !important; 
    color: #ffffff;
    min-height: 100vh;
    transition: background 0.3s ease;
}

body { 
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* --- TYPOGRAPHIE MASSIVE --- */
h1 { 
    font-size: 3.2rem; 
    text-transform: uppercase; 
    letter-spacing: -1px; 
    margin: 0;
    font-weight: 900;
    background: linear-gradient(to bottom, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--accent); }
h3 { font-size: 1.6rem; font-weight: 700; margin-bottom: 1rem; }
p { font-size: 1.25rem; line-height: 1.7; color: rgba(255,255,255,0.8); max-width: 800px; }

/* --- HEADERS (Correction Alignement) --- */
header { 
    background: var(--accent-gradient); 
    color: #fff; 
    padding: 1.5rem 2rem; /* Réduit un peu le padding vertical */
    border-radius: 0 0 30px 30px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 1200px;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-container {
    display: flex; /* Passage en Flex pour un meilleur contrôle horizontal */
    justify-content: space-between; /* Logo à gauche, Profil à droite */
    align-items: center; /* Aligne verticalement au milieu */
    width: 100%;
    margin-bottom: 10px;
}

/* On s'assure que le titre ne pousse pas tout */
header h1 { 
    margin: 0; 
    font-size: clamp(1.5rem, 5vw, 2.8rem); /* Taille adaptative pour ne pas déborder */
    flex-shrink: 1;
}

/* --- LE BOUTON PROFIL (Fixé dans le Header) --- */
#current-user {
    display: flex;
    align-items: center;
}

.profile-trigger {
    padding: 0.6rem 1.2rem; /* Taille plus compacte pour le header */
    height: fit-content;
    background: rgba(0,0,0,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    white-space: nowrap; /* Empêche le texte du bouton de revenir à la ligne */
}

.profile-trigger img { 
    width: 30px; 
    height: 30px; 
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: row; /* On garde la ligne même sur mobile */
        justify-content: space-between;
    }
    header h1 { font-size: 1.8rem; }
}

/* --- HERO SECTION (Correction de Lisibilité) --- */
.hero {
    padding: 6rem 2rem;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: var(--accent-gradient); /* Ton violet foncé */
    border-radius: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    color: #ffffff !important; /* Force tout le texte en blanc */
}

.hero h1, .hero h2 {
    color: #ffffff !important; /* Le titre "Bienvenue" devient blanc */
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); /* Ombre pour la lisibilité */
    margin-bottom: 10px;
}

.hero p {
    color: rgba(255, 255, 255, 0.9) !important; /* Blanc cassé pour le texte descriptif */
    font-weight: 500;
}
.hero .cta-button {
    background: #ffffff !important;
    color: #000000 !important;
    border: none;
    box-shadow: 0 6px 0 #dddddd, 0 10px 20px rgba(0,0,0,0.2);
    font-size: 1.1rem;
    min-width: 220px;
}

.hero .cta-button:hover {
    background: #f0f0f0 !important;
    transform: translateY(-4px);
    box-shadow: 0 8px 0 #cccccc, 0 12px 25px rgba(0,0,0,0.3);
}   

/* --- BOUTONS (DESIGN JEU VIDÉO) --- */
.cta-button, .btn-primary, .btn-secondary, .btn-danger, .profile-trigger {
    padding: 1rem 2rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    margin: 5px; /* Sécurité pour ne pas se coller */
}

.cta-button, .btn-primary {
    background: #fff !important;
    color: #000 !important;
    box-shadow: 0 4px 0 #ccc;
}

.cta-button:hover, .btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(255,255,255,0.3);
}

.btn-secondary { background: var(--input-bg); color: #fff; border: 1px solid var(--border); }
.btn-danger { background: #ff4757; color: white; box-shadow: 0 4px 0 #b33939; }

/* --- LE BOUTON PROFIL (HEADER) --- */
.profile-trigger {
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    justify-self: end;
}

.profile-trigger:hover {
    background: #fff;
    color: #000;
}

.profile-trigger img { width: 35px; height: 35px; border-radius: 50%; border: 2px solid var(--accent); }

/* --- GRILLES & CARTES --- */
.jouer-grid, .actu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    width: 90%;
    max-width: 1200px;
    margin: 3rem 0;
}

.jouer-card, .actu-card {
    background: var(--card-bg) !important;
    border: 2px solid var(--border);
    padding: 2.5rem;
    border-radius: 24px;
}

/* --- LEADERBOARD --- */
#leaderboard-container {
    width: 100%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border);
    margin: 2rem auto;
    overflow: hidden;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 80px 1fr 140px;
    align-items: center;
    padding: 1.2rem 2.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.rank-number {
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
}

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

.player-avatar-mini {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    object-fit: cover;
}

.player-name { font-size: 1.4rem; font-weight: 700; }

.player-score {
    text-align: right;
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 900;
}

/* --- MODAL (Correction de la taille et scrollbar) --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}

.modal.show { display: flex !important; }

.modal-content {
    background: var(--card-bg);
    padding: 2.5rem; /* Légèrement réduit pour gagner de la place */
    border-radius: 30px;
    border: 2px solid var(--accent);
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 500px;
    max-height: 90vh; /* Empêche de dépasser de l'écran */
    overflow-y: auto; /* Active le scroll interne */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Scrollbar interne modale */
.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }

.modal-body { width: 100%; }

.profile-field { margin: 1.2rem 0; width: 100%; }

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.edit-field input[type="text"] {
    width: 100%;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: white;
    border-radius: 10px;
    text-align: center;
}

.stats-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 1.2rem 0;
    width: 100%;
}

.stat-item {
    background: var(--input-bg);
    padding: 1.2rem;
    border-radius: 15px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label { font-size: 0.8rem; text-transform: uppercase; opacity: 0.6; margin-bottom: 5px; }
.stat-value { font-size: 1.8rem !important; color: var(--accent); font-weight: 900; }

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 1rem;
}

/* --- THEMES (Couleurs des pastilles fixées) --- */
.theme-selector { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }
.theme-dot { 
    width: 45px; height: 45px; border-radius: 50%; cursor: pointer; border: 3px solid #fff; 
    transition: transform 0.2s;
}
.theme-dot:hover { transform: scale(1.1); }

/* Couleurs forcées pour les logos de thèmes */
.theme-dot.original { background: linear-gradient(135deg, #a24fff, #602080) !important; }
.theme-dot.neon { background: #00ff88 !important; }
.theme-dot.stealth { background: #333333 !important; }

#recent-scores-list div:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* --- ANIMATIONS BOUTONS MODALE --- */
.modal-footer button {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Effet rebond fluide */
    cursor: pointer;
    font-weight: 600;
}

.modal-footer button:hover {
    transform: translateY(-3px); /* Le bouton monte légèrement */
    filter: brightness(1.1); /* Il s'illumine */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-footer button:active {
    transform: translateY(1px); /* Effet de pression au clic */
}

/* Effet spécifique pour le bouton Danger (Déconnexion/Reset) */
.btn-danger:hover {
    background-color: #ff4757 !important;
    color: white !important;
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Empêche le contenu de déborder des angles arrondis de la modale */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* Empêche la modale de dépasser de l'écran */
    overflow: hidden; /* Ici c'est safe car on va faire scroller l'intérieur */
}

/* On rend le corps de la modale scrollable si besoin */
.modal-body {
    flex: 1;
    overflow-y: auto; /* Autorise le scroll vertical uniquement ici */
    padding: 20px;
    /* Pour cacher la barre de scroll moche sur certains navigateurs */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

/* Style élégant pour l'historique (celui qui posait problème) */
#recent-scores-list {
    margin-top: 10px;
    background: var(--input-bg);
    border-radius: 12px;
    padding: 10px;
    overflow: hidden; /* Coupe les coins ici aussi */
}

/* Animation fluide pour les barres de scroll Chrome/Safari */
.modal-body::-webkit-scrollbar,
#recent-scores-list::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb,
#recent-scores-list::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}