/* ==========================================================================
   Estilos corporativos y de juego: Air hockey 3D contra la máquina
   Fijate Tools • 60 FPS • Responsive • Modales accesibles
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores temáticos arcade */
  --arcade-cyan: #00e5ff;
  --arcade-green: #00ffcc;
  --arcade-pink: #ff007f;
  --arcade-red: #ff0055;
  --arcade-yellow: #ffea00;
  --arcade-bg: #090d16;
  --arcade-card-bg: #121824;
  --arcade-border: #212c3f;
  --arcade-text-muted: #8899ac;
  --arcade-text-main: #f0f4f8;
}

[data-theme="light"] {
  --arcade-bg: #f8fafc;
  --arcade-card-bg: #ffffff;
  --arcade-border: #e2e8f0;
  --arcade-text-muted: #64748b;
  --arcade-text-main: #0f172a;
}

/* Reset y estructura canónica (Lección 342: box-sizing universal sin tocar margins de common) */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--arcade-bg);
  color: var(--arcade-text-main);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-title,
.section-title,
.hero-title,
.hockey-modal-title,
.hud-status-text {
  font-family: var(--font-heading);
}

.text-mono,
.mono,
code,
pre,
kbd {
  font-family: var(--font-mono);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* Layout canónico de Fijate Tools */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

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

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

/* Contenedor del visor 3D */
.game-viewport-card {
  position: relative;
  width: 100%;
  background: #06080d;
  border-radius: 14px;
  border: 1px solid var(--arcade-border);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-sizing: border-box;
}

/* HUD superior */
.game-hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg, rgba(6, 8, 13, 0.92) 0%, rgba(6, 8, 13, 0.6) 80%, transparent 100%);
  z-index: 10;
  pointer-events: none;
}

.hud-player-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-player-info {
  display: flex;
  flex-direction: column;
}

.hud-player-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.hud-player-name.is-player {
  color: var(--arcade-cyan);
}

.hud-player-name.is-ai {
  color: var(--arcade-red);
}

.hud-player-score {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.hud-player-score.is-player {
  color: var(--arcade-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.hud-player-score.is-ai {
  color: var(--arcade-red);
  text-shadow: 0 0 12px rgba(255, 0, 85, 0.6);
}

/* Centro del HUD: Velocímetro y estado */
.hud-center-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.hud-speedometer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(18, 24, 36, 0.85);
  border: 1px solid rgba(255, 234, 0, 0.35);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--arcade-yellow);
  box-shadow: 0 0 10px rgba(255, 234, 0, 0.2);
}

.hud-difficulty-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--arcade-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Banner de estado flotante (Goles, cuenta atrás) */
.hud-status-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  background: rgba(6, 8, 13, 0.94);
  border: 2px solid var(--arcade-cyan);
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.45);
  padding: 1rem 2rem;
  border-radius: 12px;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.hud-status-banner.is-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hud-status-text {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 1px;
  text-shadow: 0 0 16px var(--arcade-cyan);
  white-space: nowrap;
}

/* Contenedor del lienzo Three.js */
#hockey-canvas-container {
  width: 100%;
  height: clamp(680px, 76vh, 900px);
  min-height: 620px;
  position: relative;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

@media (min-width: 1400px) {
  #hockey-canvas-container {
    height: clamp(740px, 80vh, 960px);
  }
}

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

/* Barra inferior de controles y cámaras */
.game-controls-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  background: var(--arcade-card-bg);
  border: 1px solid var(--arcade-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  box-sizing: border-box;
}

.deck-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.deck-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--arcade-text-muted);
}

/* Botones de acción arcade */
.btn-hockey {
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  background: #1e293b;
  color: var(--arcade-text-main);
  min-height: 38px;
  box-sizing: border-box;
}

.btn-hockey:hover {
  background: #28374d;
  border-color: rgba(0, 229, 255, 0.4);
  color: #ffffff;
}

.btn-hockey-outline {
  background: transparent;
  border: 1px solid var(--arcade-border);
  color: var(--arcade-text-main);
}

.btn-hockey-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--arcade-cyan);
  color: var(--arcade-cyan);
}

.btn-hockey-outline.is-active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--arcade-cyan);
  color: var(--arcade-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}

.btn-hockey-sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  min-height: 32px;
}

.btn-hockey-primary {
  background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
  color: #ffffff;
  border-color: #0096c7;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
}

.btn-hockey-primary:hover {
  background: linear-gradient(135deg, #48cae4 0%, #0096c7 100%);
  box-shadow: 0 6px 16px rgba(0, 180, 216, 0.45);
}

/* ==========================================================================
   Modales accesibles de Air Hockey
   ========================================================================== */
.hockey-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.hockey-modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.hockey-modal-card {
  width: 100%;
  max-width: 520px;
  background: #111723;
  border: 1px solid var(--arcade-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 24px rgba(0, 229, 255, 0.15);
  padding: 1.5rem;
  position: relative;
  box-sizing: border-box;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--arcade-text-main);
}

.hockey-modal-overlay.is-visible .hockey-modal-card {
  transform: translateY(0) scale(1);
}

.hockey-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--arcade-border);
}

.hockey-modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.hockey-modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--arcade-text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.hockey-modal-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Formularios de configuración */
.hockey-form-group {
  margin-bottom: 1.15rem;
}

.hockey-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--arcade-text-main);
}

.hockey-select,
.hockey-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  background: #172030;
  border: 1px solid var(--arcade-border);
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: border-color 0.18s ease;
  min-height: 42px;
}

.hockey-select:focus,
.hockey-input:focus {
  outline: none;
  border-color: var(--arcade-cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

.hockey-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.hockey-range-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hockey-range-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--arcade-cyan);
}

/* Tarjetas de estadísticas */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: #172030;
  border: 1px solid var(--arcade-border);
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
}

.stat-box-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--arcade-text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.stat-box-val {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--arcade-cyan);
}

/* ==========================================================================
   Sección técnica, educativa y guía de air hockey
   ========================================================================== */
.hockey-guide-section {
  margin-top: 2rem;
  margin-bottom: 3rem;
  line-height: 1.65;
  color: var(--arcade-text-main);
}

.hockey-guide-section h2 {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 800;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: #ffffff;
}

.hockey-guide-section h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--arcade-cyan);
}

.hockey-guide-section p {
  margin-bottom: 1rem;
  color: #cbd5e1;
}

.hockey-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.hockey-feature-card {
  background: var(--arcade-card-bg);
  border: 1px solid var(--arcade-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-sizing: border-box;
}

.hockey-feature-card h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hockey-feature-card p {
  font-size: 0.88rem;
  margin: 0;
  color: #94a3b8;
}

/* ==========================================================================
   Responsive móvil
   ========================================================================== */
@media (max-width: 768px) {
  #hockey-canvas-container {
    height: 460px;
    min-height: 380px;
  }

  .game-hud-top {
    padding: 0.5rem 0.75rem;
  }

  .hud-player-score {
    font-size: 1.7rem;
  }

  .hud-status-text {
    font-size: 1.35rem;
  }

  .game-controls-deck {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .deck-group {
    justify-content: center;
    width: 100%;
  }

  .btn-hockey {
    flex: 1 1 auto;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}