/* ========================================================
   MISIÓN FRACCIONES: EL UNIVERSO MATEMÁTICO DE EVA
   Diseño Moderno, Estimulante y Responsivo para 12 años
   ======================================================== */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #31104b 100%);
  --card-bg: rgba(255, 255, 255, 0.96);
  --card-border: rgba(255, 255, 255, 0.2);
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.4);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Encabezado Principal */
.header-container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #f43f5e, #fb923c);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 8px 16px rgba(244, 63, 94, 0.35);
  animation: pulse-gentle 3s infinite ease-in-out;
}

@keyframes pulse-gentle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.brand-title {
  color: #fff;
  font-family: 'Fredoka', cursive;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.brand-subtitle {
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle .badge-name {
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

/* Barra de Estadísticas de Eva */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
}

.stat-chip.stars {
  color: #fde047;
  text-shadow: 0 0 10px rgba(253, 224, 71, 0.5);
}

.stat-chip.streak {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.15);
}

/* Botones de Barra Superior */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon-nav {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.55rem 0.9rem;
  border-radius: 16px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-icon-nav:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-2px);
}

.btn-icon-nav:active {
  transform: translateY(0);
}

/* Contenedor Principal */
.main-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1.25rem 2.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Selector de Niveles */
.level-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.level-tab {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.level-tab:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-3px);
}

.level-tab.active {
  background: #ffffff;
  color: var(--text-dark);
  border-color: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25), 0 0 20px rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.tab-badge {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.level-tab.active .tab-badge {
  color: var(--primary-dark);
}

.tab-title {
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.level-tab:not(.active) .tab-progress {
  color: #94a3b8;
}

/* Tarjeta del Desafío Principal */
.challenge-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

/* Barra superior dentro de la tarjeta */
.card-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.problem-progress-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.level-indicator-pill {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #5b21b6;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.problem-number-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-muted);
}

.problem-progress-track {
  width: 140px;
  height: 10px;
  background: #e2e8f0;
  border-radius: 20px;
  overflow: hidden;
}

.problem-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  border-radius: 20px;
  transition: width 0.4s ease;
}

/* Título e Historia */
.problem-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.85rem;
  font-weight: 700;
  color: #1e1b4b;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.problem-story {
  font-size: 1.22rem;
  line-height: 1.7;
  color: #334155;
  background: #f8fafc;
  padding: 1.4rem 1.6rem;
  border-radius: var(--radius-md);
  border-left: 5px solid var(--primary);
  margin-bottom: 1.75rem;
  font-weight: 600;
}

/* Ayuda visual interactiva incorporada */
.visual-aid-box {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.visual-aid-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.visual-canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fraction-bar-preview {
  display: flex;
  border: 2px solid #334155;
  border-radius: 8px;
  overflow: hidden;
  height: 38px;
  width: 260px;
  background: #ffffff;
}

.fraction-bar-piece {
  flex: 1;
  border-right: 1px solid #94a3b8;
  transition: all 0.2s ease;
}

.fraction-bar-piece:last-child {
  border-right: none;
}

.fraction-bar-piece.filled {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

.fraction-bar-piece.filled-alt {
  background: linear-gradient(135deg, #ec4899, #f472b6);
}

/* ========================================================
   TABLERO VISUAL DE STOCK Y SUB-PREGUNTAS (NIVEL 5)
   ======================================================== */
.stock-dashboard {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.stock-dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 0.75rem;
}

.stock-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-goal-pill {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  color: #92400e;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stock-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.stock-item-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.stock-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: #ede9fe;
  color: #6366f1;
}

.stock-item-info {
  display: flex;
  flex-direction: column;
}

.stock-item-qty {
  font-weight: 900;
  font-size: 1.05rem;
  color: #0f172a;
}

.stock-item-desc {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
}

/* NAVEGADOR DE SUB-PREGUNTAS (a, b, c, d, e, f) */
.sub-tabs-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  background: #f1f5f9;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
}

.sub-tab-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sub-tab-pill:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: var(--primary);
}

.sub-tab-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.sub-tab-pill.solved {
  border-color: #10b981;
}

.sub-tab-pill.solved .check-dot {
  color: #10b981;
  font-weight: 900;
}

.sub-tab-pill.active.solved .check-dot {
  color: #ffffff;
}

.sub-question-card {
  background: #ffffff;
  border: 2px solid #818cf8;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.08);
  animation: slideUp 0.25s ease;
}

.sub-question-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sub-question-badge {
  background: #ede9fe;
  color: #5b21b6;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sub-question-text {
  font-size: 1.18rem;
  font-weight: 800;
  color: #1e1b4b;
  line-height: 1.6;
}

/* Cuadrícula de Opciones de Respuesta */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.option-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  font-size: 1.15rem;
  font-weight: 800;
  font-family: inherit;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f5f3ff;
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(99, 102, 241, 0.2);
}

.option-btn:active:not(:disabled) {
  transform: translateY(0);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 900;
  flex-shrink: 0;
  transition: all 0.2s;
}

.option-btn:hover:not(:disabled) .option-letter {
  background: var(--primary);
  color: white;
}

/* Estados de opción: Correcta / Incorrecta */
.option-btn.correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3) !important;
}

.option-btn.correct .option-letter {
  background: #10b981 !important;
  color: white !important;
}

.option-btn.wrong-first {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
  color: #92400e !important;
  animation: shake 0.4s ease;
}

.option-btn.wrong-second {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
  opacity: 0.75;
}

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

/* ZONA DE FEEDBACK PEDAGÓGICO */
.feedback-container {
  display: none;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  animation: slideUp 0.3s ease;
}

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

/* 1er Error: PISTA SOCRÁTICA / RAZONAMIENTO */
.feedback-hint {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #f59e0b;
  color: #78350f;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

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

.feedback-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.35rem;
  font-weight: 700;
}

.feedback-hint .feedback-title {
  color: #92400e;
}

.feedback-text {
  font-size: 1.12rem;
  line-height: 1.6;
  font-weight: 600;
  margin-bottom: 1rem;
}

.btn-retry-hint {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35);
  transition: all 0.2s ease;
}

.btn-retry-hint:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.45);
}

/* 2do Error: EXPLICACIÓN DIDÁCTICA PASO A PASO */
.feedback-explanation {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 2px solid #3b82f6;
  color: #1e3a8a;
}

.feedback-explanation .feedback-title {
  color: #1e40af;
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0;
}

.step-item {
  background: rgba(255, 255, 255, 0.85);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  border-left: 4px solid #3b82f6;
}

.takeaway-box {
  background: #ffffff;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-continue-next {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  padding: 0.85rem 1.6rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.05rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
  transition: all 0.2s ease;
}

.btn-continue-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.45);
}

/* ÉXITO / RESPUESTA CORRECTA */
.feedback-success {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 2px solid #10b981;
  color: #065f46;
}

.feedback-success .feedback-title {
  color: #065f46;
}

.btn-next-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 0.85rem 1.8rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.1rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-next-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
}

/* Barra Inferior de Navegación */
.problem-footer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #e2e8f0;
  padding-top: 1.25rem;
}

.btn-secondary-action {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 0.65rem 1.2rem;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-secondary-action:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* Modales Flotantes (Pizarra de Eva, Laboratorio, Medallas) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 1rem;
}

.modal-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.6rem;
  font-weight: 700;
  color: #1e1b4b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close-modal {
  background: #f1f5f9;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 800;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* PIZARRA DE APUNTES / BLOC DE DIBUJO DE EVA */
.scratchpad-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.2s;
}

.color-dot.active {
  border-color: #1e293b;
  transform: scale(1.15);
}

.canvas-wrapper {
  position: relative;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  /* Fondo cuadriculado escolar */
  background-image: linear-gradient(#e2e8f0 1px, transparent 1px), linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: crosshair;
  overflow: hidden;
}

#scratchpadCanvas {
  display: block;
  touch-action: none;
}

/* LABORATORIO DE FRACCIONES */
.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.lab-panel {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.lab-panel-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
}

.lab-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.number-stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stepper-btn {
  background: #e2e8f0;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
}

.stepper-btn:hover {
  background: #cbd5e1;
}

.stepper-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1e1b4b;
}

.fraction-display {
  font-size: 2.2rem;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.fraction-display .frac-bar {
  width: 100%;
  height: 3px;
  background: #1e293b;
  margin: 3px 0;
}

.lab-visual-box {
  width: 100%;
  min-height: 140px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* MEDALLAS */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.badge-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.badge-card.unlocked {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: #f59e0b;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
}

.badge-icon {
  font-size: 2.5rem;
  filter: grayscale(100%);
  opacity: 0.4;
  transition: all 0.3s;
}

.badge-card.unlocked .badge-icon {
  filter: grayscale(0%);
  opacity: 1;
  transform: scale(1.1);
}

.badge-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #1e293b;
}

.badge-desc {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
}

/* Canvas de Confeti */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2000;
}

/* Responsive */
@media (max-width: 900px) {
  .level-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .lab-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .header-container {
    padding: 1rem;
  }
  .brand-title {
    font-size: 1.35rem;
  }
  .brand-icon {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
  }
  .challenge-card {
    padding: 1.3rem;
  }
  .problem-story {
    font-size: 1.05rem;
    padding: 1.1rem;
  }
  .option-btn {
    font-size: 1rem;
    padding: 1rem;
  }
}
