/* ==========================================================================
   MATEMÁTICA MAESTRA - Estilos Principales
   Diseño moderno, amigable, accesible y responsive para niñas y niños de 8 años
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-border: #c7d2fe;
  
  --secondary: #059669;
  --secondary-hover: #047857;
  --secondary-light: #ecfdf5;

  --accent-star: #f59e0b;
  --accent-star-light: #fffbeb;
  --accent-pink: #ec4899;
  --accent-pink-light: #fdf2f8;
  --accent-purple: #7c3aed;
  --accent-blue: #2563eb;
  --accent-orange: #ea580c;

  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-light: #e2e8f0;
  --border-focus: #6366f1;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12);
  --shadow-key: 0 4px 0 rgba(0, 0, 0, 0.1);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Reset y Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Contenedor Principal de la App */
#app-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
}

/* ==========================================================================
   CABECERA & BARRA SUPERIOR
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

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

.app-logo {
  font-size: 2.2rem;
  line-height: 1;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

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

.icon-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover, .icon-btn:focus-visible {
  background: var(--primary-light);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}

/* Barra de Estadísticas de la Alumna */
.student-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--primary-light);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-border);
}

.student-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-hover);
}

.student-avatar {
  font-size: 1.4rem;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.badge-stars {
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-streak {
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.badge-accuracy {
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* ==========================================================================
   VISTAS (PANTALLAS)
   ========================================================================== */
.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

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

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

/* ==========================================================================
   1. PANTALLA PRINCIPAL (HOME)
   ========================================================================== */
.home-hero {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: var(--text-inverse);
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.home-hero h1 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.home-hero p {
  font-size: 1.1rem;
  opacity: 0.95;
  max-width: 500px;
}

.daily-goal-card {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Menú de Botones Grandes Principales */
.main-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.btn-menu-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn-menu-card:hover, .btn-menu-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.btn-menu-card:active {
  transform: translateY(0);
}

.btn-menu-card.btn-primary-action {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  grid-column: 1 / -1;
  padding: 26px 24px;
}

.btn-menu-card.btn-primary-action .card-title {
  color: white;
  font-size: 1.45rem;
}

.btn-menu-card.btn-primary-action .card-desc {
  color: rgba(255, 255, 255, 0.9);
}

.menu-card-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.menu-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ==========================================================================
   2. SELECTOR DE TEMA (GRID DE MÓDULOS)
   ========================================================================== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-back:hover {
  background: var(--bg-subtle);
  transform: translateX(-2px);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.topic-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-icon {
  font-size: 1.8rem;
}

.topic-level-badge {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
}

.topic-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.topic-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-grow: 1;
}

/* Barra de Dominio */
.mastery-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mastery-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.mastery-bar-bg {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.mastery-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ==========================================================================
   3. PANTALLA DE EJERCICIO (ÁREA DE PRÁCTICA)
   ========================================================================== */
.practice-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* Barra de progreso de la sesión */
.session-progress-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.progress-track {
  height: 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  width: 0%;
  transition: width 0.3s ease;
}

/* Tarjeta del Ejercicio */
.exercise-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 10px 0;
}

.exercise-topic-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.exercise-statement {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.exercise-equation {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--primary);
  background: var(--bg-subtle);
  padding: 14px 28px;
  border-radius: var(--radius-lg);
  letter-spacing: 1px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Representaciones Visuales (Fichas, Bandejas, Triángulo) */
.visual-container {
  width: 100%;
  padding: 16px;
  background: #fdfefe;
  border: 2px dashed var(--primary-border);
  border-radius: var(--radius-md);
  margin: 6px 0;
}

/* Bandejas de galletitas */
.trays-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.tray-box {
  background: #fff7ed;
  border: 2px solid #fed7aa;
  border-radius: var(--radius-md);
  padding: 10px;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tray-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #ea580c;
}

.tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  font-size: 1.3rem;
  max-width: 120px;
}

.remainder-box {
  margin-top: 12px;
  padding: 8px 14px;
  background: #fef2f2;
  border: 2px dashed #fca5a5;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #dc2626;
}

/* Triángulo de Familias de Números */
.family-triangle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px auto;
}

.triangle-top {
  width: 60px;
  height: 60px;
  background: #7c3aed;
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: var(--shadow-md);
}

.triangle-arms {
  font-size: 1.5rem;
  color: #7c3aed;
  font-weight: 900;
  line-height: 1;
}

.triangle-bottom {
  display: flex;
  gap: 40px;
  align-items: center;
}

.triangle-node {
  width: 54px;
  height: 54px;
  background: var(--bg-card);
  border: 3px solid #7c3aed;
  color: #7c3aed;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
}

.triangle-sign {
  font-size: 1.5rem;
  font-weight: 900;
  color: #7c3aed;
}

/* ==========================================================================
   INPUTS Y TECLADO VIRTUAL TÁCTIL
   ========================================================================== */
.inputs-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.single-input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dual-inputs-wrapper {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
}

.input-field-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.input-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.math-input-box {
  width: 130px;
  height: 64px;
  background: var(--bg-card);
  border: 3px solid var(--border-focus);
  border-radius: var(--radius-md);
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.math-input-box.active-input {
  border-color: #ec4899;
  background: #fdf2f8;
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.2);
}

/* Botones de Comparación (<, =, >) */
.comparison-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
  width: 100%;
}

.btn-compare {
  width: 80px;
  height: 70px;
  font-size: 2rem;
  font-weight: 900;
  background: var(--bg-card);
  border: 3px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.btn-compare:hover, .btn-compare.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.08);
}

/* Teclado Numérico en Pantalla */
.virtual-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
  width: 100%;
  margin: 0 auto;
}

.key-btn {
  height: 56px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-bottom: 4px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}

.key-btn:active {
  transform: translateY(3px);
  border-bottom-width: 1px;
}

.key-btn.key-action {
  background: #f1f5f9;
  font-size: 1.25rem;
}

.key-btn.key-submit {
  background: #10b981;
  color: white;
  border-color: #059669;
  border-bottom-color: #047857;
  font-size: 1.4rem;
  grid-column: span 1;
}

/* Barra de Acciones del Ejercicio (Pistas, Enviar) */
.practice-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  margin-top: 6px;
}

.btn-hint {
  background: var(--accent-star-light);
  border: 2px solid #fde68a;
  color: #b45309;
  font-weight: 800;
  font-size: 1rem;
  padding: 12px 18px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-hint:hover {
  background: #fef3c7;
  transform: translateY(-2px);
}

.btn-check-answer {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-check-answer:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Caja de Pistas Desplegable */
.hint-box {
  background: #fffbeb;
  border: 2px solid #fcd34d;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

.hint-header {
  font-weight: 800;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint-text {
  font-size: 1rem;
  color: #78350f;
  line-height: 1.4;
}

/* ==========================================================================
   FEEDBACK Y EXPLICACIÓN DE ERRORES
   ========================================================================== */
.feedback-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.feedback-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.feedback-icon {
  font-size: 3.5rem;
  line-height: 1;
}

.feedback-title {
  font-size: 1.6rem;
  font-weight: 900;
}

.feedback-title.correct {
  color: var(--secondary);
}

.feedback-title.incorrect {
  color: #d97706;
}

.feedback-points-badge {
  background: var(--accent-star-light);
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 1rem;
}

.explanation-card {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.explanation-header {
  font-weight: 800;
  color: var(--text-main);
  font-size: 1.05rem;
}

.explanation-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: #334155;
}

.explanation-summary {
  font-weight: 800;
  color: var(--primary);
  margin-top: 4px;
}

.feedback-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-continue {
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  flex: 1;
  min-width: 160px;
  transition: all 0.2s ease;
}

.btn-continue:hover {
  background: var(--primary-hover);
}

.btn-retry-similar {
  background: #fff7ed;
  border: 2px solid #fdba74;
  color: #c2410c;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

/* ==========================================================================
   4. CELEBRACIÓN DE FIN DE SESIÓN
   ========================================================================== */
.celebration-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 600px;
  margin: 0 auto;
}

.celebration-trophy {
  font-size: 4rem;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.celebration-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
}

.session-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin: 10px 0;
}

.session-stat-box {
  background: var(--bg-subtle);
  padding: 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box-val {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text-main);
}

.stat-box-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ==========================================================================
   5. MODO MAESTRA (EXPLICACIÓN CONCEPTUAL)
   ========================================================================== */
.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 740px;
  margin: 0 auto;
}

.lesson-intro {
  font-size: 1.15rem;
  color: var(--text-main);
  font-weight: 600;
}

.lesson-step {
  background: var(--bg-subtle);
  border-left: 5px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lesson-step-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.lesson-visual {
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  border: 1px solid var(--border-light);
  white-space: pre-wrap;
}

.lesson-rule {
  background: #fefce8;
  border: 2px solid #fef08a;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 800;
  color: #854d0e;
}

/* ==========================================================================
   6. PANTALLA DE PROGRESO Y REPORTES PARA ADULTOS
   ========================================================================== */
.progress-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  font-size: 2rem;
}

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Gráfico de Barras SVG */
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.svg-chart {
  width: 100%;
  height: 180px;
}

/* Tabla de Historial de Errores */
.errors-table-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

.errors-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.errors-table th, .errors-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.errors-table th {
  font-weight: 800;
  color: var(--text-muted);
}

/* ==========================================================================
   7. LOGROS & MEDALLAS
   ========================================================================== */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.achievement-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.2s ease;
}

.achievement-card.locked {
  opacity: 0.55;
  filter: grayscale(0.8);
}

.achievement-card.unlocked {
  border-color: #fde68a;
  background: linear-gradient(135deg, #ffffff, #fffbeb);
}

.achievement-icon {
  font-size: 2.2rem;
  flex-shrink: 0;
}

.achievement-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.achievement-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   8. MODAL DE CONTROL PARENTAL Y CONFIGURACIÓN
   ========================================================================== */
.pin-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}

.pin-digit {
  width: 50px;
  height: 60px;
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  border: 2px solid var(--border-focus);
  border-radius: var(--radius-md);
  outline: none;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  width: 100%;
}

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

.form-group label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
}

.form-control {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
}

/* Canvas para Confeti */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    padding: 8px;
  }
  .app-header {
    padding: 12px 14px;
  }
  .app-title {
    font-size: 1.2rem;
  }
  .home-hero h1 {
    font-size: 1.6rem;
  }
  .practice-container {
    padding: 16px 12px;
  }
  .exercise-statement {
    font-size: 1.15rem;
  }
  .exercise-equation {
    font-size: 1.9rem;
    padding: 10px 18px;
  }
  .virtual-keypad {
    max-width: 100%;
    gap: 8px;
  }
  .key-btn {
    height: 50px;
    font-size: 1.4rem;
  }
  .math-input-box {
    width: 110px;
    height: 56px;
    font-size: 1.7rem;
  }
}
