/**
 * Estilos canónicos del Laberinto de madera inclinable 3D (fijate.com)
 * Estética prémium de caja de madera artesanal, latón pulido y acero cromado.
 */

:root {
  /* Paleta cromática principal - Tema oscuro */
  --bg-primary: #0a0e17;
  --bg-secondary: #131b2a;
  --bg-card: #182236;
  --bg-card-hover: #1f2c45;
  --border-color: #273752;
  --border-focus: #d4af37;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-gold: #d4af37;
  --accent-gold-light: #fef08a;
  --accent-brass: #b8860b;
  --accent-wood-dark: #3a1d10;
  --accent-wood-light: #dcb98a;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-cyan: #38bdf8;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 24px rgba(212, 175, 55, 0.25);
}

[data-theme="light"] {
  --bg-primary: #f4f6f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #b8860b;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-gold: #b8860b;
  --accent-gold-light: #854d0e;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
  --shadow-gold: 0 0 24px rgba(184, 134, 11, 0.2);
}

/* Reset y estructura global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: clip;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

/* Contenedor canónico de Fijate Tools */
.tool-layout {
  max-width: 1240px;
  width: 100%;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
}

/* Tarjeta principal del juego */
.labyrinth-game-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
}

/* Barra superior de telemetría y controles */
.game-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.telemetry-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.telemetry-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.telemetry-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.telemetry-value.is-gold {
  color: var(--accent-gold);
}

.telemetry-value.is-cyan {
  color: var(--accent-cyan);
}

/* Selector de nivel canónico (Lección 208) */
.level-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-select {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 2.5rem 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 40px;
  width: 100%;
  max-width: 230px;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-color: #0d1624;
  color: var(--text-main);
  color-scheme: dark;
  border: 1px solid var(--border-color);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
}

.form-select option {
  background-color: #132238;
  color: #f8fafc;
  padding: 10px;
}

.form-select optgroup {
  background-color: #0b1320;
  color: var(--accent-gold);
  font-weight: 700;
}

[data-theme="light"] .form-select {
  background-color: #ffffff;
  color: #0f172a;
  color-scheme: light;
  border-color: #cbd5e1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b8860b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="light"] .form-select option {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .form-select optgroup {
  background-color: #f1f5f9;
  color: #854d0e;
}

/* Barra de botones de acción */
.game-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-tool:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-tool:active {
  transform: scale(0.98);
}

.btn-tool.btn-primary {
  background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  color: #110d06;
  border-color: #d4af37;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-tool.btn-primary:hover {
  background: linear-gradient(135deg, #facc15 0%, #d4af37 100%);
  color: #000000;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.45);
}

.btn-tool.is-active {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-icon-only {
  width: 40px;
  padding: 0;
}

/* Contenedor del Canvas 3D */
.canvas-stage-wrapper {
  position: relative;
  width: 100%;
  height: 600px;
  background: radial-gradient(circle at center, #1b2638 0%, #0c121e 100%);
  overflow: hidden;
  touch-action: none; /* Crucial para evitar scroll nativo en táctil */
}

@media (max-width: 768px) {
  .canvas-stage-wrapper {
    height: 480px;
  }
}

@media (max-width: 480px) {
  .canvas-stage-wrapper {
    height: 380px;
  }
}

#canvas-container {
  width: 100%;
  height: 100%;
  display: block;
}

/* Indicador visual de control y pista flotante */
.stage-overlay-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  transition: opacity 0.3s;
}

.stage-overlay-hint svg {
  color: var(--accent-gold);
}

[data-theme="light"] .canvas-stage-wrapper {
  background: radial-gradient(circle at center, #cbd5e1 0%, #94a3b8 100%);
}

[data-theme="light"] .stage-overlay-hint {
  background: rgba(255, 255, 255, 0.88);
  color: #1e293b;
  border-color: rgba(184, 134, 11, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Panel inferior de mandos manuales y deslizadores */
.game-bottom-controls {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .game-bottom-controls {
    grid-template-columns: 1fr;
  }
}

.knob-control-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.knob-control-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.knob-control-header span:first-child {
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.knob-control-header svg {
  color: var(--accent-gold);
}

/* Sliders estilizados de latón */
.knob-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #0d1624;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.knob-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1a8 0%, #d4af37 60%, #854d0e 100%);
  border: 2px solid #5a3a10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transition: transform 0.1s;
}

.knob-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.knob-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1a8 0%, #d4af37 60%, #854d0e 100%);
  border: 2px solid #5a3a10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

/* Guía rápida de instrucciones / controles */
.control-badges-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .control-badges-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .control-badges-grid {
    grid-template-columns: 1fr;
  }
}

.control-badge-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.control-badge-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.control-badge-info h4 {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.control-badge-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Secciones divulgativas y didácticas */
.info-section-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 2rem;
}

.info-section-card h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-main);
}

.info-section-card h2 svg {
  color: var(--accent-gold);
}

.info-section-card p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.features-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .features-two-col {
    grid-template-columns: 1fr;
  }
}

.feature-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.feature-box h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.feature-box p {
  font-size: 0.88rem;
  margin-bottom: 0;
}

/* Acordeón FAQ Schema */
.faq-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  gap: 1rem;
}

.faq-question:hover {
  color: var(--accent-gold);
}

.faq-icon-chevron {
  transition: transform 0.25s ease;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.faq-item.is-open .faq-icon-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 0.85rem;
}

.faq-item.is-open .faq-answer {
  display: block;
}

/* Modales canónicos accesibles (sin alerts) */
.modal-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(10, 14, 23, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-container.is-active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-container.is-active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-body p {
  margin-bottom: 0.75rem;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.badge-record {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Responsividad táctil */
@media (max-width: 640px) {
  .game-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .telemetry-group {
    justify-content: space-between;
    width: 100%;
  }
  .game-actions-group {
    justify-content: stretch;
    width: 100%;
  }
  .game-actions-group .btn-tool {
    flex: 1 1 0%;
  }
  .form-select {
    max-width: 100%;
  }
}
