/* ============================================================
   1. AMBIENTE ISOLA (COLORI ORIGINALI)
   ============================================================ */
.pagina-lievito {
    background: linear-gradient(to bottom, #87CEEB, #f4e4bc); /* Cielo e spiaggia */
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container-lievito {
    max-width: 800px;
    margin: 0 auto;
    /* Spazio per l'header in legno */
    padding-top: 160px; 
    padding-left: 20px;
    padding-right: 20px;
    text-align: center;
}

@media (max-width: 768px) {
    .container-lievito {
        padding-top: 180px; /* Più spazio su mobile per l'header */
    }
    .header-isola h1 { font-size: 2.2rem !important; }
}

.header-isola h1 {
    font-family: 'Pirata One', cursive;
    color: #a02d2d;
    font-size: 3.5rem;
    margin-bottom: 10px;
}

/* ============================================================
   2. AREA MASCOTTE E ANIMAZIONI
   ============================================================ */
.area-mascotte {
    position: relative;
    margin: 60px auto;
    max-width: 300px;
}

.mascotte-lievito {
    width: 100%;
    max-width: 250px;
    height: auto;
    transition: all 0.3s ease;
}

/* Salto Felice */
.area-mascotte.felice .mascotte-lievito {
    animation: saltoFelice 1s infinite alternate;
}

@keyframes saltoFelice {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

/* Stato Triste: Grigio e fermo */
.area-mascotte.triste .mascotte-lievito {
    filter: grayscale(80%) brightness(0.8);
}

/* Stato Disperato: Tremolio */
.area-mascotte.disperato .mascotte-lievito {
    filter: grayscale(40%) sepia(20%);
    animation: tremolioDisperato 0.2s infinite;
}

@keyframes tremolioDisperato {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -1px); }
    100% { transform: translate(1px, -1px); }
}

/* ============================================================
   3. IL FUMETTO (RESPONSIVE)
   ============================================================ */
.fumetto-lievito {
    background: white;
    padding: 15px;
    border-radius: 20px;
    position: absolute;
    top: -60px;
    right: -20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    max-width: 180px;
    z-index: 10;
    font-size: 0.9rem;
    border: 2px solid #63422e;
}

@media (max-width: 600px) {
    .fumetto-lievito {
        position: relative; /* Su mobile lo mettiamo sopra la mascotte */
        top: 0;
        right: 0;
        margin: 0 auto 20px auto;
        max-width: 90%;
    }
}

/* ============================================================
   4. STATO E AZIONI
   ============================================================ */
.stato-lievito {
    margin: 30px auto;
    max-width: 400px;
}

.progress-bar {
    width: 100%;
    height: 25px;
    background: #e0e0e0;
    border-radius: 50px;
    overflow: hidden;
    border: 3px solid #63422e;
}

.progress {
    height: 100%;
    background: #4CAF50; /* Verde energia */
    transition: width 0.8s ease-in-out;
}

.azioni-lievito {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
}

.btn-azione {
    padding: 15px 25px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    transition: 0.2s;
}

.btn-rinfresca { background: #63422e; color: white; }
.btn-canta { background: #a02d2d; color: white; }

.btn-azione:active {
    transform: translateY(3px);
    box-shadow: none;
}

@media (max-width: 500px) {
    .azioni-lievito {
        flex-direction: column; /* Bottoni impilati su mobile */
        align-items: center;
    }
    .btn-azione { width: 80%; }
}
/* --- TRANSIZIONE GLOBALE --- */
.pagina-lievito {
    transition: background 2s ease, filter 2s ease;
    overflow-x: hidden; /* Per le note che volano via */
}

/* --- STATO: FELICE (Cielo e Sole) --- */
.stato-felice {
    background: linear-gradient(to bottom, #87CEEB, #f4e4bc);
}

/* --- STATO: AFFAMATO (Tramonto - Inizia l'attesa) --- */
.stato-affamato {
    background: linear-gradient(to bottom, #ff9e2c, #f4e4bc);
}

/* --- STATO: TRISTE (Tramonto) --- */
.stato-triste {
    background: linear-gradient(to bottom, #69111c, #703244);
    filter: sepia(20%);
}
.stato-moltotriste {
    background: linear-gradient(to bottom, #4a4e69, #9a8c98);
    filter: sepia(20%);
}

/* --- STATO: DISPERATO (Notte Temporalesca) --- */
.stato-disperato {
    background: linear-gradient(to bottom, #1a1a2e, #16213e);
    filter: grayscale(30%) contrast(110%);
}
.nota-musicale {
    position: absolute;
    font-size: 2rem;
    color: #a02d2d;
    pointer-events: none;
    animation: volaNota 2s linear forwards;
    z-index: 100;
}

@keyframes volaNota {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-200px) translateX(50px) rotate(20deg); opacity: 0; }
}
.stato-disperato::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('https://www.transparenttextures.com/patterns/stardust.png'); /* Effetto puntini/pioggia */
    opacity: 0.3;
    pointer-events: none;
}
/* Particelle Magiche Grandi */
.particella-magica {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    /* Animazione più lenta (2 secondi) e fluida */
    animation: volaLento 2s cubic-bezier(0.1, 0.5, 0.3, 1) forwards;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
    font-size: 2.5rem; /* Dimensione molto più grande */
}

@keyframes volaLento {
    0% {
        transform: translate(0, 0) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    15% {
        opacity: 1;
        transform: translate(0, -20px) scale(1.2) rotate(10deg);
    }
    100% {
        /* Direzione verso l'alto con rotazione */
        transform: translate(var(--dx), var(--dy)) scale(0.8) rotate(360deg);
        opacity: 0;
    }
}
@keyframes volaVersoLievito {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        /* Le particelle si dirigono verso il centro alto dello schermo */
        transform: translate(var(--dx), var(--dy)) scale(0.5);
        opacity: 0;
    }
}

.animazione-ballo {
    animation: balloMaghetto 0.6s infinite alternate ease-in-out;
    transform-origin: bottom center;
}

@keyframes balloMaghetto {
    0% { transform: rotate(-5deg) scale(1.05); }
    100% { transform: rotate(5deg) scale(1.05); }
}
/* --- FIX LEGGIBILITÀ PER STATI SCURI --- */

/* Quando il body ha queste classi, cambiamo il colore del testo globale */
.stato-triste, .stato-moltotriste, .stato-disperato {
    color: #ffffff !important;
}

/* Il titolo deve risaltare: usiamo un'ombra chiara per staccarlo */
.stato-triste h1, .stato-moltotriste h1, .stato-disperato h1 {
    color: #ffffff !important;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4), 2px 2px 4px rgba(0,0,0,0.5);
}

/* La tagline e le info del tempo devono diventare bianche */
.stato-triste .tagline, .stato-moltotriste .tagline, .stato-disperato .tagline,
.stato-triste .info-tempo, .stato-moltotriste .info-tempo, .stato-disperato .info-tempo {
    color: #f0f0f0 !important;
}

/* IMPORTANTE: Il fumetto deve restare leggibile (nero su bianco) */
.fumetto-lievito p {
    color: #333333 !important;
    text-shadow: none !important;
}

/* Barra energia: rendiamo la label bianca */
.barra-energia label {
    color: white;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}