/* === Variables Globales (único :root) === */
:root {
  --color-principal: #FF7043;
  --color-secundario: #FFD54F;
  --color-fondo: #FFF3E0;
  --color-texto: #333;

  --color-suma: #BA68C8;
  --color-resta: #AED581;
  --color-multiplicacion: #4FC3F7;
  --color-division: #FFF176;

  /* colores nuevos para nuevas operaciones */
  --color-factorial: #FFB74D;
  --color-fracciones: #81C784;
  --color-numeros-primos: #64B5F6;
  --color-porcentajes: #FF8A65;
  --color-potencias: #CE93D8;

  /* colores nuevos para modos de salas */
  --color-clasico:   #4FC3F7;
  --color-opciones:  #66BB6A;
  --color-visual:    #FFCA28;
  --color-reto:      #AB47BC;
  --color-completar: #EF5350;
  --color-enunciado: #26C6DA;

  --color-error: #e57373;
  --color-exito: #81C784;

  --border-radius: 20px;
  --fuente: 'Fredoka', sans-serif;
}

/* === Reset Básico === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--fuente);
  background-color: var(--color-fondo);
  color: var(--color-texto);
  text-align: center;
  padding-bottom: 3rem;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === MAIN FIJO A 960PX (sin cambios por pantalla) === */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}

h1.titulo {
  font-size: 3rem;
  color: var(--color-principal);
  margin: 1rem 0;
}

h2.slogan {
  font-size: 1.8rem; /* ← MÁS GRANDE */
  color: #333; /* ← GRIS OSCURO (más visible) */
  font-weight: 600; /* ← MÁS GRUESO */
  margin-bottom: 1.5rem;
  text-align: center;
  background: none;
  box-shadow: none;
  text-shadow: 1px 1px 3px rgba(255,255,255,0.8); /* ← Sombra suave */
}
/* === Logo animado (video MP4) === */
.logo-hero {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  width: 100px;
  z-index: 10;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background-color: white;
  padding: 0.4rem;
  border: 2px solid #FFD54F;
}

.logo-hero video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

/* === HERO FIJO A 960PX (sin cambios) === */
#hero {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 2rem auto;
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: #FFE0B2;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
}

.hero-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Banners (900x150) === */
.banner-placeholder,
.banner-img {
  width: 100%;
  max-width: 900px;
  height: 150px;
  background-color: #eee;
  border: 2px dashed #ccc;
  border-radius: var(--border-radius);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  color: #999;
  margin: 1rem auto;
}

/* === Botones de operaciones: SIEMPRE EN COLUMNA === */
.operaciones,
.modo-selector {
  display: flex;
  flex-direction: column; /* ← SIEMPRE uno arriba del otro */
  align-items: center;
  gap: 1.5rem;
  margin: 2.5rem 0;
}

.game-btn {
  color: white;
  padding: 1.2rem 2.5rem;
  font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.3s;
  max-width: 500px;
  width: 100%;
  font-weight: 600;
}

.game-btn:hover {
  transform: scale(1.05);
}

/* Colores por operación */
#btn-suma,
[data-modo="suma"]       { background-color: var(--color-suma) !important; }

#btn-resta,
[data-modo="resta"]      { background-color: var(--color-resta) !important; }

#btn-multiplica,
[data-modo="multiplicacion"] { background-color: var(--color-multiplicacion) !important; }

#btn-divide,
[data-modo="division"]   { background-color: var(--color-division) !important; color: #333 !important; }

/* Colores para nuevas operaciones */
#btn-factorial,
[data-modo="factorial"]  { background-color: var(--color-factorial) !important; }

#btn-fracciones,
[data-modo="fracciones"] { background-color: var(--color-fracciones) !important; }

#btn-numeros-primos,
[data-modo="numeros-primos"] { background-color: var(--color-numeros-primos) !important; }

#btn-porcentajes,
[data-modo="porcentajes"] { background-color: var(--color-porcentajes) !important; }

#btn-potencias,
[data-modo="potencias"]  { background-color: var(--color-potencias) !important; }

/* Botones de modos de sala */
.btn-modo {
  color: #000;
  font-weight: 600;
  border: 2px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-modo[data-modo="clasico"]     { background-color: var(--color-clasico); }
.btn-modo[data-modo="opciones"]    { background-color: var(--color-opciones); }
.btn-modo[data-modo="visual"]      { background-color: var(--color-visual); }
.btn-modo[data-modo="desafio"]     { background-color: var(--color-reto); }
.btn-modo[data-modo="completar"]   { background-color: var(--color-completar); }
.btn-modo[data-modo="palabras"]    { background-color: var(--color-enunciado); }

.btn-modo:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* === Zona de juego y mapa === */
.zona-juego,
.mapa-zona {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem;
  border-radius: var(--border-radius);
  background-color: #ffffffcc;
  box-shadow: 0 0 15px rgba(0,0,0,0.12);
  text-align: center;
}

.modo-selector {
  background-color: #f9f9f9;
  border-radius: var(--border-radius);
  padding: 1.8rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

/* === Cuadro de juego (juego rápido y salas) === */
#game-area,
#area-juego {
  margin: 2.5rem auto;
  padding: 2.5rem;
  max-width: 850px;
  width: 100%;
  text-align: center;
  background-color: #ffffff;
  border-radius: var(--border-radius);
  box-shadow: 0 0 12px rgba(0,0,0,0.1);
}

.pregunta {
  font-size: clamp(2.2rem, 6vw, 4rem); /* ← MÁS GRANDE */
  color: var(--color-principal);
  margin-bottom: 1.8rem;
  font-weight: 700; /* ← MÁS GRUESO */
  line-height: 1.3;
}

/* === Modo visual === */
#visual-area {
  margin: 1.5rem auto;
  min-height: 120px;
  padding: 1.5rem;
  background-color: #f0f0f0;
  border: 2px dashed #ccc;
  border-radius: var(--border-radius);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

#visual-area .bloque {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-block;
  background-color: var(--color-suma);
}

#visual-area .palito {
  width: 14px;
  height: 48px;
  border-radius: 6px;
  display: inline-block;
  background-color: var(--color-resta);
}

#visual-area .grupo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#visual-area .bolita {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-block;
  margin: 0 4px;
  background-color: var(--color-division);
}

/* === Formularios / inputs === */
#respuesta,
#resp {
  padding: 1.2rem 1.6rem;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  border: 2px solid #ccc;
  border-radius: var(--border-radius);
  width: 85%;
  max-width: 420px;
  margin: 0.8rem auto;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* === Botones en área de juego === */
#area-juego button {
  background-color: var(--color-principal);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 1.3rem 1.8rem;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 700;
  margin: 0.6rem auto;
  cursor: pointer;
  min-width: 90px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 14px rgba(255, 112, 67, 0.2);
  transition: all 0.25s ease;
  width: 85%;
  max-width: 420px;
}

#area-juego button:hover {
  background-color: #e65100;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(255, 112, 67, 0.28);
}

/* === Modo Opciones === */
#area-juego .opts,
#area-juego > div:not(.pregunta):not(#feedback):not(#visual-area):not(#timer) {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

#area-juego .opts button,
#area-juego > div button {
  width: auto;
  padding: 1rem 1.2rem;
  font-size: clamp(1.4rem, 4.8vw, 2rem);
  min-width: 80px;
  min-height: 80px;
  margin: 0;
}

/* === Feedback === */
#feedback {
  margin-top: 1.5rem;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  min-height: 2.5rem;
  transition: all 0.3s ease;
  font-weight: bold;
  line-height: 1.5;
}

.correcto   { color: var(--color-exito); }
.incorrecto { color: var(--color-error); }

.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

/* === YouTube === */
.youtube-section {
  max-width: 520px;
  margin: 2.5rem auto;
  display: flex;
  justify-content: center;
}

.youtube-video {
  width: 100%;
  max-width: 520px;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: 0 0 12px rgba(0,0,0,0.08);
}

/* === Decoraciones Laterales - AJUSTADAS === */
.decoracion-izquierda,
.decoracion-derecha {
  position: fixed;
  top: 50%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.95;
  transform: translateY(-50%);
  border: 4px solid #FFD54F;
  border-radius: var(--border-radius); /* ← BORDES REDONDEADOS IGUAL AL SITIO */
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  width: 180px;
  height: 320px;
}

/* Posición segura */
.decoracion-izquierda {
  left: calc((100vw - 960px) / 2 - 200px);
}

.decoracion-derecha {
  right: calc((100vw - 960px) / 2 - 200px);
}

/* Videos llenan contenedor */
.decoracion-izquierda video,
.decoracion-derecha video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.flotando {
  animation: flotar 3.5s ease-in-out infinite;
}
@keyframes flotar {
  0%, 100% { transform: translateY(-50%) translateY(0); }
  50% { transform: translateY(-50%) translateY(-12px); }
}

/* Escalado por pantalla */
@media (min-width: 1025px) and (max-width: 1440px) {
  .decoracion-izquierda,
  .decoracion-derecha {
    width: 190px;
    height: 338px;
  }
  .decoracion-izquierda {
    left: calc((100vw - 960px) / 2 - 210px);
  }
  .decoracion-derecha {
    right: calc((100vw - 960px) / 2 - 210px);
  }
}

@media (min-width: 1441px) and (max-width: 1920px) {
  .decoracion-izquierda,
  .decoracion-derecha {
    width: 220px;
    height: 391px;
  }
  .decoracion-izquierda {
    left: calc((100vw - 960px) / 2 - 240px);
  }
  .decoracion-derecha {
    right: calc((100vw - 960px) / 2 - 240px);
  }
}

@media (min-width: 1921px) {
  .decoracion-izquierda,
  .decoracion-derecha {
    width: 260px;
    height: 462px;
  }
  .decoracion-izquierda {
    left: calc((100vw - 960px) / 2 - 280px);
  }
  .decoracion-derecha {
    right: calc((100vw - 960px) / 2 - 280px);
  }
}

/* Ocultar en tablet y móvil */
@media (max-width: 1024px) {
  .decoracion-izquierda,
  .decoracion-derecha {
    display: none !important;
  }
}

/* === Botón Volver arriba === */
#volver-arriba {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--color-principal);
  color: white;
  border: none;
  border-radius: 50%;
  padding: 0.9rem 1.1rem;
  font-size: 1.3rem;
  cursor: pointer;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: background 0.3s;
  z-index: 99;
}
#volver-arriba:hover { background-color: #e64a19; }

/* === Páginas legales === */
.legal-container {
  display: flex;
  justify-content: center;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.legal-box {
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  padding: 2.5rem;
  max-width: 750px;
  width: 100%;
  line-height: 1.7;
  text-align: justify;
  font-size: 1.15rem;
  color: #333;
  border: 1px solid #eee;
}

.legal-box h2 {
  margin: 1.6rem 0 1.1rem 0;
  color: var(--color-principal);
  font-size: 1.45rem;
}

.legal-box h1 {
  color: var(--color-principal);
}

/* === Chatbot educativo === */
#chatbot-container {
  max-width: 520px;
  margin: 2.5rem auto;
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
  text-align: left;
  display: block;
  border: 2px solid #FFD54F;
}

.chatbot-header {
  background-color: var(--color-principal);
  color: white;
  padding: 0.9rem 1.1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.chatbot-body {
  padding: 1.5rem;
  font-size: 1.1rem;
  min-height: 180px;
  background-color: #fff;
  line-height: 1.6;
  color: #333;
}

/* Botón dentro del chatbot */
#chatbot-container button {
  background-color: var(--color-principal);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 1.1rem 1.6rem;
  font-size: clamp(1.3rem, 4.5vw, 1.8rem);
  font-weight: 700;
  margin: 0.6rem 0;
  cursor: pointer;
  min-width: 80px;
  min-height: 68px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 112, 67, 0.18);
  transition: all 0.25s ease;
  width: auto;
}

#chatbot-container button:hover {
  background-color: #e65100;
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(255, 112, 67, 0.25);
}

/* Ocultar botón de cerrar en index.html */
body > main + section#chatbot-section .chatbot-close,
body > main ~ #chatbot-section .chatbot-close {
  display: none !important;
}

.chatbot-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  padding: 0.6rem;
  margin-left: auto;
  display: block;
  text-align: right;
  width: fit-content;
  font-weight: bold;
}

.chatbot-close:hover {
  color: #333;
}

/* === Cuadro "Por y para Akili Indali" === */
.descripcion-personalizada {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 1.8rem 2.2rem;
  background-color: #fffefb;
  border-radius: var(--border-radius);
  box-shadow: 0 6px 14px rgba(255, 112, 67, 0.08);
  text-align: justify;
  border-top: 3px solid #FFD54F;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

.descripcion-personalizada h3 {
  color: var(--color-principal);
  margin-bottom: 0.9rem;
  font-size: 1.45rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.descripcion-personalizada h3::before {
  content: "✨";
  font-size: 1.3rem;
}

.descripcion-personalizada p {
  color: #555;
  line-height: 1.65;
  font-size: 1.18rem;
}

/* === Footer === */
footer {
  background-color: var(--color-principal);
  color: #fffde7;
  padding: 1.1rem;
  font-size: 0.85rem;
  text-align: center;
  margin-top: auto;
  border-top: 2px solid #FF8A65;
}

footer a {
  color: #fff8e1;
  text-decoration: none;
  margin: 0 0.6rem;
}
footer a:hover { text-decoration: underline; }

/* === RESPONSIVE ADICIONAL === */

@media (max-width: 480px) {
  .logo-hero {
    width: 70px;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem;
  }

  h1.titulo {
    font-size: 2.4rem;
  }

  .game-btn {
    padding: 1rem 1.8rem;
    font-size: 1.25rem;
  }

  #area-juego,
  .zona-juego,
  .mapa-zona {
    padding: 1.8rem 1rem;
  }

  .pregunta {
    font-size: clamp(1.5rem, 6vw, 2.6rem);
  }

  #chatbot-container {
    margin: 1.8rem auto;
    max-width: 95%;
  }
}
/* ========================================
   CORRECCIONES RESPONSIVE - NO TOCAR ARRIBA
   ======================================== */

/* === TABLETS (768px - 1024px) === */
@media (max-width: 1024px) {
  main {
    max-width: 100%;
    padding: 1rem 1.5rem;
  }

  #hero {
    max-width: 100%;
    margin: 1.5rem auto;
  }

  .banner-placeholder,
  .banner-img,
  .banner img {
    max-width: 100%;
    height: auto;
  }
}

/* === MÓVILES GRANDES (481px - 767px) === */
@media (max-width: 767px) {
  main {
    max-width: 100%;
    padding: 1rem;
  }

  #hero {
    max-width: 100%;
    margin: 1rem auto;
  }

  .logo-hero {
    width: 80px;
    top: 0.8rem;
    left: 1rem;
  }

  h1.titulo {
    font-size: 2.2rem;
  }

  h2.slogan {
    font-size: 1.3rem;
  }

  .game-btn {
    padding: 1.1rem 2rem;
    font-size: 1.3rem;
    max-width: 100%;
  }

  #area-juego,
  #game-area,
  .zona-juego,
  .mapa-zona {
    padding: 1.5rem 1rem;
    max-width: 100%;
  }

  .pregunta {
    font-size: 2rem;
  }

  #respuesta,
  #resp {
    width: 95%;
    font-size: 1.6rem;
  }

  .banner-placeholder,
  .banner-img,
  .banner img {
    max-width: 100%;
    height: auto;
  }

  footer {
    font-size: 0.8rem;
    padding: 1rem 0.5rem;
  }

  .legal-box {
    padding: 1.8rem 1.2rem;
    font-size: 1rem;
  }

  #chatbot-container {
    max-width: 95%;
    margin: 1.5rem auto;
  }

  .descripcion-personalizada {
    padding: 1.5rem 1.2rem;
    font-size: 1.05rem;
  }
}

/* === MÓVILES PEQUEÑOS (320px - 480px) === */
@media (max-width: 480px) {
  body {
    padding-bottom: 2rem;
  }

  main {
    max-width: 100%;
    padding: 0.8rem;
  }

  #hero {
    max-width: 100%;
    margin: 0.8rem auto;
    border-radius: 15px;
  }

  .logo-hero {
    width: 70px;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem;
  }

  h1.titulo {
    font-size: 2rem;
    margin: 0.8rem 0;
  }

  h2.slogan {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }

  .game-btn {
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    max-width: 100%;
  }

  .operaciones,
  .modo-selector {
    gap: 1rem;
    margin: 1.5rem 0;
  }

  #area-juego,
  #game-area,
  .zona-juego,
  .mapa-zona {
    padding: 1.2rem 0.8rem;
    margin: 1.5rem auto;
    max-width: 100%;
  }

  .pregunta {
    font-size: 1.8rem;
    margin-bottom: 1.2rem;
  }

  #respuesta,
  #resp {
    width: 95%;
    font-size: 1.5rem;
    padding: 1rem 1.2rem;
  }

  #area-juego button {
    padding: 1rem 1.3rem;
    font-size: 1.6rem;
    min-height: 70px;
    width: 95%;
  }

  #area-juego .opts button,
  #area-juego > div button {
    padding: 0.9rem 1rem;
    font-size: 1.5rem;
    min-width: 70px;
    min-height: 70px;
  }

  #feedback {
    font-size: 1.2rem;
  }

  .banner-placeholder,
  .banner-img,
  .banner,
  .banner img {
    max-width: 100%;
    height: auto;
    margin: 1rem auto;
  }

  footer {
    font-size: 0.75rem;
    padding: 0.9rem 0.3rem;
  }

  footer a {
    margin: 0 0.3rem;
    display: inline-block;
  }

  .legal-box {
    padding: 1.5rem 1rem;
    font-size: 0.95rem;
  }

  .legal-box h1 {
    font-size: 1.8rem;
  }

  .legal-box h2 {
    font-size: 1.3rem;
  }

  #chatbot-container {
    max-width: 95%;
    margin: 1.2rem auto;
  }

  .chatbot-header {
    font-size: 1rem;
    padding: 0.8rem;
  }

  .chatbot-body {
    padding: 1.2rem;
    font-size: 1rem;
    min-height: 150px;
  }

  #chatbot-container button {
    padding: 0.9rem 1.3rem;
    font-size: 1.4rem;
    min-height: 60px;
  }

  .descripcion-personalizada {
    padding: 1.2rem 1rem;
  }

  .descripcion-personalizada h3 {
    font-size: 1.25rem;
  }

  .descripcion-personalizada p {
    font-size: 1rem;
    line-height: 1.55;
  }

  .youtube-section {
    max-width: 95%;
    margin: 1.5rem auto;
  }

  #visual-area {
    padding: 1rem;
    min-height: 100px;
    gap: 8px;
  }

  #visual-area .bloque {
    width: 35px;
    height: 35px;
  }

  #visual-area .palito {
    width: 12px;
    height: 40px;
  }

  #visual-area .bolita {
    width: 28px;
    height: 28px;
  }

  #volver-arriba {
    bottom: 15px;
    right: 15px;
    padding: 0.8rem 1rem;
    font-size: 1.2rem;
  }
}

/* === FIX: Evitar overflow horizontal en móviles === */
@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }

  * {
    max-width: 100%;
  }

  img {
    max-width: 100%;
    height: auto;
  }
}