/* ============================================================
   TUTTO IN VALIGIA — stile locale
   Carica prima css/kids-base.css (variabili, header, footer).
   Le convenzioni condivise sono in GUIDA-APP-KIDS.md.

   NOTA IMPORTANTE: la valigia NON deve mai mostrare la sagoma di ciò
   che ci va dentro. La versione precedente aveva
       .item-slot::after { content: attr(data-icon); }
   e con quella riga il gioco diventava accoppiare due figure uguali,
   non scegliere. Se qualcuno la rimette, il gioco perde il senso.
   ============================================================ */

/* JS accende e spegne i posti con `hidden`: senza questa riga i
   display qui sotto lo scavalcherebbero. NON togliere. */
[hidden] { display: none !important; }

/* ---------- 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(560px 300px at 3% -40px, rgba(56, 189, 248, .14), transparent 62%),
        radial-gradient(560px 320px at 99% 4%, rgba(251, 191, 36, .13), transparent 62%),
        linear-gradient(180deg, #f0f9ff 0%, #fffbeb 55%, #ecfeff 100%);
}

.bg-decor { position: absolute; inset: 0; pointer-events: none; z-index: 0; }

.bg-decor span {
    position: absolute;
    opacity: .10;
    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: 780px;
    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 #bae6fd;
    box-shadow: 0 5px 0 rgba(3, 105, 161, .15);
    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; border-color: #e0e7ff; }
.hero-item:nth-child(3) { animation-delay: .7s; border-color: #cbd5e1; }
.hero-item:nth-child(4) { animation-delay: 1.05s; border-color: #bbf7d0; }

@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.2rem;
}

/* ---------- Selettore della lingua ---------- */
.lang-switch {
    display: flex;
    gap: 6px;
    margin-bottom: 1.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.lang-btn {
    appearance: none;
    border: 2px solid #d7efec;
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-family: var(--kids-font-body);
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--ink-2);
    cursor: pointer;
    box-shadow: var(--kids-shadow-sm);
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.lang-btn:hover { transform: translateY(-2px); }
.lang-btn.active { border-color: var(--brand); background: #f0fdfa; color: var(--brand); }

.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); }

/* dal più semplice al più difficile */
.level-card.serve   { --lvl: #22c55e; --lvl-dark: #15803d; --lvl-soft: #f0fdf4; }
.level-card.intruso { --lvl: #f59e0b; --lvl-dark: #b45309; --lvl-soft: #fffbeb; }
.level-card.meteo   { --lvl: #0ea5e9; --lvl-dark: #0369a1; --lvl-soft: #f0f9ff; }
.level-card.sceglie { --lvl: #8b5cf6; --lvl-dark: #6d28d9; --lvl-soft: #f5f3ff; }

.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;
}

.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, #fbbf24);
    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.1rem;
    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 meta e la 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: 8px;
}

.meta { display: flex; align-items: center; justify-content: center; gap: 10px; }
.meta-icona { font-size: clamp(1.8rem, 6vw, 2.4rem); line-height: 1; }

.meta-nome {
    font-family: var(--kids-font-title);
    font-size: clamp(1.05rem, 3.4vw, 1.4rem);
    font-weight: 700;
    color: var(--ink);
}

.prompt-text {
    font-family: var(--kids-font-title);
    font-size: clamp(.95rem, 3vw, 1.2rem);
    font-weight: 600;
    color: var(--ink-2);
    line-height: 1.3;
}

.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.1rem;
    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); }

/* ---------- LA VALIGIA ----------
   È uno spazio aperto, non caselle: dentro non c'è nessun
   suggerimento su che cosa ci vada messo. */
.valigia {
    position: relative;
    width: 100%;
    max-width: 460px;
    min-height: 150px;
    margin: 0 auto 1.2rem;
    background: linear-gradient(180deg, #a16207 0%, #854d0e 100%);
    border: 5px solid #713f12;
    border-radius: 18px;
    box-shadow: 0 8px 0 #57310c, var(--kids-shadow);
    padding: 16px 14px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

/* il manico, così si capisce che è una valigia anche senza scritte */
.valigia-manico {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 76px;
    height: 18px;
    border: 5px solid #713f12;
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    background: transparent;
}

.valigia-dentro {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 8px;
    min-height: 110px;
    border-radius: 12px;
    background: rgba(255, 248, 236, .35);
    border: 3px dashed rgba(255, 248, 236, .55);
    padding: 8px;
}

.in-valigia {
    font-size: clamp(1.7rem, 6vw, 2.3rem);
    line-height: 1;
    animation: entra .45s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes entra {
    from { opacity: 0; transform: translateY(-24px) scale(.5) rotate(-12deg); }
}

/* Quando una cosa è in mano, la valigia si offre */
.valigia.waiting { animation: valigiaWait 1.4s ease-in-out infinite; }

@keyframes valigiaWait {
    0%, 100% { box-shadow: 0 8px 0 #57310c, 0 0 0 0 rgba(254, 168, 0, .5); }
    50%      { box-shadow: 0 8px 0 #57310c, 0 0 0 12px rgba(254, 168, 0, 0); }
}

.valigia.over { transform: translateY(-4px) scale(1.02); border-color: var(--accent); }

.valigia.wrong { border-color: #ef4444; animation: shakeCard .5s ease; }

@keyframes shakeCard {
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.valigia.pronta { border-color: #22c55e; box-shadow: 0 8px 0 #15803d, var(--kids-shadow); }

/* I posti: si vedono solo dove il numero conta davvero */
.valigia-posti {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.posto {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 248, 236, .3);
    border: 2px solid rgba(255, 248, 236, .7);
    transition: background .25s ease;
}

.posto.pieno { background: #fbbf24; border-color: #fde68a; }

/* ---------- La roba da scegliere ---------- */
.roba-card {
    width: 100%;
    background: #fff;
    border: 3px solid #e6f2f0;
    border-radius: var(--kids-radius);
    box-shadow: var(--kids-shadow-sm);
    padding: 12px;
}

.roba {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2.2vw, 14px);
    min-height: 100px;
}

.cosa {
    appearance: none;
    position: relative;
    width: clamp(84px, 23vw, 116px);
    background: #fff;
    border: 3px solid #e6f2f0;
    border-radius: var(--kids-radius-sm);
    box-shadow: 0 5px 0 rgba(10, 91, 99, .10), var(--kids-shadow-sm);
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0.7rem 0.4rem;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
    animation: cardIn .35s cubic-bezier(.34, 1.56, .64, 1) backwards;
}

@keyframes cardIn { from { opacity: 0; transform: scale(.6); } }

.cosa-icona { font-size: clamp(1.9rem, 7vw, 2.6rem); line-height: 1; }

.cosa-nome {
    font-family: var(--kids-font-title);
    font-size: clamp(.72rem, 2.4vw, .9rem);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.15;
}

.cosa:hover {
    transform: translateY(-5px);
    border-color: #bfe6e0;
    box-shadow: 0 10px 0 rgba(10, 91, 99, .10), var(--kids-shadow);
}

.cosa:active { transform: scale(.95); box-shadow: 0 2px 0 rgba(10, 91, 99, .10); }

.cosa.chosen {
    border-color: var(--accent);
    background: #fff8ec;
    transform: translateY(-6px) scale(1.05);
    box-shadow: 0 10px 0 #b97b00, var(--kids-shadow);
    z-index: 2;
}

.cosa.dragging { opacity: .35; }
.cosa.wrong { border-color: #ef4444; background: #fef2f2; animation: shakeCard .5s ease; }

/* Una cosa già provata, che resta a casa. Non sparisce — toglierla
   sposterebbe le altre proprio mentre il dito sta scendendo — ma si
   spegne e non si tocca più. Niente rosso e niente croce: si è già
   spiegato perché, e il giro non è finito, si riprova sulle altre. */
.cosa.fuori {
    opacity: .3;
    pointer-events: none;
    filter: grayscale(1);
    box-shadow: none;
    transform: none;
}

/* ---------- Riscontro ---------- */
.feedback-msg {
    min-height: 3.6em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--kids-font-title);
    font-size: clamp(1rem, 3.1vw, 1.3rem);
    font-weight: 600;
    text-align: center;
    padding: 0.7rem 4px 0;
}

.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: #b45309; border: 2px solid #fed7aa; background: #fffbeb; }

/* 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.15rem;
    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.4rem;
}

.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)); }
}

/* ---------- 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; }

    .valigia { min-height: 132px; }
    .valigia-dentro { min-height: 96px; }
    .cosa { border-width: 2px; }
}

@media (max-width: 380px) {
    .cosa { width: clamp(76px, 26vw, 96px); }
    .cosa-nome { font-size: .68rem; }
}

/* Meno animazioni se richiesto dal sistema */
@media (prefers-reduced-motion: reduce) {
    .hero-item,
    .bg-decor span,
    .end-icon,
    .cosa,
    .valigia,
    .valigia.waiting,
    .in-valigia,
    .screen.active {
        animation: none !important;
    }
    .confetti-piece { display: none; }
}
