/* ============================================================
   IL GIOCO DELLE ROTELLE — stile locale
   Il resto (variabili, intestazione, footer, regole touch) arriva da
   css/kids-base.css.

   Il pezzo centrale è il CANVAS (#canvas-container), dove il motore
   disegna la catena di ruote: quella parte era già fatta bene e la si
   tiene. Tolto invece tutto il resto — i pulsanti radio, gli overlay a
   tutto schermo «Oh no ❌», gli stili inline — e messo lo scheletro
   standard delle app kids: modalità, HUD, opzioni a tocco, attestato.
   ============================================================ */

.app-container {
    width: 100%;
    max-width: 800px;
    margin: 0.5rem auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
    overflow: hidden;
    min-height: 500px;
    position: relative;
    padding-bottom: 20px;
}

.screen { display: none; padding: 1.5rem; text-align: center; }
.screen.active { display: block; }

.title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(1.8rem, 6vw, 2.5rem);
    color: var(--brand);
    margin-bottom: 0.8rem;
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #64748b;
    margin-bottom: 1.2rem;
}

/* ---------- Selettore della lingua ---------- */
.lang-switch {
    display: flex;
    gap: 6px;
    margin: 0 0 1.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.lang-btn {
    appearance: none;
    border: 2px solid #dbeafe;
    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;
    transition: transform .15s ease, border-color .15s ease;
}

.lang-btn:hover { transform: translateY(-2px); }
.lang-btn.active { border-color: var(--brand); background: #eff6ff; color: var(--brand); }

/* ---------- Le tre modalità ---------- */
.choose-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--brand);
    margin: 0 0 1rem;
}

.level-grid {
    display: grid;
    gap: 0.7rem;
    max-width: 460px;
    margin: 0 auto 2rem;
}

.level-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-align: left;
    background: #fff;
    border: 3px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.9rem 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.level-card:hover {
    transform: translateY(-3px);
    border-color: var(--brand);
    box-shadow: 0 8px 18px rgba(0, 0, 0, .1);
}

.level-icon { font-size: 2.1rem; line-height: 1; flex: none; }

.level-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.level-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
}

.level-desc { font-size: .9rem; color: #4b5563; line-height: 1.25; }

/* ---------- Intestazione del gioco ---------- */
.game-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.8rem;
}

.btn-mini-home {
    background: #f1f5f9;
    border: none;
    font-size: 1.4rem;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 0 #cbd5e1;
    line-height: 1;
}

.score { font-size: 1rem; font-weight: bold; color: var(--ink); }

.progress-track {
    height: 8px;
    background: #e6eefb;
    border-radius: 999px;
    overflow: hidden;
    max-width: 560px;
    margin: 0 auto 0.9rem;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--brand);
    border-radius: 999px;
    transition: width .35s ease;
}

/* ---------- Il passaggio fra una sfida e l'altra ---------- */
#game-screen .prompt-card,
#game-screen #canvas-container,
#game-screen .options-grid {
    transition: opacity .4s ease, transform .4s ease;
}

#game-screen.in-uscita .prompt-card,
#game-screen.in-uscita #canvas-container,
#game-screen.in-uscita .options-grid {
    opacity: 0;
    transform: translateY(-6px);
}

@media (prefers-reduced-motion: reduce) {
    #game-screen.in-uscita .prompt-card,
    #game-screen.in-uscita #canvas-container,
    #game-screen.in-uscita .options-grid { transform: none; }
}

/* ---------- La consegna, sempre anche a voce ---------- */
.prompt-card {
    position: relative;
    background: #fff;
    border: 3px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.9rem 3.4rem 0.9rem 1rem;
    margin: 0 auto 1rem;
    max-width: 560px;
}

.prompt-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    min-height: 1.4em;
}

.say-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--brand);
    background: #eff6ff;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}

@media (pointer: coarse) {
    .say-btn, .btn-mini-home { min-width: 44px; min-height: 44px; }
}

/* ---------- IL CANVAS ----------
   Dove il motore disegna la catena di ruote. Responsivo: sta sempre
   nella larghezza, con proporzione 2:1. */
#canvas-container {
    background: #f8fafc;
    border: 3px solid #cbd5e1;
    border-radius: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1);
    margin: 0 auto 1rem;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 2 / 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- Le opzioni: i due versi più «falle girare» ---------- */
.options-grid { max-width: 460px; margin: 0 auto; }

.options-grid.rotelle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
}

.opzione {
    background: #fff;
    border: 3px solid #e2e8f0;
    border-radius: 18px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, opacity .3s ease;
    min-height: 60px;
}

.opzione:hover { transform: translateY(-3px); border-color: var(--brand); }

/* I due versi, affiancati. */
.options-grid.rotelle .verso {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 320px;
    padding: 0.7rem 1rem;
    font-size: 1.2rem;
}

.verso-seg { font-size: 1.8rem; line-height: 1; }
.verso-nome { text-transform: capitalize; }

.opzione.verso.scelta {
    border-color: var(--brand);
    background: #eff6ff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .16);
}

/* Dopo la simulazione: il verso vero si accende, l'altro si spegne. */
.opzione.verso.giusto {
    border-color: #22c55e;
    background: #f0fdf4;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .18);
}

.opzione.verso.fuori {
    opacity: .35;
    filter: grayscale(1);
    box-shadow: none;
}

.opzione.fai {
    width: 100%;
    max-width: 320px;
    padding: 0.8rem 1rem;
    font-size: 1.2rem;
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: 0 4px 0 #1d4ed8;
}

.opzione.fai:disabled {
    background: #cbd5e1;
    border-color: #cbd5e1;
    color: #eef2f7;
    box-shadow: 0 4px 0 #94a3b8;
    cursor: not-allowed;
}

.opzione.locked { pointer-events: none; }

/* ---------- Il riscontro ---------- */
.feedback-msg {
    display: none;
    max-width: 560px;
    margin: 1rem auto 0;
    padding: 1rem;
    border-radius: 18px;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
}

.feedback-msg.correct,
.feedback-msg.mostra { display: block; }
.feedback-msg.correct { background: #f0fdf4; border: 3px solid #22c55e; color: #166534; }
.feedback-msg.mostra  { background: #eff6ff; border: 3px solid #3b82f6; color: #1e3a8a; }

/* ---------- La 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: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    color: var(--brand);
    margin: 0 0 0.7rem;
}

.info-box h3 {
    font-family: 'Fredoka', sans-serif;
    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: #eff6ff;
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
}

/* ---------- Attestato ---------- */
.certificate-container {
    background: #fffbef;
    border: 4px dashed #f59e0b;
    outline: 6px solid #10b981;
    outline-offset: 3px;
    padding: 15px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    margin: 5px auto 15px;
    position: relative;
    box-shadow: 0 10px 20px rgba(0, 0, 0, .15);
    text-align: center;
}

.certificate-container::before,
.certificate-container::after {
    content: '★';
    position: absolute;
    font-size: 24px;
    color: #fbbf24;
    top: 5px;
}
.certificate-container::before { left: 8px; transform: rotate(-15deg); }
.certificate-container::after { right: 8px; transform: rotate(15deg); }

.cert-header {
    font-family: 'Fredoka', sans-serif;
    color: #fff;
    background: #ef4444;
    display: inline-block;
    padding: 5px 20px;
    border-radius: 50px;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    box-shadow: 0 3px 0 #b91c1c;
    transform: rotate(-2deg);
}

.cert-text { font-size: .9rem; color: #4b5563; margin: 2px 0; }

.cert-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.3rem;
    color: #d97706;
    margin: 2px 0 8px;
    text-decoration: underline wavy #fcd34d;
    text-underline-offset: 4px;
}

.cert-body {
    background: #fff;
    padding: 10px;
    border-radius: 10px;
    margin: 5px 0;
    border: 2px solid #e5e7eb;
}

.cert-message {
    font-size: .95rem;
    color: #374151;
    font-style: italic;
    margin-bottom: 5px;
    line-height: 1.3;
}

.cert-score {
    font-size: 1.1rem;
    font-weight: bold;
    color: #10b981;
    background: #ecfdf5;
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
}

.cert-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 10px;
    font-size: .8rem;
    color: #9ca3af;
    border-top: 1px dashed #d1d5db;
    padding-top: 5px;
}

.cert-signature { font-family: 'Fredoka', sans-serif; color: var(--brand); font-size: 1rem; }
.cert-date { font-weight: bold; }

.btn-play {
    background-color: var(--brand);
    color: #fff;
    border: none;
    padding: 0.9rem 1.8rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    box-shadow: 0 4px 0 #1d4ed8;
}

.btn-stampa { background-color: #3b82f6; }

.result-buttons {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.audio-btn.spento { opacity: .55; }

/* ---------- Tablet ---------- */
@media (min-width: 700px) {
    .app-container { max-width: 980px; }
    .level-grid { grid-template-columns: repeat(3, 1fr); max-width: 820px; }
    #canvas-container { max-width: 720px; }
    .prompt-card, .feedback-msg { max-width: 720px; }
    .prompt-text { font-size: 1.35rem; }
    .feedback-msg { font-size: 1.15rem; }
}

/* ---------- Stampa dell'attestato ---------- */
@media print {
    body * { visibility: hidden !important; }
    #certificate, #certificate * { visibility: visible !important; }
    #certificate { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
    .site-header, .site-footer, .result-buttons, .btn-play { display: none !important; }
}
