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

body {
    background-color: #1a1a1a;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    min-height: 100vh;
    overflow-x: hidden;
}

#ui-container {
    position: relative; /* MODIFIÉ : Permet de caler le bouton home par rapport à ce bloc */
    text-align: center;
    background: #2a2a2a;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    width: 100%;
    max-width: 1000px;
}

/* AJOUTÉ : Style du bouton Home */
#btn-home {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #444;
    color: #fff;
    padding: 8px 14px;
    font-size: 0.9em;
    border-radius: 5px;
    text-decoration: none; /* Enlève le soulignement du lien */
    font-weight: bold;
    border: 1px solid #555;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 5px;
}

#btn-home:hover {
    background: #555;
}

#btn-home:active {
    transform: scale(0.95);
}

h1 { 
    margin-bottom: 15px; 
    color: #ffcc00; 
    font-size: calc(1.3rem + 1vw);
    padding: 0 80px; /* AJOUTÉ : Évite que le titre ne chevauche le bouton Home sur petit écran */
}

.setup-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.setup-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05em;
    font-weight: bold;
}

select, button {
    padding: 10px 15px;
    font-size: 1em;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

select { background: #444; color: white; }
select:disabled { opacity: 0.4; cursor: not-allowed; }

#btn-new { background: #008cba; color: white; }
#btn-start { background: #4caf50; color: white; }
#btn-mute { background: #e67e22; color: white; }
#btn-mute.muted { background: #7f8c8d; color: #eee; }
button:disabled { background: #555 !important; cursor: not-allowed; opacity: 0.5; }

#names-panel {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    background: #1e1e1e;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
    text-align: left;
}

.player-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-input-group label {
    font-size: 0.9em;
    font-weight: bold;
}

.player-input-group input {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 2px solid #555;
    background: #2a2a2a;
    color: white;
    font-weight: bold;
    font-size: 1em;
}

.player-input-group input:focus { outline: none; background: #333; }

#gorgees-display {
    margin-top: 15px;
    font-size: 1.3em;
    font-weight: bold;
    color: #ff9f1c; 
    background: #3a2a1a;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ff9f1c;
}

canvas {
    background-color: #333;
    border: 4px solid #fff;
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    width: 100%;
    max-width: 1000px;
    height: auto;
    display: block;
}

#scoreboard-container {
    background: #222;
    width: 100%;
    max-width: 1000px;
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #444;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

#scoreboard-container h2 {
    color: #ffcc00;
    font-size: 1.2em;
    margin-bottom: 12px;
    text-align: center;
}

#scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

#scoreboard-table th {
    background: #111;
    padding: 10px;
    font-size: 0.9em;
    text-transform: uppercase;
    color: #aaa;
    border-bottom: 2px solid #444;
}

#scoreboard-table td {
    padding: 10px;
    font-weight: bold;
    font-size: 1.05em;
    border-bottom: 1px solid #333;
}

#scoreboard-table tr:last-child td { border-bottom: none; }

.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 10;
    padding: 20px;
}

.modal-content {
    background: #222;
    padding: 25px;
    border-radius: 15px;
    border: 3px solid #ffcc00;
    text-align: center;
    width: 100%;
    max-width: 450px;
    position: relative;
    padding-bottom: 70px; 
}

#podium-list {
    text-align: left;
    font-size: 1.3em;
    margin: 20px auto;
    width: 85%;
}

#podium-list li { margin-bottom: 10px; font-weight: bold;}

#gorgees-reminder { 
    font-size: 1.3em; 
    color: #ffffff; 
    font-weight: bold; 
    margin-bottom: 25px;
}

.modal-buttons { display: flex; justify-content: center; }

#btn-modal-replay { 
    background: #9b59b6; 
    color: white; 
    padding: 12px 35px; 
    font-size: 1.1em;
    width: 100%;
    max-width: 250px;
}

#btn-close-modal { 
    position: absolute; bottom: 15px; left: 15px;
    background: #444; color: #bbb; padding: 6px 12px; font-size: 0.8em;
    border: 1px solid #555;
}

.hidden { display: none !important; }

@media (max-width: 480px) {
    .setup-panel { flex-direction: column; width: 100%; }
    .setup-group, select, button { width: 100%; text-align: center; }
    select { text-align-last: center; }
    
    /* AJOUTÉ : Repositionne le bouton proprement au-dessus du titre sur de très petits écrans si nécessaire */
    #btn-home {
        position: relative;
        margin: 0 auto 10px auto;
        top: 0; left: 0;
        width: fit-content;
    }
    h1 { padding: 0; }
}