/* ============================================================
   CHE ANIMALE? — stile locale
   Carica prima css/kids-base.css (variabili, header, footer).
   ============================================================ */

/* ---------- Layout principale ---------- */
.game-container {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 3vw, 36px) 12px 48px;
    overflow: hidden;
    color: var(--ink);
    font-family: var(--kids-font-body);
    background:
        radial-gradient(620px 320px at 6% -40px, rgba(132, 204, 22, .14), transparent 60%),
        radial-gradient(720px 420px at 104% 104%, rgba(56, 189, 248, .14), transparent 60%),
        linear-gradient(180deg, #f7fee7 0%, #ecfeff 100%);
}

/* Animaletti che galleggiano sullo sfondo */
.bg-decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.bg-decor span {
    position: absolute;
    opacity: .14;
    line-height: 1;
    animation: decorFloat 9s ease-in-out infinite alternate;
}

@keyframes decorFloat {
    from { transform: translateY(-12px) rotate(-8deg); }
    to   { transform: translateY(14px) rotate(10deg); }
}

/* ---------- Schermate ---------- */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 760px;
    padding: 0.5rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Schermata iniziale ---------- */
.hero-animals {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 2vw, 16px);
    margin-bottom: 0.9rem;
    min-height: 96px;
}

.hero-animals img {
    width: clamp(62px, 12vw, 92px);
    height: clamp(62px, 12vw, 92px);
    object-fit: contain;
    background: #fff;
    border: 3px solid #d9f99d;
    border-radius: 50%;
    padding: 4px;
    box-shadow: 0 5px 0 rgba(10, 91, 99, .10), var(--kids-shadow-sm);
    animation: heroBob 2.6s ease-in-out infinite;
}

.hero-animals img:nth-child(2) { animation-delay: .35s; border-color: #fde68a; }
.hero-animals img:nth-child(3) { animation-delay: .7s;  border-color: #bfdbfe; }
.hero-animals img:nth-child(4) { animation-delay: 1.05s; border-color: #fbcfe8; }

@keyframes heroBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

.game-title {
    font-family: var(--kids-font-title);
    font-size: clamp(2.2rem, 6vw, 3.2rem);
    font-weight: 700;
    color: var(--brand);
    margin: 0 0 0.4rem;
    text-shadow: 0 3px 0 rgba(10, 91, 99, .12);
}

.game-subtitle {
    font-size: clamp(1.05rem, 3vw, 1.35rem);
    color: var(--ink-2);
    font-weight: 700;
    margin: 0 0 1.8rem;
}

.choose-label {
    font-family: var(--kids-font-title);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--brand);
    margin: 0 0 1rem;
    text-transform: uppercase;
    letter-spacing: .6px;
}

/* Card dei livelli */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 210px));
    gap: clamp(12px, 2.5vw, 22px);
    justify-content: center;
    width: 100%;
}

.level-card {
    --lvl: #22c55e;
    --lvl-dark: #15803d;
    --lvl-soft: #f0fdf4;
    appearance: none;
    border: 3px solid var(--lvl);
    background: #fff;
    border-radius: var(--kids-radius);
    padding: 1.1rem 0.9rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    box-shadow: 0 7px 0 var(--lvl-dark), var(--kids-shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    font-family: var(--kids-font-body);
}

.level-card:hover {
    transform: translateY(-4px);
    background: var(--lvl-soft);
    box-shadow: 0 11px 0 var(--lvl-dark), var(--kids-shadow);
}

.level-card:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--lvl-dark);
}

.level-card.medium { --lvl: #f59e0b; --lvl-dark: #b45309; --lvl-soft: #fffbeb; }
.level-card.hard   { --lvl: #8b5cf6; --lvl-dark: #6d28d9; --lvl-soft: #f5f3ff; }
.level-card.learn  { --lvl: #0ea5e9; --lvl-dark: #0369a1; --lvl-soft: #f0f9ff; }

/* Card larga "Ascolta" sotto i tre livelli */
.level-card.wide {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    padding: 1rem 1.2rem;
}

.level-card.wide .level-text {
    align-items: flex-start;
    text-align: left;
}

.level-icon {
    font-size: 2.4rem;
    line-height: 1;
}

.level-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.level-name {
    font-family: var(--kids-font-title);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
}

.level-desc {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink-2);
}

/* ---------- Scheda informativa per adulti ---------- */
.info-box {
    background: #fff;
    border: 2px dashed #cfe2e2;
    border-radius: 18px;
    padding: 1.3rem 1.4rem;
    margin-top: 2.2rem;
    width: 100%;
    text-align: left;
    color: #3b4a4a;
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-box h2 {
    font-family: var(--kids-font-title);
    font-size: 1.15rem;
    color: var(--brand);
    margin: 0 0 0.7rem;
}

.info-box h3 {
    font-family: var(--kids-font-title);
    font-size: 1rem;
    color: var(--brand);
    margin: 1.1rem 0 0.4rem;
}

.info-box p { margin: 0 0 0.55rem; }
.info-box ul { margin: 0 0 0.55rem; padding-left: 1.2rem; }
.info-box li { margin-bottom: 0.35rem; }

.info-box .info-tip {
    margin-top: 0.9rem;
    background: #f0fdfa;
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
}

/* ---------- HUD ---------- */
.hud {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 1rem;
}

.hud-pill {
    background: #fff;
    border: 2px solid #ffe1a6;
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-family: var(--kids-font-title);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    box-shadow: var(--kids-shadow-sm);
    white-space: nowrap;
}

.learn-pill {
    border-color: #bae6fd;
    font-size: 1.05rem;
    margin-right: auto;
}

.score-pill.bump { animation: scoreBump .45s ease; }

@keyframes scoreBump {
    30% { transform: scale(1.22); }
}

.hud-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* Il fondo resta neutro: con un fondo verde la barra sembrava già piena */
.progress-track {
    flex: 1;
    height: 16px;
    background: #e4ece7;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(10, 91, 99, .12);
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #84cc16, #2dd4bf);
    transition: width .5s cubic-bezier(.22, 1, .36, 1);
}

.progress-label {
    font-family: var(--kids-font-title);
    font-weight: 600;
    color: var(--brand);
    font-size: 1rem;
    white-space: nowrap;
}

.hud-right { display: flex; gap: 8px; }

.hud-btn {
    appearance: none;
    border: 2px solid #d7efec;
    background: #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--kids-shadow-sm);
    transition: transform .15s ease, background .15s ease;
    padding: 0;
    line-height: 1;
}

.hud-btn:hover { transform: translateY(-2px); background: #f0fdfa; }
.hud-btn.home { border-color: var(--brand); background: #f0fdfa; }
.hud-btn.home:hover { background: #ccfbf1; }

/* ---------- Pulsante "Ascolta il verso" ---------- */
.listen-btn {
    appearance: none;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #4a3200;
    font-family: var(--kids-font-title);
    font-size: clamp(1.1rem, 3.6vw, 1.5rem);
    font-weight: 700;
    padding: 0.85rem 1.8rem;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 0 #b45309, var(--kids-shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
    margin-bottom: 1.2rem;
    max-width: 100%;
}

.listen-btn:hover { transform: translateY(-2px); }
.listen-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b45309; }

.listen-icon { font-size: 1.3em; line-height: 1; }

/* Onde animate: si muovono solo mentre il verso sta suonando */
.listen-waves {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 1.2em;
}

.listen-waves i {
    display: block;
    width: 4px;
    height: 30%;
    border-radius: 2px;
    background: rgba(74, 50, 0, .45);
    transition: height .2s ease;
}

.listen-btn.playing .listen-waves i {
    animation: wave .9s ease-in-out infinite;
    background: rgba(74, 50, 0, .75);
}

.listen-btn.playing .listen-waves i:nth-child(2) { animation-delay: .12s; }
.listen-btn.playing .listen-waves i:nth-child(3) { animation-delay: .24s; }
.listen-btn.playing .listen-waves i:nth-child(4) { animation-delay: .36s; }
.listen-btn.playing .listen-waves i:nth-child(5) { animation-delay: .48s; }

@keyframes wave {
    0%, 100% { height: 25%; }
    50%      { height: 100%; }
}

/* Invito a toccare finché il bambino non ascolta la prima volta */
.listen-btn.pulse {
    animation: listenPulse 1.6s ease-in-out infinite;
}

@keyframes listenPulse {
    0%, 100% { box-shadow: 0 6px 0 #b45309, 0 0 0 0 rgba(245, 158, 11, .5); }
    50%      { box-shadow: 0 6px 0 #b45309, 0 0 0 16px rgba(245, 158, 11, 0); }
}

/* ---------- Griglia degli animali ---------- */
.animals-grid {
    display: grid;
    gap: clamp(8px, 2vw, 16px);
    justify-content: center;
    width: 100%;
    margin-bottom: 0.4rem;
}

.animals-grid.n3  { grid-template-columns: repeat(3, minmax(0, 190px)); }
.animals-grid.n6  { grid-template-columns: repeat(3, minmax(0, 170px)); }
.animals-grid.n12 { grid-template-columns: repeat(4, minmax(0, 150px)); }

.animal-card {
    appearance: none;
    position: relative;
    background: #fff;
    border: 3px solid #e6f2f0;
    border-radius: var(--kids-radius);
    box-shadow: 0 5px 0 rgba(10, 91, 99, .10), var(--kids-shadow-sm);
    cursor: pointer;
    padding: 6px 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease, opacity .3s ease;
    animation: cardIn .35s cubic-bezier(.34, 1.56, .64, 1) backwards;
    overflow: hidden;
}

@keyframes cardIn {
    from { opacity: 0; transform: scale(.6); }
}

.animal-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    pointer-events: none;
}

.animal-name {
    font-family: var(--kids-font-title);
    font-size: clamp(.85rem, 2.6vw, 1.05rem);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
}

.animal-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: #bfe6e0;
    box-shadow: 0 10px 0 rgba(10, 91, 99, .10), var(--kids-shadow);
}

.animal-card:active { transform: scale(.94); box-shadow: 0 2px 0 rgba(10, 91, 99, .10); }

/* Stati della risposta */
.animal-card.correct {
    border-color: #22c55e;
    background: #f0fdf4;
    animation: popCorrect .5s ease;
    z-index: 2;
}

@keyframes popCorrect {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.12) rotate(-3deg); }
    70%  { transform: scale(.97) rotate(2deg); }
    100% { transform: scale(1); }
}

.animal-card.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    animation: shakeCard .5s ease;
}

@keyframes shakeCard {
    20%, 60% { transform: translateX(-9px); }
    40%, 80% { transform: translateX(9px); }
}

/* Una scelta già provata e sbagliata: resta al suo posto — sparire
   sposterebbe le altre sotto il dito — ma si spegne e non si tocca
   più. Il giro non è finito: si riprova sulle rimanenti, e la
   risposta giusta non viene MAI svelata dall'app.
   animation:none è obbligatorio: togliendo .wrong l'animazione
   torna a cardIn e RIPARTIREBBE da capo, cioè da opacity 0 — la
   carta sparirebbe un attimo invece di spegnersi. */
.animal-card.fuori {
    opacity: .3;
    pointer-events: none;
    filter: grayscale(1);
    box-shadow: none;
    transform: none;
    animation: none;
}

.animal-card.locked { pointer-events: none; }

/* Modalità Ascolta: la card "suona" mentre riproduce il verso */
.animal-card.speaking {
    border-color: #38bdf8;
    background: #f0f9ff;
    animation: speakingPulse .9s ease infinite;
}

@keyframes speakingPulse {
    0%, 100% { box-shadow: 0 5px 0 rgba(56, 189, 248, .35), 0 0 0 0 rgba(56, 189, 248, .45); }
    50%      { box-shadow: 0 5px 0 rgba(56, 189, 248, .35), 0 0 0 12px rgba(56, 189, 248, 0); }
}

/* Scintille sulla risposta giusta */
.sparkle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkleFly .65s ease-out forwards;
    z-index: 3;
}

@keyframes sparkleFly {
    from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    to   { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.1); opacity: 0; }
}

/* ---------- Feedback ---------- */
.feedback-msg {
    min-height: 3.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--kids-font-title);
    font-size: clamp(1.1rem, 3.4vw, 1.45rem);
    font-weight: 600;
    text-align: center;
    padding: 0 4px;
}

.feedback-msg span {
    display: inline-block;
    padding: 0.35rem 1.2rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: var(--kids-shadow-sm);
    animation: toastIn .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes toastIn {
    from { opacity: 0; transform: scale(.6) translateY(8px); }
}

.feedback-msg.correct span {
    color: #15803d;
    border: 2px solid #bbf7d0;
    background: #f0fdf4;
}

.feedback-msg.wrong span {
    color: #b91c1c;
    border: 2px solid #fecaca;
    background: #fef2f2;
}

/* Badge serie di risposte giuste */
.streak-badge {
    position: fixed;
    top: 18%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f97316, #fbbf24);
    color: #fff;
    font-family: var(--kids-font-title);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.5rem 1.6rem;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(249, 115, 22, .4);
    opacity: 0;
    pointer-events: none;
    z-index: 40;
}

.streak-badge.show { animation: badgePop 1.4s ease forwards; }

@keyframes badgePop {
    0%   { opacity: 0; transform: translateX(-50%) scale(.4); }
    15%  { opacity: 1; transform: translateX(-50%) scale(1.15); }
    25%  { transform: translateX(-50%) scale(1); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scale(.9) translateY(-18px); }
}

/* ---------- Schermata finale ---------- */
.result-content {
    background: #fff;
    border: 3px solid #d9f99d;
    color: var(--ink);
    padding: clamp(1.6rem, 5vw, 3rem);
    border-radius: 28px;
    text-align: center;
    width: min(480px, 94%);
    box-shadow: var(--kids-shadow);
}

.stars-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: clamp(2.4rem, 8vw, 3.4rem);
    margin-bottom: 0.4rem;
    min-height: 1.2em;
}

.stars-row .star { filter: grayscale(1) opacity(.35); }

.stars-row .star.earned {
    filter: none;
    animation: starPop .5s cubic-bezier(.34, 1.56, .64, 1) backwards;
}

@keyframes starPop {
    from { transform: scale(0) rotate(-40deg); }
}

.end-icon {
    font-size: clamp(3rem, 9vw, 4.2rem);
    margin-bottom: 0.6rem;
    animation: heroBob 2.4s ease-in-out infinite;
}

#end-title {
    font-family: var(--kids-font-title);
    font-size: clamp(1.8rem, 5.5vw, 2.4rem);
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: var(--brand);
}

.final-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink-2);
    margin: 0 0 1.6rem;
}

.final-score span {
    color: var(--accent);
    font-family: var(--kids-font-title);
    font-size: 1.45rem;
}

.action-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.btn-big {
    appearance: none;
    font-family: var(--kids-font-title);
    font-size: 1.15rem;
    font-weight: 600;
    padding: 0.8rem 1.6rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s ease, box-shadow .15s ease;
}

.btn-big.primary { background: var(--brand); color: #fff; box-shadow: 0 5px 0 #063d42; }
.btn-big.secondary { background: var(--accent); color: #4a3200; box-shadow: 0 5px 0 #b97b00; }
.btn-big.ghost { background: #fff; color: var(--brand); border: 2px solid var(--brand); box-shadow: 0 5px 0 rgba(10, 91, 99, .25); }

.btn-big:hover { transform: translateY(-2px); }
.btn-big:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }

/* ---------- Coriandoli ---------- */
.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -5vh;
    width: 10px;
    height: 15px;
    border-radius: 3px;
    animation: confettiFall linear forwards;
}

.confetti-piece.round { height: 10px; border-radius: 50%; }

@keyframes confettiFall {
    to { top: 108vh; transform: translateX(var(--drift)) rotate(var(--spin)); }
}

/* ---------- Header (bottone "Torna alle App") ---------- */
.site-header .btn {
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 14px;
    box-shadow: none;
}

/* ---------- Touch ----------
   kids-base.css impone min-height:44px a tutti i button sugli schermi
   touch: sui pulsanti tondi alzava solo l'altezza, schiacciandoli in
   ovali. Il minimo va imposto anche in larghezza. */
@media (pointer: coarse) {
    .hud-btn { min-width: 44px; min-height: 44px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .level-grid { grid-template-columns: minmax(200px, 340px); }

    .level-card {
        flex-direction: row;
        justify-content: flex-start;
        gap: 14px;
        padding: 0.8rem 1.1rem;
        text-align: left;
    }

    .level-card .level-text { align-items: flex-start; text-align: left; }
    .level-icon { font-size: 2rem; }
    .level-name { font-size: 1.15rem; }
    .level-desc { font-size: 0.85rem; }

    .hud { flex-wrap: wrap; gap: 8px; }
    .hud-progress { order: 3; width: 100%; flex-basis: 100%; }
    .hud-right { margin-left: auto; }
    .hud-pill { font-size: 1rem; padding: 0.4rem 0.8rem; }

    .listen-btn { width: 100%; padding: 0.8rem 1rem; margin-bottom: 1rem; }

    .animals-grid { gap: 8px; }
    .animals-grid.n3  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .animals-grid.n6  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .animals-grid.n12 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    .animal-card { padding: 4px 4px 3px; border-width: 2px; }
    .animal-card img { border-radius: 10px; }
}

/* Telefoni stretti: due colonne, così le figure restano riconoscibili */
@media (max-width: 380px) {
    .animals-grid.n6,
    .animals-grid.n12 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Meno animazioni se richiesto dal sistema */
@media (prefers-reduced-motion: reduce) {
    .hero-animals img,
    .bg-decor span,
    .end-icon,
    .animal-card,
    .listen-btn.pulse,
    .screen.active {
        animation: none !important;
    }
}

/* ---------- Pulsante dell'audio ----------
   Sta nell'HUD accanto al 🏠: si spegne mentre si gioca. Da spento
   resta ben visibile che è spento, altrimenti un adulto pensa che
   l'app sia rotta. */
.hud-btn.audio-btn { border-color: #ffe1a6; background: #fff8ec; }
.hud-btn.audio-btn.spento { border-color: #fecaca; background: #fef2f2; opacity: .85; }
