/* ==========================================================================
   ESTILOS - MUNDO DIVISIÓN (CENTRO INTEGRAL TALENTIA)
   Diseñado para alumnos de 4º de Primaria (9-10 años)
   ========================================================================== */

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

:root {
  --primary: #5c35eb;
  --primary-light: #7b5af5;
  --primary-dark: #401ec4;
  --accent: #ff9f1c;
  --accent-light: #ffbf69;
  --accent-pink: #ff477e;
  --success: #10b981;
  --success-bg: #d1fae5;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --bg-gradient: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #fdf2f8 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: #e0e7ff;
  --text-main: #1e1b4b;
  --text-muted: #64748b;
  --shadow-sm: 0 4px 6px -1px rgba(92, 53, 235, 0.08);
  --shadow-md: 0 10px 25px -5px rgba(92, 53, 235, 0.15);
  --shadow-lg: 0 20px 35px -10px rgba(92, 53, 235, 0.25);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-main);
  overflow-x: hidden;
  position: relative;
}

/* Fondo decorativo con burbujas matemáticas flotantes */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-shape {
  position: absolute;
  opacity: 0.12;
  font-family: 'Fredoka', cursive;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--primary);
  animation: floatSlow 12s infinite ease-in-out;
}

.shape-1 { top: 10%; left: 5%; animation-delay: 0s; }
.shape-2 { top: 75%; left: 8%; animation-delay: 2s; }
.shape-3 { top: 20%; right: 7%; animation-delay: 4s; }
.shape-4 { top: 80%; right: 6%; animation-delay: 6s; }
.shape-5 { top: 45%; left: 88%; animation-delay: 1s; }
.shape-6 { top: 60%; left: 45%; animation-delay: 3s; }

@keyframes floatSlow {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-25px) rotate(15deg); }
}

/* ==========================================================================
   BANNER FLOTANTE DISIMULADO (DEDICATORIA)
   ========================================================================== */
.floating-dedication-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(92, 53, 235, 0.2);
  box-shadow: 0 6px 20px rgba(92, 53, 235, 0.12);
  border-radius: 50px;
  padding: 6px 16px 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-main);
  animation: dropBannerAnim 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 92vw;
}

@keyframes dropBannerAnim {
  from { transform: translate(-50%, -40px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes fadeOutUpAnim {
  from { transform: translate(-50%, 0); opacity: 1; }
  to { transform: translate(-50%, -30px); opacity: 0; }
}

.floating-dedication-banner .talentia-name-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  transition: color 0.2s;
}

.floating-dedication-banner .talentia-name-link:hover {
  color: var(--accent);
}

.banner-sparkle {
  font-size: 1rem;
}

.btn-close-banner {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
  line-height: 1;
  transition: all 0.2s;
  margin-left: 4px;
}

.btn-close-banner:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* ==========================================================================
   HEADER Y BARRA SUPERIOR
   ========================================================================== */
header {
  position: relative;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid #e2e8f0;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  margin-top: 48px; /* Espacio para el banner flotante superior */
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.brand-logo-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(92, 53, 235, 0.35);
  transition: transform 0.2s;
}

.brand-logo-badge:hover {
  transform: scale(1.08) rotate(-6deg);
}

.brand-titles h1 {
  font-family: 'Fredoka', cursive;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-titles h1 span.highlight {
  color: var(--accent);
}

.brand-titles p {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-titles a {
  color: var(--primary);
  text-decoration: none;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  background: white;
  border: 2px solid #e0e7ff;
  border-radius: 50px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

.stat-pill.ops-config {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #f8faff, #eff6ff);
}

.ops-select-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  white-space: nowrap;
}

.header-select, .hero-select {
  border: 1.5px solid #a5b4fc;
  border-radius: 20px;
  padding: 4px 8px;
  font-family: 'Fredoka', cursive;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: #ffffff;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.header-select:hover, .hero-select:hover,
.header-select:focus, .hero-select:focus {
  border-color: var(--primary);
  background: #f5f3ff;
  box-shadow: 0 0 0 2px rgba(92, 53, 235, 0.2);
}

.stat-pill.points {
  border-color: #fef08a;
  background: linear-gradient(135deg, #fffbeb, #fef9c3);
  color: #854d0e;
}

.stat-pill.points .icon {
  font-size: 1.3rem;
  animation: pulseGold 2s infinite;
}

@keyframes pulseGold {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.btn-header-action {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-header-action:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  border-color: var(--primary);
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL Y VISTAS
   ========================================================================== */
main {
  position: relative;
  z-index: 5;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.view-section {
  display: none;
  animation: fadeIn 0.35s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   VISTA 1: MENÚ PRINCIPAL Y SELECCIÓN DE NIVELES
   ========================================================================== */
.welcome-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%);
  border: 3px solid #ddd6fe;
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.welcome-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-mascot-avatar {
  font-size: 4rem;
  margin-bottom: 8px;
  display: inline-block;
  animation: bounceSoft 2.5s infinite ease-in-out;
}

@keyframes bounceSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.welcome-hero h2 {
  font-family: 'Fredoka', cursive;
  font-size: 2.2rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.welcome-hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 650px;
  margin: 0 auto 20px;
}

.hero-config-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
}

.player-input-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 8px 16px;
  border-radius: 50px;
  border: 2px solid #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.player-input-card.hero-ops-card {
  border-color: #c7d2fe;
}

.player-input-card input {
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--primary-dark);
  width: 180px;
}

.levels-grid-container {
  margin-top: 20px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title-wrap h3 {
  font-family: 'Fredoka', cursive;
  font-size: 1.6rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.level-card {
  background: white;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 22px;
  cursor: pointer;
  position: relative;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.level-card:hover:not(.locked) {
  transform: translateY(-6px);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.level-card.locked {
  opacity: 0.65;
  background: #f8fafc;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.level-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.level-num-badge {
  background: var(--primary);
  color: white;
  font-family: 'Fredoka', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
}

.level-card.cifras-2 .level-num-badge {
  background: var(--accent);
}

.level-stars-display {
  color: #fbbf24;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.level-card h4 {
  font-family: 'Fredoka', cursive;
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.level-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
  flex-grow: 1;
}

.level-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 2px dashed #f1f5f9;
}

.level-progress-tag {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.btn-start-level {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  font-family: 'Fredoka', cursive;
  font-size: 1rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(92, 53, 235, 0.3);
  transition: all 0.2s;
}

.level-card:hover:not(.locked) .btn-start-level {
  transform: scale(1.05);
}

/* ==========================================================================
   VISTA 2: ÁREA DE JUEGO Y DIVISIONES INTERACTIVAS
   ========================================================================== */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.game-level-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-back-levels {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px 14px;
  font-family: 'Fredoka', cursive;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-back-levels:hover {
  background: #e2e8f0;
}

.level-current-badge {
  font-family: 'Fredoka', cursive;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
}

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

.div-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: all 0.3s;
}

.div-dot.active {
  background: var(--primary);
  transform: scale(1.25);
  box-shadow: 0 0 8px rgba(92, 53, 235, 0.5);
}

.div-dot.completed {
  background: var(--success);
}

/* Panel Principal de División */
.division-workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .division-workspace {
    grid-template-columns: 1fr;
  }
}

.division-board-card {
  background: white;
  border: 3px solid #e0e7ff;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  position: relative;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.division-prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 2px dashed #f1f5f9;
}

.instruction-step-pill {
  background: #e0e7ff;
  color: var(--primary-dark);
  font-family: 'Fredoka', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: pulseLight 2s infinite;
}

@keyframes pulseLight {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.division-points-badge {
  background: #fffbeb;
  border: 2px solid #fde047;
  color: #a16207;
  font-family: 'Fredoka', cursive;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 6px 14px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   TABLERO DE LA DIVISIÓN (FORMATO ESPAÑOL TRADICIONAL / CAJA ALINEADA)
   ========================================================================== */
.division-math-layout {
  font-family: 'Fredoka', cursive;
  font-size: 2.2rem;
  margin: 15px auto;
  user-select: none;
  display: inline-block;
  align-self: center;
}

/* Fila Superior: Dividendo y Divisor en la MISMA LÍNEA EXACTA */
.top-math-row {
  display: flex;
  align-items: flex-start; /* Misma altura superior */
  justify-content: center;
}

.dividend-grid-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Sombrerito/Arco para agrupar cifras tomadas */
.dividend-arc {
  position: absolute;
  top: -12px;
  left: 0;
  height: 12px;
  border: 3px solid var(--accent);
  border-bottom: none;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.math-columns-row {
  display: flex;
  position: relative;
  align-items: center;
}

.math-col-cell {
  width: 48px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-main);
  position: relative;
}

.math-col-cell.taken {
  color: var(--primary);
  background: rgba(92, 53, 235, 0.08);
  border-radius: 8px;
}

.math-col-cell.brought-down {
  animation: dropDigitAnim 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--accent);
  font-weight: 800;
}

@keyframes dropDigitAnim {
  0% { transform: translateY(-35px) scale(0.6); opacity: 0; }
  60% { transform: translateY(4px) scale(1.15); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Caja del Divisor y Cociente */
.divisor-column-wrapper {
  display: flex;
  flex-direction: column;
}

.divisor-box {
  border-left: 4px solid var(--text-main);
  border-bottom: 4px solid var(--text-main);
  height: 54px;
  min-width: 100px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: #f8fafc;
  border-top-right-radius: 10px;
}

.quotient-box {
  border-left: 4px solid var(--text-main);
  min-height: 56px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Inputs interactivos */
.math-input-slot {
  width: 44px;
  height: 48px;
  border: 3px solid #cbd5e1;
  border-radius: 10px;
  font-family: 'Fredoka', cursive;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-main);
  background: white;
  outline: none;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  padding: 0;
}

.math-input-slot:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(92, 53, 235, 0.2);
  transform: scale(1.05);
}

.math-input-slot.correct {
  border-color: var(--success) !important;
  background: var(--success-bg) !important;
  color: #065f46 !important;
  animation: popSuccess 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.math-input-slot.incorrect {
  border-color: var(--error) !important;
  background: var(--error-bg) !important;
  color: #991b1b !important;
  animation: shakeError 0.4s ease;
}

@keyframes popSuccess {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Contenedor de Restas Alineadas por Columnas */
.subtraction-steps-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.sub-step-block {
  display: flex;
  flex-direction: column;
  position: relative;
}

.minus-sign-fixed {
  position: absolute;
  left: -26px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  font-weight: 700;
  color: var(--error);
  user-select: none;
}

.step-bar-line {
  height: 3px;
  background: var(--text-main);
  border-radius: 2px;
  margin: 3px 0;
}

.down-arrow-tag {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 800;
  animation: pointDown 1.2s infinite ease-in-out;
  pointer-events: none;
}
}

.step-bar-line {
  height: 3px;
  background: var(--text-main);
  border-radius: 2px;
  margin: 4px 0;
  width: 100%;
}

.down-arrow-indicator {
  position: absolute;
  color: var(--accent);
  font-size: 1.4rem;
  animation: pointDown 1.2s infinite ease-in-out;
  pointer-events: none;
}

@keyframes pointDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* Teclado Virtual Numérico Integrado */
.virtual-keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: auto;
  padding-top: 24px;
}

.key-btn {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 0;
  font-family: 'Fredoka', cursive;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 3px 0 #cbd5e1;
}

.key-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.key-btn:hover {
  background: #f1f5f9;
  border-color: var(--primary-light);
}

.key-btn.action-btn {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
  box-shadow: 0 3px 0 #fca5a5;
}

/* ==========================================================================
   COLUMNA LATERAL: MASCOTA Y RINCÓN ILUSTRADO DEL REPARTO
   ========================================================================== */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Card Mascota Talentín */
.talentin-mascot-card {
  background: white;
  border: 3px solid #e0e7ff;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: transform 0.2s;
}

.mascot-avatar-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ddd6fe, #fae8ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}

.talentin-speech-bubble {
  background: #f5f3ff;
  border: 2px solid #ddd6fe;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.45;
  position: relative;
  text-align: center;
  width: 100%;
}

.talentin-speech-bubble::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid #ddd6fe;
}

/* ==========================================================================
   RINCÓN ILUSTRADO DEL REPARTO DINÁMICO (GRÁFICO DE DIVISIONES)
   ========================================================================== */
.reparto-visual-card {
  background: white;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.reparto-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 10px;
}

.reparto-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.reparto-tag {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Selector de temas de reparto */
.reparto-theme-pills {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.theme-pill {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 50px;
  padding: 4px 10px;
  font-family: 'Fredoka', cursive;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-pill:hover {
  background: #f1f5f9;
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.theme-pill.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(92, 53, 235, 0.3);
}

/* Escenario interactivo de reparto */
.reparto-visual-box {
  background: linear-gradient(135deg, #faf5ff 0%, #f0fdf4 100%);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.reparto-formula-pill {
  background: white;
  border: 1.5px solid #ddd6fe;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.reparto-items-stream {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 260px;
  margin: 4px 0;
}

.reparto-item {
  font-size: 1.35rem;
  display: inline-block;
  animation: bobFloat 2s infinite ease-in-out;
  transition: transform 0.2s;
}

.reparto-item:hover {
  transform: scale(1.3) rotate(10deg);
}

@keyframes bobFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.reparto-more-tag {
  background: rgba(92, 53, 235, 0.1);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 6px;
  align-self: center;
}

.reparto-arrow-divider {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.reparto-groups-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reparto-group-bucket {
  background: white;
  border: 2px solid #a7f3d0;
  border-radius: 12px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.15);
  animation: popBucket 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popBucket {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reparto-group-bucket .group-icon {
  font-size: 1.2rem;
}

.reparto-group-bucket .group-sublabel {
  font-size: 0.7rem;
  font-weight: 800;
  color: #065f46;
}

/* Guía ilustrada de los 4 términos de la división */
.division-terms-guide {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
}

.term-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.term-badge {
  font-family: 'Fredoka', cursive;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  min-width: 74px;
  text-align: center;
  color: white;
  flex-shrink: 0;
}

.badge-dividendo {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.badge-divisor {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.badge-cociente {
  background: linear-gradient(135deg, #10b981, #059669);
}

.badge-resto {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

.term-text {
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.2;
}

/* Ilustración decorativa de niños compartiendo */
.reparto-illustration-footer {
  text-align: center;
  padding-top: 4px;
}

.cartoon-sharing-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.5rem;
  background: #fffbeb;
  border: 1.5px solid #fef3c7;
  border-radius: 14px;
  padding: 6px 10px;
}

.scene-item {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scene-item:hover {
  transform: scale(1.35) rotate(-8deg);
}

.item-1 { animation: danceLeft 2.2s infinite ease-in-out; }
.item-2 { animation: danceRight 2.2s infinite ease-in-out; }
.item-sweet { animation: bounceUp 1.8s infinite ease-in-out 0.2s; }
.item-sweet2 { animation: bounceUp 1.8s infinite ease-in-out 0.6s; }

@keyframes danceLeft {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-6deg); }
}

@keyframes danceRight {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(6deg); }
}

@keyframes bounceUp {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.15); }
}

/* ==========================================================================
   NOTIFICACIÓN FLOTANTE DE PUNTOS GANADOS / PERDIDOS
   ========================================================================== */
.floating-points-alert {
  position: fixed;
  top: 90px;
  right: 24px;
  background: white;
  padding: 12px 20px;
  border-radius: 50px;
  font-family: 'Fredoka', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  animation: slidePoints 1.8s forwards cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.floating-points-alert.positive {
  border: 3px solid var(--success);
  color: #065f46;
  background: var(--success-bg);
}

.floating-points-alert.negative {
  border: 3px solid var(--error);
  color: #991b1b;
  background: var(--error-bg);
}

@keyframes slidePoints {
  0% { opacity: 0; transform: translateY(-20px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  80% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ==========================================================================
   MODALES Y CELEBRACIONES
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  animation: popModal 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popModal {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-icon-header {
  font-size: 4rem;
  margin-bottom: 12px;
}

.modal-content-card h3 {
  font-family: 'Fredoka', cursive;
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.modal-content-card p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-modal-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-family: 'Fredoka', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(92, 53, 235, 0.4);
  transition: transform 0.2s;
}

.btn-modal-primary:hover {
  transform: scale(1.04);
}

.btn-modal-secondary {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-family: 'Fredoka', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

/* ==========================================================================
   DIPLOMA OFICIAL - CENTRO INTEGRAL TALENTIA
   ========================================================================== */
.diploma-card {
  background: #fffdf7;
  border: 12px double #b45309;
  border-radius: 12px;
  padding: 36px 28px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.diploma-header {
  border-bottom: 2px solid #d97706;
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.diploma-header h2 {
  font-family: 'Fredoka', cursive;
  font-size: 2rem;
  color: #92400e;
  letter-spacing: 1px;
}

.diploma-body {
  font-size: 1.1rem;
  color: #451a03;
  line-height: 1.6;
  margin-bottom: 24px;
}

.diploma-student-name {
  font-family: 'Fredoka', cursive;
  font-size: 2.2rem;
  color: var(--primary-dark);
  text-decoration: underline wavy var(--accent);
  margin: 12px 0;
}

.diploma-seal-badge {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #f59e0b, #b45309);
  color: white;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.4);
  margin-bottom: 16px;
}

/* ==========================================================================
   BOTÓN DEL DIPLOMA (BLOQUEADO VS DESBLOQUEADO)
   ========================================================================== */
.btn-diploma-hub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 32px;
  font-family: 'Fredoka', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-md);
}

.btn-diploma-hub.locked {
  background: linear-gradient(135deg, #64748b, #475569);
  color: #f8fafc;
  border: 2px dashed #94a3b8;
  opacity: 0.95;
}

.btn-diploma-hub.locked:hover {
  background: linear-gradient(135deg, #475569, #334155);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-diploma-hub.unlocked {
  background: linear-gradient(135deg, #b45309, #f59e0b, #d97706);
  background-size: 200% 200%;
  color: #ffffff;
  border: 2px solid #fde68a;
  box-shadow: 0 8px 25px rgba(217, 119, 6, 0.45);
  animation: shineGold 3s infinite linear;
}

.btn-diploma-hub.unlocked:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 30px rgba(217, 119, 6, 0.6);
}

@keyframes shineGold {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.level-card.completed {
  border-color: #10b981;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.level-card.completed .level-num-badge {
  background: #059669;
}

/* Canvas Confetti */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    margin-top: 54px;
  }
  .header-stats {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .brand-titles h1 {
    font-size: 1.15rem;
  }
  .brand-titles p {
    font-size: 0.72rem;
    line-height: 1.2;
  }
  .digit-box {
    width: 36px;
    height: 42px;
    font-size: 1.6rem;
  }
  .divisor-box {
    font-size: 1.6rem;
    min-width: 80px;
    padding: 4px 8px;
  }
  .math-input-slot {
    width: 36px;
    height: 42px;
    font-size: 1.4rem;
  }
  .virtual-keypad {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .key-btn {
    padding: 8px 0;
    font-size: 1.2rem;
  }
  .btn-diploma-hub {
    font-size: 1rem;
    padding: 12px 20px;
  }
}

/* ==========================================================================
   PIE DE PÁGINA CORPORATIVO Y LEGAL
   ========================================================================== */
.app-footer {
  background: white;
  border-top: 2px solid #e2e8f0;
  padding: 30px 20px 24px;
  margin-top: 40px;
  position: relative;
  z-index: 10;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.03);
}

.footer-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.footer-talentia-logo {
  height: 58px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.footer-logo-link:hover .footer-talentia-logo {
  transform: scale(1.05);
}

.footer-brand-info h4 {
  font-family: 'Fredoka', cursive;
  font-size: 1.15rem;
  color: var(--primary-dark);
  margin-bottom: 2px;
}

.footer-brand-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.footer-brand-info .footer-address {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

.footer-info-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.footer-contact-items {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-contact-items a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-contact-items a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-legal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-legal-trigger {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-legal-trigger:hover {
  color: var(--primary);
  text-decoration: underline;
  background: #f5f3ff;
}

.legal-separator {
  color: #cbd5e1;
  font-size: 0.8rem;
}

.footer-bottom-copy {
  max-width: 1100px;
  margin: 18px auto 0;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
}

@media (max-width: 768px) {
  .footer-container {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .footer-brand {
    flex-direction: column;
  }
  .footer-info-col {
    align-items: center;
  }
  .footer-contact-items {
    justify-content: center;
  }
}

/* ==========================================================================
   MODAL DE TEXTOS LEGALES
   ========================================================================== */
.modal-legal-card {
  max-width: 760px;
  width: 95vw;
  text-align: left;
  padding: 24px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-legal-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
  margin-bottom: 14px;
  gap: 10px;
}

.legal-tab-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-legal-btn {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'Fredoka', cursive;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-legal-btn:hover {
  background: #e2e8f0;
}

.tab-legal-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(92, 53, 235, 0.25);
}

.btn-close-modal-x {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close-modal-x:hover {
  background: #fee2e2;
  color: #ef4444;
}

.modal-legal-body-scroll {
  overflow-y: auto;
  padding-right: 8px;
  flex: 1;
  max-height: 55vh;
}

.modal-legal-body-scroll::-webkit-scrollbar {
  width: 6px;
}

.modal-legal-body-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.legal-tab-pane {
  display: none;
  color: var(--text-main);
  font-size: 0.92rem;
  line-height: 1.6;
}

.legal-tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.legal-tab-pane h3 {
  font-family: 'Fredoka', cursive;
  font-size: 1.4rem;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.legal-tab-pane h4 {
  font-family: 'Fredoka', cursive;
  font-size: 1.05rem;
  color: #4338ca;
  margin: 16px 0 6px;
}

.legal-tab-pane p {
  margin-bottom: 10px;
  color: #334155;
}

.legal-tab-pane ul {
  margin: 8px 0 12px 20px;
  color: #334155;
}

.legal-tab-pane li {
  margin-bottom: 6px;
}

.legal-tab-pane a {
  color: var(--primary);
  font-weight: 600;
}

/* Reglas de impresión para el Diploma */
@media print {
  body {
    background: white !important;
  }
  body * {
    visibility: hidden;
  }
  #modal-diploma, #modal-diploma .diploma-card, #modal-diploma .diploma-card * {
    visibility: visible;
  }
  #modal-diploma {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    min-height: 100%;
    background: white !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  #modal-diploma .modal-content-card {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 20px !important;
    margin: 0 auto !important;
  }
  #modal-diploma .modal-actions {
    display: none !important;
  }
  .diploma-card {
    box-shadow: none !important;
    border: 10px double #b45309 !important;
    page-break-inside: avoid;
    margin: 0 auto;
  }
}
