/* Reset total */
* {
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&family=Fredoka+One&display=swap');

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    background: #fdd2dc;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    text-transform: uppercase !important;
    position: relative;
}

.text-white-pink {
    color: #fed593;
    -webkit-text-stroke: 2px #e75ca9;
    text-stroke: 2px #e75ca9;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

h2 {
    font-family: 'Fredoka', sans-serif !important;
    font-weight: 700 !important;
    font-size: 72px;
    letter-spacing: 0.05em;
    color:#fed593;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
    text-align: center;
    margin: 20px 0;
}

.titulo-principal {
    font-family: 'Fredoka One', sans-serif;
    font-size: 80px;
    color: #fed593;
    -webkit-text-stroke: 3px #e75ca9;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
    text-align: center;
    margin: 40px 0;
    text-transform: uppercase;
}

/* Contenedor principal */
.cuento-wrapper {
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 99999;
    overflow: visible !important;
}

/* FORMULARIO CENTRADO - SOLO PARA CUANDO NO HAY DATOS */
.cuento-formulario-wrapper h2 {
    font-size: 28px;
    margin-bottom: 10px !important;
    color: #fed593 !important;
}

.cuento-formulario-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.cuento-formulario-wrapper:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 0;
}

.cuento-formulario-wrapper > * {
    max-width: 500px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.cuento-formulario-wrapper p {
    color: white;
    font-size: 1.2em;
    margin-bottom: 30px !important;
    line-height: 1.5;
}

.cuento-formulario-wrapper .button {
    background: #ff6b6b;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.cuento-formulario-wrapper .button:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.cuento-formulario-wrapper.ocultar-formulario {
    display: none !important;
}

/* ========================================================================== */
/* BIBLIOTECA Y MINIATURAS DE LIBROS - ESTRUCTURA CORREGIDA */
/* ========================================================================== */

/* 📚 Contenedor principal de biblioteca */
.biblioteca {
  width: 100vw;
  max-width: 100%;
  margin-top: 40px !important;
  display: flex;
  flex-direction: column;
  gap: 200px !important; /* REDUCIDO para móviles */
  background-color: #fdd2dc;
  overflow: visible !important;
}

/* 🪵 Contenedor de estante + libros */
.estante-contenedor {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px !important; /* ESPACIO EXTRA ARRIBA para hover */
  padding-bottom: 20px !important; /* ESPACIO EXTRA ABAJO para hover */
  overflow: visible !important;
}

/* 🎨 Imagen del estante */
.estante {
  width: 100%;
  display: block;
  z-index: 1;
}

/* 📘 Contenedor de libros - POSICIÓN MÁS ALTA en móviles */
.libros {
  display: flex;
  flex-direction: row;
  width: 100%;
  position: absolute;
  bottom: 72% !important; /* MUCHO MÁS ARRIBA en móviles */
  left: 0;
  z-index: 3;
  padding-left: 0 !important;
  padding-right: 20px !important;
  box-sizing: border-box;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: 20px !important;
  overflow-y: visible !important;
}

/* Espacio inicial igual al gap entre libros */
.libros::before {
  content: '';
  flex: 0 0 20px;
  height: 1px;
}

/* 📕 Cada libro */
.libro {
  flex: 0 0 auto;
  width: 140px;
  height: 196px;
  border-radius: 0;
  transition: all 0.4s ease;
  cursor: pointer;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  background: transparent !important;
  border: none !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
}

/* Efecto hover - AJUSTADO para móviles */
.libro:hover {
  transform: perspective(800px) rotateY(8deg) rotateX(3deg) translateY(-5px) !important; /* MENOS INCLINACIÓN en móviles */
  z-index: 100;
  filter: 
    drop-shadow(0 6px 15px rgba(255, 255, 255, 0.7)) /* MÁS BRILLO para contraste */
    drop-shadow(0 3px 8px rgba(255, 215, 0, 0.5))
    brightness(1.1) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important; /* SOMBRA MÁS SUAVE */
}

/* 🏷️ Título centrado - POSICIÓN MÁS ALTA */
.titulo-estante {
  position: absolute;
  bottom: 48% !important; /* MUCHO MÁS ARRIBA en móviles */
  width: 100%;
  text-align: center;
  font-size: 1.1em;
  font-weight: 600;
  color: #a64f2d;
  text-shadow: 1px 1px 2px #fff;
  z-index: 2;
  font-family: 'Fredoka', sans-serif !important;
}

/* Ocultar scrollbar */
.libros::-webkit-scrollbar {
  display: none;
}

/* Asegurar que el contenedor no recorte el hover */
.estante-contenedor {
  overflow: visible !important;
}

.libros {
  overflow-x: auto;
  overflow-y: visible;
}

/* ========================================================================== */
/* ESTILOS PARA FORMULARIOS EN LA NUEVA ESTRUCTURA DE BIBLIOTECA */
/* ========================================================================== */

.libro-form {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block;
    flex: 0 0 auto;
}

.libro-form input[type="image"] {
    width: 140px !important;
    height: 196px !important;
    object-fit: contain !important;
    cursor: pointer !important;
    transition: all 0.4s ease !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)) !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

.libro-form input[type="image"]:hover {
    transform: perspective(800px) rotateY(8deg) rotateX(3deg) translateY(-5px) !important;
    filter: 
        drop-shadow(0 6px 15px rgba(255, 255, 255, 0.7))
        drop-shadow(0 3px 8px rgba(255, 215, 0, 0.5))
        brightness(1.1) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important;
}

/* MINIATURAS DE CUENTOS - MANTENER COMPATIBILIDAD */
.categoria-wrapper {
    background-color: #fdd2dc;
    padding: 10px 0 80px 0 !important;
    margin-bottom: 30px !important;
    overflow: visible !important;
    width: 100%;
    position: relative;
}

.titulo-categoria {
    font-family: 'Fredoka', sans-serif !important;
    font-weight: 700 !important;
    font-size: 72px;
    letter-spacing: 0.05em;
    position: absolute;
    bottom: 160px;
    left: 0;
    width: 100%;
    text-align: center;
    margin: 0 !important;
    z-index: 2;
    padding: 8px 0 !important;
    border-radius: 10px;
    max-width: 80%;
    left: 10%;
    color:#fed593;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
}

.cuentos-miniaturas-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    position: relative;
    overflow: visible !important;
}

.cuentos-miniaturas {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0px;
    padding: 20px 40px 0px 40px !important;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 40px;
    -webkit-overflow-scrolling: touch;
}

.cuentos-miniaturas::before, .cuentos-miniaturas::after {
    content: '';
    flex: 0 0 20px;
    min-width: calc(50% - 230px);
}

/* Contenedor de miniaturas */
.cuentos-miniaturas form {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 180px;
    height: 180px;
    aspect-ratio: 3/4;
    overflow: visible !important;
    scroll-snap-align: center;
    flex-shrink: 0;
    position: relative;
    transition: transform 0.5s ease;
    margin-bottom: 0px !important;
    transform: translateY(0) translateZ(10px);
    filter: none;
    z-index: 3;
}

/* EFECTO HOVER */
.cuentos-miniaturas form:hover {
    transform: translateY(-15px) translateZ(20px) rotate(5deg) scale(1.05);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Imagen de miniatura */
.cuentos-miniaturas input[type="image"] {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* Evita bordes fantasmas */
.cuentos-miniaturas form:focus, .cuentos-miniaturas form:hover, .cuentos-miniaturas input[type="image"]:focus, .cuentos-miniaturas input[type="image"]:hover {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}

/* Firefox-specific fix */
.cuentos-miniaturas input[type="image"]::-moz-focus-inner {
    border: 0 !important;
}

/* Chrome-specific fix */
.cuentos-miniaturas input[type="image"]::-webkit-focus-ring-color {
    outline: none !important;
}

/* Scrollbar */
.cuentos-miniaturas::-webkit-scrollbar {
    height: 8px;
}

.cuentos-miniaturas::-webkit-scrollbar-thumb {
    background: #ffa500;
    border-radius: 4px;
}

.cuentos-miniaturas::-webkit-scrollbar-track {
    background: rgba(255, 165, 0, 0.1);
}

/* TÍTULO "ELEGÍ TU CUENTO" CON CARTEL DE MADERA REAL */
.elige-tu-cuento-titulo {
    text-align: center;
    color: #fed593;
    font-size: 28px;
    margin: 0px auto 10px !important;
    width: 100%;
    max-width: 500px;
    padding: 0px 0 20px;
    min-height: 0px;
    position: relative;
    z-index: 1;
    height: 220px;
    width: 100%;
    background: url('https://storymals.com/wp-content/uploads/cartel-madera.png') center/contain no-repeat;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6);
    font-family: 'Fredoka One', sans-serif;
    line-height: 1.2;
    letter-spacing: 1px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Flip 3D - CORREGIDO PARA EVITAR SCROLL */
.cuento-container {
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    perspective: 2500px;
    overflow: visible !important;
}

.cuento-pagina {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    min-height: 100vh;
    transform-origin: left center;
    transition: transform 1.2s cubic-bezier(0.65, 0, 0.35, 1);
    transform-style: preserve-3d;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: visible !important;
}

.cuento-pagina.flipped {
    transform: rotateY(-180deg);
}

.pagina-frente, .pagina-dorso {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    overflow: visible !important;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 !important;
    z-index: 1;
}

/* CORRECCIÓN PRINCIPAL: Cambiar backface-visibility */
.pagina-frente {
    transform: rotateY(0deg);
    backface-visibility: visible !important;
}

.pagina-dorso {
    background: #111;
    transform: rotateY(180deg);
    backface-visibility: hidden;
}

.pagina-video-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 1;
}

/* MEJORA PRINCIPAL: Ajuste de posición del contenido según la presencia del círculo */
.cuento-container.con-circulo {
    padding-top: 140px !important;
}

.cuento-container.con-circulo .pagina-contenido {
    justify-content: flex-start;
    padding-top: 190px !important; /* MODIFICADO: 160px → 190px (+30px) */
    margin-top: 0 !important;
}

.cuento-container.sin-circulo .pagina-contenido {
    justify-content: flex-start;
    padding-top: 50px !important; /* MODIFICADO: 20px → 50px (+30px) */
    margin-top: 0 !important;
}

.pagina-contenido {
    position: relative;
    z-index: 2;
    max-width: 800px;
    width: 90%;
    margin: 0 auto !important;
    height: auto;
    max-height: 80vh;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    padding: 70px 20px 20px 20px !important; /* MODIFICADO: 40px → 70px (+30px) */
    color: white;
    font-size: clamp(1em, 3vw, 2em);
    line-height: 1.7 !important;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.7), 0 0 12px rgba(0, 0, 0, 0.5);
    background: transparent;
    white-space: normal !important;
    word-spacing: normal !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mejoras para el modo subtítulos */
.subtitulo-container {
    width: 100%;
    min-height: 4em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    margin: 20px 0;
}

/* MODIFICACIÓN IMPORTANTE: Tamaño de fuente igual al modo normal */
.subtitulo-linea {
    font-size: clamp(1em, 3vw, 2em) !important;
    text-align: center;
    margin: 0.5em 0;
    padding: 0.8em 1.2em;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    transition: opacity 0.5s ease;
    max-width: 90%;
    line-height: 1.4;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Asegurar que el contenido original esté oculto en modo subtítulos */
.pagina-contenido[data-modo-texto="subtitulos"] > :not(.subtitulo-container):not(.cuento-opciones):not(.contenedor-minijuego) {
    display: none !important;
}

/* Restaurar contenido cuando se cambia de modo */
.pagina-contenido:not([data-modo-texto="subtitulos"]) .subtitulo-container {
    display: none !important;
}

.pagina-contenido:not([data-modo-texto="subtitulos"]) > * {
    display: block !important;
}

/* Contenedor de opciones - MODIFICACIÓN IMPORTANTE */
.cuento-opciones {
    display: none !important;
}

/* Ocultar el código de opciones dentro del contenedor */
.cuento-opciones,
.cuento-opciones * {
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Contenedor de opciones - Mismo estilo para ambos modos */
.opciones-container {
    display: flex;
    flex-direction: column;
    gap: 12px !important;
    margin: 15px 0 !important;
    width: 100%;
    max-width: 400px;
    align-self: center;
}

/* Botones de opciones - Mismo estilo para ambos modos */
.opcion-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 12px 18px !important;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    text-transform: uppercase !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    margin: 4px 0 !important;
}

.opcion-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.7);
    transform: scale(1.03);
}

.opcion-btn:active {
    transform: scale(0.98);
}

/* Fuerza la visualización correcta en ambos modos */
.pagina-contenido[data-modo-texto="normal"] .opciones-container,
.pagina-contenido[data-modo-texto="subtitulos"] .opciones-container {
    display: flex !important;
    flex-direction: column;
    gap: 12px !important;
    margin: 15px 0 !important;
}

.pagina-contenido[data-modo-texto="normal"] .opcion-btn,
.pagina-contenido[data-modo-texto="subtitulos"] .opcion-btn {
    margin: 4px 0 !important;
}

.contenedor-palabras {
    display: block !important;
    width: 100%;
    text-align: center;
    line-height: inherit !important;
}

/* Estilos para palabras */
.pagina-contenido span {
    transition: color 0.2s, background-color 0.2s;
    white-space: normal;
    display: inline;
}

/* Botones inferiores - RESTAURADO COLOR ORIGINAL */
.botones-inferiores {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(190, 150, 120, 0.6) !important; /* COLOR ORIGINAL RESTAURADO */
    padding: 8px 15px !important;
    z-index: 2147483647 !important; /* Z-index MÁXIMO */
    border-radius: 14px;
    width: 90%;
    max-width: 500px;
    backdrop-filter: blur(5px) !important; /* EFECTO BLUR RESTAURADO */
    border: 1px solid rgba(255, 255, 255, 0.1) !important; /* BORDE ORIGINAL */
}

.botones-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.botones-fila button {
    background: none;
    border: none;
    padding: 0;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.botones-fila button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.botones-fila button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.contador-pagina {
    color: white;
    font-size: 16px;
}

/* Barra de progreso general */
.barra-progreso {
    height: 5px;
    background: rgba(255,255,255,0.2);
    width: 100%;
    border-radius: 3px;
    margin-bottom: 8px !important;
    overflow: hidden;
}

/* Barra de progreso relleno - COLORES POR PERSONAJE */
.barra-progreso .relleno {
    height: 100%;
    transition: width 0.3s ease;
}

/* DINO - Verde azulado */
.skin-dino .barra-progreso .relleno {
    background: linear-gradient(to right, #ff6b6b, #4ecdc4) !important;
}

/* MONO - Naranja/marrón */
.skin-mono .barra-progreso .relleno {
    background: linear-gradient(to right, #ff9a3c, #ff6f69) !important;
}

/* DEFAULT - Color original */
.skin-default .barra-progreso .relleno {
    background: linear-gradient(to right, #ff66cc, #cc99ff) !important;
}

/* ========================================================================== */
/* MODIFICACIÓN IMPORTANTE: CÍRCULO DE PERSONAJE CON TAMAÑO FÍSICO FIJO */
/* ========================================================================== */

.circulo-personaje {
    position: absolute !important;
    top: 10px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 4.5cm !important; /* TAMAÑO FÍSICO FIJO EN CENTÍMETROS */
    height: 4.5cm !important; /* TAMAÑO FÍSICO FIJO EN CENTÍMETROS */
    border-radius: 50%;
    background: #ffe4e1;
    color: #333;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    z-index: 10001;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    padding: 5px !important;
    animation: colorPulse 6s infinite alternate ease-in-out, scalePulse 2s infinite ease-in-out;
}

/* Ocultar círculo cuando no hay cuento activo */
.cuento-wrapper:not(.cuento-activo) .circulo-personaje {
    display: none !important;
}

/* Ocultar círculo cuando no se desea mostrar */
.circulo-personaje.ocultar-circulo {
    display: none !important;
}

@keyframes colorPulse {
    0% { background-color: #ffe4e1; }
    25% { background-color: #ffdee9; }
    50% { background-color: #e1f0ff; }
    75% { background-color: #d4ffea; }
    100% { background-color: #ffe4e1; }
}

@keyframes scalePulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.07); }
}

/* Círculo del micrófono personalizado por personaje */
.circulo-microfono {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #4a90e2;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 3px solid #fff;
    z-index: 10001;
}

.circulo-microfono .mic-icono {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Animación de ondas sonoras */
.circulo-microfono::before, .circulo-microfono::after {
    content: '';
    position: absolute;
    border: 2px solid #4a90e2;
    border-radius: 50%;
    animation: pulso-ondas 2s linear infinite;
    opacity: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.circulo-microfono::after {
    animation-delay: 1s;
}

.circulo-microfono.escuchando {
    animation: pulse 1.5s infinite;
    background-color: #f44336;
}

/* Mensaje de voz */
.circulo-microfono .mensaje-voz {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    max-width: 250px;
    border: none;
    z-index: 1000;
    white-space: nowrap;
}

@keyframes pulso-ondas {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

/* Estilos específicos para skins */
body .cuento-wrapper.skin-dino .cuento-formulario-wrapper {
    background: url('https://storymals.com/wp-content/uploads/skins/dino/fondo.jpg') no-repeat center center !important;
    background-size: cover !important;
}

body .cuento-wrapper.skin-dino .cuento-formulario-wrapper:before {
    background-color: rgba(0,0,0,0.3) !important;
}

body .cuento-wrapper.skin-mono .cuento-formulario-wrapper {
    background: url('https://storymals.com/wp-content/uploads/skins/mono/fondo.jpg') no-repeat center center !important;
    background-size: cover !important;
}

body .cuento-wrapper.skin-mono .cuento-formulario-wrapper:before {
    background-color: rgba(0,0,0,0.3) !important;
}

/* ========================================================================== */
/* CONTENEDOR GLOBAL OF MINIJUEGOS - FUERA DEL CONTEXTO 3D */
/* ========================================================================== */

#contenedor-minijuegos-global {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483640 !important; /* Z-index más bajo que la barra */
    pointer-events: none !important;
    background: transparent !important;
    overflow: visible !important;
}

#contenedor-minijuegos-global > * {
    pointer-events: auto !important;
}

/* Contenedor específico para minijuegos */
#contenedor-minijuegos-global .contenedor-minijuego {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    display: block !important;
    overflow: visible !important;
}

/* Excepción para el juego Simon - necesitamos centrarlo */
#contenedor-minijuegos-global .contenedor-minijuego.juego-simon-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}
/* ========================================================================== */
/* ESTILOS PARA CONFETI MEJORADO CON ESTRELLAS
/* ========================================================================== */

/* Animación base para la caída */
@keyframes caerConfeti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Estilo para los confetis rectangulares */
.confeti-rectangulo {
    position: fixed;
    border-radius: 2px;
    opacity: 0.8;
    animation-timing-function: linear;
}

/* Estilo para las esferas (círculos) */
.confeti-esfera {
    position: fixed;
    border-radius: 50%;
    opacity: 0.9;
    animation-timing-function: ease-in-out;
}

/* Estilo para las estrellas con puntas redondeadas */
.confeti-estrella {
    position: fixed;
    opacity: 0.9;
    animation-timing-function: ease-in-out;
    /* Forma de estrella de 5 puntas con puntas ligeramente redondeadas */
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    /* Borde suave para redondear las puntas */
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.3));
}

/* ========================================================================== */
/* MEDIA QUERIES PARA DISPOSITIVOS CON DIFERENTES RESOLUCIONES (TIPO TABLET) */
/* ========================================================================== */

/* Dispositivos pequeños tipo tablet (600px - 768px) */
@media only screen and (min-width: 600px) and (max-width: 768px) {
    .biblioteca {
        gap: 240px !important;
    }
    
    .libro {
        width: 170px !important;
        height: 238px !important;
    }
    
    .libro-form input[type="image"] {
        width: 170px !important;
        height: 238px !important;
    }
    
    .titulo-estante {
        font-size: 2em !important;
        bottom: 46% !important;
    }
    
    .titulo-categoria {
        font-size: 52px !important;
        bottom: 145px !important;
    }
    
    .titulo-principal {
        font-size: 62px !important;
    }
    
    h2 {
        font-size: 54px !important;
    }
    
    .pagina-contenido {
        font-size: clamp(1.1em, 3.2vw, 1.7em) !important;
    }
    
    .cuentos-miniaturas form {
        width: 160px !important;
        height: 160px !important;
    }
}

/* Dispositivos medianos tipo tablet (769px - 1024px) */
@media only screen and (min-width: 769px) and (max-width: 1024px) {
    .biblioteca {
        gap: 280px !important;
    }
    
    .libro {
        width: 190px !important;
        height: 266px !important;
    }
    
    .libro-form input[type="image"] {
        width: 190px !important;
        height: 266px !important;
    }
    
    .titulo-estante {
        font-size: 2.4em !important;
        bottom: 45% !important;
    }
    
    .titulo-categoria {
        font-size: 60px !important;
        bottom: 155px !important;
    }
    
    .titulo-principal {
        font-size: 72px !important;
    }
    
    h2 {
        font-size: 64px !important;
    }
    
    .pagina-contenido {
        font-size: clamp(1.2em, 3vw, 1.8em) !important;
        max-width: 850px !important;
    }
    
    .cuentos-miniaturas form {
        width: 180px !important;
        height: 180px !important;
    }
    
    .botones-inferiores {
        max-width: 550px !important;
        padding: 10px 18px !important;
    }
    
    .botones-fila button {
        width: 42px !important;
        height: 42px !important;
    }
}

/* Dispositivos grandes tipo tablet (1025px - 1366px) */
@media only screen and (min-width: 1025px) and (max-width: 1366px) {
    .biblioteca {
        gap: 320px !important;
    }
    
    .libro {
        width: 210px !important;
        height: 294px !important;
    }
    
    .libro-form input[type="image"] {
        width: 210px !important;
        height: 294px !important;
    }
    
    .titulo-estante {
        font-size: 2.8em !important;
        bottom: 44% !important;
    }
    
    .titulo-categoria {
        font-size: 68px !important;
        bottom: 165px !important;
    }
    
    .titulo-principal {
        font-size: 78px !important;
    }
    
    h2 {
        font-size: 70px !important;
    }
    
    .pagina-contenido {
        font-size: clamp(1.3em, 2.8vw, 2em) !important;
        max-width: 900px !important;
    }
    
    .cuentos-miniaturas form {
        width: 200px !important;
        height: 200px !important;
    }
    
    .botones-inferiores {
        max-width: 600px !important;
        padding: 12px 20px !important;
    }
    
    .botones-fila button {
        width: 45px !important;
        height: 45px !important;
    }
}

/* Dispositivos muy grandes (1367px - 1920px) */
@media only screen and (min-width: 1367px) and (max-width: 1920px) {
    .biblioteca {
        gap: 350px !important;
    }
    
    .libro {
        width: 230px !important;
        height: 322px !important;
    }
    
    .libro-form input[type="image"] {
        width: 230px !important;
        height: 322px !important;
    }
    
    .titulo-estante {
        font-size: 3.2em !important;
        bottom: 43% !important;
    }
    
    .titulo-categoria {
        font-size: 76px !important;
        bottom: 175px !important;
    }
    
    .titulo-principal {
        font-size: 85px !important;
    }
    
    h2 {
        font-size: 78px !important;
    }
    
    .pagina-contenido {
        font-size: clamp(1.4em, 2.5vw, 2.2em) !important;
        max-width: 950px !important;
    }
    
    .cuentos-miniaturas form {
        width: 220px !important;
        height: 220px !important;
    }
}

/* Orientación horizontal para tablets */
@media only screen and (min-width: 600px) and (max-width: 1366px) and (orientation: landscape) {
    .biblioteca {
        gap: 200px !important;
    }
    
    .libros {
        bottom: 68% !important;
        padding-right: 35px !important;
        gap: 22px !important;
    }
    
    .titulo-estante {
        bottom: 48% !important;
        font-size: 1.8em !important;
    }
    
    .libro {
        width: 150px !important;
        height: 210px !important;
    }
    
    .libro-form input[type="image"] {
        width: 150px !important;
        height: 210px !important;
    }
    
    .pagina-contenido {
        padding-top: 100px !important;
    }
}

/* ========================================================================== */
/* ESTILOS RESPONSIVE Y MEDIA QUERIES PARA MÓVILES */
/* ========================================================================== */

@media (max-width: 768px) {
    .titulo-principal {
        font-size: 50px;
        margin: 20px 0;
    }
    
    h2 {
        font-size: 40px;
    }
    
    .cuento-formulario-wrapper h2 {
        font-size: 24px;
    }
    
    .cuento-formulario-wrapper p {
        font-size: 1.1em;
    }
    
    .titulo-categoria {
        font-size: 40px;
        bottom: 120px;
    }
    
    .cuentos-miniaturas {
        padding: 15px 20px 0px 20px !important;
    }
    
    .cuentos-miniaturas form {
        width: 140px;
        height: 140px;
    }
    
    .pagina-contenido {
        font-size: clamp(0.9em, 4vw, 1.5em);
        padding: 60px 15px 15px 15px !important; /* MODIFICADO: 30px → 60px (+30px) */
    }
    
    .botones-inferiores {
        width: 95%;
        padding: 6px 12px !important;
    }
    
    .botones-fila button {
        width: 35px;
        height: 35px;
    }
    
    .circulo-microfono {
        width: 70px;
        height: 70px;
        bottom: 90px;
    }
    
    .circulo-microfono .mic-icono {
        width: 35px;
        height: 35px;
    }
    
  
    
    /* 🧠 AJUSTES ESPECÍFICOS PARA TABLETS - LIBROS 20% MÁS GRANDES Y TÍTULOS 50% MÁS GRANDES */
    .biblioteca {
        gap: 300px !important; /* ESPACIO NORMAL en tablets */
    }
    
    .estante-contenedor {
        padding-top: 30px !important; /* MÁS ESPACIO en tablets */
        padding-bottom: 30px !important;
    }
    
    /* LIBROS 20% MÁS GRANDES EN TABLETS */
    .libro {
        width: 216px !important; /* 180px + 20% = 216px */
        height: 302px !important; /* 252px + 20% = 302px */
    }
    
    .libros {
        bottom: 67% !important; /* POSICIÓN ORIGINAL en tablets */
        padding-right: 30px !important;
        gap: 30px !important;
    }
    
    .libros::before {
        flex-basis: 30px;
    }
    
    /* TÍTULOS 50% MÁS GRANDES EN TABLETS */
    .titulo-estante {
        bottom: 44% !important; /* POSICIÓN ORIGINAL en tablets */
        font-size: 3.5em !important; /* TAMAÑO GRANDE PARA TABLETS */
        font-weight: 700 !important;
    }
    
    /* Hover completo en tablets */
    .libro:hover {
        transform: perspective(1000px) rotateY(10deg) rotateX(5deg) translateY(-8px) !important;
        filter: 
          drop-shadow(0 8px 20px rgba(255, 255, 255, 0.6))
          drop-shadow(0 4px 12px rgba(255, 215, 0, 0.4))
          brightness(1.1) !important;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25) !important;
    }
    
    /* Ajustes para formularios en tablets - 20% MÁS GRANDES */
    .libro-form input[type="image"] {
        width: 216px !important; /* 180px + 20% = 216px */
        height: 302px !important; /* 252px + 20% = 302px */
    }
    
    .libro-form input[type="image"]:hover {
        transform: perspective(1000px) rotateY(10deg) rotateX(5deg) translateY(-8px) !important;
        filter: 
            drop-shadow(0 8px 20px rgba(255, 255, 255, 0.6))
            drop-shadow(0 4px 12px rgba(255, 215, 0, 0.4))
            brightness(1.1) !important;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25) !important;
    }
}

/* ========================================================================== */
/* VERSIÓN DEFINITIVA PARA TELÉFONOS */
/* ========================================================================== */

@media (max-width: 480px) {
    .titulo-principal {
        font-size: 36px;
        -webkit-text-stroke: 2px #e75ca9;
    }
    
    h2 {
        font-size: 28px;
    }
    
    .cuentos-miniaturas form {
        width: 120px;
        height: 120px;
    }
    
    .titulo-categoria {
        font-size: 32px;
        bottom: 100px;
    }
    
    .pagina-contenido {
        font-size: clamp(0.8em, 4.5vw, 1.2em);
        padding: 55px 10px 10px 10px !important; /* MODIFICADO: 25px → 55px (+30px) */
    }
    
    .subtitulo-linea {
        font-size: clamp(0.8em, 4.5vw, 1.2em) !important;
        padding: 0.6em 1em;
    }
    
    /* AJUSTES ESPECÍFICOS PARA MÓVILES */
    .biblioteca {
        gap: 180px !important;
    }
    
    /* LIBROS MÁS ABAJO EN MÓVILES */
    .libros {
        bottom: 65% !important;
        padding-left: 10px !important;
        padding-right: 20px !important;
    }
    
    /* ELIMINAR ESPACIO INICIAL */
    .libros::before {
        flex: 0 0 0 !important;
    }
    
    /* TÍTULOS MÁS ABAJO EN MÓVILES */
    .titulo-estante {
        bottom: 42% !important;
        font-size: 1.1em !important; /* TAMAÑO PEQUEÑO PARA MÓVILES */
    }
    
    .libro {
        width: 130px;
        height: 182px;
    }
    
    /* Ajustes para formularios en pantallas muy pequeñas */
    .libro-form input[type="image"] {
        width: 130px !important;
        height: 182px !important;
    }
}

/* ========================================================================== */
/* CORRECCIÓN DEFINITIVA PARA TABLETS - TÍTULOS GRANDES SOLO EN TABLETS */
/* ========================================================================== */

@media (min-width: 481px) and (max-width: 768px) {
    /* CONFIRMAR QUE LOS LIBROS SEAN 20% MÁS GRANDES */
    .libro {
        width: 216px !important;
        height: 302px !important;
    }
    
    /* CONFIRMAR QUE LOS TÍTULOS SEAN GRANDES SOLO EN TABLETS */
    .titulo-estante {
        font-size: 2.5em !important; /* GRANDE SOLO EN TABLETS */
        bottom: 44% !important;
    }
    
    /* CONFIRMAR FORMULARIOS 20% MÁS GRANDES */
    .libro-form input[type="image"] {
        width: 216px !important;
        height: 302px !important;
    }
}

/* ========================================================================== */
/* ESTILOS PARA IMPRESIÓN */
/* ========================================================================== */

@media print {
    .botones-inferiores,
    .circulo-personaje,
    .circulo-microfono,
    .cuento-formulario-wrapper:before {
        display: none !important;
    }
    
    .cuento-pagina {
        position: relative !important;
        transform: none !important;
        page-break-after: always;
    }
    
    .pagina-frente, .pagina-dorso {
        position: relative !important;
        transform: none !important;
    }
}

/* ========================================================================== */
/* ESTILOS DE ACCESIBILIDAD */
/* ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .cuento-pagina {
        transition: none !important;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    .text-white-pink {
        -webkit-text-stroke: 3px #000;
        text-stroke: 3px #000;
    }
    
    .pagina-contenido {
        text-shadow: 2px 2px 0 #000, 0 0 10px #000;
    }
    
    .opcion-btn, .respuesta-btn {
        border-width: 3px;
    }
}

/* ========================================================================== */
/* UTILIDADES Y ESTILOS AUXILIARES */
/* ========================================================================== */

.oculto {
    display: none !important;
}

.transparente {
    opacity: 0 !important;
    pointer-events: none !important;
}

.texto-centrado {
    text-align: center !important;
}

.texto-izquierda {
    text-align: left !important;
}

.texto-derecha {
    text-align: right !important;
}

.margen-superior {
    margin-top: 20px !important;
}

.margen-inferior {
    margin-bottom: 20px !important;
}

.padding-lateral {
    padding-left: 20px !important;
    padding-right: 20px !important;
}

/* Estados de carga */
.cargando {
    position: relative;
    overflow: hidden;
}

.cargando::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ========================================================================== */
/* ESTILOS PARA MENSAJE DE VICTORIA - MEJORADO CON ESPACIADO */
/* ========================================================================== */

.mensaje-victoria {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    padding: 25px 35px !important;
    border-radius: 12px !important;
    font-size: 26px !important;
    z-index: 2147483648 !important;
    text-align: center !important;
    max-width: 80% !important;
    font-family: 'Fredoka', sans-serif !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(5px) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    animation: aparecerMensaje 0.3s ease-out !important;
    line-height: 1.4 !important;
    margin: 0 !important;
}

@keyframes aparecerMensaje {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========================================================================== */
/* RESPONSIVE PARA MENSAJE DE VICTORIA */
/* ========================================================================== */

@media (max-width: 768px) {
    .mensaje-victoria {
        font-size: 22px !important;
        padding: 20px 30px !important;
        max-width: 85% !important;
    }
}

@media (max-width: 480px) {
    .mensaje-victoria {
        font-size: 20px !important;
        padding: 18px 25px !important;
        max-width: 90% !important;
    }
}



/* Fin del CSS */