/*
 * AI Draw Battle - Stile
 * ======================
 * Colori vivaci e divertenti, adatti a bambini di 10 anni.
 */

/* --- Reset e base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Comic Sans MS', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* --- Schermate --- */
.schermata {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}

.nascosta {
    display: none !important;
}

/* --- Titolo del gioco --- */
.titolo-gioco {
    font-size: 3.5em;
    color: #fff;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-top: 30px;
    letter-spacing: 2px;
}

.sottotitolo {
    font-size: 1.3em;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
}

/* --- Card (contenitore bianco) --- */
.card {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
}

.card h2 {
    color: #764ba2;
    margin-bottom: 5px;
    font-size: 1.5em;
}

.hint {
    color: #999;
    font-size: 0.9em;
    margin-bottom: 20px;
}

/* --- Input login --- */
.input-login {
    margin-bottom: 20px;
}

.input-login input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1.1em;
    transition: border-color 0.3s;
    outline: none;
    text-align: center;
}

.input-login input:focus {
    border-color: #764ba2;
}

/* --- Input giocatori --- */
.input-giocatori {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.input-gruppo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.numero-giocatore {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    flex-shrink: 0;
}

.input-gruppo input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1em;
    transition: border-color 0.3s;
    outline: none;
}

.input-gruppo input:focus {
    border-color: #764ba2;
}

/* --- Bottoni --- */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-grande {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: #fff;
    width: 100%;
    padding: 15px;
    font-size: 1.3em;
    letter-spacing: 1px;
}

.btn-cancella {
    background: #ff6b6b;
    color: #fff;
    flex: 1;
}

.btn-invia {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: #333;
    flex: 2;
}

.btn-prossimo {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    width: 100%;
    margin-top: 15px;
}

/* --- Errori --- */
.errore {
    color: #ff6b6b;
    margin-top: 10px;
    font-weight: bold;
    min-height: 20px;
}

/* --- Barra del turno --- */
.barra-turno {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    margin-bottom: 20px;
    gap: 20px;
    flex-wrap: wrap;
}

.info-giocatore,
.info-parola {
    font-size: 1.2em;
    color: #fff;
    font-weight: bold;
}

.nome-evidenziato {
    background: #f5576c;
    padding: 4px 14px;
    border-radius: 8px;
    color: #fff;
}

.parola-evidenziata {
    background: #43e97b;
    padding: 4px 14px;
    border-radius: 8px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- Contenuto gioco (canvas + pannello) --- */
.contenuto-gioco {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- Area di disegno --- */
.area-disegno {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

canvas {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    cursor: crosshair;
    touch-action: none;
}

.bottoni-canvas {
    display: flex;
    gap: 12px;
}

/* --- Pannello laterale --- */
.pannello-laterale {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 280px;
    flex: 1;
}

/* --- Classifica --- */
.classifica {
    padding: 20px;
}

.classifica h3 {
    color: #764ba2;
    margin-bottom: 12px;
    font-size: 1.3em;
}

.riga-classifica {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 1.1em;
    font-weight: bold;
}

.riga-classifica:nth-child(odd) {
    background: #f8f0ff;
}

.riga-classifica:nth-child(even) {
    background: #f0f0ff;
}

.riga-classifica.attivo {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.punti-badge {
    background: #f5576c;
    color: #fff;
    padding: 3px 12px;
    border-radius: 15px;
    font-size: 0.95em;
}

.riga-classifica.attivo .punti-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Risultato AI --- */
.risultato {
    padding: 20px;
}

.risultato h3 {
    color: #764ba2;
    margin-bottom: 10px;
}

.testo-risposta {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    padding: 10px;
    background: #f8f0ff;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 10px;
}

.testo-esito {
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    padding: 8px;
    border-radius: 10px;
}

.testo-esito.corretto {
    background: #d4edda;
    color: #155724;
}

.testo-esito.sbagliato {
    background: #f8d7da;
    color: #721c24;
}

.testo-parola-corretta {
    text-align: center;
    font-size: 1em;
    color: #666;
    margin-top: 5px;
}

/* --- Overlay di caricamento --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-container {
    background: #fff;
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.spinner-container p {
    margin-top: 15px;
    font-size: 1.1em;
    color: #764ba2;
    font-weight: bold;
}

/* Animazione dello spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid #764ba2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Toggle Modalità PRO --- */
.pro-toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 15px 20px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 14px;
    border: 2px solid #e94560;
}

.pro-label-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pro-label-text {
    font-size: 1.15em;
    font-weight: bold;
    color: #e94560;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.pro-label-desc {
    font-size: 0.8em;
    color: #aaa;
}

/* Toggle switch */
.pro-toggle {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
    flex-shrink: 0;
}

.pro-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pro-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    border-radius: 30px;
    transition: 0.3s;
}

.pro-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.pro-toggle input:checked + .pro-slider {
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.5);
}

.pro-toggle input:checked + .pro-slider::before {
    transform: translateX(26px);
}

/* --- Timer PRO --- */
.timer-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 18px;
    border-radius: 12px;
}

.timer-display {
    font-size: 1.6em;
    font-weight: bold;
    color: #43e97b;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
}

.timer-display .attenzione {
    color: #ffc107;
}

.timer-display .critico {
    color: #ff4444;
    animation: lampeggia 0.5s infinite;
}

.timer-barra-sfondo {
    width: 120px;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

.timer-barra {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #43e97b, #38f9d7);
    border-radius: 5px;
    transition: width 1s linear;
}

.timer-barra.attenzione {
    background: linear-gradient(90deg, #ffc107, #ffdb4d);
}

.timer-barra.critico {
    background: linear-gradient(90deg, #ff4444, #ff6b6b);
}

@keyframes lampeggia {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* --- Responsive: schermi piccoli --- */
@media (max-width: 700px) {
    .titolo-gioco {
        font-size: 2.2em;
    }

    canvas {
        width: 100%;
        height: auto;
    }

    .barra-turno {
        flex-direction: column;
        text-align: center;
    }

    .contenuto-gioco {
        flex-direction: column;
        align-items: center;
    }

    .pannello-laterale {
        width: 100%;
        min-width: unset;
    }

    .timer-container {
        width: 100%;
        justify-content: center;
    }

    .timer-barra-sfondo {
        flex: 1;
        max-width: 200px;
    }
}
