/* ============================================================
   LO XILOFONO DEGLI ANIMALI — stile locale (dal modello delle app kids)
   Carica prima css/kids-base.css (variabili, header, footer).

   Questo file contiene le parti che si ripetono in ogni app kids:
   schermate, HUD, card dei livelli, opzioni, riscontro, risultato,
   coriandoli, e in fondo le parti di questa app: lo xilofono, il palco
   con l'onda del suono, le due carte di «Grave o acuto?».
   ============================================================ */

/* ---------- 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);
    /* Sfondo della sala da concerto: lilla in alto, cielo in basso */
    background:
        radial-gradient(620px 320px at 6% -40px, rgba(168, 85, 247, .14), transparent 60%),
        radial-gradient(720px 420px at 104% 104%, rgba(56, 189, 248, .16), transparent 60%),
        linear-gradient(180deg, #faf5ff 0%, #eff6ff 100%);
}

/* Decorazioni che galleggiano sullo sfondo */
.bg-decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.bg-decor span {
    position: absolute;
    opacity: .13;
    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-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2.5vw, 18px);
    margin-bottom: 0.9rem;
    min-height: 92px;
}

.hero-item {
    width: clamp(62px, 12vw, 88px);
    aspect-ratio: 1;
    border-radius: 20px;
    background: #fff;
    border: 3px solid #d7efec;
    box-shadow: 0 5px 0 rgba(10, 91, 99, .12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.9rem, 6vw, 2.6rem);
    line-height: 1;
    animation: heroBob 2.6s ease-in-out infinite;
}

.hero-item:nth-child(2) { animation-delay: .35s; }
.hero-item:nth-child(3) { animation-delay: .7s; }
.hero-item:nth-child(4) { animation-delay: 1.05s; }

@keyframes heroBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

.game-title {
    font-family: var(--kids-font-title);
    font-size: clamp(2rem, 5.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 delle modalità */
.level-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 300px));
    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: 1rem 1.1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    text-align: left;
    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);
}

/* Un colore per modalità */
.level-card.medium { --lvl: #f59e0b; --lvl-dark: #b45309; --lvl-soft: #fffbeb; }
.level-card.hard   { --lvl: #8b5cf6; --lvl-dark: #6d28d9; --lvl-soft: #f5f3ff; }
.level-card.libera { --lvl: #0ea5e9; --lvl-dark: #0369a1; --lvl-soft: #f0f9ff; }

.level-card.wide { grid-column: 1 / -1; }

.level-icon { font-size: 2.2rem; line-height: 1; flex-shrink: 0; }

.level-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.level-name {
    font-family: var(--kids-font-title);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}

.level-desc {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink-2);
}

/* ---------- Scheda per gli 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;
}

.free-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;
}

.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, #38bdf8, #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; }

/* ---------- Consegna ---------- */
.prompt-card {
    position: relative;
    background: #fff;
    border: 3px solid #d7efec;
    border-radius: var(--kids-radius);
    box-shadow: var(--kids-shadow-sm);
    padding: 1rem 3.6rem 1rem 1.4rem;
    width: 100%;
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Ripete la consegna a voce: per chi non sa ancora leggere */
.say-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #ffe1a6;
    background: #fff8ec;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: var(--kids-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: transform .15s ease;
}

.say-btn:hover { transform: scale(1.1); }
.say-btn:active { transform: scale(0.9); }

.prompt-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 0;
}

.prompt-text {
    font-family: var(--kids-font-title);
    font-size: clamp(1.15rem, 3.6vw, 1.6rem);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
}

/* ---------- Opzioni ---------- */
.options-grid {
    display: grid;
    gap: clamp(10px, 2.4vw, 18px);
    justify-content: center;
    width: 100%;
    margin-bottom: 0.4rem;
}

.options-grid.n3 { grid-template-columns: repeat(3, minmax(0, 180px)); }
.options-grid.n4 { grid-template-columns: repeat(4, minmax(0, 150px)); }
.options-grid.n6 { grid-template-columns: repeat(3, minmax(0, 160px)); }

.option-btn {
    appearance: none;
    position: relative;
    aspect-ratio: 1;
    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;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    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); }
}

.option-btn:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: #bfe6e0;
    box-shadow: 0 10px 0 rgba(10, 91, 99, .10), var(--kids-shadow);
}

.option-btn:active { transform: scale(.94); box-shadow: 0 2px 0 rgba(10, 91, 99, .10); }

/* Stati della risposta: sempre questi quattro, in tutte le app */
.option-btn.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); }
}

.option-btn.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    animation: shakeCard .5s ease;
}

@keyframes shakeCard {
    20%, 60% { transform: translateX(-9px); }
    40%, 80% { transform: translateX(9px); }
}

/* Qui c'erano `.reveal` (la risposta giusta che si accendeva e pulsava)
   e `.dim` (le altre che si spegnevano attorno). Erano i pezzi con cui
   il modello rispondeva al posto del bambino dopo un errore: tolti.
   Sbagliando si ritenta, e la risposta giusta si accende solo quando è
   il bambino a toccarla. */

.option-btn.locked { pointer-events: none; }

/* Una scelta già provata e sbagliata. Resta AL SUO POSTO — farla
   sparire sposterebbe le altre sotto il dito, e il bambino toccherebbe
   quella arrivata al posto di quella che stava guardando — ma si spegne
   e non si tocca più. Niente croce e niente rosso acceso: si è già
   detto che non andava, e il giro non è finito. */
.option-btn.fuori {
    opacity: .3;
    pointer-events: none;
    filter: grayscale(1);
    box-shadow: none;
    transform: none;
}

/* Il contenuto della card: l'animale e il suo nome. L'elefante è
   disegnato più grande dell'uccellino: anche la misura dice «grave». */
.opt-figure {
    line-height: 1;
    font-size: clamp(3.2rem, 13vw, 5.4rem);
}

.option-btn.acuto .opt-figure { font-size: clamp(2rem, 7.5vw, 3.1rem); }

.opt-tasto {
    font-family: var(--kids-font-body);
    font-size: .8rem;
    font-weight: 800;
    color: var(--ink-2);
}

.opt-name {
    font-family: var(--kids-font-title);
    font-size: clamp(.85rem, 2.6vw, 1.05rem);
    font-weight: 600;
    color: var(--ink);
}

/* 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; }
}

/* ---------- Riscontro ---------- */
.feedback-msg {
    min-height: 3.2em;
    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; }

/* 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 #d7efec;
    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. NON togliere. */
@media (pointer: coarse) {
    .hud-btn, .say-btn { min-width: 44px; min-height: 44px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .level-grid { grid-template-columns: minmax(200px, 340px); }

    .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; }

    .prompt-card { padding: 0.9rem 3.2rem 0.9rem 1rem; }
    .say-btn { top: 0.6rem; right: 0.6rem; }

    /* Le griglie cambiano forma, non solo scala */
    .options-grid.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .options-grid.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .options-grid.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    .option-btn { border-width: 2px; }
}

@media (max-width: 380px) {
    .options-grid.n6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Meno animazioni se richiesto dal sistema */
@media (prefers-reduced-motion: reduce) {
    .hero-item,
    .bg-decor span,
    .end-icon,
    .option-btn,
    .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; }

/* ============================================================
   LE PARTI DI QUESTA APP
   ============================================================ */

/* I colori delle note sono quelli dei tubi sonori da classe:
   Do rosso, Re arancio, Mi giallo, Fa verde, Sol azzurro, La blu,
   Si viola, e il Do alto di nuovo rosso (è sempre un Do). */
.game-container {
    --n0: #ef4444; --n1: #f97316; --n2: #facc15; --n3: #22c55e;
    --n4: #06b6d4; --n5: #3b82f6; --n6: #a855f7; --n7: #ef4444;
    --legno: #c08a4e;
    --legno-scuro: #8a5a2b;
}

.level-card.easy   { --lvl: #a855f7; --lvl-dark: #7e22ce; --lvl-soft: #faf5ff; }
.level-card.medium { --lvl: #f59e0b; --lvl-dark: #b45309; --lvl-soft: #fffbeb; }
.level-card.brani  { --lvl: #ec4899; --lvl-dark: #be185d; --lvl-soft: #fdf2f8; }

/* ---------- Tastiera, nella schermata iniziale ---------- */
.keys-hint {
    margin: 1.4rem 0 0;
    font-weight: 700;
    color: var(--ink-2);
    font-size: .95rem;
    line-height: 2;
}

kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: .05em .4em;
    border: 2px solid #c7d2fe;
    border-bottom-width: 4px;
    border-radius: 8px;
    background: #fff;
    font-family: var(--kids-font-title);
    font-weight: 700;
    color: var(--ink);
    line-height: 1.4;
}

/* ---------- Che cosa si vede in ogni modalità ---------- */
#game-screen .free-pill { display: none; }
#game-screen.libera .free-pill { display: block; }
#game-screen.libera .score-pill,
#game-screen.libera .hud-progress,
#game-screen.libera .prompt-card { display: none; }
#game-screen.libera .hud-right { margin-left: auto; }

#game-screen .options-grid { display: none; }
#game-screen.grave .options-grid { display: grid; }
#game-screen.grave .xilofono { display: none; }

/* Il 🎤 «Senti il canto» c'è solo mentre si rifà un brano */
.canto-btn { right: auto; left: .75rem; border-color: #fbcfe8; background: #fdf2f8; }
#game-screen .canto-btn { display: none; }
#game-screen.musichetta:not(.scegli):not(.concerto) .canto-btn { display: flex; }
#game-screen.musichetta .prompt-card { padding-left: 3.6rem; }

/* ---------- I pulsanti a due o tre scelte (strumento, come sentire) ---------- */
.strumenti {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: .7rem;
}

.strumento-btn,
.come-btn {
    appearance: none;
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
    background: #fff;
    border: 3px solid #e9d5ff;
    border-radius: 999px;
    padding: .45rem 1rem;
    box-shadow: 0 4px 0 #d8b4fe;
    cursor: pointer;
}

.strumento-btn[aria-pressed="true"],
.come-btn[aria-pressed="true"] {
    background: #a855f7;
    border-color: #7e22ce;
    color: #fff;
    box-shadow: 0 4px 0 #6b21a8;
}

.strumento-btn:active,
.come-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #6b21a8; }

#game-screen .pallini { display: none; }
#game-screen.ripeti .pallini,
#game-screen.musichetta .pallini { display: flex; }

/* Musichette, prima di cominciare: si sceglie il brano */
#game-screen.scegli .options-grid { display: grid; }
#game-screen.scegli .xilofono,
#game-screen.scegli .palco,
#game-screen.scegli .score-pill,
#game-screen.scegli .hud-progress { display: none; }
#game-screen.scegli .hud-right,
#game-screen.concerto .hud-right { margin-left: auto; }

/* «Ascoltale tutte»: si ascolta e basta, niente punteggio */
#game-screen.concerto .score-pill,
#game-screen.concerto .hud-progress,
#game-screen.concerto .pallini { display: none; }

.option-btn.tutte { border-color: #fcd34d; background: #fffbeb; }

/* Diciannove brani e i due «tutte»: sette file piene da tre */
.options-grid.brani { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 600px; }
.options-grid.brani .opt-name { font-size: clamp(.72rem, 2.5vw, 1rem); }


/* Come sentire il brano scelto: a pezzi, tutto di seguito, cantato */
.come-fare {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: .3rem;
}
.options-grid.brani .opt-figure { font-size: clamp(2.4rem, 9vw, 3.6rem); }
.options-grid.brani .opt-name { line-height: 1.15; }

/* ---------- Il palco: chi canta, e il suono disegnato ---------- */
.palco {
    position: relative;
    width: 100%;
    background: #fff;
    border: 3px solid #e9d5ff;
    border-radius: var(--kids-radius);
    box-shadow: var(--kids-shadow-sm);
    padding: .6rem .8rem .5rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    row-gap: 4px;
}

.palco-animale {
    grid-row: 1 / 3;
    font-size: clamp(3rem, 12vw, 4.6rem);
    line-height: 1;
    width: 1.3em;
    text-align: center;
}

.palco-animale.canta { animation: canta .45s ease; }

@keyframes canta {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.22) rotate(-6deg); }
    70%  { transform: scale(.95) rotate(3deg); }
    100% { transform: scale(1); }
}

.palco-nome {
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    color: var(--brand);
    text-align: left;
    min-height: 1.3em;
}

/* L'onda: più la nota è acuta, più è fitta. La disegna script.js */
.onda {
    width: 100%;
    height: clamp(64px, 14vw, 96px);
    display: block;
    border-radius: 12px;
    background: #faf5ff;
}

.pallini {
    grid-column: 1 / -1;
    justify-content: center;
    gap: 10px;
    margin-top: .3rem;
    min-height: 26px;
}

.pallino {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid #d8b4fe;
    background: #fff;
}

.pallino.fatto { background: #a855f7; border-color: #7e22ce; }

/* ---------- Grave o acuto: due carte ---------- */
.options-grid.n2 { grid-template-columns: repeat(2, minmax(0, 220px)); }

/* ---------- Lo xilofono ---------- */
.xilofono {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-items: center;
    gap: clamp(5px, 1.3vw, 12px);
    height: clamp(210px, 34vw, 280px);
    padding: 14px clamp(8px, 2vw, 16px);
    border-radius: 24px;
    background: linear-gradient(180deg, var(--legno) 0%, var(--legno-scuro) 100%);
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 7px 0 #5f3c1a, var(--kids-shadow-sm);
    margin-bottom: .4rem;
}

.barra {
    --c: var(--n0);
    appearance: none;
    position: relative;
    height: var(--h, 100%);
    min-height: 0;
    border: 3px solid rgba(15, 23, 42, .28);
    border-radius: 14px;
    padding: 12px 2px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .5) 0 10%, rgba(255, 255, 255, 0) 32%),
        var(--c);
    box-shadow: 0 6px 0 rgba(15, 23, 42, .3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
    font-family: var(--kids-font-title);
    color: var(--ink);
}

/* i due chiodini che tengono la barra, come su uno xilofono vero */
.barra::before,
.barra::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 9px;
    height: 9px;
    margin-left: -4.5px;
    border-radius: 50%;
    background: #e5e7eb;
    border: 2px solid rgba(15, 23, 42, .35);
}

.barra::before { top: 3px; }
.barra::after  { bottom: 3px; }

.barra-animale {
    font-size: clamp(1.4rem, 4.4vw, 2.3rem);
    line-height: 1;
    margin-top: 6px;
}

.barra-nota {
    font-size: clamp(.8rem, 2.4vw, 1.15rem);
    font-weight: 700;
    background: rgba(255, 255, 255, .9);
    border-radius: 999px;
    padding: 2px 7px 1px;
}

.barra-tasto {
    font-family: var(--kids-font-body);
    font-size: clamp(.68rem, 1.8vw, .85rem);
    font-weight: 900;
    background: rgba(255, 255, 255, .8);
    border-radius: 6px;
    padding: 1px 5px;
    margin-bottom: 9px;
    white-space: nowrap;
}

.barra:hover { filter: brightness(1.06); }

.barra.colpita {
    transform: translateY(5px);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .3);
    filter: brightness(1.2) saturate(1.15);
}

/* la nota che il gioco fa sentire in «Ripeti» */
.barra.accesa {
    filter: brightness(1.2);
    box-shadow: 0 0 0 4px #fff, 0 0 26px 10px var(--c);
}

/* i cerchi del suono che escono dalla barra */
.anello {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border-radius: 50%;
    border: 4px solid var(--c);
    pointer-events: none;
    animation: anello .75s ease-out forwards;
    z-index: 2;
}

@keyframes anello {
    from { transform: scale(.4); opacity: .9; }
    to   { transform: scale(2.6); opacity: 0; }
}

.notina {
    position: absolute;
    left: 50%;
    top: 10%;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--c);
    -webkit-text-stroke: 1px rgba(15, 23, 42, .35);
    pointer-events: none;
    animation: notina 1s ease-out forwards;
    z-index: 3;
}

@keyframes notina {
    from { transform: translate(-50%, 0) scale(.8); opacity: 1; }
    to   { transform: translate(calc(-50% + var(--dx, 0px)), -90px) scale(1.2); opacity: 0; }
}

.xilofono.locked .barra { cursor: default; }

/* Su un telefono otto barre in fila sarebbero larghe meno di 44 px:
   le figure non si rimpiccioliscono, cambia la disposizione. */
@media (max-width: 520px) {
    .xilofono {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        height: auto;
        row-gap: 14px;
    }
    .barra { height: var(--hpx); }
    .options-grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .options-grid.brani { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .options-grid.brani .option-btn { padding: 4px; }
    .palco { padding: .5rem .6rem .4rem; margin-bottom: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
    .palco-animale.canta { animation: none !important; }
    .anello, .notina { display: none; }
}

/* ---------- La pianola ----------
   Otto tasti bianchi in griglia, con in fondo una striscia del colore
   della nota; i cinque neri sopra, messi a cavallo dei bianchi. */
/* Due ottave: quindici bianchi. Sul telefono la pianola è più larga
   dello schermo e si scorre di lato dentro il suo contenitore (la
   pagina no: niente scorrimento orizzontale della pagina). */
.pianola-scorre {
    display: none;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    margin-bottom: .4rem;
}

.pianola {
    display: grid;
    position: relative;
    width: 100%;
    min-width: 0;          /* su computer sta tutta nel suo spazio, senza scorrere */
    height: clamp(200px, 32vw, 260px);
    padding: 12px 10px 14px;
    border-radius: 22px;
    background: linear-gradient(180deg, #334155 0%, #0f172a 100%);
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .15), 0 7px 0 #020617, var(--kids-shadow-sm);
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 3px;
    box-sizing: border-box;
}

#game-screen.piano .pianola-scorre { display: block; }

/* La barra di scorrimento grigia sotto la pianola compariva su computer
   (la pianola era larga 740 px, il riquadro qualche pixel meno). Ora si
   allarga solo dove lo schermo è stretto, e lì si scorre col dito: la
   barra non si mostra, il bordo tagliato dei tasti dice già che continua. */
.pianola-scorre { scrollbar-width: none; }
.pianola-scorre::-webkit-scrollbar { display: none; }

@media (max-width: 760px) {
    .pianola { min-width: 740px; }   /* 15 bianchi da almeno 44 px, regola del tocco */
}
#game-screen.piano .xilofono { display: none; }
#game-screen.grave .strumenti,
#game-screen.grave .pianola-scorre,
#game-screen.scegli .strumenti,
#game-screen.scegli .pianola-scorre { display: none; }

.tasto {
    appearance: none;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-family: var(--kids-font-title);
    transition: transform .06s ease, background .06s ease;
    padding: 0 0 10px;
    min-width: 0;
    touch-action: pan-x;   /* si scorre di lato anche partendo da un tasto */
}

.tasto.bianco {
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    border: 2px solid #cbd5e1;
    border-radius: 0 0 10px 10px;
    box-shadow: inset 0 -9px 0 var(--c), 0 4px 0 #94a3b8;
    color: var(--ink);
    padding-bottom: 16px;
}

.tasto.nero {
    position: absolute;
    top: 12px;
    z-index: 3;
    height: 58%;
    width: calc((100% - 20px) / 15 * .62);
    left: calc(10px + (100% - 20px) * var(--pos) / 15 - (100% - 20px) / 15 * .31);
    background: linear-gradient(180deg, #475569 0%, #0f172a 100%);
    border: 2px solid #020617;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 0 #020617;
    color: #fff;
    padding-bottom: 6px;
}

/* l'animale sta in basso, sotto la fine dei tasti neri */
.tasto-animale { font-size: clamp(1.1rem, 3.6vw, 2rem); line-height: 1; }

.tasto-nota {
    font-size: clamp(.68rem, 2.1vw, 1rem);
    font-weight: 700;
    background: rgba(255, 255, 255, .9);
    color: var(--ink);
    border-radius: 999px;
    padding: 1px 6px 0;
}

.tasto.nero .tasto-nota { background: rgba(255, 255, 255, .15); color: #fff; font-size: clamp(.5rem, 1.5vw, .72rem); padding: 1px 3px 0; }

.tasto-tasto {
    font-family: var(--kids-font-body);
    font-size: clamp(.6rem, 1.6vw, .8rem);
    font-weight: 900;
    opacity: .75;
    white-space: nowrap;
}

.tasto.nero .tasto-tasto { font-size: clamp(.5rem, 1.4vw, .7rem); }

.tasto.bianco.colpita { transform: translateY(3px); background: #e2e8f0; box-shadow: inset 0 -9px 0 var(--c), 0 1px 0 #94a3b8; }
.tasto.nero.colpita { transform: translateY(3px); background: #64748b; box-shadow: 0 1px 0 #020617; }
.tasto.bianco.accesa { box-shadow: inset 0 -9px 0 var(--c), 0 0 0 3px var(--c), 0 0 24px 8px var(--c); z-index: 1; }
.tasto.nero.accesa { box-shadow: 0 0 0 3px #fbbf24, 0 0 24px 8px #fbbf24; }

.tasto .anello { border-color: var(--c); }
.tasto.nero .anello { border-color: #fbbf24; }
.tasto .notina { top: 30%; }
.pianola.locked .tasto { cursor: default; }


/* ---------- «↩ 🎼 Musichette»: tornare all'elenco dei brani ----------
   Solo dentro un brano (a pezzi, intero o cantato), non nell'elenco. */
.torna-musichette {
    display: none;
    appearance: none;
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    background: #ec4899;
    border: 3px solid #be185d;
    border-radius: 999px;
    padding: .35rem .9rem;
    box-shadow: 0 4px 0 #9d174d;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
}

.torna-musichette:active { transform: translateY(3px); box-shadow: 0 1px 0 #9d174d; }
#game-screen.musichetta:not(.scegli) .torna-musichette { display: inline-flex; align-items: center; }
/* ---------- «🔁 Ascolta di nuovo» ----------
   C'è dove c'è qualcosa da riascoltare: Ripeti, Grave o acuto?, e dentro
   un brano. Non in Suona (lì non c'è niente da rifare) né nell'elenco. */
.ascolta-di-nuovo {
    display: none;
    appearance: none;
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
    background: #fff8ec;
    border: 3px solid #fbbf24;
    border-radius: 999px;
    padding: .35rem .9rem;
    box-shadow: 0 4px 0 #d97706;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    align-items: center;
}

.ascolta-di-nuovo:active { transform: translateY(3px); box-shadow: 0 1px 0 #d97706; }
#game-screen.ripeti .ascolta-di-nuovo,
#game-screen.grave .ascolta-di-nuovo,
#game-screen.musichetta:not(.scegli) .ascolta-di-nuovo { display: inline-flex; }

/* Sul telefono i pulsanti dell'HUD vanno a capo tutti insieme, a destra */
@media (max-width: 640px) {
    #game-screen .hud-right { flex-wrap: wrap; justify-content: flex-end; }
    .ascolta-di-nuovo, .torna-musichette { font-size: .9rem; padding: .3rem .7rem; }
}