/* --- RESET & BASE --- */
* { 
    box-sizing: border-box; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    background-color: #e9ecef;
    margin: 0;
    padding: 20px;
    color: #333;
}

/* --- CONTENEURS (ÉCRANS) --- */
.screen {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    max-width: 500px;
    margin: 2vh auto;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 { color: #2c3e50; margin-top: 0; font-size: 2.5rem; }
h2 { color: #34495e; }
hr { border: 0; height: 1px; background: #ddd; margin: 25px 0; }

/* --- BOUTONS & INPUTS --- */
button {
    padding: 12px 24px;
    margin: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 123, 255, 0.2);
}

button:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.3);
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

input {
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
    outline: none;
}

/* --- LAYOUT DU SALON D'ATTENTE --- */
.menu-actions { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}

.input-container {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-container label { 
    font-weight: bold; 
    width: 70px; 
    text-align: left; 
    color: #555;
}

.input-container input { 
    flex: 1; /* Le champ prend tout l'espace disponible */
}

#btn-random-start, #btn-random-end { 
    margin: 0; 
    padding: 10px 15px; 
    font-size: 20px; 
}

/* --- ÉCRAN DE JEU ET WIKIPÉDIA --- */
#game-screen {
    max-width: 95%; /* Prend presque tout l'écran au lieu de 900px */
    width: 100%;
    text-align: left;
    padding: 0;
    margin: 2vh auto;
}

/* Le Bandeau Fixe (HUD) */
.hud {
    position: sticky;
    top: 0; /* Reste collé en haut de l'écran */
    background: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(8px); /* Effet verre dépoli iOS/Windows */
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #007bff;
    border-radius: 12px 12px 0 0;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.hud p { margin: 0; font-size: 18px; font-weight: bold; color: #555; }
.hud strong { color: #007bff; font-size: 22px; }

#wiki-content {
    padding: 30px;
    background: #fff;
    border-radius: 0 0 12px 12px;
    line-height: 1.6;
}

#wiki-content img { 
    max-width: 100%; 
    height: auto; 
    border-radius: 5px;
}

/* --- LES MENUS DÉROULANTS (AUTOCOMPLÉTION de start et end) --- */
.custom-datalist {
    list-style: none;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 100%;
    left: 80px; /* Aligné après le label */
    right: 65px; /* Aligné avant le bouton dé */
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: none;
    text-align: left;
}

.custom-datalist li { 
    padding: 12px 15px; 
    cursor: pointer; 
    border-bottom: 1px solid #f0f0f0; 
    font-size: 15px; 
    transition: background-color 0.2s;
}

.custom-datalist li:last-child { border-bottom: none; }
.custom-datalist li:hover { background-color: #007bff; color: white; }

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
    body { padding: 10px; }
    
    .input-container { 
        flex-direction: column; 
        align-items: stretch; 
        gap: 8px; 
    }
    
    .input-container label { width: auto; }
    .custom-datalist { left: 0; right: 0; } /* Le menu prend toute la largeur */
    
    .hud { 
        flex-direction: column; 
        gap: 10px; 
        text-align: center; 
        padding: 15px; 
    }
    
    #wiki-content { padding: 15px; }
}

/* --- DESIGN SPÉCIFIQUE WIKIPÉDIA (INFOBOX & NETTOYAGE) --- */

/* Forcer le conteneur à englober les éléments flottants */
#wiki-content::after {
    content: "";
    display: table;
    clear: both;
}

/* L'encadré de détails (Infobox) */
.infobox, .infobox_v2, .infobox_v3 {
    float: right; /* Aligne l'encadré à droite */
    clear: right;
    margin: 0 0 15px 20px;
    width: 300px;
    background-color: #f8f9fa;
    border: 1px solid #a2a9b1;
    border-radius: 5px;
    padding: 10px;
    font-size: 0.9em;
    border-collapse: collapse;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.infobox th, .infobox td {
    padding: 8px 5px;
    vertical-align: top;
    border-bottom: 1px solid #eaecf0;
}

/* L'entête de l'infobox (Le titre de l'encadré) */
.infobox caption {
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    background-color: #eaecf0;
    border-radius: 4px 4px 0 0;
    margin-bottom: 5px;
}

/* Les colonnes de gauche de l'infobox */
.infobox th {
    text-align: left;
    background-color: transparent;
    width: 40%;
}

/* Les images flottantes de Wikipédia */
.thumb.tright {
    float: right;
    clear: right;
    margin: 0 0 15px 20px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    padding: 5px;
    text-align: center;
    font-size: 0.85em;
}

/* Masquer les éléments inutiles pour le Wiki Race */
.reference,      /* Les liens [1], [2] qui ne mènent nulle part */
.navbox,         /* Les gros menus déroulants tout en bas des pages */
.bandeau-portail,/* Les bandeaux de portails en bas */
.ambox {         /* Les messages d'avertissement Wikipédia */
    display: none !important;
}

/* 4. Amélioration de la typographie générale */
#wiki-content p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.2em;
    color: #2c3e50;
}

#wiki-content a {
    color: #0645ad;
    text-decoration: none;
    font-weight: 500;
}

#wiki-content a:hover {
    text-decoration: underline;
}

/* --- LISTE DES JOUEURS DANS LE SALON--- */
.player-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.player-list li {
    background: #e2e8f0;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    color: #2c3e50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-size: 14px;
}

/* --- MODALE SAISIE PSEUDO --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px); /* Floute le fond */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease-out;
    width: 90%;
    max-width: 400px;
}

.modal-content input {
    width: 100%;
    margin: 15px 0;
    text-align: center;
}

.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover:not(:disabled) {
    background-color: #5a6268;
}

/* --- SOMMAIRE --- */
.custom-toc {
    background-color: #f8f9fa;
    border: 1px solid #a2a9b1;
    padding: 15px;
    margin: 20px 0;
    border-radius: 2px;
    display: inline-block;
    min-width: 250px;
}

.custom-toc h3 {
    margin-top: 0;
    font-size: 1.1em;
    border-bottom: 1px solid #eaecf0;
    padding-bottom: 5px;
}

.custom-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.custom-toc li { margin-bottom: 4px; font-size: 0.95em; }
.custom-toc a { color: #0645ad; text-decoration: none; }
.custom-toc a:hover { text-decoration: underline; }

/* On indente les sous-titres un peu plus */
.toc-level-1 { padding-left: 0; font-weight: bold; }
.toc-level-2 { padding-left: 15px; }
.toc-level-3 { padding-left: 30px; }


/* --- BOUTON ABANDON ET HUD --- */
.hud-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    font-size: 14px;
    padding: 8px 15px;
    margin: 0;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

@media (max-width: 600px) {
    .hud { flex-direction: row; flex-wrap: wrap; }
    .btn-danger { width: 100%; margin-top: 10px; }
}