/* ============================================================
   NAVICELLA SPAZIALE — stile locale
   Carica prima css/kids-base.css (variabili, header, footer).
   Le parti comuni vengono da _modello/style.css; da «IL CAMPO»
   in giu' quelle proprie di questa app.
   ============================================================ */

/* ---------- 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);
    /* lo sfondo di questa app: notte stellata chiara */
    background:
        radial-gradient(620px 320px at 6% -40px, rgba(129, 140, 248, .18), transparent 60%),
        radial-gradient(720px 420px at 104% 104%, rgba(236, 72, 153, .12), transparent 60%),
        linear-gradient(180deg, #eef2ff 0%, #f5f3ff 100%);
}

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

.hero-item {
    width: clamp(62px, 12vw, 88px);
    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.6rem;
}

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

/* Lettere o numeri: due interruttori grandi */
.scelta-contenuto {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 1.6rem;
}

.contenuto-btn {
    appearance: none;
    font-family: var(--kids-font-title);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    background: #fff;
    border: 3px solid #c7d2fe;
    border-radius: 999px;
    padding: 0.6rem 1.5rem;
    min-width: 150px;
    cursor: pointer;
    box-shadow: 0 6px 0 #a5b4fc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.contenuto-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #a5b4fc; }

.contenuto-btn[aria-pressed="true"] {
    background: #4f46e5;
    border-color: #4338ca;
    color: #fff;
    box-shadow: 0 6px 0 #312e81;
}

.contenuto-icona { font-size: 1.4rem; line-height: 1; }

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

.level-card.piccoli { --lvl: #ec4899; --lvl-dark: #be185d; --lvl-soft: #fdf2f8; }
.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: 0.8rem; }

.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: #c7d2fe; 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: #e0e7ff;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(49, 46, 129, .12);
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #818cf8, #ec4899);
    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.audio-btn { border-color: #ffe1a6; background: #fff8ec; }
.hud-btn.audio-btn.spento { border-color: #fecaca; background: #fef2f2; opacity: .85; }

/* ---------- La consegna: il radar ----------
   Fondo chiaro, fuori dal campo scuro: e' la domanda, e si deve
   distinguere a colpo d'occhio dagli alieni da colpire. */
.consegna {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    min-height: 84px;
    padding: 0.6rem 3.6rem 0.6rem 0.8rem;
    margin-bottom: 0.7rem;
    background: linear-gradient(180deg, #fefce8 0%, #fff 80%);
    border: 3px solid #fde68a;
    border-radius: var(--kids-radius);
    box-shadow: var(--kids-shadow-sm);
}

.radar {
    width: 74px;
    height: 74px;
    flex-shrink: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle, transparent 54%, rgba(34, 197, 94, .25) 55%, transparent 58%),
        radial-gradient(circle, #052e16 0%, #064e3b 70%);
    border: 3px solid #16a34a;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .18), inset 0 0 14px rgba(34, 197, 94, .5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #bbf7d0;
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: 2.2rem;
    line-height: 1;
    text-shadow: 0 0 8px rgba(134, 239, 172, .9);
}

.radar.spento {
    font-size: 1.9rem;
    color: #4ade80;
}

/* Con i pallini (numeri, Piccolissimi) il radar si allarga: cifra e dado
   affiancati, abbastanza grandi da contarli. */
.radar.con-pallini {
    width: auto;
    flex-direction: row;
    gap: 10px;
    padding: 0 16px;
    border-radius: 40px;
}

.radar .pallini { --dim: 40px; --pallino: #86efac; }

.radar.sveglia { animation: sveglia .8s ease; }

@keyframes sveglia {
    20%, 60% { transform: rotate(-8deg) scale(1.1); }
    40%, 80% { transform: rotate(8deg) scale(1.1); }
}

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

.say-btn {
    position: absolute;
    top: 50%;
    right: 0.7rem;
    transform: translateY(-50%);
    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;
}

.say-btn:active { transform: translateY(-50%) scale(.9); }

/* ============================================================
   IL CAMPO
   ============================================================ */
.campo {
    position: relative;
    width: 100%;
    height: clamp(340px, 58vh, 500px);
    border-radius: 24px;
    overflow: hidden;
    background:
        radial-gradient(500px 260px at 80% 0%, rgba(168, 85, 247, .35), transparent 70%),
        radial-gradient(420px 240px at 10% 100%, rgba(56, 189, 248, .25), transparent 70%),
        linear-gradient(180deg, #0b1033 0%, #1e1b4b 100%);
    border: 4px solid #312e81;
    box-shadow: 0 8px 0 #1e1b4b, var(--kids-shadow);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Le stelle: due strati che scorrono lenti verso il basso */
.stelle,
.stelle::after {
    position: absolute;
    inset: -100% 0 0 0;
    background-image:
        radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
        radial-gradient(1px 1px at 27% 62%, #c7d2fe, transparent),
        radial-gradient(2px 2px at 44% 33%, #fff, transparent),
        radial-gradient(1px 1px at 61% 81%, #fde68a, transparent),
        radial-gradient(1.5px 1.5px at 78% 12%, #fff, transparent),
        radial-gradient(1px 1px at 88% 54%, #c7d2fe, transparent),
        radial-gradient(1.5px 1.5px at 6% 88%, #fff, transparent),
        radial-gradient(1px 1px at 53% 6%, #fff, transparent);
    background-size: 240px 240px;
    animation: scorriStelle 26s linear infinite;
    pointer-events: none;
}

.stelle::after {
    content: '';
    inset: 0;
    background-size: 170px 170px;
    opacity: .6;
    animation-duration: 16s;
}

@keyframes scorriStelle { to { transform: translateY(50%); } }

/* La flotta: in alto, centrata. Il movimento cambia col livello. */
.flotta {
    position: absolute;
    top: 7%;
    left: 4%;
    right: 4%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: clamp(8px, 2.4vw, 22px) clamp(10px, 3vw, 28px);
    z-index: 2;
}

/* Piccolissimi e Facile: un dondolio lento, il bersaglio resta facile da toccare */
.flotta.dondola { animation: dondola 3.2s ease-in-out infinite alternate; }

@keyframes dondola {
    from { transform: translateX(-10px); }
    to   { transform: translateX(10px); }
}

/* Pilota: la marcia a scatti da sala giochi */
.flotta.marcia { animation: marcia 7s steps(14, end) infinite alternate; }

@keyframes marcia {
    from { transform: translateX(-7%); }
    to   { transform: translateX(7%); }
}

/* ---------- L'alieno ---------- */
.alieno {
    --col: #22c55e;
    --col-dark: #15803d;
    appearance: none;
    position: relative;
    background: none;
    border: none;
    padding: 0;
    width: var(--alieno, 104px);
    aspect-ratio: 1 / 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: entraAlieno .55s cubic-bezier(.34, 1.56, .64, 1) backwards;
}

.flotta.n3 { --alieno: clamp(92px, 26vw, 132px); }
.flotta.n5 { --alieno: clamp(76px, 20vw, 108px); }
/* Pilota: SEMPRE una fila sola. Su due file un alieno poteva stare
   esattamente dietro un altro: il raggio si fermava sempre su quello
   davanti e, marciando tutti insieme, il bersaglio restava coperto. */
.flotta.n6 {
    --alieno: clamp(46px, 11.5vw, 96px);
    flex-wrap: nowrap;
    gap: clamp(4px, 1.6vw, 18px);
}
.flotta.esplora { --alieno: clamp(62px, 15vw, 84px); }

@keyframes entraAlieno {
    from { opacity: 0; transform: translateY(-160px) scale(.4); }
}

.alieno svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--col) 60%, transparent));
    animation: galleggia 2.2s ease-in-out infinite;
    animation-delay: var(--ritardo, 0s);
}

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

/* il simbolo sulla pancia */
.alieno .simbolo {
    position: absolute;
    left: 50%;
    top: 62%;
    transform: translate(-50%, -50%);
    width: 46%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--col-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: calc(var(--alieno, 104px) * .3);
    line-height: 1;
    color: #1e1b4b;
    pointer-events: none;
}

.alieno:hover svg { transform: scale(1.05); }

/* Lo scudo: il bersaglio sbagliato trema, poi si spegne al suo posto */
.alieno.wrong { animation: shakeAlieno .5s ease; }
.alieno.wrong::after {
    content: '';
    position: absolute;
    inset: -6%;
    border-radius: 50%;
    border: 3px solid rgba(147, 197, 253, .9);
    box-shadow: 0 0 16px rgba(147, 197, 253, .8), inset 0 0 14px rgba(147, 197, 253, .6);
    pointer-events: none;
}

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

/* animation:none e' obbligatorio (GUIDA-APP-KIDS.md, cap. 3): togliendo
   .wrong ripartirebbe l'animazione d'ingresso, da opacity 0. */
.alieno.fuori {
    opacity: .3;
    pointer-events: none;
    filter: grayscale(1);
    animation: none;
}
.alieno.fuori svg { animation: none; filter: none; }

.alieno.locked { pointer-events: none; }

/* Colpito: si gonfia, lampeggia bianco e sparisce in stelline */
.alieno.colpito {
    pointer-events: none;
    animation: esplode .6s ease-out forwards;
}

@keyframes esplode {
    0%   { transform: scale(1); filter: brightness(1); }
    25%  { transform: scale(1.25); filter: brightness(2.2); }
    100% { transform: scale(.2); opacity: 0; filter: brightness(2.5); }
}

/* L'alieno dell'esplorazione che ritorna dopo l'esplosione */
.alieno.torna { animation: entraAlieno .55s cubic-bezier(.34, 1.56, .64, 1); }

/* ---------- La navicella ---------- */
.navicella {
    position: absolute;
    bottom: 12px;
    left: 50%;
    width: clamp(64px, 14vw, 84px);
    aspect-ratio: 1 / 1.1;
    transform: translateX(-50%);
    transition: left .32s cubic-bezier(.22, 1, .36, 1);
    z-index: 3;
    pointer-events: none;
}

.navicella.libera-guida { transition: none; }

/* In due: la navicella che aspetta il suo turno resta al suo posto,
   tenue e sotto l'altra, con la fiamma quasi spenta. */
.navicella.in-attesa { opacity: .42; filter: saturate(.55); z-index: 2; transition: left .32s cubic-bezier(.22, 1, .36, 1), opacity .3s ease; }
.navicella.in-attesa .fiamma { animation: none; opacity: .35; }
.navicella[hidden] { display: none; }

/* Di chi è il turno, nel colore delle ali della navicella che gioca */
.turno {
    align-self: center;
    margin: 0 auto 0.5rem;
    padding: 0.35rem 1.1rem;
    border-radius: 999px;
    background: var(--tinta, #ec4899);
    border: 3px solid var(--tinta-scura, #9d174d);
    box-shadow: 0 4px 0 var(--tinta-scura, #9d174d);
    color: #fff;
    font-family: var(--kids-font-title);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    width: fit-content;
    max-width: 100%;
}
.turno[hidden] { display: none; }
.turno.nuovo { animation: turnoPop .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes turnoPop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.navicella svg { width: 100%; height: 100%; display: block; overflow: visible; }

.navicella .fiamma { transform-origin: 50% 0; animation: fiamma .18s ease-in-out infinite alternate; }

@keyframes fiamma {
    from { transform: scaleY(.75); opacity: .85; }
    to   { transform: scaleY(1.15); opacity: 1; }
}

.navicella.spara { animation: rinculo .2s ease; }
@keyframes rinculo { 40% { transform: translateX(-50%) translateY(6px); } }

/* Il raggio laser */
.laser {
    position: absolute;
    width: 8px;
    margin-left: -4px;
    border-radius: 4px;
    background: linear-gradient(180deg, #fff 0%, #f0abfc 30%, #ec4899 100%);
    box-shadow: 0 0 10px #f0abfc, 0 0 22px #ec4899;
    transform-origin: 50% 100%;
    animation: laser .32s ease-out forwards;
    z-index: 2;
    pointer-events: none;
}

@keyframes laser {
    0%   { transform: scaleY(0); opacity: 1; }
    45%  { transform: scaleY(1); opacity: 1; }
    100% { transform: scaleY(1); opacity: 0; }
}

/* Scintille dell'esplosione */
.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkleFly .7s ease-out forwards;
    z-index: 4;
}

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

/* ---------- I comandi del Pilota ---------- */
.comandi {
    display: grid;
    grid-template-columns: 1fr 1.6fr 1fr;
    gap: 12px;
    width: 100%;
    margin-top: 0.8rem;
}

.comandi[hidden] { display: none; }

/* Durante la partita la freccia «torna su» del sito (js/torna-su.js) non
   serve e sul telefono finiva proprio sopra il tasto ▶. */
body:has(#game-screen.active) .to-top,
body:has(#free-screen.active) .to-top { display: none !important; }

/* Nel Pilota il campo e' piu' basso: campo e comandi devono stare
   insieme nello schermo, senza dover scorrere per guidare. */
.campo.pilota { height: clamp(260px, 46vh, 440px); }

.cmd-btn {
    appearance: none;
    min-height: 72px;
    border-radius: var(--kids-radius);
    font-family: var(--kids-font-title);
    font-weight: 700;
    font-size: 2rem;
    color: #fff;
    background: #4f46e5;
    border: 3px solid #4338ca;
    box-shadow: 0 7px 0 #312e81;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cmd-btn.fuoco {
    font-size: 1.6rem;
    letter-spacing: 1px;
    background: radial-gradient(circle at 50% 35%, #f87171, #dc2626);
    border-color: #b91c1c;
    box-shadow: 0 7px 0 #7f1d1d;
}

.cmd-btn:active,
.cmd-btn.premuto { transform: translateY(5px); box-shadow: 0 2px 0 #312e81; }
.cmd-btn.fuoco:active,
.cmd-btn.fuoco.premuto { box-shadow: 0 2px 0 #7f1d1d; }

/* ---------- 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; }
.feedback-msg.info span    { color: #3730a3; border: 2px solid #c7d2fe; background: #eef2ff; }

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

/* ---------- I pallini (dado) ---------- */
.pallini {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: var(--dim, 30px);
    aspect-ratio: 1;
}

.pallini i { display: block; border-radius: 50%; aspect-ratio: 1; }
.pallini i.si { background: var(--pallino, #dc2626); }

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

    .contenuto-btn { min-width: 0; flex: 1; max-width: 170px; padding: 0.6rem 1rem; font-size: 1.15rem; }

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

    .consegna { min-height: 76px; }
    .radar { width: 64px; height: 64px; font-size: 1.9rem; }

    .campo { height: clamp(330px, 56vh, 440px); border-radius: 18px; }
    .campo.pilota { height: clamp(220px, 34vh, 360px); }
    .flotta.n6 { left: 2%; right: 2%; --alieno: clamp(46px, 13vw, 96px); gap: 3px; }

    .cmd-btn { min-height: 64px; }
}

@media (max-width: 380px) {
    .flotta.n5 { --alieno: 74px; }
}

/* Meno animazioni se richiesto dal sistema */
@media (prefers-reduced-motion: reduce) {
    .hero-item,
    .bg-decor span,
    .end-icon,
    .stelle, .stelle::after,
    .flotta,
    .alieno, .alieno svg,
    .navicella .fiamma, .turno.nuovo,
    .screen.active {
        animation: none !important;
    }
}
