/* ==============================================================
   MATHREALM: LA CARRERA DE LOS NÚMEROS
   Estilos modernos, dinámicos, adaptables y atractivos para 12 años
   ============================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-border: rgba(148, 163, 184, 0.15);
  --bg-glass: rgba(15, 23, 42, 0.75);
  
  --color-primary: #8b5cf6;
  --color-primary-light: #a78bfa;
  --color-secondary: #06b6d4;
  --color-accent: #f59e0b;
  --color-success: #10b981;
  --color-danger: #ef4444;
  
  --p1-color: #38bdf8;
  --p1-glow: rgba(56, 189, 248, 0.6);
  --p2-color: #f43f5e;
  --p2-glow: rgba(244, 63, 94, 0.6);

  --font-main: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-display: 'Fredoka', 'Segoe UI', cursive, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: radial-gradient(circle at 20% 20%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
  color: #f8fafc;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* HEADER & NAVBAR */
.header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
}

.logo-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.7));
  animation: float 3s ease-in-out infinite;
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #a78bfa 0%, #38bdf8 50%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 0.75rem;
  color: #94a3b8;
  display: block;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.action-tools {
  display: flex;
  gap: 0.5rem;
}

.tool-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--bg-card-border);
  color: #cbd5e1;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: #334155;
  color: white;
  transform: translateY(-2px);
}

/* APP CONTAINER */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
}

.view-section {
  display: none;
  flex-direction: column;
  gap: 1.2rem;
  animation: fadeIn 0.3s ease-out;
}

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

/* PANEL SUPERIOR DE ESTADO DEL JUEGO */
.game-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 18px;
  padding: 0.8rem 1.4rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  flex-wrap: wrap;
  gap: 1rem;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 14px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: rgba(15, 23, 42, 0.6);
  min-width: 200px;
}

.player-card.active-turn {
  transform: scale(1.04);
  box-shadow: 0 0 20px var(--turn-glow, rgba(99, 102, 241, 0.5));
  border-color: var(--turn-color, #6366f1);
  background: rgba(30, 41, 59, 0.9);
}

.player-card.p1 {
  --turn-glow: var(--p1-glow);
  --turn-color: var(--p1-color);
}

.player-card.p2 {
  --turn-glow: var(--p2-glow);
  --turn-color: var(--p2-color);
}

.avatar-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

.turn-indicator-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
  display: none;
  animation: pulse 1.5s infinite;
}

.player-card.active-turn .turn-indicator-dot {
  display: block;
}

.player-info-name {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.player-role-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  text-transform: uppercase;
}

.player-stats {
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  gap: 0.8rem;
  margin-top: 2px;
}

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

/* CENTRO DE ACCIÓN: DADOS Y MENSAJE DE TURNO */
.center-turn-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
}

.turn-message {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
}

.turn-instruction {
  font-size: 0.85rem;
  color: #94a3b8;
}

.dice-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* BOTÓN DEL DADO */
.btn-roll-dice {
  position: relative;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  border: none;
  border-radius: 20px;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-roll-dice:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.btn-roll-dice:active:not(:disabled) {
  transform: translateY(2px) scale(0.96);
}

.btn-roll-dice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.dice-face {
  font-size: 2.2rem;
  line-height: 1;
  transition: transform 0.6s ease;
}

.dice-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 2px;
  text-transform: uppercase;
}

.dice-rolling {
  animation: diceSpin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* ÁREA PRINCIPAL DEL TABLERO */
.board-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* MAPA DE CASILLAS DEL TABLERO */
.board-grid-path {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
  padding: 10px;
}

/* CASILLA INDIVIDUAL */
.board-cell {
  aspect-ratio: 1 / 1;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  position: relative;
  transition: all 0.25s ease;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.board-cell:hover {
  transform: translateY(-4px) scale(1.05);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

/* TIPOS DE CASILLAS CON COLORES ATRACTIVOS */
.board-cell.type-suma {
  border-color: rgba(16, 185, 129, 0.5);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.85));
}
.board-cell.type-suma:hover {
  border-color: #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.board-cell.type-resta {
  border-color: rgba(6, 182, 212, 0.5);
  background: linear-gradient(145deg, rgba(6, 182, 212, 0.15), rgba(15, 23, 42, 0.85));
}
.board-cell.type-resta:hover {
  border-color: #06b6d4;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.board-cell.type-multi {
  border-color: rgba(168, 85, 247, 0.5);
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.15), rgba(15, 23, 42, 0.85));
}
.board-cell.type-multi:hover {
  border-color: #a855f7;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.board-cell.type-divi {
  border-color: rgba(236, 72, 153, 0.5);
  background: linear-gradient(145deg, rgba(236, 72, 153, 0.15), rgba(15, 23, 42, 0.85));
}
.board-cell.type-divi:hover {
  border-color: #ec4899;
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

.board-cell.type-combinada {
  border-color: rgba(245, 158, 11, 0.6);
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.2), rgba(15, 23, 42, 0.85));
}
.board-cell.type-combinada:hover {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.board-cell.type-portal {
  border-color: #3b82f6;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.3) 0%, rgba(15, 23, 42, 0.85) 100%);
  animation: pulseGlow 2.5s infinite;
}

.board-cell.type-trampa {
  border-color: #f43f5e;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.25) 0%, rgba(15, 23, 42, 0.85) 100%);
}

.board-cell.type-duelo {
  border-color: #ec4899;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
}

.board-cell.type-inicio {
  border-color: #10b981;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.3), #0f172a);
}

.board-cell.type-meta {
  border-color: #fbbf24;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.4) 0%, rgba(15, 23, 42, 0.9) 100%);
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.4);
}

/* NÚMERO DE CASILLA */
.cell-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 2px;
}

.cell-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
}

.cell-badge-icon {
  font-size: 0.85rem;
}

.cell-body-icon {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.cell-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: #cbd5e1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* CONTENEDOR DE FICHAS DENTRO DE CASILLA */
.cell-tokens-slot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  display: flex;
  gap: 3px;
  z-index: 5;
}

.token-pawn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.token-pawn.p1-token {
  background: var(--p1-color);
  box-shadow: 0 0 10px var(--p1-glow);
}

.token-pawn.p2-token {
  background: var(--p2-color);
  box-shadow: 0 0 10px var(--p2-glow);
}

.token-hop-anim {
  animation: pawnHop 0.4s ease-out;
}

/* LEYENDA DEL TABLERO */
.board-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 1.2rem;
  padding: 0.7rem 1.2rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

/* ==============================================================
   MODAL DE RETO MATEMÁTICO (PREGUNTA)
   ============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.challenge-modal-card {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  width: 100%;
  max-width: 580px;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  position: relative;
  overflow: hidden;
}

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

.challenge-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.challenge-timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: #f59e0b;
  font-size: 0.95rem;
}

.challenge-player-tag {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #cbd5e1;
}

.operation-display-box {
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 18px;
  padding: 1.8rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.operation-formula {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.operation-context-hint {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: 0.4rem;
}

/* OPCIONES DE RESPUESTA */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.option-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.option-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.25);
  border-color: #818cf8;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

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

.option-btn.selected-correct {
  background: rgba(16, 185, 129, 0.35) !important;
  border-color: #10b981 !important;
  color: #6ee7b7 !important;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.6) !important;
}

.option-btn.selected-wrong {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: #ef4444 !important;
  color: #fca5a5 !important;
  animation: shake 0.4s ease-in-out;
}

/* BOTÓN DE TECLADO O PISTAS */
.challenge-actions-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-toggle-input {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}
.btn-toggle-input:hover {
  color: white;
}

/* ==============================================================
   MODAL DIDÁCTICO ANTE EL ERROR (CLAVE PEDAGÓGICA)
   ============================================================== */
.didactic-modal-card {
  background: linear-gradient(170deg, #1e1b4b 0%, #0f172a 100%);
  border: 2px solid #818cf8;
  border-radius: 28px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.2rem;
  box-shadow: 0 25px 60px -15px rgba(99, 102, 241, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

.didactic-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1rem;
}

.mentor-avatar {
  font-size: 3rem;
  background: rgba(99, 102, 241, 0.2);
  width: 65px;
  height: 65px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #818cf8;
}

.didactic-title-group h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
}

.didactic-title-group p {
  font-size: 0.85rem;
  color: #a5b4fc;
}

/* CONTENEDOR DE LA COMPARACIÓN */
.comparison-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.7);
  padding: 1.2rem;
  border-radius: 18px;
  border: 1px solid var(--bg-card-border);
}

.compare-card {
  padding: 0.8rem;
  border-radius: 12px;
  text-align: center;
}

.compare-card.wrong {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.compare-card.correct {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.compare-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}
.compare-card.wrong .compare-label { color: #f87171; }
.compare-card.correct .compare-label { color: #34d399; }

.compare-val {
  font-size: 1.6rem;
  font-weight: 800;
}

/* DESGLOSE PASO A PASO */
.step-by-step-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.step-card {
  background: rgba(30, 41, 59, 0.6);
  border-left: 4px solid var(--color-primary);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
}

.step-number {
  background: var(--color-primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-text strong {
  color: #38bdf8;
}

.step-text .math-code {
  font-family: 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 6px;
  color: #facc15;
  font-weight: 700;
}

/* CAJA DE TRUCO MENTAL */
.magic-trick-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.05) 100%);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 16px;
  padding: 1.1rem 1.3rem;
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.magic-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.magic-content h4 {
  font-size: 0.95rem;
  color: #fbbf24;
  margin-bottom: 0.2rem;
}

.magic-content p {
  font-size: 0.85rem;
  color: #fef3c7;
  line-height: 1.4;
}

/* BOTONES DEL MODAL DIDÁCTICO */
.didactic-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.btn-revenge {
  flex: 1;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-revenge:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.btn-continue {
  background: rgba(51, 65, 85, 0.8);
  border: 1px solid var(--bg-card-border);
  color: #cbd5e1;
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-continue:hover {
  background: #475569;
  color: white;
}

/* ==============================================================
   MODAL DE REVANCHA INMEDIATA
   ============================================================== */
.revenge-modal-card {
  background: linear-gradient(160deg, #064e3b 0%, #0f172a 100%);
  border: 2px solid #10b981;
  border-radius: 24px;
  width: 100%;
  max-width: 540px;
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(16, 185, 129, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ==============================================================
   MODAL DE VICTORIA / FIN DE PARTIDA
   ============================================================== */
.victory-modal-card {
  background: linear-gradient(160deg, #312e81 0%, #0f172a 100%);
  border: 2px solid #fbbf24;
  border-radius: 28px;
  width: 100%;
  max-width: 520px;
  padding: 2.5rem 2rem;
  box-shadow: 0 25px 60px rgba(251, 191, 36, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.2rem;
}

.victory-trophy {
  font-size: 5rem;
  animation: bounce 1.5s infinite;
}

.victory-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fbbf24;
}

.victory-subtitle {
  font-size: 1.1rem;
  color: #e2e8f0;
}

.victory-stats-summary {
  display: flex;
  gap: 1.5rem;
  background: rgba(15, 23, 42, 0.7);
  padding: 1rem 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 0.5rem;
}

.stat-item-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-item-box .val {
  font-size: 1.5rem;
  font-weight: 800;
  color: #38bdf8;
}

.stat-item-box .lbl {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ==============================================================
   VISTA: MODO DUELO RÁPIDO (1 VS 1 PANTALLA DIVIDIDA)
   ============================================================== */
.duel-arena {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.duel-header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: 20px;
  border: 1px solid var(--bg-card-border);
}

.duel-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  min-height: 480px;
}

.duel-side {
  border-radius: 24px;
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.duel-side.p1-side {
  background: linear-gradient(160deg, rgba(56, 189, 248, 0.15) 0%, rgba(15, 23, 42, 0.9) 100%);
  border: 2px solid rgba(56, 189, 248, 0.4);
}

.duel-side.p2-side {
  background: linear-gradient(160deg, rgba(244, 63, 94, 0.15) 0%, rgba(15, 23, 42, 0.9) 100%);
  border: 2px solid rgba(244, 63, 94, 0.4);
}

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

.duel-score-big {
  font-size: 2.2rem;
  font-weight: 900;
}

.duel-op-box {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  margin: 1rem 0;
}

.duel-op-formula {
  font-size: 2.4rem;
  font-weight: 800;
}

.duel-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.duel-opt-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 14px;
  padding: 1rem;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.duel-opt-btn:active {
  transform: scale(0.95);
}

.duel-opt-btn.correct-burst {
  background: #10b981 !important;
  color: white !important;
  border-color: #34d399 !important;
}

.duel-opt-btn.wrong-burst {
  background: #ef4444 !important;
  color: white !important;
  border-color: #f87171 !important;
}

/* ==============================================================
   VISTA: EL LABORATORIO MATEMÁTICO (EXPLORADOR DIDÁCTICO)
   ============================================================== */
.lab-container {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.5rem;
}

.lab-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 24px;
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.lab-title-box h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lab-title-box p {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.op-selector-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.op-chip-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--bg-card-border);
  color: #cbd5e1;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.op-chip-btn:hover {
  background: #334155;
  color: white;
}

.op-chip-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary-light);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.lab-inputs-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.lab-input-number {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(148, 163, 184, 0.2);
  color: white;
  border-radius: 14px;
  padding: 0.9rem;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease;
}

.lab-input-number:focus {
  border-color: var(--color-primary);
}

.lab-op-symbol {
  font-size: 1.8rem;
  font-weight: 800;
  color: #38bdf8;
}

.btn-lab-solve {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-lab-solve:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

/* RESULTADOS DIDÁCTICOS DEL LABORATORIO */
.lab-results-container {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ==============================================================
   MODAL DE AJUSTES Y NUEVA PARTIDA
   ============================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
}

.form-input-text {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--bg-card-border);
  color: white;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  outline: none;
}

.avatar-picker-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.avatar-choice-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(30, 41, 59, 0.8);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.avatar-choice-btn:hover {
  transform: scale(1.1);
  background: #334155;
}

.avatar-choice-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* CANVAS DE CONFETI */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2000;
}

/* ==============================================================
   ANIMACIONES
   ============================================================== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

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

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
  50% { box-shadow: 0 0 25px rgba(59, 130, 246, 0.7); }
}

@keyframes pawnHop {
  0% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.4) translateY(-25px); }
  100% { transform: scale(1) translateY(0); }
}

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

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

@keyframes diceSpin {
  0% { transform: rotate(0deg) scale(0.9); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(0.9); }
}

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

/* TOAST NOTIFICATION MODERNO */
.toast-notification {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #10b981;
  color: #f8fafc;
  padding: 1rem 2rem;
  border-radius: 20px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 25px rgba(16, 185, 129, 0.4);
  font-weight: 700;
  font-size: 1.05rem;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast-notification.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-notification.info {
  border-color: #38bdf8;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 25px rgba(56, 189, 248, 0.4);
}

/* ==============================================================
   RESPONSIVIDAD (MÓVIL Y TABLETS)
   ============================================================== */
@media (max-width: 900px) {
  .board-grid-path {
    grid-template-columns: repeat(6, 1fr);
  }
  .lab-container {
    grid-template-columns: 1fr;
  }
  .duel-split-container {
    grid-template-columns: 1fr;
  }
  .game-status-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .player-card {
    min-width: 100%;
  }
}

@media (max-width: 600px) {
  .board-grid-path {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .operation-formula {
    font-size: 2rem;
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .comparison-box {
    grid-template-columns: 1fr;
  }
}
