:root {
    --lila: #7c3aed;
    --rosa: #ec4899;
    --oro: #f59e0b;
    --cielo: #38bdf8;
    --menta: #34d399;
    --crema: #fff7ed;
    --texto: #3b2064;
    --sombra: 0 16px 40px rgba(124, 58, 237, 0.16);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(236, 72, 153, 0.25);
}

html,
body {
    margin: 0;
    min-height: 100%;
}

[hidden] {
    display: none !important;
}

button,
a,
select,
input,
.carta,
.libro,
.opcion,
.ficha,
.modo {
    touch-action: manipulation;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Nunito", "Segoe UI", sans-serif;
    color: var(--texto);
    background: linear-gradient(180deg, #dbeafe 0%, #fce7f3 48%, #fef3c7 100%);
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .logo, .insignia, .boton, .modo strong {
    font-family: "Fredoka", "Nunito", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.fondo-cielo {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.nube {
    position: absolute;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 50px;
    filter: blur(0.4px);
    animation: flotar 12s ease-in-out infinite;
}

.nube::before,
.nube::after {
    content: "";
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.n1 { width: 140px; height: 42px; top: 70px; left: 8%; }
.n2 { width: 110px; height: 34px; top: 150px; right: 12%; animation-delay: -4s; }
.n3 { width: 90px; height: 28px; bottom: 80px; left: 18%; animation-delay: -7s; }

.nube::before { width: 48px; height: 48px; top: -24px; left: 18px; }
.nube::after { width: 36px; height: 36px; top: -16px; right: 16px; }

.estrella {
    position: absolute;
    color: #fbbf24;
    font-size: 22px;
    animation: brillar 2.4s ease-in-out infinite;
}

.s1 { top: 40px; right: 18%; }
.s2 { top: 120px; left: 28%; animation-delay: -0.6s; }
.s3 { bottom: 140px; right: 24%; animation-delay: -1.2s; }
.s4 { top: 220px; left: 8%; animation-delay: -1.8s; }

.sol {
    position: absolute;
    top: 24px;
    left: 42px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 0 10px rgba(251, 191, 36, 0.25);
    animation: brillar 3s ease-in-out infinite;
}

.arcoiris {
    position: absolute;
    top: 18px;
    right: 8%;
    width: 140px;
    height: 70px;
    border: 10px solid #f472b6;
    border-bottom: 0;
    border-radius: 140px 140px 0 0;
    box-shadow: 0 -12px 0 #fbbf24, 0 -24px 0 #38bdf8;
    opacity: 0.55;
}

.corazon {
    position: absolute;
    color: #f472b6;
    font-size: 18px;
    animation: flotar 6s ease-in-out infinite;
}

.c1 { top: 90px; right: 32%; }
.c2 { bottom: 180px; left: 10%; }

.paloma-fondo {
    position: absolute;
    bottom: 90px;
    right: 10%;
    font-size: 28px;
    animation: flotar 8s ease-in-out infinite;
}

.mascota {
    display: inline-flex;
    flex-shrink: 0;
}

.mascota.grande {
    filter: drop-shadow(0 6px 0 rgba(251, 191, 36, 0.4));
}

.mascota-habla {
    display: flex;
    gap: 14px;
    align-items: center;
    margin: 0 0 22px;
    padding: 14px;
    border-radius: 20px;
    background: #fff7ed;
}

.camino {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    margin: 0 0 22px;
    list-style: none;
}

.camino li {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
    font-weight: 800;
    font-size: 0.92rem;
}

.camino span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fde68a;
    color: #92400e;
}

.modo-sino { background: #d1fae5; }

.botones-sino {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 24px 0;
}

.boton-sino {
    min-height: 120px;
    border: 0;
    border-radius: 28px;
    font: inherit;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
}

.boton-sino.si {
    background: linear-gradient(135deg, #34d399, #059669);
    box-shadow: 0 10px 0 #047857;
}

.boton-sino.no {
    background: linear-gradient(135deg, #fb7185, #e11d48);
    box-shadow: 0 10px 0 #be123c;
}

.boton-sino:active {
    transform: translateY(4px);
    box-shadow: 0 6px 0 #047857;
}

.boton-sino.no:active {
    box-shadow: 0 6px 0 #be123c;
}

.confeti {
    position: fixed;
    top: -12px;
    width: 10px;
    height: 16px;
    border-radius: 3px;
    z-index: 8;
    pointer-events: none;
    animation: caer 1.4s ease-in forwards;
}

@keyframes caer {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.2;
    }
}

.encabezado,
.contenedor,
.pie {
    position: relative;
    z-index: 1;
}

.encabezado {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 4vw;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    min-width: 0;
}

.logo > span:last-child {
    white-space: nowrap;
}

.nombre-cabecera {
    margin-left: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fce7f3;
    color: #9d174d;
    font-size: 0.85rem;
}

.saludo-jugador {
    margin: 0 0 18px;
}

.saludo-jugador .aviso {
    font-size: 1.4rem;
    text-align: center;
}

.enlace-cambiar {
    display: block;
    margin: 8px auto 0;
    border: 0;
    background: none;
    color: #7c3aed;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    text-decoration: underline;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.carta {
    min-height: 280px;
    padding: 28px 24px;
    border-radius: 28px;
    background: linear-gradient(160deg, #fff7ed, #fce7f3);
    box-shadow: inset 0 0 0 4px #fff;
    cursor: pointer;
    display: grid;
    align-content: start;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.carta .boton {
    justify-self: start;
    margin-top: 8px;
}

.fichas-tema {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 18px 0 22px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
}

.ficha {
    padding: 10px 14px;
    border-radius: 999px;
    background: #f3e8ff;
    color: var(--texto);
    font-size: 0.95rem;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
}

.ficha.activa {
    background: var(--lila);
    color: #fff;
}

@media (hover: hover) {
    .ficha:hover {
        background: var(--lila);
        color: #fff;
    }
}

.logo-icono {
    font-size: 1.8rem;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.menu a,
.boton,
.ficha,
.opcion,
.libro {
    border: 0;
    cursor: pointer;
    font-weight: 800;
}

.menu a {
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
}

.menu a.activo {
    background: #fff;
    box-shadow: var(--sombra);
}

@media (hover: hover) {
    .menu a:hover {
        background: #fff;
        box-shadow: var(--sombra);
    }
}

.contenedor {
    width: min(980px, 92vw);
    margin: 0 auto 40px;
}

.tarjeta {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 32px;
    padding: 32px 28px;
    box-shadow: var(--sombra);
}

.portada h1,
.tarjeta h1 {
    margin: 8px 0 10px;
    font-size: clamp(1.8rem, 5vw, 2.7rem);
    line-height: 1.15;
}

.subtitulo {
    margin: 0 0 22px;
    font-size: 1.15rem;
}

.insignia {
    display: inline-block;
    margin: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fde68a;
    color: #92400e;
    font-size: 0.92rem;
}

.formulario-nina {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.formulario-nina label,
.filtros label {
    display: grid;
    gap: 6px;
    font-weight: 800;
}

.formulario-nina input,
.filtros select {
    width: 100%;
    padding: 14px 16px;
    border: 3px solid #e9d5ff;
    border-radius: 16px;
    font: inherit;
    font-size: 1.1rem;
    background: #fff;
}

.aviso {
    margin: 0 0 18px;
    padding: 10px 14px;
    border-radius: 14px;
    background: #d1fae5;
    color: #065f46;
    font-weight: 800;
}

.boton {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 52px;
    padding: 12px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--rosa), var(--lila));
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 8px 0 #6d28d9;
}

.boton:active {
    transform: translateY(3px);
    box-shadow: 0 5px 0 #6d28d9;
}

.boton-suave {
    background: #fff;
    color: var(--lila);
    box-shadow: 0 8px 0 #ddd6fe;
}

.boton-grande {
    width: 100%;
    min-height: 60px;
    font-size: 1.2rem;
}

.rejilla-modos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.modo {
    display: grid;
    gap: 6px;
    padding: 22px 18px;
    border: 0;
    border-radius: 24px;
    text-align: left;
    background: #fff;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.06);
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.modo strong {
    font-size: 1.25rem;
}

.modo-emoji {
    font-size: 2rem;
}

.modo-aprender { background: #ede9fe; }
.modo-jugar { background: #fce7f3; }
.modo-libros { background: #dbeafe; }
.modo-ranking { background: #fef3c7; }

.titulo-pagina {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.escenario-tarjeta {
    display: grid;
    gap: 16px;
}

.carta-paso,
.carta-pista {
    margin: 0;
    opacity: 0.75;
}

.carta-pregunta {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 800;
    margin: 18px 0;
}

.respuesta-grande {
    margin: 0 0 8px;
    font-size: 1.45rem;
    color: #6d28d9;
    font-weight: 800;
}

.respuesta-detalle {
    margin: 0;
}

.controles-carta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.barra-juego {
    display: flex;
    justify-content: space-between;
    font-weight: 800;
}

.barra-progreso {
    height: 14px;
    margin: 10px 0 22px;
    border-radius: 999px;
    background: #f3e8ff;
    overflow: hidden;
}

.barra-progreso span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--cielo), var(--menta));
    transition: width 0.3s ease;
}

.opciones {
    display: grid;
    gap: 12px;
    margin: 18px 0;
}

.opcion {
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    border-radius: 18px;
    background: #fff;
    border: 3px solid #e9d5ff;
    font-size: 1.05rem;
    color: var(--texto);
}

.opcion:focus {
    border-color: var(--lila);
}

@media (hover: hover) {
    .opcion:hover {
        border-color: var(--lila);
    }
}

.opcion.correcta {
    background: #d1fae5;
    border-color: #059669;
}

.opcion.incorrecta {
    background: #fee2e2;
    border-color: #dc2626;
}

.capa {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: start center;
    align-content: center;
    background: rgba(59, 32, 100, 0.45);
    z-index: 5;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.capa[hidden] {
    display: none !important;
}

.globo-feedback {
    width: min(460px, 100%);
    padding: 28px 22px;
    border-radius: 28px;
    background: #fff;
    text-align: center;
    box-shadow: var(--sombra);
}

.feedback-emoji {
    margin: 0;
    font-size: 3rem;
}

.centro {
    text-align: center;
}

.estrellas-final {
    font-size: 2.6rem;
    letter-spacing: 6px;
    margin: 10px 0 16px;
}

.rejilla-libros {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 18px 0 22px;
}

.libro {
    min-height: 72px;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
    border: 3px solid #bfdbfe;
    color: var(--texto);
    font-size: 0.98rem;
}

.libro.tono-rosa { background: #fce7f3; border-color: #f9a8d4; }
.libro.tono-lila { background: #ede9fe; border-color: #c4b5fd; }
.libro.tono-cielo { background: #e0f2fe; border-color: #7dd3fc; }
.libro.tono-menta { background: #d1fae5; border-color: #6ee7b7; }
.libro.tono-oro { background: #fef3c7; border-color: #fcd34d; }

.libro.elegido {
    background: #fce7f3;
    border-color: var(--rosa);
    transform: translateY(-2px);
}

.libro.acierto {
    background: #d1fae5;
    border-color: #059669;
}

.libro.fallo {
    background: #fee2e2;
    border-color: #dc2626;
}

.filtros {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.podio {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.puesto {
    padding: 18px;
    border-radius: 22px;
    background: #fff7ed;
}

.puesto.oro { background: #fef3c7; }
.puesto.plata { background: #e5e7eb; }

.tabla-caja {
    overflow-x: auto;
}

.tabla-ranking {
    width: 100%;
    border-collapse: collapse;
}

.tabla-ranking th,
.tabla-ranking td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #f3e8ff;
}

.tabla-ranking tr:first-child td {
    font-weight: 800;
}

.pie {
    text-align: center;
    padding: 10px 20px 30px;
    color: #6b21a8;
    font-weight: 700;
}

@keyframes flotar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes brillar {
    0%, 100% { opacity: 0.35; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 900px) {
    .encabezado {
        flex-direction: column;
        align-items: stretch;
    }

    .menu {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .menu a {
        text-align: center;
        font-size: 0.9rem;
        padding: 10px 8px;
    }

    .rejilla-modos,
    .filtros,
    .podio,
    .camino,
    .botones-sino {
        grid-template-columns: 1fr;
    }

    .tarjeta {
        padding: 18px 14px;
        overflow: visible;
    }

    .carta {
        min-height: 220px;
        padding: 18px 16px;
    }

    .carta-pregunta {
        font-size: 1.25rem;
        margin: 10px 0;
    }

    .controles-carta .boton {
        flex: 1 1 140px;
    }

    .titulo-pagina .boton {
        width: 100%;
    }
}
