/* Ricalca le Lettere – gioco di pregrafismo (base condivisa in css/kids-base.css) */

.app-container {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
}

.rl-screen {
    display: none;
    animation: rl-fade 0.35s ease-out;
}

.rl-screen.active {
    display: block;
}

@keyframes rl-fade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Schermata iniziale ---------- */
.rl-title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    font-weight: 700;
    color: var(--brand, #0A5B63);
    text-align: center;
    margin: 0.5rem 0 0.25rem;
}

.rl-subtitle {
    text-align: center;
    color: #5d6b6b;
    font-size: 1.1rem;
    margin: 0 0 1.5rem;
}

/* Scheda di configurazione */
.rl-setup-card {
    background: #fff;
    border-radius: 22px;
    padding: 1.4rem 1.3rem;
    box-shadow: 0 10px 26px rgba(10, 91, 99, 0.14);
    margin-bottom: 1.5rem;
}

.rl-choice-label {
    display: block;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--brand, #0A5B63);
    margin: 0 0 0.5rem;
}

.rl-choice-label + .rl-seg {
    margin-bottom: 1.2rem;
}

/* Selettore segmentato (2 opzioni) */
.rl-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #eef4f4;
    border-radius: 18px;
    padding: 6px;
}

.rl-seg-btn {
    border: none;
    background: transparent;
    border-radius: 13px;
    padding: 0.9rem 0.5rem;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #5d6b6b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.rl-seg-btn:active {
    transform: scale(0.96);
}

.rl-seg-btn.active {
    background: var(--brand, #0A5B63);
    color: #fff;
    box-shadow: 0 5px 14px rgba(10, 91, 99, 0.28);
}

.rl-seg-glyph {
    font-family: 'Andika', sans-serif;
    font-weight: 700;
    font-size: 2.4rem;
    line-height: 1;
}

.rl-seg-emoji {
    font-size: 2rem;
    line-height: 1;
}

.rl-act-hint {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #5d6b6b;
    background: #f3f8f8;
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    margin: 0 0 1.2rem;
}

.rl-act-hint strong {
    color: var(--brand, #0A5B63);
}

.rl-play-btn {
    width: 100%;
    border: none;
    border-radius: 16px;
    padding: 1rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #fea800, #f59e0b);
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.rl-play-btn:active {
    transform: scale(0.97);
}

/* Box informativo per i genitori */
.rl-age-info {
    background: #fff;
    border: 2px dashed #cfe2e2;
    border-radius: 18px;
    padding: 1.2rem 1.3rem;
    color: #3b4a4a;
    font-size: 0.95rem;
    line-height: 1.6;
}

.rl-age-info h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    color: var(--brand, #0A5B63);
    margin: 0 0 0.6rem;
}

.rl-age-info p {
    margin: 0 0 0.6rem;
}

.rl-age-info p:last-child {
    margin-bottom: 0;
}

/* ---------- Schermata di gioco ---------- */
.rl-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.rl-icon-btn {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 16px;
    background: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(10, 91, 99, 0.15);
    -webkit-tap-highlight-color: transparent;
}

.rl-icon-btn:active {
    transform: scale(0.92);
}

/* Striscia lettere scorrevole */
.rl-letter-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.rl-letter-strip::-webkit-scrollbar {
    display: none;
}

.rl-chip {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 14px;
    background: #fff;
    font-family: 'Andika', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: #5d6b6b;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(10, 91, 99, 0.12);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.rl-chip.current {
    background: var(--brand, #0A5B63);
    color: #fff;
    transform: scale(1.08);
}

.rl-chip.done {
    background: #fea800;
    color: #4a3200;
}

/* Area di ricalco */
.rl-stage {
    background: #fff;
    border-radius: 24px;
    padding: 14px;
    box-shadow: 0 12px 30px rgba(10, 91, 99, 0.15);
}

.rl-progress {
    height: 14px;
    background: #eef4f4;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}

.rl-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #fea800, #f59e0b);
    transition: width 0.15s ease-out;
}

/* Riga: foglio + tavolozza (affiancati su schermo largo, impilati su mobile) */
.rl-play-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.rl-canvas-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    aspect-ratio: 1;
    border-radius: 18px;
    overflow: hidden;
    background:
        repeating-linear-gradient(0deg, transparent 0 38px, rgba(10, 91, 99, 0.06) 38px 40px),
        #fbfefe;
    border: 2px solid #e3eeee;
}

#trace-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; /* il dito disegna, non scorre la pagina */
    cursor: crosshair;
}

/* Festeggiamento */
.rl-celebrate {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.82);
    font-family: 'Fredoka', sans-serif;
    text-align: center;
    pointer-events: none;
}

.rl-celebrate.show {
    display: flex;
    animation: rl-pop 0.4s ease-out;
}

.rl-celebrate .big {
    font-size: 4rem;
    line-height: 1;
}

.rl-celebrate .msg {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand, #0A5B63);
}

@keyframes rl-pop {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stelline che volano */
.rl-star {
    position: absolute;
    font-size: 1.8rem;
    animation: rl-fly 1s ease-out forwards;
    pointer-events: none;
}

@keyframes rl-fly {
    from {
        transform: translate(0, 0) scale(0.6);
        opacity: 1;
    }

    to {
        transform: translate(var(--dx), var(--dy)) scale(1.4);
        opacity: 0;
    }
}

/* ---------- Strumenti laterali (Colori e Spessore) ---------- */
.rl-tools-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
    justify-content: center;
}

/* ---------- Tavolozza colori ---------- */
.rl-palette {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    justify-content: center;
}

.rl-swatch {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: var(--sw);
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(10, 91, 99, 0.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.rl-swatch:active {
    transform: scale(0.9);
}

.rl-swatch.active {
    /* anello del colore stesso attorno alla pastiglia selezionata */
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sw), 0 4px 10px rgba(0, 0, 0, 0.2);
    transform: scale(1.08);
}

/* ---------- Spessore pennarello ---------- */
.rl-thickness {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    background: #eef4f4;
    border-radius: 20px;
    padding: 10px 6px;
}

.rl-swatch-thick {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background 0.12s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.rl-swatch-thick:active {
    transform: scale(0.9);
}

.rl-swatch-thick.active {
    border-color: var(--brand, #0A5B63);
    box-shadow: 0 2px 6px rgba(10, 91, 99, 0.15);
}

.rl-swatch-thick .dot {
    background: #5d6b6b;
    border-radius: 50%;
}
.rl-swatch-thick.active .dot {
    background: var(--brand, #0A5B63);
}

.rl-swatch-thick .d-small { width: 8px; height: 8px; }
.rl-swatch-thick .d-medium { width: 14px; height: 14px; }
.rl-swatch-thick .d-large { width: 22px; height: 22px; }

/* Pulsanti grandi sotto il canvas */
.rl-controls {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
}

.rl-big-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: #eef4f4;
    font-size: 1.7rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(10, 91, 99, 0.15);
    transition: transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.rl-big-btn:active {
    transform: scale(0.9);
}

.rl-big-btn.rl-prev,
.rl-big-btn.rl-next {
    background: var(--brand, #0A5B63);
}

/* Su telefono: foglio sopra, tavolozza in orizzontale sotto */
@media (max-width: 560px) {
    .rl-play-row {
        flex-direction: column;
    }

    .rl-palette {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .rl-thickness {
        flex-direction: row;
        justify-content: center;
        padding: 6px 10px;
    }
}

/* Mobile stretto */
@media (max-width: 400px) {
    .app-container {
        padding: 10px;
    }

    .rl-mode-glyph {
        font-size: 3.2rem;
    }

    .rl-big-btn {
        width: 58px;
        height: 58px;
    }

    .rl-swatch {
        width: 38px;
        height: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .rl-screen,
    .rl-celebrate.show,
    .rl-star {
        animation: none;
    }
}
