* { box-sizing: border-box; }

body {
    margin: 0;
    height: 100vh;
    background: linear-gradient(135deg, #020617, #0f172a);
    font-family: Arial, sans-serif;
    color: white;
}

.container {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-box {
    width: 90%;
    max-width: 700px;
    min-height: 85vh;
    background: #020617;
    border-radius: 25px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    border: 2px solid #38bdf8;
}

/* SCHERMATE SETUP */
.setup {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.hidden { display: none !important; } /* Aggiunto !important per sicurezza */

h1, h2 { 
    color: #e0f2fe; 
    text-align: center;
    width: 100%;
    margin: 0;
}

/* GIOCATORI */
#playersContainer {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e0f2fe;
    border-radius: 14px;
    padding: 10px;
}

.player-field input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 1.2rem;
    outline: none;
    color: #020617;
}

/* Bottone per rimuovere giocatore */
.remove-btn {
    margin-left: 10px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottone + per aggiungere giocatori */
.add-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2.8rem;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    border: none;
    color: white;
    margin: 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Bottoni generali */
button, select {
    padding: 14px 30px;
    font-size: 1.1rem;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

button:hover, button:focus {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
    outline: none;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
}

select {
    width: 200px;
}

/* SCHERMATA GIOCO */
#game {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    gap: 30px;
}

.player-name {
    font-size: 2rem;
    text-align: center;
    color: #bae6fd;
}

/* AREA PER PRESSIONE */
.press-area {
    width: 100%;
    max-width: 400px;
    height: 250px;
    background: #0f172a;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px dashed #38bdf8;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;     
    touch-action: none;          
}

.card {
    font-size: 2rem;
    text-align: center;
    z-index: 10;
}

.impostor {
    color: #dc2626;
    font-weight: bold;
}

#pressText {
    position: absolute;
    font-size: 1.2rem;
    color: #38bdf8;
}

/* Bottone next player */
#nextBtn {
    padding: 14px 30px;
    font-size: 1.2rem;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

#nextBtn:hover, #nextBtn:focus {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
    outline: none;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
}

/* Role card nascosta all’inizio */
#roleCard {
    /* La classe .hidden gestisce la visibilità */
    min-height: 50px;
}

/* SWITCH LINGUA */
.language-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

/* TIMER SCREEN - CENTRATO PERFETTAMENTE */
#timerScreen {
    position: fixed; /* Si fissa sopra tutto */
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Tutta l'altezza dello schermo */
    background-color: #0f172a; /* Colore di sfondo scuro come il resto */
    z-index: 1000; /* Sta sopra a qualsiasi altra cosa */
    
    /* Flexbox per centrare tutto */
    display: flex;
    flex-direction: column; /* Elementi uno sotto l'altro */
    justify-content: center; /* Centra verticalmente */
    align-items: center; /* Centra orizzontalmente */
    text-align: center;
}

.timer-display {
    font-size: 5rem; /* Molto grande */
    font-weight: 800;
    color: #38bdf8;
    margin: 20px 0;
    font-family: 'Courier New', monospace; /* Monospace per numeri stabili */
    text-shadow: 0 0 30px rgba(56, 189, 248, 0.4);
}

/* Stile quando mancano 10 secondi */
.timer-warning {
    color: #ef4444;
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Fix per i pulsanti e le select nelle impostazioni per essere sicuri siano centrati */
.control-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* Centra gli elementi dentro il gruppo */
    margin-bottom: 20px;
}

select {
    width: 60%;            /* Occupa tutto lo spazio disponibile */
    padding: 10px;
    text-align: center; /* Centra il testo dentro il menu a tendina */
    text-align-last: center; /* Fix per alcuni browser */
}

/* CLASSE DI UTILITÀ PER CENTRARE LE SCHERMATE A TUTTO SCHERMO */
.centered-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: #0f172a;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Bottone STOP (Rosso) */
.stop-btn {
    background: #ef4444;
    color: white;
    font-size: 1.5rem;
    padding: 15px 40px;
    margin-top: 20px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}
.stop-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* NOME DELL'IMPOSTORE RIVELATO */
.impostor-reveal-name {
    font-size: 3rem;
    font-weight: bold;
    color: #ef4444; /* Rosso */
    text-transform: uppercase;
    margin: 15px 0;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Stile per chi inizia a parlare */
.starting-player {
    font-size: 1.8rem;
    color: #4ade80;       /* Verde brillante */
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
    min-height: 60px;     /* Riserva spazio per evitare scatti */
}

.starting-player span {
    display: block;
    font-size: 1rem;
    color: #94a3b8;       /* Grigio chiaro per la scritta "Inizia:" */
    font-weight: normal;
    margin-bottom: 5px;
    text-shadow: none;
}

@media (max-width: 600px) {
    .game-box {
        padding: 20px; /* Riduciamo il padding su mobile */
        width: 95%;    /* Usiamo più schermo possibile */
    }
    
    h1 {
        font-size: 1.8rem; /* Riduciamo leggermente il font del titolo su mobile */
    }
}

/* Bottone "?" in alto a sinistra */
.rules-btn-trigger {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #38bdf8;
    color: #38bdf8;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    padding: 0; /* Reset padding */
    transition: all 0.3s ease;
}

.rules-btn-trigger:hover {
    background: #38bdf8;
    color: #0f172a;
    transform: rotate(15deg) scale(1.1);
}

/* Sfondo scuro che copre tutto lo schermo */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.85); /* Sfondo scuro semi-trasparente */
    backdrop-filter: blur(5px); /* Effetto sfocatura dietro */
    z-index: 2000; /* Sopra a TUTTO */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards; /* Animazione entrata */
}

/* Finestra delle regole */
.modal-content {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #38bdf8;
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.2);
    text-align: left;
    position: relative;
    max-height: 80vh; /* Se lo schermo è piccolo, non esce fuori */
    overflow-y: auto; /* Aggiunge scroll se necessario */
}

.modal-content h2 {
    text-align: center;
    color: #38bdf8;
    margin-top: 0;
    margin-bottom: 20px;
}

.rules-text p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #cbd5e1;
}

.rules-text strong {
    color: #e0f2fe;
}

/* Bottone chiudi dentro il modale */
.close-rules-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
    background: #38bdf8;
    color: #0f172a;
    font-weight: bold;
}

.close-rules-btn:hover {
    background: #0ea5e9;
}

/* Animazione di entrata */
@keyframes fadeIn {
    to { opacity: 1; }
}

/* Quando è nascosto, non occupa spazio */
.modal-overlay.hidden {
    display: none !important;
}