/* ==========================================================================
   1191 JUEGOS DE GYM MENTAL - SALA DE EXPOSICIÓN 3D MOBILE-FIRST
   Viewport: 100dvh estricto, sin scroll global, diseño táctil inmersivo
   ========================================================================== */

:root {
  --primary: #f59e0b;
  --primary-glow: rgba(245, 158, 11, 0.4);
  --accent: #10b981;
  --bg-dark: #090c15;
  --card-bg: rgba(17, 24, 39, 0.88);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --gold-gradient: linear-gradient(135deg, #fcd34d 0%, #f59e0b 50%, #d97706 100%);
  --gold-glow: 0 0 24px rgba(245, 158, 11, 0.5);
  --shelf-wood: #2c1a0e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100vh);
  overflow: hidden;
  position: fixed;
  background-color: var(--bg-dark);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  touch-action: manipulation;
}

/* ==========================================================================
   CONTENEDOR MAESTRO DE LA APLICACIÓN (100dvh)
   ========================================================================== */
#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Fondo inmersivo del librero */
.bookshelf-backdrop {
  position: absolute;
  inset: 0;
  background-image: url('assets/bookshelf-bg.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: brightness(0.85) contrast(1.1);
  transform: scale(1.02);
  transition: filter 0.6s ease, transform 0.6s ease;
  z-index: 1;
}

.backdrop-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(10, 14, 26, 0.2) 0%, rgba(7, 9, 18, 0.88) 100%),
              linear-gradient(to bottom, rgba(5, 7, 15, 0.75) 0%, transparent 20%, transparent 75%, rgba(5, 7, 15, 0.95) 100%);
  z-index: 2;
  pointer-events: none;
}

.reader-active .bookshelf-backdrop {
  filter: brightness(0.35) blur(10px);
  transform: scale(1.08);
}

/* Capa de protección anti-descargas */
.security-shield {
  position: absolute;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: transparent;
}

/* ==========================================================================
   HEADER SUPERIOR (MÓVIL COMPACTO)
   ========================================================================== */
.app-header {
  position: relative;
  z-index: 10;
  padding: calc(var(--safe-top) + 8px) 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(8, 11, 20, 0.85) 0%, rgba(8, 11, 20, 0) 100%);
  flex-shrink: 0;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #0f172a;
  background: var(--gold-gradient);
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.live-dot {
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.7; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

.icon-btn.active {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.15);
}

/* ==========================================================================
   VISTA 1: SALA DE EXPOSICIÓN 3D (LIBRERO INTERACTIVO)
   ========================================================================== */
.view-shelf {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding-bottom: calc(var(--safe-bottom) + 8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.view-shelf.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
  position: absolute;
  inset: 0;
}

.shelf-title-zone {
  text-align: center;
  padding: 6px 16px 2px;
}

.shelf-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.3px;
  line-height: 1.15;
  background: linear-gradient(180deg, #ffffff 40%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.shelf-tagline {
  font-size: 11px;
  color: #fbbf24;
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Escenario 3D para el carrusel de libros */
.shelf-3d-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  perspective-origin: 50% 48%;
  width: 100%;
  touch-action: pan-y pinch-zoom;
}

.shelf-track {
  position: relative;
  width: 200px;
  height: 285px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.25, 1);
}

/* Libro 3D individual en el estante */
.book-3d-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 0.4s ease;
}

.book-card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(-18deg) rotateX(6deg);
  transition: transform 0.4s ease;
}

.book-3d-wrapper.active .book-card-3d {
  transform: rotateY(-8deg) rotateX(2deg) scale(1.04);
}

/* Portada del libro */
.book-cover-front {
  position: absolute;
  inset: 0;
  border-radius: 4px 9px 9px 4px;
  overflow: hidden;
  box-shadow: 6px 12px 28px rgba(0, 0, 0, 0.8),
              0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  background-color: #1e293b;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.book-cover-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Brillo y relieve de la portada */
.book-cover-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0) 35%,
    rgba(0, 0, 0, 0.35) 90%
  );
  pointer-events: none;
}

/* Lomo 3D del libro (lado izquierdo) */
.book-spine-3d {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 100%;
  transform-origin: left center;
  transform: rotateY(90deg) translateX(-22px);
  border-radius: 4px 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset -2px 0 6px rgba(0, 0, 0, 0.6);
}

.book-spine-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
}

/* Corte de páginas 3D (borde derecho con textura de hojas apiladas) */
.book-pages-edge {
  position: absolute;
  top: 3px;
  right: 0;
  width: 19px;
  height: calc(100% - 6px);
  transform-origin: right center;
  transform: rotateY(-90deg) translateX(19px);
  background: repeating-linear-gradient(
    to bottom,
    #f8fafc 0px,
    #f8fafc 1px,
    #e2e8f0 1.5px,
    #cbd5e1 2px
  );
  box-shadow: inset 2px 0 5px rgba(0, 0, 0, 0.4);
}

/* Sombra realista proyectada sobre el estante de madera */
.book-shelf-shadow {
  position: absolute;
  bottom: -18px;
  left: 10%;
  width: 85%;
  height: 22px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 72%);
  transform: rotateX(85deg);
  filter: blur(4px);
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.book-3d-wrapper.active .book-shelf-shadow {
  transform: rotateX(85deg) scale(1.15) translateY(-5px);
  opacity: 0.95;
}

/* Estante de madera iluminado bajo el libro */
.wooden-ledge {
  position: absolute;
  bottom: 0px;
  left: -20%;
  width: 140%;
  height: 14px;
  background: linear-gradient(180deg, #452a18 0%, #29180c 60%, #150b06 100%);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.9),
              0 -2px 10px rgba(245, 158, 11, 0.4) inset;
  transform: translateZ(-30px);
}

.wooden-ledge-glow {
  position: absolute;
  top: -2px;
  left: 15%;
  width: 70%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #fbbf24, transparent);
  filter: blur(2px);
}

/* Tarjeta informativa del libro activo en el estante */
.shelf-book-meta {
  text-align: center;
  padding: 0 20px;
  margin-top: 4px;
  min-height: 72px;
}

.active-book-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  margin-bottom: 5px;
  backdrop-filter: blur(8px);
}

.active-book-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.active-book-subtitle {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

/* Controles de navegación en el estante */
.shelf-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

.shelf-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shelf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.25s ease;
  cursor: pointer;
}

.shelf-dot.active {
  width: 22px;
  border-radius: 999px;
  background: var(--gold-gradient);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Botón principal de apertura 3D */
.btn-open-3d {
  width: 100%;
  max-width: 330px;
  height: 48px;
  background: var(--gold-gradient);
  border: none;
  border-radius: 12px;
  color: #111827;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45),
              0 1px 0 rgba(255, 255, 255, 0.5) inset;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: pulse-open 2.5s infinite;
}

@keyframes pulse-open {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45); }
  50% { transform: scale(1.02); box-shadow: 0 8px 26px rgba(245, 158, 11, 0.7); }
}

.btn-open-3d:active {
  transform: scale(0.97);
}

.shelf-swipe-hint {
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ==========================================================================
   VISTA 2: LECTOR 3D INTERACTIVO (MOBILE VIEWPORT CONSTRAINED)
   ========================================================================== */
.view-reader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-reader.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Barra superior del lector */
.reader-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 6px) 14px 6px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.back-to-shelf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-to-shelf-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.2);
}

.reader-book-info {
  text-align: center;
  flex: 1;
  padding: 0 10px;
}

.reader-book-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
  margin: 0 auto;
}

.reader-page-counter {
  font-size: 10px;
  color: #fbbf24;
  font-weight: 700;
  margin-top: 1px;
}

/* Área central del libro en 3D (para mobile viewport ~52%) */
.reader-book-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  perspective: 1500px;
  perspective-origin: 50% 50%;
  touch-action: none; /* Tomamos control táctil total con JS */
}

/* ==========================================================================
   CUADERNILLO 3D REALISTA (EFECTO DE HOJA CURVADA, LOMO Y PÁGINAS APILADAS)
   ========================================================================== */
.reader-3d-booklet {
  position: relative;
  width: min(88vw, 320px);
  height: 100%;
  max-height: 380px;
  transform-style: preserve-3d;
  perspective: 1800px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Base de soporte y tapa trasera del cuadernillo */
.booklet-cover-base {
  position: absolute;
  inset: 0;
  border-radius: 6px 12px 12px 6px;
  background: #141c2e;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.9),
              0 2px 6px rgba(0, 0, 0, 0.6);
  z-index: 1;
}

/* Borde derecho: grosor realista de hojas de papel apiladas */
.booklet-edge-stack-right {
  position: absolute;
  top: 4px;
  right: -6px;
  width: 6px;
  height: calc(100% - 8px);
  background: repeating-linear-gradient(
    to bottom,
    #ffffff 0px,
    #f8fafc 1px,
    #e2e8f0 1.5px,
    #94a3b8 2.2px
  );
  border-radius: 0 3px 3px 0;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.4);
}

/* Borde inferior de páginas */
.booklet-edge-stack-bottom {
  position: absolute;
  bottom: -4px;
  left: 20px;
  width: calc(100% - 24px);
  height: 4px;
  background: repeating-linear-gradient(
    to right,
    #ffffff 0px,
    #f8fafc 1px,
    #cbd5e1 1.5px,
    #94a3b8 2.2px
  );
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Lomo encuadernado del cuadernillo (grapas y textura de encuadernación) */
.booklet-spine-binding {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, #1e293b 0%, #334155 70%, #0f172a 100%);
  border-radius: 6px 0 0 6px;
  z-index: 35;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.5),
              inset 1px 0 0 rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  padding: 24px 0;
  pointer-events: none;
}

.spine-staples {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 80%;
  align-items: center;
}

.staple {
  width: 3.5px;
  height: 18px;
  background: linear-gradient(90deg, #94a3b8 0%, #f8fafc 45%, #64748b 100%);
  border-radius: 1.5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.spine-crease-shadow {
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 100%;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.45) 0%, transparent 100%);
  pointer-events: none;
}

/* Hoja estática subyacente (queda expuesta debajo al doblar la hoja activa) */
.booklet-page-under {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 18px;
  width: calc(100% - 18px);
  height: 100%;
  border-radius: 0 10px 10px 0;
  background-color: #ffffff;
  overflow: hidden;
  z-index: 5;
  box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.2);
}

.page-under-shadow {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.15) 35%, transparent 65%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

/* Hoja 3D interactiva que se dobla y voltea con el dedo */
.booklet-flipper-3d {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 18px;
  width: calc(100% - 18px);
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
  border-radius: 0 10px 10px 0;
  z-index: 20;
  cursor: grab;
  /* Curvatura de papel sutil al rotar */
  will-change: transform;
}

.booklet-flipper-3d:active {
  cursor: grabbing;
}

/* Caras delantera y trasera de la hoja */
.page-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 10px 10px 0;
  overflow: hidden;
  background-color: #ffffff;
}

.page-face-front {
  z-index: 2;
  transform: rotateY(0deg);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

.page-face-back {
  z-index: 1;
  transform: rotateY(180deg);
  background-color: #fcfbf9;
}

/* Reverso realista con textura de papel de cuadernillo */
.page-back-wrapper {
  opacity: 0.88;
  filter: blur(0.3px);
}

.cuadernillo-paper-pattern {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(to right, rgba(0, 0, 0, 0.15) 0%, transparent 8%);
  background-size: 16px 16px, 100% 100%;
  z-index: 2;
  pointer-events: none;
}

.page-back-crease {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 100%;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
  z-index: 4;
  pointer-events: none;
}

.page-back-shading {
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.35) 0%, rgba(255, 255, 255, 0.3) 40%, transparent 100%);
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}

/* Pliegue interno del lomo en la cara frontal */
.page-gutter-crease {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.12) 45%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 6;
}

/* Sombreado dinámico de curvatura / cilindro durante el giro */
.page-curl-shading {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.25) 0%,
    rgba(255, 255, 255, 0.45) 30%,
    rgba(0, 0, 0, 0.3) 70%,
    rgba(0, 0, 0, 0.4) 100%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 7;
}

/* Sombra proyectada en la mesa/fondo cuando la hoja se levanta */
.booklet-ground-shadow {
  position: absolute;
  bottom: -16px;
  left: 20px;
  width: calc(100% - 24px);
  height: 20px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.75) 0%, transparent 75%);
  filter: blur(5px);
  pointer-events: none;
  z-index: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Imagen dentro de cada hoja */
.page-image-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.page-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Marca de agua elegante de muestra protegida */
.page-sample-watermark {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #f1f5f9;
  font-size: 8px;
  font-weight: 700;
  padding: 2.5px 6.5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 10;
}

/* Zonas de toque lateral para pasar página sin arrastrar */
.touch-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-zone-prev {
  left: 0;
}

.touch-zone-next {
  right: 0;
}

.zone-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0.55;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.touch-zone:active .zone-arrow {
  opacity: 1;
  transform: scale(1.1);
  background: var(--gold-gradient);
  color: #0f172a;
}

/* Barra de progreso de páginas */
.reader-progress-track {
  position: relative;
  width: calc(100% - 28px);
  margin: 0 auto 4px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.reader-progress-bar {
  height: 100%;
  width: 8.33%;
  background: var(--gold-gradient);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ==========================================================================
   PANEL INFERIOR: EXPLICACIÓN DE LA PÁGINA (DEBAJO DEL LIBRO)
   "debajo tiene que tener una explicacion de la pagina"
   ========================================================================== */
.reader-explanation-sheet {
  position: relative;
  z-index: 25;
  background: rgba(13, 17, 30, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px 18px 0 0;
  padding: 10px 14px calc(var(--safe-bottom) + 8px);
  flex-shrink: 0;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.7);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Cabecera de la explicación */
.explanation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exercise-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.skill-tag {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2.5px 7px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.brain-area-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 2.5px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.exercise-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.25;
}

/* Cuerpo de la explicación */
.explanation-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.explanation-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.explanation-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 4px;
}

.explanation-text {
  font-size: 11.5px;
  color: #e2e8f0;
  line-height: 1.35;
}

/* Fila interactiva de pista / beneficio */
.tip-interactive-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tip-interactive-box:active {
  background: rgba(245, 158, 11, 0.1);
}

.tip-box-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fde68a;
}

.tip-box-toggle {
  font-size: 10px;
  color: #94a3b8;
}

.tip-content-reveal {
  font-size: 11px;
  color: #fef08a;
  line-height: 1.35;
  padding-top: 4px;
  display: none;
}

.tip-content-reveal.open {
  display: block;
}

/* Botón de compra permanente en el lector */
.reader-sales-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.btn-buy-reader {
  flex: 1;
  height: 42px;
  background: var(--gold-gradient);
  border: none;
  border-radius: 10px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
  transition: transform 0.2s ease;
}

.btn-buy-reader:active {
  transform: scale(0.97);
}

.page-flip-hint {
  text-align: center;
  font-size: 9.5px;
  color: #64748b;
  margin-top: 1px;
}

/* ==========================================================================
   MODAL DE VENTA / CHECKOUT DEL COMBO 1191 JUEGOS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 15, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sales-drawer {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  max-height: 88vh;
  background: #0f1422;
  border-top: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 24px 24px 0 0;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.9);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .sales-drawer {
  transform: translateY(0);
}

.drawer-drag-pill {
  width: 42px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  margin: 0 auto 4px;
}

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

.drawer-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drawer-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.drawer-title {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;
  color: #ffffff;
}

.drawer-subtitle {
  font-size: 11.5px;
  color: #94a3b8;
  line-height: 1.35;
}

/* Oferta con cronómetro regresivo */
.urgency-banner {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.urgency-text {
  font-size: 10.5px;
  font-weight: 700;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.countdown-clock {
  font-size: 12.5px;
  font-weight: 900;
  font-family: monospace;
  color: #fbbf24;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  letter-spacing: 1px;
}

/* Lista de lo que incluye el combo */
.bundle-items-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
}

.bundle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  font-size: 11px;
  gap: 8px;
  box-sizing: border-box;
}

.bundle-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #f1f5f9;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.bundle-item-left span:last-child {
  line-height: 1.25;
  white-space: normal;
}

.bundle-item-val {
  font-size: 10px;
  color: #64748b;
  text-decoration: line-through;
  flex-shrink: 0;
}

/* Caja de precio final */
.price-box {
  background: radial-gradient(circle at center, rgba(245, 158, 11, 0.15) 0%, rgba(15, 23, 42, 0.6) 100%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.original-price {
  font-size: 12px;
  color: #94a3b8;
  text-decoration: line-through;
}

.discount-price {
  font-size: 28px;
  font-weight: 900;
  color: #fbbf24;
  line-height: 1.1;
  text-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.discount-badge-bubble {
  font-size: 10px;
  font-weight: 800;
  color: #0f172a;
  background: #10b981;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
  margin-top: 4px;
}

/* Botones de acción de compra */
.drawer-ctas {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-whatsapp-order {
  height: 48px;
  background: #16a34a;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
  transition: transform 0.2s ease;
  text-decoration: none;
}

.btn-whatsapp-order:active {
  transform: scale(0.97);
}

.btn-online-checkout {
  height: 46px;
  background: var(--gold-gradient);
  border: none;
  border-radius: 12px;
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  text-decoration: none;
}

.guarantee-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 9.5px;
  color: #94a3b8;
  margin-top: 2px;
}

.guarantee-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ==========================================================================
   ANIMACIONES DE APERTURA 3D
   ========================================================================== */
@keyframes bookOpenFly {
  0% {
    transform: translateY(0) scale(1) rotateY(-8deg);
  }
  50% {
    transform: translateY(-20px) scale(1.1) rotateY(0deg);
  }
  100% {
    transform: translateY(0) scale(1) rotateY(0deg);
  }
}

/* Ajustes finos de accesibilidad y landscape móvil */
@media (max-height: 600px) {
  .shelf-track {
    height: 230px;
    width: 160px;
  }
  .shelf-title {
    font-size: 17px;
  }
  .reader-explanation-sheet {
    max-height: 48vh;
    padding: 8px 12px;
  }
}
