/* styles/tema68-juego.css - Estilos Premium para MathQuest */

:root {
  --neon-cyan: #00f2fe;
  --neon-pink: #ff007f;
  --neon-green: #39ff14;
  --neon-yellow: #fffb00;
  --panel-bg: rgba(11, 22, 44, 0.85);
  --glass-border: rgba(0, 242, 254, 0.25);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Contenedor del Juego */
.mathquest-container {
  margin: 2rem 0;
  background: radial-gradient(circle at center, #0f1c3f 0%, #070d1e 100%);
  border: 2px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(7, 13, 30, 0.8), inset 0 0 20px rgba(0, 242, 254, 0.1);
  overflow: hidden;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Encabezado del Tablero */
.mathquest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 28, 63, 0.6);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.mathquest-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--neon-cyan), #ffffff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mathquest-title::before {
  content: "🎮";
}

.mathquest-level-badge {
  background: rgba(255, 0, 127, 0.15);
  border: 1px solid var(--neon-pink);
  color: var(--neon-pink);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.25);
  animation: pulse-pink 2s infinite alternate;
}

/* Área de Juego Principal */
.mathquest-body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  min-height: 520px;
}

@media (max-width: 991px) {
  .mathquest-body {
    grid-template-columns: 1fr;
  }
}

/* Columna del Canvas (Renderer) */
.mathquest-viewport {
  position: relative;
  background: #000209;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--glass-border);
}

@media (max-width: 991px) {
  .mathquest-viewport {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
  }
}

.mathquest-viewport canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: transparent;
}

/* Overlay de Instrucciones de Juego */
.mathquest-instructions-overlay {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(7, 13, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  pointer-events: none;
  backdrop-filter: blur(4px);
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  max-width: 320px;
}

.mathquest-instructions-overlay h4 {
  margin: 0 0 0.4rem 0;
  font-size: 0.95rem;
  color: var(--neon-cyan);
}

.mathquest-instructions-overlay ul {
  margin: 0;
  padding-left: 1rem;
}

.mathquest-instructions-overlay li {
  margin-bottom: 0.2rem;
  color: #cbd5e1;
}

/* Columna del Inspector Matemático */
.mathquest-inspector {
  background: var(--panel-bg);
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  height: 520px;
}

.mathquest-tabs {
  display: flex;
  background: rgba(7, 13, 30, 0.5);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.5rem 0.5rem 0 0.5rem;
}

.mathquest-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 0.6rem 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s ease;
  text-align: center;
  border: 1px solid transparent;
  border-bottom: none;
}

.mathquest-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.mathquest-tab-btn.active {
  color: var(--neon-cyan);
  background: #0f1c3f;
  border-color: var(--glass-border);
  box-shadow: inset 0 2px 0 var(--neon-cyan);
}

.mathquest-inspector-content {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

/* Ocultar pestañas no seleccionadas */
.mathquest-tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-out forwards;
}

.mathquest-tab-pane.active {
  display: block;
}

/* Elementos del Inspector */
.formula-block {
  background: rgba(7, 13, 30, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.formula-block h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--neon-cyan);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.formula-block h4 span {
  font-size: 0.75rem;
  color: #64748b;
  font-family: var(--font-mono);
}

.formula-code {
  font-family: var(--font-mono);
  background: #020617;
  color: #38bdf8;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  overflow-x: auto;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--neon-cyan);
}

.formula-live {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #94a3b8;
  background: rgba(15, 28, 63, 0.4);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}

.formula-value {
  font-family: var(--font-mono);
  color: var(--neon-green);
  font-weight: 700;
}

/* HUD Overlay en el Canvas */
.mathquest-hud {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.hud-item {
  background: rgba(7, 13, 30, 0.85);
  border: 1px solid rgba(0, 242, 254, 0.15);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.hud-item.life {
  border-color: rgba(255, 0, 127, 0.25);
}

.life-bar {
  width: 80px;
  height: 8px;
  background: #1e293b;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}

.life-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff0055, var(--neon-pink));
  width: 100%;
  transition: width 0.15s ease-out;
}

.cooldown-wheel {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #334155;
  border-top-color: var(--neon-cyan);
  animation: spin 1s linear infinite;
  display: inline-block;
}

/* Controles de depuración e interacción */
.mathquest-footer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(15, 28, 63, 0.7);
  border-top: 1px solid var(--glass-border);
  flex-wrap: wrap;
  gap: 1rem;
}

.debug-options {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.debug-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  transition: color 0.15s;
}

.debug-checkbox-label:hover {
  color: #e2e8f0;
}

.debug-checkbox-label input {
  accent-color: var(--neon-cyan);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Botones de acción del juego */
.game-action-btn {
  background: linear-gradient(135deg, #0b4f8a 0%, #168aad 100%);
  color: #fff;
  border: 1px solid rgba(0, 242, 254, 0.3);
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(22, 138, 173, 0.3);
}

.game-action-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
  box-shadow: 0 6px 18px rgba(0, 242, 254, 0.4);
}

.game-action-btn:active {
  transform: translateY(0);
}

.game-action-btn.reset {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-color: rgba(255,255,255,0.1);
  box-shadow: none;
}

.game-action-btn.reset:hover {
  background: linear-gradient(135deg, #334155 0%, #475569 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* Enlace a Código Fuente debajo del juego */
.source-code-trigger-wrapper {
  margin: 1.5rem 0;
  text-align: center;
}

.source-code-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.15) 0%, rgba(20, 184, 166, 0.15) 100%);
  border: 1px solid rgba(20, 184, 166, 0.4);
  color: #14b8a6 !important;
  text-decoration: none !important;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(20, 184, 166, 0.12);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.source-code-link:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.25) 0%, rgba(20, 184, 166, 0.25) 100%);
  box-shadow: 0 14px 30px rgba(20, 184, 166, 0.22);
  color: #2dd4bf !important;
}

.source-code-link::before {
  content: "📂";
  font-size: 1.05rem;
}

/* Estilos de la Ventana Modal para Código */
.modal-code-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-code-viewer.open {
  display: flex;
  opacity: 1;
}

.modal-code-dialog {
  background: #0f172a;
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 16px;
  width: 100%;
  max-width: 1000px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 70px rgba(0,0,0,0.65), 0 0 40px rgba(0, 242, 254, 0.08);
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  background: #0b0f19;
  border-bottom: 1px solid #1e293b;
}

.modal-code-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-code-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.copy-code-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #94a3b8;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.copy-code-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

.copy-code-btn.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #10b981;
}

.modal-code-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-code-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.modal-code-body {
  padding: 0;
  flex: 1;
  overflow-y: auto;
  background: #050814;
}

.modal-code-body pre {
  margin: 0;
  padding: 1.5rem;
  background: transparent !important;
}

.modal-code-body code {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
  background: transparent !important;
}

/* Custom Scrollbars */
.mathquest-inspector-content::-webkit-scrollbar,
.modal-code-body::-webkit-scrollbar {
  width: 8px;
}

.mathquest-inspector-content::-webkit-scrollbar-track,
.modal-code-body::-webkit-scrollbar-track {
  background: #020617;
}

.mathquest-inspector-content::-webkit-scrollbar-thumb,
.modal-code-body::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
  border: 1px solid #0f172a;
}

.mathquest-inspector-content::-webkit-scrollbar-thumb:hover,
.modal-code-body::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Animaciones y Efectos */
@keyframes pulse-pink {
  0% {
    box-shadow: 0 0 6px rgba(255, 0, 127, 0.2);
  }
  100% {
    box-shadow: 0 0 14px rgba(255, 0, 127, 0.45);
  }
}

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

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

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Indicadores de Daño flotantes en Canvas */
.particle-effect {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--neon-pink);
  text-shadow: 0 0 4px #000, 0 0 8px var(--neon-pink);
  animation: floatUpFade 0.8s ease-out forwards;
}

@keyframes floatUpFade {
  0% {
    transform: translate(-50%, -50%) translateY(0) scale(0.8);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) translateY(-25px) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translateY(-50px) scale(0.9);
    opacity: 0;
  }
}

/* Overlay de Inicio del Juego */
.mathquest-start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 13, 30, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  backdrop-filter: blur(8px);
  visibility: visible;
  opacity: 1;
}

.mathquest-start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  text-align: center;
  padding: 2.25rem;
  max-width: 440px;
  background: rgba(15, 28, 63, 0.65);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.start-card h2 {
  font-size: 2.2rem;
  margin: 0 0 0.85rem 0;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: floatUpDown 3s ease-in-out infinite alternate;
}

.start-card p {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1.75rem 0;
  text-align: center !important;
}

.start-game-btn {
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #168aad 100%);
  color: #fff;
  border: 1px solid rgba(0, 242, 254, 0.4);
  padding: 0.85rem 2.25rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.start-game-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(0, 242, 254, 0.65), 0 0 10px var(--neon-cyan);
}

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