/* ==========================================================================
   MAIN.CSS — Sistema de Diseño Principal
   Proyecto: JUEGOSONLINE
   Descripción: Variables CSS, reset, glassmorphism, dual-mode claro/oscuro,
                tipografía, componentes base, toasts, modales y animaciones.
   Última actualización: 2026-07-26
   ========================================================================== */

/* --- GOOGLE FONTS (importados en HTML) --- */

/* --- VARIABLES CSS (MODO CLARO POR DEFECTO) --- */
:root {
  /* Colores base */
  --bg-primary: #f0f2ff;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.65);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

  /* Colores semánticos */
  --accent: #7367F0;
  --accent-light: #9d94ff;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Colores por nivel */
  --kinder-primary: #ff758c;
  --kinder-secondary: #ff7eb3;
  --kinder-bg: linear-gradient(135deg, #fff5f7 0%, #ffe8f0 100%);
  --primaria-primary: #7367F0;
  --primaria-secondary: #8b5cf6;
  --primaria-bg: linear-gradient(135deg, #f0f0ff 0%, #e8e5ff 100%);
  --secundaria-primary: #06b6d4;
  --secundaria-secondary: #0ea5e9;
  --secundaria-bg: linear-gradient(135deg, #ecfeff 0%, #e0f7ff 100%);

  /* Colores por género */
  --nino-accent: #3b82f6;
  --nino-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
  --nina-accent: #ec4899;
  --nina-gradient: linear-gradient(135deg, #ec4899, #a855f7);

  /* Tipografía */
  --font-heading: 'Fredoka', 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Espaciado */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-full: 50%;
  --gap: 12px;
  --gap-lg: 20px;

  /* Glass */
  --glass-blur: 12px;
  --glass-border: 1px solid rgba(255, 255, 255, 0.25);

  /* Transiciones */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- MODO OSCURO (Vuexy Theme) --- */
[data-theme="dark"] {
  --bg-primary: #25293C;
  --bg-card: #2F3349;
  --bg-glass: rgba(47, 51, 73, 0.85);
  --text-primary: #CFD3EC;
  --text-secondary: #A3A7C5;
  --text-muted: #7E829B;
  --border: rgba(225, 222, 245, 0.08);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);

  --kinder-bg: linear-gradient(135deg, #2f2538 0%, #25293c 100%);
  --primaria-bg: linear-gradient(135deg, #25293c 0%, #2f3349 100%);
  --secundaria-bg: linear-gradient(135deg, #1f2e3d 0%, #25293c 100%);
}

/* --- RESET Y BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  max-width: 100vw;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.4s ease, color 0.4s ease;
}

/* --- ESTILOS DE INPUTS Y PLACEHOLDERS (ALTA VISIBILIDAD MODO CLARO/OSCURO) --- */
input, select, textarea, .input-name {
  color: var(--text-primary) !important;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.75;
}

/* --- TIPOGRAFÍA --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
}

h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1rem, 3vw, 1.5rem); }

/* --- CANVAS DE FONDO --- */
#bgCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#confettiCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9998;
  pointer-events: none;
}

/* --- CONTENEDOR PRINCIPAL DE LA APP --- */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* --- HEADER PRINCIPAL --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: var(--glass-border);
  border-radius: 0 0 var(--radius) var(--radius);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 8px;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(180deg, #a78bfa 0%, #7367F0 100%);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 0 #5b4ee4, 0 6px 15px rgba(115, 103, 240, 0.4);
  border: 1.5px solid #c4b5fd;
  animation: pulse-glow 2s ease-in-out infinite;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  background: linear-gradient(180deg, #7367F0 0%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: -0.3px;
  filter: drop-shadow(0 2px 4px rgba(115, 103, 240, 0.2));
}

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

/* --- BOTONES ICON ESTILO 3D CANDY CRUSH --- */
.btn-icon {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-heading);
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--border), 0 4px 10px rgba(0,0,0,0.06);
}

.btn-icon:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 5px 0 var(--border), 0 6px 15px rgba(0,0,0,0.12);
}

.btn-icon:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: 0 1px 0 var(--border);
}

/* Botón 3D Dorado de Ranking en Header */
#btnOpenRanking {
  background: linear-gradient(180deg, #ffd700 0%, #f59e0b 100%) !important;
  color: #3b1a00 !important;
  border: 2px solid #ffea79 !important;
  box-shadow: 0 4px 0 #b45309, 0 6px 15px rgba(245, 158, 11, 0.5) !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
  font-family: var(--font-heading) !important;
  font-weight: 900 !important;
  font-size: 0.88rem !important;
  padding: 6px 14px !important;
  border-radius: 20px !important;
}

#btnOpenRanking:hover {
  transform: translateY(-2px) scale(1.06) !important;
  box-shadow: 0 6px 0 #b45309, 0 8px 20px rgba(245, 158, 11, 0.5) !important;
}

#starCounter {
  background: linear-gradient(180deg, #fef08a 0%, #facc15 100%) !important;
  color: #451a03 !important;
  border: 2px solid #fef9c3 !important;
  box-shadow: 0 3.5px 0 #ca8a04, 0 4px 10px rgba(234, 179, 8, 0.4) !important;
  font-family: var(--font-heading) !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

#streakCounter {
  background: linear-gradient(180deg, #ffedd5 0%, #fb923c 100%) !important;
  color: #431407 !important;
  border: 2px solid #ffedd5 !important;
  box-shadow: 0 3.5px 0 #c2410c, 0 4px 10px rgba(249, 115, 22, 0.4) !important;
  font-family: var(--font-heading) !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* --- BADGES STATS ESTILO CANDY CRUSH 3D NÍTIDOS --- */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-family: var(--font-heading);
  font-weight: 900;
  padding: 5px 12px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: 0 3.5px 0 var(--border), 0 4px 8px rgba(0,0,0,0.08);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
  opacity: 1 !important;
  white-space: nowrap;
}

.stat-badge:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 5px 0 var(--border), 0 6px 12px rgba(0,0,0,0.12);
}

/* --- TARJETA DE PERFIL DEL JUGADOR DE CABECERA (2-TIER CLEAN) --- */
.player-profile {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(115, 103, 240, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  margin-bottom: 16px;
  transition: var(--transition);
}

.player-profile-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.player-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(115, 103, 240, 0.15), rgba(16, 185, 129, 0.15));
  border: 2.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.25);
  cursor: pointer;
}

.player-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
}

.player-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

#playerNameDisplay {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-level {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 3px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.player-counters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.player-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.player-actions-row .stat-badge {
  flex: 1;
  justify-content: center;
  text-align: center;
  padding: 6px 8px;
  font-size: 0.82rem;
}

/* --- BARRA DE PESTAÑAS 3 PILARES PEDAGÓGICOS (Juegos, Ejercicios, Trucos) --- */
.main-category-tabs {
  display: flex;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 22px;
  padding: 5px;
  gap: 6px;
  margin-bottom: 18px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.main-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  border-radius: 18px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.main-tab-btn:hover {
  color: var(--accent);
  background: rgba(115, 103, 240, 0.08);
}

.main-tab-btn.active {
  background: linear-gradient(135deg, #7367F0 0%, #9e95f5 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.4), 0 2px 0 #5b4ee4;
}

#btnOpenStickers {
  background: linear-gradient(180deg, #c084fc 0%, #9333ea 100%) !important;
  color: #ffffff !important;
  border: 2px solid #f3e8ff !important;
  box-shadow: 0 3.5px 0 #581c87, 0 4px 10px rgba(147, 51, 234, 0.4) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

#btnOpenRankingProfile {
  background: linear-gradient(180deg, #fde047 0%, #ca8a04 100%) !important;
  color: #3b1a00 !important;
  border: 2px solid #fef9c3 !important;
  box-shadow: 0 3.5px 0 #854d0e, 0 4px 10px rgba(202, 138, 4, 0.4) !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

#btnOpenRepaso {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%) !important;
  color: #ffffff !important;
  border: 2px solid #bae6fd !important;
  box-shadow: 0 3.5px 0 #0369a1, 0 4px 10px rgba(2, 132, 199, 0.4) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.stat-badge.stat-badge-stars {
  background: linear-gradient(180deg, #fef08a 0%, #facc15 100%) !important;
  color: #451a03 !important;
  border: 2px solid #fef9c3 !important;
  box-shadow: 0 3.5px 0 #ca8a04, 0 4px 8px rgba(234, 179, 8, 0.3) !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.stat-badge.stat-badge-streak {
  background: linear-gradient(180deg, #ffedd5 0%, #fb923c 100%) !important;
  color: #431407 !important;
  border: 2px solid #ffedd5 !important;
  box-shadow: 0 3.5px 0 #c2410c, 0 4px 8px rgba(249, 115, 22, 0.3) !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* --- BOTONES ACCIÓN REDONDOS EN HEADER (Voz, Tema, Ajustes) 3D VIBRANTES Y NÍTIDOS --- */
#btnToggleVoice {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%) !important;
  color: #ffffff !important;
  border: 2px solid #bae6fd !important;
  box-shadow: 0 4px 0 #0369a1, 0 6px 15px rgba(2, 132, 199, 0.5) !important;
  border-radius: 50% !important;
  width: 38px;
  height: 38px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.15rem !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

#btnThemeToggle {
  background: linear-gradient(180deg, #c084fc 0%, #7e22ce 100%) !important;
  color: #ffffff !important;
  border: 2px solid #f3e8ff !important;
  box-shadow: 0 4px 0 #581c87, 0 6px 15px rgba(126, 34, 206, 0.5) !important;
  border-radius: 50% !important;
  width: 38px;
  height: 38px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.15rem !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

#btnEditProfile {
  background: linear-gradient(180deg, #f472b6 0%, #db2777 100%) !important;
  color: #ffffff !important;
  border: 2px solid #fce7f3 !important;
  box-shadow: 0 4px 0 #9d174d, 0 6px 15px rgba(219, 39, 119, 0.5) !important;
  border-radius: 50% !important;
  width: 38px;
  height: 38px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.15rem !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-action {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-action:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.1); }
.btn-action:active { transform: scale(0.97); }

/* --- GLASS CARDS --- */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: var(--glass-border);
  border-radius: var(--radius);
  padding: var(--gap-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.glass-card:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* --- PANTALLAS / VISTAS --- */
.screen-view {
  display: none;
  flex-direction: column;
  gap: var(--gap-lg);
  padding: var(--gap) 0;
  flex: 1;
  animation: fadeSlideIn 0.4s ease;
}

#categoriesContainer {
  display: flex !important;
  flex-direction: column !important;
  gap: 18px !important;
  width: 100% !important;
}

.screen-view.active {
  display: flex;
}

/* --- CATEGORIAS DE NIVEL (KINDER / PRIMARIA / SECUNDARIA) --- */
.level-category {
  margin-bottom: var(--gap-lg);
}

.level-category-title {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  margin-bottom: var(--gap);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
}

.level-category-title .category-badge {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  color: #fff;
}

.category-badge.kinder { background: var(--kinder-primary); }
.category-badge.primaria { background: var(--primaria-primary); }
.category-badge.secundaria { background: var(--secundaria-primary); }

/* --- GRID DE JUEGOS --- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--gap);
}

/* --- TARJETAS DE JUEGO --- */
.game-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-bounce);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-accent, var(--accent));
  transition: height 0.3s ease;
}

.game-card:hover {
  transform: translateY(-6px) scale(1.03);
  border-color: var(--card-accent, var(--accent));
  box-shadow: 0 12px 30px rgba(115, 103, 240, 0.2);
}

.game-card:hover::before { height: 6px; }

.game-card:active { transform: scale(0.95); }

.game-card.locked {
  opacity: 0.55;
  cursor: pointer;
  filter: grayscale(0.3);
}

.game-card.locked:hover {
  transform: none;
  box-shadow: none;
}

.free-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
  z-index: 2;
  white-space: nowrap;
  pointer-events: none;
}

.game-card .card-emoji {
  font-size: 2.3rem;
  line-height: 1;
  margin-top: 4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.game-card .card-img-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin-top: 4px;
  border-radius: 12px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12));
  transition: transform 0.3s ease;
}

.game-card:hover .card-img-icon {
  transform: scale(1.1);
}

.game-card .card-title {
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.game-card .card-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Pestañas internas de modales (ej: Repaso) */
.repaso-subtab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.repaso-subtab-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  font-weight: 800;
}

.game-card .lock-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.9rem;
}

/* Colores por juego */
.game-card[data-game="kinder-vocales"] { --card-accent: #ff758c; }
.game-card[data-game="kinder-conteo"] { --card-accent: #ff9a3c; }
.game-card[data-game="kinder-puzzle"] { --card-accent: #a855f7; }
.game-card[data-game="kinder-memoria"] { --card-accent: #ec4899; }
.game-card[data-game="math-tablas"] { --card-accent: #7367F0; }
.game-card[data-game="math-sumaresta"] { --card-accent: #10b981; }
.game-card[data-game="math-division"] { --card-accent: #f59e0b; }
.game-card[data-game="math-cazador"] { --card-accent: #ef4444; }
.game-card[data-game="math-memoria"] { --card-accent: #06b6d4; }
.game-card[data-game="sec-fracciones"] { --card-accent: #8b5cf6; }
.game-card[data-game="sec-ecuaciones"] { --card-accent: #0ea5e9; }
.game-card[data-game="sec-combinadas"] { --card-accent: #f97316; }

/* --- PERFIL DEL JUGADOR (BARRA SUPERIOR) --- */
.player-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  border: 1.5px solid var(--border);
  border-radius: 20px;
  margin-bottom: 8px;
  box-shadow: 0 4px 15px rgba(115, 103, 240, 0.08);
}

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  border: 3px solid var(--accent);
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  box-shadow: 0 4px 10px rgba(115, 103, 240, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.player-avatar:hover {
  transform: scale(1.1) rotate(5deg);
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.player-info:hover {
  opacity: 0.85;
}

.player-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.player-level {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.player-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- BADGES STATS ESTILO CANDY CRUSH 3D --- */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-family: var(--font-heading);
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: 0 3px 0 var(--border), 0 4px 8px rgba(0,0,0,0.05);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.stat-badge:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 5px 0 var(--border), 0 6px 12px rgba(0,0,0,0.1);
}

#btnOpenStickers {
  background: linear-gradient(180deg, #f3e8ff 0%, #ddd6fe 100%) !important;
  color: #581c87 !important;
  border: 1.5px solid #c084fc !important;
  box-shadow: 0 3.5px 0 #7e22ce, 0 4px 10px rgba(168, 85, 247, 0.3) !important;
}

#btnOpenRankingProfile {
  background: linear-gradient(180deg, #fef3c7 0%, #fde047 100%) !important;
  color: #713f12 !important;
  border: 1.5px solid #facc15 !important;
  box-shadow: 0 3.5px 0 #ca8a04, 0 4px 10px rgba(234, 179, 8, 0.3) !important;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.stat-badge.stat-badge-stars {
  background: linear-gradient(180deg, #fff3c4 0%, #fde047 100%) !important;
  color: #713f12 !important;
  border: 1.5px solid #facc15 !important;
  box-shadow: 0 3.5px 0 #ca8a04, 0 4px 8px rgba(234, 179, 8, 0.25) !important;
}

.stat-badge.stat-badge-streak {
  background: linear-gradient(180deg, #ffedd5 0%, #fb923c 100%) !important;
  color: #7c2d12 !important;
  border: 1.5px solid #f97316 !important;
  box-shadow: 0 3.5px 0 #c2410c, 0 4px 8px rgba(249, 115, 22, 0.25) !important;
}

/* --- BOTONES ACCIÓN REDONDOS EN HEADER (Voz, Tema, Ajustes) --- */
#btnToggleVoice {
  background: linear-gradient(180deg, #e0f2fe 0%, #38bdf8 100%) !important;
  color: #0369a1 !important;
  border: 1.5px solid #7dd3fc !important;
  box-shadow: 0 3.5px 0 #0284c7, 0 4px 10px rgba(56, 189, 248, 0.35) !important;
  border-radius: 50% !important;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.05rem !important;
}

#btnThemeToggle {
  background: linear-gradient(180deg, #f3e8ff 0%, #c084fc 100%) !important;
  color: #581c87 !important;
  border: 1.5px solid #e9d5ff !important;
  box-shadow: 0 3.5px 0 #9333ea, 0 4px 10px rgba(192, 132, 252, 0.35) !important;
  border-radius: 50% !important;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.05rem !important;
}

#btnEditProfile {
  background: linear-gradient(180deg, #ffe4e6 0%, #fb7185 100%) !important;
  color: #881337 !important;
  border: 1.5px solid #fecdd3 !important;
  box-shadow: 0 3.5px 0 #e11d48, 0 4px 10px rgba(251, 113, 133, 0.35) !important;
  border-radius: 50% !important;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  justify-content: center;
  font-size: 1.05rem !important;
}

/* --- ESTILOS VIP Y DISTINTIVOS DE CUENTA VINCULADA 3D --- */
.header-vip-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.header-vip-pill.is-linked {
  background: linear-gradient(180deg, #a7f3d0 0%, #10b981 100%) !important;
  color: #064e3b !important;
  border: 1.5px solid #34d399 !important;
  box-shadow: 0 3.5px 0 #047857, 0 4px 10px rgba(16, 185, 129, 0.35) !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.header-vip-pill.is-vip {
  background: linear-gradient(180deg, #fef08a 0%, #eab308 100%) !important;
  color: #422006 !important;
  border: 1.5px solid #facc15 !important;
  box-shadow: 0 3.5px 0 #a16207, 0 4px 10px rgba(234, 179, 8, 0.45) !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: pulse 2s infinite;
}

.header-vip-pill:hover {
  transform: translateY(-2px) scale(1.05);
}

.player-profile.vip-active-card {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.22), rgba(115, 103, 240, 0.18)) !important;
  border: 2px solid #ffd700 !important;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.45) !important;
  animation: vipGlow 3s infinite alternate;
}

@keyframes vipGlow {
  0% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.3); }
  100% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.65); }
}

.player-avatar.vip-avatar {
  border: 3.5px solid #ffd700 !important;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.9) !important;
  background: linear-gradient(135deg, #fef08a, #fde047) !important;
}

.badge-vip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, #fde047 0%, #eab308 100%);
  color: #422006;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 14px;
  border: 1.5px solid #ca8a04;
  box-shadow: 0 3px 0 #a16207, 0 4px 10px rgba(234, 179, 8, 0.4);
  letter-spacing: 0.5px;
  animation: pulse 2s infinite;
}

.badge-account-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, #d1fae5 0%, #34d399 100%);
  color: #064e3b;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 14px;
  border: 1.5px solid #10b981;
  box-shadow: 0 3px 0 #059669, 0 4px 10px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   NUEVOS ESTILOS: 3 PILARES PEDAGÓGICOS (Juegos, Ejercicios, Trucos)
   ========================================================================== */

/* --- BARRA DE PESTAÑAS DE NAVEGACIÓN (TABS 3D CANDY) --- */
.main-category-tabs {
  display: flex;
  gap: 6px;
  background: rgba(115, 103, 240, 0.08);
  border: 1.5px solid rgba(115, 103, 240, 0.18);
  padding: 6px;
  border-radius: 20px;
  margin: 0 0 14px 0;
  backdrop-filter: blur(12px);
  box-sizing: border-box;
  width: 100%;
}

.main-tab-btn {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  font-weight: 800;
  padding: 10px 6px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.main-tab-btn:hover {
  background: rgba(115, 103, 240, 0.12);
  color: var(--accent);
  transform: translateY(-1px);
}

.main-tab-btn.active {
  background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border: 1.5px solid #a78bfa;
  box-shadow: 0 4px 0 #4c1d95, 0 8px 20px rgba(109, 40, 217, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* --- TARJETAS DE TRUCOS MATEMÁTICOS (.trick-card) --- */
.game-card.trick-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(115, 103, 240, 0.08));
  border: 2px solid rgba(245, 158, 11, 0.3);
}

.game-card.trick-card:hover {
  border-color: #f59e0b;
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.35);
}

.trick-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
  z-index: 2;
}

/* --- TARJETAS DE EJERCICIOS GUIADOS (.exercise-card) --- */
.game-card.exercise-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.08));
  border: 2px solid rgba(16, 185, 129, 0.3);
}

.game-card.exercise-card:hover {
  border-color: #10b981;
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.35);
}

.exercise-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
  z-index: 2;
}

.header-vip-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.header-vip-pill.is-vip {
  background: linear-gradient(135deg, #ffd700, #ff9800);
  color: #4a2800;
  box-shadow: 0 2px 10px rgba(255, 152, 0, 0.4);
  border: 1px solid #ffe066;
}

.header-vip-pill.is-linked {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

/* --- MODAL OVERLAY --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  animation: fadeIn 0.3s ease;
}

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

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg) var(--gap-lg) var(--gap-lg);
  max-width: 440px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff4757 0%, #d63031 100%) !important;
  color: #ffffff !important;
  border: 2px solid #ff7675 !important;
  box-shadow: 0 4px 0 #890000, 0 6px 15px rgba(214, 48, 49, 0.45) !important;
  font-family: var(--font-heading) !important;
  font-weight: 900 !important;
  font-size: 1.15rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.2s ease !important;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.modal-close:hover {
  color: #ffffff !important;
  transform: translateY(-2px) scale(1.15) rotate(90deg) !important;
  background: linear-gradient(180deg, #ff6b81 0%, #ff4757 100%) !important;
  box-shadow: 0 6px 0 #890000, 0 8px 20px rgba(255, 71, 87, 0.6) !important;
}

.modal-close:active {
  transform: translateY(2px) scale(0.95) !important;
  box-shadow: 0 1px 0 #890000 !important;
}

.modal-title {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  text-align: center;
  margin-bottom: var(--gap);
  padding-left: 32px;
  padding-right: 32px;
}

.modal-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--gap-lg);
  padding-left: 24px;
  padding-right: 24px;
}

/* --- FORMULARIO MODAL BIENVENIDA --- */
.welcome-form { display: flex; flex-direction: column; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-input {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1.1rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(115, 103, 240, 0.15);
}

/* --- ESTILOS ULTRA-COMPACTOS PARA MODAL DE PERFIL (ZERO-SCROLL) --- */
.welcome-form .form-group {
  margin-bottom: 8px;
}

.welcome-form .form-label {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 3px;
  display: block;
}

.welcome-form .form-input {
  padding: 8px 12px;
  font-size: 0.95rem;
  border-radius: 12px;
}

/* Fila dual compacta (Género + Foto) */
.form-row-dual {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.form-row-dual .form-group {
  flex: 1;
  min-width: 0;
  margin-bottom: 8px;
}

/* Selector de Género Compacto */
.gender-selector {
  display: flex;
  gap: 6px;
  height: 42px;
}

.gender-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2px 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--bg-primary);
}

.gender-option:hover { transform: translateY(-1px); }

.gender-option.selected { border-color: var(--accent); background: rgba(115, 103, 240, 0.1); }
.gender-option[data-gender="NINO"].selected { border-color: var(--nino-accent); background: rgba(59, 130, 246, 0.12); }
.gender-option[data-gender="NINA"].selected { border-color: var(--nina-accent); background: rgba(236, 72, 153, 0.12); }

.gender-emoji { font-size: 1.3rem; line-height: 1; }
.gender-label { font-family: var(--font-heading); font-weight: 700; font-size: 0.82rem; }

/* Box de Avatar/Foto Compacto */
.avatar-upload-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(115, 103, 240, 0.05);
  padding: 3px 6px;
  border-radius: 12px;
  border: 1.5px dashed var(--accent);
  height: 42px;
}

.avatar-preview-box {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(115, 103, 240, 0.2);
  flex-shrink: 0;
}

.avatar-btns-group {
  flex: 1;
  display: flex;
  gap: 4px;
}

.avatar-btns-group .btn-icon {
  flex: 1;
  font-size: 0.72rem !important;
  padding: 5px 2px !important;
  border-radius: 8px !important;
  justify-content: center !important;
}

/* Selector de edad (slider visual) */
.age-slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.age-display {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
}

.age-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 4px;
  outline: none;
}

.age-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(115, 103, 240, 0.4);
}

/* Selector de grado */
.grade-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.grade-option {
  padding: 5px 2px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.74rem;
  font-family: var(--font-heading);
  font-weight: 700;
  text-align: center;
  transition: var(--transition-fast);
  background: var(--bg-primary);
  color: var(--text-primary);
  white-space: nowrap;
}

.grade-option:hover { border-color: var(--accent); }
.grade-option.selected { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(115, 103, 240, 0.3); }

/* --- BOTÓN CTA PRINCIPAL --- */
.cta-button {
  width: 100%;
  padding: 16px;
  font-size: 1.2rem;
  font-family: var(--font-heading);
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--kinder-primary));
  box-shadow: 0 6px 20px rgba(115, 103, 240, 0.35);
  position: relative;
  overflow: hidden;
}

.cta-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: shimmer-btn 3s infinite;
}

.cta-button:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 30px rgba(115, 103, 240, 0.4); }
.cta-button:active { transform: scale(0.97); }

/* --- TOASTS --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999999 !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastSlideIn 0.4s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1f2937; }
.toast.info { background: var(--info); }

.toast.removing { animation: toastSlideOut 0.3s ease forwards; }

/* --- SKELETON LOADERS --- */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* --- PANTALLA DE JUEGO FULLSCREEN (Solución quirúrgica global) ---
   Cuando #screenGame está activo, se convierte en overlay fixed que cubre
   el header y toda la pantalla. Aplica a TODOS los juegos automáticamente.
   Los juegos individuales NO necesitan position:fixed propios. */
#screenGame.active {
  position: fixed !important;
  inset: 0 !important;
  z-index: 200 !important;        /* Por encima de .app-header (z-index:100) */
  width: 100vw !important;
  height: 100dvh !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  overflow: hidden !important;
  background: var(--bg-primary);
  display: flex !important;
  flex-direction: column !important;
}

/* Cuando hay juego activo, bloquear scroll del body (NO touch-action:none que rompe clicks) */
body.game-active,
html.game-active {
  overflow: hidden !important;
  height: 100dvh !important;
}

/* --- ARENA DE JUEGO (COMPARTIDA) --- */
.game-arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Dentro de fullscreen game, la arena ocupa todo el espacio restante */
#screenGame.active .game-arena {
  flex: 1 !important;
  min-height: 0 !important;
  overflow: auto !important;       /* auto, NO hidden — permite scroll interno si el juego lo necesita */
  max-height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 4px !important;
  margin: 0 !important;
}

/* Ocultar el battle header container por defecto en fullscreen (se muestra solo si hay batalla) */
#screenGame.active #battleHeaderContainer[style*="display: none"] {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================================================
   🎨 CAPA VISUAL: JUEGOS CON VIDA (Aplica a los 28 juegos automáticamente)
   Keypad 3D, preguntas dramáticas, feedback animado, dark mode completo.
   ========================================================================== */

/* --- ARENA HEADER PREMIUM --- */
.arena-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(115, 103, 240, 0.08), rgba(99, 102, 241, 0.04));
  border-radius: 16px;
  border: 1px solid rgba(115, 103, 240, 0.12);
  margin-bottom: 8px;
}

[data-theme="dark"] .arena-header {
  background: linear-gradient(135deg, rgba(115, 103, 240, 0.12), rgba(99, 102, 241, 0.06));
  border-color: rgba(115, 103, 240, 0.18);
}

.btn-back {
  background: linear-gradient(135deg, #7367F0, #5b4ee4);
  color: #ffffff !important;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 14px rgba(115, 103, 240, 0.38);
  transition: var(--transition-bounce);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-back:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(115, 103, 240, 0.55);
  background: linear-gradient(135deg, #5b4ee4, #4a3ccb);
  color: #ffffff !important;
}

.btn-back:active {
  transform: scale(0.92);
}

.arena-title {
  font-size: clamp(0.85rem, 2.8vw, 1.3rem);
  text-align: center;
  flex: 1;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

/* --- STAT BADGES CON VIDA (dentro de juegos) --- */
.arena-header .stat-badge {
  background: linear-gradient(135deg, rgba(115, 103, 240, 0.15), rgba(99, 102, 241, 0.08));
  border: 1.5px solid rgba(115, 103, 240, 0.25);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
  transition: var(--transition-bounce);
}

.arena-header .stat-badge.celebrating {
  animation: statBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes statBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); filter: brightness(1.3); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* --- PROGRESS BAR CON GRADIENTE ANIMADO --- */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7367F0, #10b981, #06b6d4, #7367F0);
  background-size: 300% 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: progressFlow 3s linear infinite;
  box-shadow: 0 0 8px rgba(115, 103, 240, 0.4);
}

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

/* --- KEYPAD NUMÉRICO 3D CANDY --- */
.keypad-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 300px;
  margin: 0 auto;
  padding: 12px;
  background: linear-gradient(145deg, rgba(115, 103, 240, 0.05), rgba(99, 102, 241, 0.02));
  border-radius: 20px;
  border: 1px solid rgba(115, 103, 240, 0.08);
}

[data-theme="dark"] .keypad-container {
  background: linear-gradient(145deg, rgba(115, 103, 240, 0.08), rgba(0, 0, 0, 0.15));
  border-color: rgba(115, 103, 240, 0.12);
}

.keypad-btn {
  padding: 14px 8px;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-family: var(--font-heading);
  font-weight: 800;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(115, 103, 240, 0.06) 100%);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .keypad-btn {
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(115, 103, 240, 0.1) 100%);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.keypad-btn:hover {
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(91, 78, 228, 0.4), 0 8px 20px rgba(115, 103, 240, 0.35);
}

.keypad-btn:active {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
  transition-duration: 0.06s;
}

/* Ripple al tocar */
.keypad-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(115, 103, 240, 0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}
.keypad-btn:active::after { opacity: 1; }

.keypad-btn.key-enter {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 3px 0 rgba(5, 150, 105, 0.5), 0 4px 12px rgba(16, 185, 129, 0.3);
  animation: enterPulse 2s ease-in-out infinite;
}

@keyframes enterPulse {
  0%, 100% { box-shadow: 0 3px 0 rgba(5, 150, 105, 0.5), 0 4px 12px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 3px 0 rgba(5, 150, 105, 0.5), 0 4px 20px rgba(16, 185, 129, 0.6), 0 0 30px rgba(16, 185, 129, 0.2); }
}

.keypad-btn.key-enter:active {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.keypad-btn.key-delete {
  background: linear-gradient(180deg, #fca5a5 0%, #ef4444 100%);
  color: #fff;
  box-shadow: 0 3px 0 rgba(185, 28, 28, 0.4), 0 4px 12px rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .keypad-btn.key-delete {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
}

.keypad-btn.key-delete:active {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
}

.keypad-btn.key-zero {
  grid-column: span 1;
}

/* --- DISPLAY DE PREGUNTA CON DRAMATISMO --- */
.question-display {
  text-align: center;
  padding: 16px;
  background: linear-gradient(145deg, var(--bg-glass), rgba(115, 103, 240, 0.06));
  backdrop-filter: blur(var(--glass-blur));
  border: 1.5px solid rgba(115, 103, 240, 0.15);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(115, 103, 240, 0.08);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .question-display {
  background: linear-gradient(145deg, var(--bg-glass), rgba(115, 103, 240, 0.1));
  border-color: rgba(115, 103, 240, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Shimmer decorativo sutil en la pregunta */
.question-display::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(115, 103, 240, 0.03), transparent, rgba(16, 185, 129, 0.03), transparent);
  animation: questionShimmer 8s linear infinite;
  pointer-events: none;
}

@keyframes questionShimmer {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.question-text {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 5.5vw, 2.8rem);
  font-weight: 900;
  color: var(--text-primary);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .question-text {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Animación de entrada para preguntas nuevas */
.question-new {
  animation: questionSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes questionSlideIn {
  0% { transform: scale(0.7) translateY(10px); opacity: 0; filter: blur(4px); }
  100% { transform: scale(1) translateY(0); opacity: 1; filter: blur(0); }
}

.answer-display {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 900;
  color: var(--accent);
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.answer-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent);
  animation: cursorGlow 1.2s ease-in-out infinite;
  margin-left: 2px;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(115, 103, 240, 0.5);
}

@keyframes cursorGlow {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(115, 103, 240, 0.5); }
  50% { opacity: 0.2; box-shadow: 0 0 2px rgba(115, 103, 240, 0.2); }
}

/* --- FEEDBACK VISUAL CORRECTO / INCORRECTO (Clases globales) --- */
.correct-flash {
  animation: correctPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes correctPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.06); box-shadow: 0 0 30px rgba(16, 185, 129, 0.4); }
  100% { transform: scale(1); box-shadow: none; }
}

.wrong-shake {
  animation: wrongShake 0.5s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(10px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}

/* Badge de racha con fuego cuando está alta */
.streak-fire {
  animation: streakGlow 1s ease-in-out infinite alternate;
}

@keyframes streakGlow {
  0% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.3); }
  100% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.7), 0 0 30px rgba(239, 68, 68, 0.3); }
}

/* --- BOTONES DE OPCIONES (Ejercicio Guiado, Fracciones, etc.) --- */
.option-btn, [class*="option-card"], [class*="option-btn"] {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.option-btn:hover, [class*="option-card"]:hover, [class*="option-btn"]:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(115, 103, 240, 0.2);
}

.option-btn:active, [class*="option-card"]:active, [class*="option-btn"]:active {
  transform: scale(0.96);
}

/* --- MASCOTA REACTIVA (emoji que reacciona a eventos) --- */
.game-mascot {
  font-size: 2.5rem;
  display: inline-block;
  animation: mascotFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

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

.game-mascot.happy { animation: mascotHappy 0.6s ease; }
.game-mascot.sad { animation: mascotSad 0.6s ease; }

@keyframes mascotHappy {
  0% { transform: scale(1); }
  30% { transform: scale(1.3) rotate(10deg); }
  60% { transform: scale(0.95) rotate(-5deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes mascotSad {
  0% { transform: translateY(0); }
  30% { transform: translateY(5px) rotate(-5deg); }
  60% { transform: translateY(-3px); }
  100% { transform: translateY(0) rotate(0); }
}

/* --- POPÍN GLOBAL (para elementos que aparecen dinámicamente) --- */
@keyframes popIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

/* --- MODAL VIP / COOLDOWN COMPACTO VIEWPORT-FIT --- */
.vip-modal .modal-content {
  border: 2px solid var(--warning);
  text-align: center;
  max-width: 430px;
  padding: 14px 12px 10px 12px;
  max-height: 96vh;
  overflow: hidden;
  box-sizing: border-box;
}

.vip-modal .price-comparison {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 6px !important;
  margin: 6px 0 !important;
}

/* --- PRICE CARDS (PLAN MENSUAL Y PLAN ANUAL 3D CANDY) --- */
.price-card {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 8px 6px !important;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  position: relative;
  opacity: 0.72;
}

.price-card:hover {
  opacity: 1;
  transform: translateY(-2px);
  border-color: var(--accent);
}

.price-card.selected {
  opacity: 1 !important;
  border: 2.5px solid var(--accent) !important;
  background: linear-gradient(180deg, rgba(115, 103, 240, 0.2) 0%, rgba(115, 103, 240, 0.08) 100%) !important;
  box-shadow: 0 0 18px rgba(115, 103, 240, 0.45), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  transform: translateY(-2px) scale(1.03) !important;
}

.price-card.selected::after {
  content: '✔ SELECCIONADO';
  position: absolute;
  top: -9px;
  right: 50%;
  transform: translateX(50%);
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.58rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
  white-space: nowrap;
  letter-spacing: 0.3px;
  z-index: 5;
}

/* Plan Anual Seleccionado (Dorado Resplandeciente) */
.price-card[data-plan="ANUAL"].selected {
  border: 2.5px solid #f59e0b !important;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22) 0%, rgba(255, 215, 0, 0.1) 100%) !important;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.5), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.price-card[data-plan="ANUAL"].selected::after {
  background: linear-gradient(180deg, #fde047 0%, #eab308 100%);
  color: #422006;
}

.price-original {
  text-decoration: line-through;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.price-offer {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--success);
}

.price-savings {
  font-size: 0.72rem;
  color: var(--danger);
  font-weight: 700;
}

.countdown-timer {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--danger);
  font-weight: 700;
  padding: 8px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
}

/* --- VIP BADGE --- */
.vip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* --- ANIMACIONES --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.85) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(120%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(120%); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(115, 103, 240, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(115, 103, 240, 0); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes shimmer-btn {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes blink {
  50% { opacity: 0; }
}

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

@keyframes comboPop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.8); opacity: 0; }
}

@keyframes bounce-in {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

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

@keyframes pop-burst {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.8; filter: brightness(1.3); }
  100% { transform: scale(1.9); opacity: 0; filter: blur(6px); }
}

.shake { animation: shake 0.5s ease; }
.bounce-in { animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.float-anim { animation: float 3s ease-in-out infinite; }
.pop-burst { animation: pop-burst 0.4s ease-out forwards; pointer-events: none; }

/* --- SCROLLBAR CUSTOM --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- BOTONES Y COMPONENTES DE RANKING Y WHATSAPP --- */
.btn-whatsapp {
  background: linear-gradient(135deg, #25D366, #128C7E) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4) !important;
  border: none !important;
  font-weight: 700 !important;
}

.btn-facebook {
  background: linear-gradient(135deg, #1877F2, #0d5cb6) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(24, 119, 242, 0.4) !important;
  border: none !important;
  font-weight: 700 !important;
}

.podium-card-gold {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(255, 215, 0, 0.15)) !important;
  border: 2px solid #f59e0b !important;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35) !important;
}

/* --- RESPONSIVE ADAPTATIVO MÓVIL Y SMARTPHONES --- */
@media (max-width: 768px) {
  .btn-text-mobile {
    display: none !important;
  }

  .brand-title {
    display: inline-block !important; /* Muestra el nombre KDR Kids en móvil */
    font-size: 1.15rem !important;
    font-weight: 900 !important;
    letter-spacing: -0.5px !important;
  }

  .app-header {
    padding: 8px 10px;
    gap: 6px;
  }

  .brand-container {
    gap: 6px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
  }

  .header-actions {
    gap: 4px;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .header-actions::-webkit-scrollbar {
    display: none;
  }

  .btn-icon {
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: 14px;
  }

  #btnOpenRanking, #btnShareApp {
    padding: 5px 8px !important;
    font-size: 0.8rem !important;
  }

  /* Perfil Adaptativo 2-Tier */
  .player-profile {
    padding: 10px 12px;
    gap: 10px;
  }

  .player-profile-top {
    gap: 8px;
  }

  .player-avatar {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  .player-info {
    min-width: 0;
    flex: 1;
  }

  .player-name {
    font-size: 1.02rem;
  }

  .player-level {
    font-size: 0.76rem;
    line-height: 1.3;
    white-space: normal;
  }

  .player-counters .stat-badge {
    padding: 4px 6px;
    font-size: 0.74rem;
  }

  .player-actions-row {
    padding-top: 8px;
    gap: 6px;
  }

  .player-actions-row .stat-badge {
    padding: 5px 4px;
    font-size: 0.74rem;
  }

  /* Pestañas Adaptativas */
  .main-category-tabs {
    padding: 4px;
    gap: 4px;
    margin-bottom: 14px;
  }

  .main-tab-btn {
    padding: 8px 4px;
    font-size: 0.85rem;
  }

  .badge-vip-tag, .badge-account-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    margin-left: 4px;
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
  }

  .game-card {
    padding: 12px 8px;
  }

  .game-card .card-emoji {
    font-size: 2rem;
  }

  .keypad-btn {
    padding: 12px;
    font-size: clamp(1rem, 3.5vw, 1.4rem);
  }

  .modal-content {
    padding: var(--gap);
  }
}

@media (min-width: 769px) {
  .btn-text-mobile {
    display: inline !important;
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* ==========================================================================
   ANIMACIONES DE ESTRELLAS VOLADORAS Y TRANSICIÓN DE PASOS (POLISH V94)
   ========================================================================== */
@keyframes flyingStarAnim {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    opacity: 1;
    transform: translate(calc(var(--target-x) * 0.5), calc(var(--target-y) * 0.5 - 50px)) scale(1.4) rotate(180deg);
  }
  100% {
    transform: translate(var(--target-x), var(--target-y)) scale(0.4) rotate(360deg);
    opacity: 0;
  }
}

.flying-star-particle {
  position: fixed;
  z-index: 99999;
  font-size: 1.8rem;
  pointer-events: none;
  animation: flyingStarAnim 0.8s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.6));
}

@keyframes targetBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.badge-bounce {
  animation: targetBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.step-transition-enter {
  animation: stepSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   ESTILOS MOTOR DE BATALLAS MULTIJUGADOR E-SPORTS Y POWER-UPS
   ========================================================================== */
.powerup-chip {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.powerup-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.2);
}
.powerup-chip.active {
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(115, 103, 240, 0.35);
}

/* ==========================================================================
   SELECTOR DE GRADOS ESCOLARES SEGMENTADO ULTRA-COMPACTO (MÁX 72PX ALTO)
   ========================================================================== */
.categorized-grade-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.level-segment-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: transparent;
  padding: 2px 0;
}

.level-tab-btn {
  padding: 8px 4px;
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  user-select: none;
  text-align: center;
  line-height: 1.15;
}

.level-tab-btn .tab-title {
  font-weight: 900;
  font-size: 0.82rem;
  white-space: nowrap;
}

.level-tab-btn .tab-badge {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.88;
  white-space: nowrap;
}

/* Unselected State: Bright Color Outlines (100% Clickable & Vibrant) */
.level-tab-btn.tab-kinder {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.05));
  color: #047857;
  border: 2px solid rgba(16, 185, 129, 0.45);
}

.level-tab-btn.tab-primaria {
  background: linear-gradient(135deg, rgba(115, 103, 240, 0.12), rgba(99, 102, 241, 0.05));
  color: #5b4edb;
  border: 2px solid rgba(115, 103, 240, 0.45);
}

.level-tab-btn.tab-secundaria {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(217, 119, 6, 0.05));
  color: #b45309;
  border: 2px solid rgba(245, 158, 11, 0.45);
}

.level-tab-btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.08);
}

/* Active Level Segment Tabs: Vibrant 3D Glowing Cards */
.level-tab-btn.tab-kinder.active {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45) !important;
  transform: scale(1.03);
}

.level-tab-btn.tab-primaria.active {
  background: linear-gradient(135deg, #7367F0, #5b4edb) !important;
  color: #ffffff !important;
  border-color: #7367F0 !important;
  box-shadow: 0 6px 18px rgba(115, 103, 240, 0.45) !important;
  transform: scale(1.03);
}

.level-tab-btn.tab-secundaria.active {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  border-color: #f59e0b !important;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.45) !important;
  transform: scale(1.03);
}

/* Sub-grade Panels */
.subgrade-panels-wrapper {
  min-height: 42px;
}

.subgrade-panel {
  display: grid;
  gap: 6px;
  animation: fadeIn 0.2s ease;
}

#panelInicial {
  grid-template-columns: 1fr;
}

#panelPrimaria {
  grid-template-columns: repeat(6, 1fr);
}

#panelSecundaria {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 440px) {
  #panelPrimaria {
    grid-template-columns: repeat(3, 1fr);
  }
  #panelSecundaria {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grade-option {
  padding: 9px 4px;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  border: 2px solid rgba(115, 103, 240, 0.2);
  background: var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* 1. KINDER / INICIAL (VERDE ESMERALDA) */
.grade-kind {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border: 2px solid rgba(16, 185, 129, 0.35);
}
.grade-kind.selected, .grade-kind:hover {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
  box-shadow: 0 5px 16px rgba(16, 185, 129, 0.45) !important;
  transform: translateY(-2px) scale(1.04);
  font-weight: 900;
}

/* 2. PRIMARIA (PÚRPURA / AZUL VIOLETA) */
.grade-prim {
  background: rgba(115, 103, 240, 0.1);
  color: #5b4edb;
  border: 2px solid rgba(115, 103, 240, 0.35);
}
.grade-prim.selected, .grade-prim:hover {
  background: linear-gradient(135deg, #7367F0, #5b4edb) !important;
  color: #ffffff !important;
  border-color: #7367F0 !important;
  box-shadow: 0 5px 16px rgba(115, 103, 240, 0.45) !important;
  transform: translateY(-2px) scale(1.04);
  font-weight: 900;
}

/* 3. SECUNDARIA (ÁMBAR FUEGO) */
.grade-sec {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  border: 2px solid rgba(245, 158, 11, 0.35);
}
.grade-sec.selected, .grade-sec:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  border-color: #f59e0b !important;
  box-shadow: 0 5px 16px rgba(245, 158, 11, 0.45) !important;
  transform: translateY(-2px) scale(1.04);
  font-weight: 900;
}

/* ==========================================================================
   MODAL DE SELECCIÓN DE MODO DE JUEGO & BATALLA E-SPORTS (VITALIDAD & GAMING)
   ========================================================================== */
.mode-select-modal-content {
  max-width: 420px !important;
  padding: 24px 18px 20px 18px !important;
  text-align: center;
  border-radius: 22px !important;
  border: 1.5px solid rgba(115, 103, 240, 0.25) !important;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22) !important;
  background: var(--bg-card) !important;
  position: relative;
  overflow: visible !important;
}

.mode-select-header-badge {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 6px auto 10px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-halo-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7367F0, #ff416c);
  filter: blur(10px);
  opacity: 0.7;
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 0.9; }
  100% { transform: scale(0.95); opacity: 0.6; }
}

.badge-icon {
  position: relative;
  z-index: 2;
  font-size: 2.2rem;
  background: linear-gradient(135deg, #ffffff, #f0fdf4);
  border: 3px solid #ffffff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(115, 103, 240, 0.35);
}

.mode-select-title {
  margin-bottom: 4px;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.mode-select-game-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
  background: rgba(115, 103, 240, 0.08);
  border: 1px solid rgba(115, 103, 240, 0.2);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* INSTRUCCIÓN DE SELECCIÓN DE MODO */
.mode-select-instruction {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  background: rgba(115, 103, 240, 0.08);
  border: 1px dashed rgba(115, 103, 240, 0.3);
  padding: 5px 12px;
  border-radius: 10px;
  margin: 6px auto 12px auto;
  display: inline-block;
}

.mode-cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-card-btn {
  width: 100%;
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.mode-card-btn * {
  pointer-events: none;
}

.mode-card-badge-top {
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  margin-bottom: 6px;
}

.mode-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-card-icon {
  font-size: 1.8rem;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  overflow: hidden;
}

.mode-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.mode-card-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.mode-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-card-sub {
  font-size: 0.73rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.25;
}

.mode-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.mode-btn-cta {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 5px 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

/* CARD 1: PRACTICAR SOLO (ULTRA HIGH CONTRAST & LEGIBLE) */
.card-solo {
  background: linear-gradient(135deg, #3730a3 0%, #4338ca 50%, #4f46e5 100%) !important;
  border: 2px solid #818cf8 !important;
  box-shadow: 0 8px 24px rgba(67, 56, 202, 0.4) !important;
  color: #ffffff !important;
}
.card-solo .mode-card-title,
.card-solo h4,
.card-solo div {
  color: #ffffff !important;
}
.card-solo-sub {
  color: #e0e7ff !important;
  font-weight: 800 !important;
}
.card-solo:hover, .card-solo:active {
  transform: translateY(-3px) scale(1.02) !important;
  box-shadow: 0 12px 32px rgba(67, 56, 202, 0.6) !important;
  border-color: #a5b4fc !important;
}
.cta-solo {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5) !important;
}

/* SEPARADOR Ó */
.mode-or-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0;
}

.or-line {
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(115, 103, 240, 0.3), transparent);
}

.or-badge {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--accent);
  background: var(--bg-card);
  border: 1.5px solid rgba(115, 103, 240, 0.3);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* CARD 2: CREAR SALA DE BATALLA (ULTRA HIGH CONTRAST & LEGIBLE) */
.card-battle {
  background: linear-gradient(135deg, #881337 0%, #9f1239 50%, #be123c 100%) !important;
  border: 2px solid #fb7185 !important;
  box-shadow: 0 8px 24px rgba(159, 18, 57, 0.4) !important;
  color: #ffffff !important;
}
.card-battle .mode-card-title,
.card-battle h4,
.card-battle div {
  color: #ffffff !important;
}
.card-battle-sub {
  color: #fecdd3 !important;
  font-weight: 800 !important;
}
.card-battle:hover, .card-battle:active {
  transform: translateY(-3px) scale(1.02) !important;
  box-shadow: 0 12px 32px rgba(159, 18, 57, 0.6) !important;
  border-color: #fda4af !important;
}
.cta-battle {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5) !important;
}
  box-shadow: 0 12px 32px rgba(225, 29, 72, 0.5);
  border-color: #fb7185;
}
.battle-badge-glow {
  background: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.cta-battle {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}

.pulse-icon {
  animation: pulseIcon 2s infinite ease-in-out;
}

@keyframes pulseIcon {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.powerup-selector-box {
  background: rgba(115, 103, 240, 0.05);
  border: 1.5px dashed rgba(115, 103, 240, 0.35);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: left;
}

.powerup-header {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.powerup-limit-badge {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-secondary);
  opacity: 0.85;
}

.powerup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.powerup-chip {
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.powerup-chip .powerup-icon {
  font-size: 1.3rem;
  transition: transform 0.2s;
}

.powerup-chip .powerup-name {
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--text-primary);
}

.powerup-chip .powerup-desc {
  font-size: 0.62rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.powerup-chip:hover {
  transform: translateY(-2px);
}

.powerup-chip.active {
  border-width: 2px !important;
  transform: translateY(-2px);
}

.powerup-shield.active {
  background: rgba(16, 185, 129, 0.12) !important;
  border-color: #10b981 !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35) !important;
}
.powerup-shield.active .powerup-name { color: #059669; }

.powerup-bomb.active {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: #f59e0b !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35) !important;
}
.powerup-bomb.active .powerup-name { color: #d97706; }

.powerup-turbo.active {
  background: rgba(115, 103, 240, 0.12) !important;
  border-color: #7367F0 !important;
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.35) !important;
}
.powerup-turbo.active .powerup-name { color: #7367F0; }

.join-room-box {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: center;
}

.join-room-label {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.join-room-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.join-code-input {
  width: 130px;
  box-sizing: border-box;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 4px;
  padding: 8px 6px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: rgba(115, 103, 240, 0.05);
  color: var(--text-primary);
  font-family: var(--font-heading);
  outline: none;
  transition: all 0.2s;
}

.join-code-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.join-code-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 900;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.join-code-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* RESPONSIVE MEDIA QUERIES PARA PANTALLAS PEQUEÑAS (iPhone SE, Móviles <480px, Altura <700px) */
@media (max-width: 480px), (max-height: 700px) {
  .mode-select-modal-content {
    padding: 16px 12px 14px 12px !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
  }

  .mode-select-header-badge {
    width: 52px;
    height: 52px;
    margin: 2px auto 6px auto;
  }

  .badge-icon {
    width: 48px;
    height: 48px;
    font-size: 1.7rem;
  }

  .mode-select-title {
    font-size: 1.15rem;
    margin-bottom: 2px;
  }

  .mode-select-game-chip {
    margin-bottom: 6px;
    font-size: 0.72rem;
    padding: 2px 8px;
  }

  .mode-select-instruction {
    font-size: 0.7rem;
    padding: 3px 8px;
    margin: 2px auto 6px auto;
  }

  .mode-cards-container {
    gap: 6px;
    margin-bottom: 8px;
  }

  .mode-card-btn {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .mode-card-icon {
    width: 38px;
    height: 38px;
    font-size: 1.4rem;
  }

  .mode-card-title {
    font-size: 0.92rem;
  }

  .mode-card-sub {
    font-size: 0.7rem;
  }

  .mode-btn-cta {
    font-size: 0.76rem;
    padding: 4px 10px;
  }

  .mode-or-divider {
    margin: 2px 0;
  }

  .powerup-selector-box {
    padding: 6px 8px;
    margin-top: 4px;
    border-radius: 12px;
  }

  .powerup-header {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .powerup-chip {
    padding: 5px 2px;
  }

  .powerup-chip .powerup-icon {
    font-size: 1.1rem;
  }

  .powerup-chip .powerup-name {
    font-size: 0.68rem;
  }

  .join-room-box {
    padding: 6px 8px;
    margin-top: 4px;
    border-radius: 12px;
  }

  .join-room-label {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .join-code-input {
    width: 100px;
    font-size: 1rem;
    padding: 5px;
  }

  .join-code-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}

#btnModalDeclineChallenge:hover,
#btnModalDeclineChallenge:active {
  background: rgba(239, 68, 68, 0.16) !important;
  border-color: #ef4444 !important;
  transform: translateY(-1px);
}

/* ==========================================================================
   ESTILOS DE CORONAS VIP, MARCOS Y PRESENCIA EN LÍNEA
   ========================================================================== */

/* 1. Animaciones GPU Ultra-Livianas */
@keyframes crownRotateGlow {
  0% { transform: scale(1) rotate(-6deg); filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6)); }
  50% { transform: scale(1.18) rotate(6deg); filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.9)); }
  100% { transform: scale(1) rotate(-6deg); filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6)); }
}

@keyframes pulseRing {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes textGlowRainbow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* 2. Coronas por Rango */
.crown-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  z-index: 10;
  pointer-events: none;
  line-height: 1;
}

.crown-basic {
  font-size: 1.1rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.crown-imperial {
  font-size: 1.35rem;
  animation: crownRotateGlow 3s ease-in-out infinite;
}

.crown-legendary {
  font-size: 1.6rem;
  animation: crownRotateGlow 2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px #f59e0b) drop-shadow(0 0 18px #a855f7);
}

/* 3. Marcos Resplandecientes de Avatar VIP */
.avatar-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-frame-imperial {
  border: 2px solid #f59e0b !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6), inset 0 0 8px rgba(245, 158, 11, 0.3) !important;
  border-radius: 50% !important;
}

.avatar-frame-legendary {
  border: 2.5px solid #a855f7 !important;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.8), 0 0 8px rgba(245, 158, 11, 0.9) !important;
  border-radius: 50% !important;
  animation: textGlowRainbow 6s linear infinite;
}

/* 4. Indicador "En Línea" */
.online-pulse-dot {
  width: 10px;
  height: 10px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: inline-block;
  animation: pulseRing 1.8s infinite;
}

/* 5. Nombres VIP en Competencia y Ranking */
.vip-name-imperial {
  color: #f59e0b !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 3px rgba(245, 158, 11, 0.4);
}

.vip-name-legendary {
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900 !important;
  display: inline-block;
  animation: textGlowRainbow 4s linear infinite;
}

/* Selector de Personajes de Perfil */
.avatar-gallery-chip {
  font-size: 1.6rem;
  padding: 6px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.avatar-gallery-chip:hover {
  transform: scale(1.15);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.3);
}

.avatar-gallery-chip.active {
  border-color: var(--accent);
  background: rgba(115, 103, 240, 0.15);
  box-shadow: 0 0 10px rgba(115, 103, 240, 0.4);
}

/* Fila Dual: Género (Izquierda) + Foto/Avatar (Derecha) */
.form-row-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

@media (max-width: 480px) {
  .form-row-dual {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 8px;
  }
}

.gender-selector {
  display: flex;
  gap: 6px;
  background: rgba(115, 103, 240, 0.08);
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.gender-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  user-select: none;
}

.gender-option.selected {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(115, 103, 240, 0.35);
}

.avatar-center-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.avatar-clickable-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(115, 103, 240, 0.08);
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  padding: 4px 10px 4px 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(115, 103, 240, 0.12);
  user-select: none;
}

.avatar-clickable-box:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(115, 103, 240, 0.25);
  background: rgba(115, 103, 240, 0.14);
}

.avatar-preview-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.avatar-preview-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-change-pill {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

/* --- ESTILOS RESPONSIVE DUAL-MODE PARA MATEMATRIS --- */

/* Variables adaptativas por tema */
.matematris-wrapper {
  --mt-bg: #ffffff;
  --mt-text: #1f2937;
  --mt-text-sec: #6b7280;
  --mt-surface: rgba(115, 103, 240, 0.06);
  --mt-craft-bg: rgba(115, 103, 240, 0.05);
  --mt-craft-border: rgba(115, 103, 240, 0.25);
  --mt-btn-bg: rgba(0, 0, 0, 0.05);
  --mt-btn-text: #374151;
  --mt-btn-border: rgba(0, 0, 0, 0.12);
  --mt-input-bg: #f3f4f6;
  --mt-input-text: #1f2937;
  --mt-controls-bg: rgba(0, 0, 0, 0.04);
  --mt-controls-border: rgba(0, 0, 0, 0.08);
  --mt-key-bg: rgba(0, 0, 0, 0.04);
  --mt-key-text: #374151;
  --mt-key-border: rgba(0, 0, 0, 0.1);
  --mt-key-hover: rgba(115, 103, 240, 0.15);
}

html[data-theme="dark"] .matematris-wrapper {
  --mt-bg: #2f3349;
  --mt-text: #cfd3ec;
  --mt-text-sec: #a3a7c5;
  --mt-surface: rgba(115, 103, 240, 0.12);
  --mt-craft-bg: rgba(115, 103, 240, 0.1);
  --mt-craft-border: rgba(115, 103, 240, 0.4);
  --mt-btn-bg: rgba(255, 255, 255, 0.08);
  --mt-btn-text: #e0e0e0;
  --mt-btn-border: rgba(255, 255, 255, 0.15);
  --mt-input-bg: #1e2235;
  --mt-input-text: #ffffff;
  --mt-controls-bg: rgba(0, 0, 0, 0.25);
  --mt-controls-border: rgba(255, 255, 255, 0.08);
  --mt-key-bg: rgba(255, 255, 255, 0.08);
  --mt-key-text: #ffffff;
  --mt-key-border: rgba(255, 255, 255, 0.15);
  --mt-key-hover: rgba(115, 103, 240, 0.3);
}

.matematris-wrapper {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: 20px;
  border: 2px solid var(--accent);
  box-shadow: 0 10px 35px rgba(115, 103, 240, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  background: var(--mt-bg) !important;
  color: var(--mt-text) !important;
}

.matematris-wrapper h2 { color: var(--mt-text) !important; }
.matematris-wrapper span { color: var(--mt-text-sec); }
.matematris-wrapper p { color: var(--mt-text-sec); }

.matematris-wrapper .btn-back {
  background: var(--mt-btn-bg) !important;
  color: var(--mt-btn-text) !important;
  border: 1px solid var(--mt-btn-border) !important;
}

.matematris-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--mt-surface);
  border-radius: 12px;
  padding: 6px 12px;
  border: 1px solid var(--mt-craft-border);
}

.matematris-body {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.matematris-canvas-col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.matematris-canvas-col canvas {
  background: #151828;
  border: 2.5px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
  height: 100%;
  max-height: 48vh;
  width: auto;
  aspect-ratio: 1 / 2;
}

.matematris-panel-col {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.matematris-craft-card {
  background: var(--mt-craft-bg) !important;
  border: 1.5px solid var(--mt-craft-border);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  color: var(--mt-text) !important;
}

.matematris-wrapper .craft-btn {
  color: var(--mt-btn-text) !important;
  background: var(--mt-btn-bg) !important;
  border-color: var(--mt-btn-border) !important;
}
.matematris-wrapper .craft-btn.active {
  background: rgba(115, 103, 240, 0.2) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.matematris-wrapper input[type="text"] {
  background: var(--mt-input-bg) !important;
  color: var(--mt-input-text) !important;
  border-color: var(--accent) !important;
}

.num-key-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
}

.matematris-wrapper .num-key {
  background: var(--mt-key-bg) !important;
  color: var(--mt-key-text) !important;
  border: 1px solid var(--mt-key-border) !important;
}
.matematris-wrapper .num-key:hover,
.matematris-wrapper .num-key:active {
  background: var(--mt-key-hover) !important;
  border-color: var(--accent) !important;
}

.matematris-wrapper #btnKeypadClear {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.matematris-controls {
  display: flex;
  justify-content: center;
  gap: 6px;
  background: var(--mt-controls-bg) !important;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--mt-controls-border);
}

/* --- ADAPTACIÓN RESPONSIVE CELULARES (< 640px) --- */
@media (max-width: 640px) {
  .matematris-wrapper {
    padding: 6px 8px !important;
    gap: 6px !important;
    border-radius: 16px !important;
  }
  .matematris-body {
    flex-direction: column !important;
    gap: 6px !important;
  }
  .matematris-canvas-col canvas {
    max-height: 38vh !important;
  }
  .matematris-panel-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
  }
  .num-key-grid {
    max-width: 100% !important;
  }
}
