/* ==========================================================================
   Tetris Neo Arcade - Estilos Visuales Cyberpunk Glassmorphism
   Tipografías canónicas: Outfit, Inter, JetBrains Mono
   ========================================================================== */

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

  /* Paleta Cyberpunk / Neo Arcade */
  --neon-cyan: #00f0ff;
  --neon-cyan-glow: rgba(0, 240, 255, 0.4);
  --neon-purple: #bf00ff;
  --neon-purple-glow: rgba(191, 0, 255, 0.4);
  --neon-yellow: #ffe600;
  --neon-green: #00ff66;
  --neon-red: #ff1744;
  --neon-orange: #ff9100;
  --neon-blue: #2979ff;

  /* Tokens institucionales para fijate.com */
  --primary-color: #00f0ff;
  --primary-light: rgba(0, 240, 255, 0.12);
  --border-color: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(15, 23, 42, 0.7);
  --bg-card-header: rgba(30, 41, 59, 0.6);

  /* Tema Oscuro (Predeterminado) */
  --bg-base: #06080f;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-surface-elevated: rgba(30, 41, 59, 0.75);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-glow: rgba(0, 240, 255, 0.25);
  --glass-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-base: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.9);
  --bg-surface-elevated: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-glow: rgba(0, 150, 200, 0.3);
  --glass-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
  --border-color: rgba(0, 0, 0, 0.1);
  --bg-input: #ffffff;
  --bg-card-header: #f8fafc;
}

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

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

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

.mono,
.stat-val,
.hud-val,
.timer-val {
  font-family: var(--font-mono);
}

/* Contenedor principal de la herramienta */
.tool-layout {
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

.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%;
}

/* --------------------------------------------------------------------------
   Barra superior del juego (Modos, acciones rápidas)
   -------------------------------------------------------------------------- */
.game-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--glass-shadow);
}

.mode-tabs-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  background: var(--neon-cyan);
  color: #06080f;
  box-shadow: 0 0 14px var(--neon-cyan-glow);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-game-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-game-action:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan-glow);
  transform: translateY(-1px);
}

.btn-game-action.is-muted {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.05);
}

/* --------------------------------------------------------------------------
   Escenario del Juego (Stage HiDPI)
   -------------------------------------------------------------------------- */
.game-stage-wrapper {
  position: relative;
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: #06080f;
  border: 1px solid var(--glass-border-glow);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.8), 0 0 30px -5px rgba(0, 240, 255, 0.15);
  margin-bottom: 1.5rem;
}

/* Canvas de fondo ambiental */
#canvas-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Contenedor flexible del HUD y Tablero */
.stage-inner-layout {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
}

/* Columnas laterales de telemetría HUD */
.hud-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 140px;
  flex-shrink: 0;
}

.hud-card {
  background: rgba(10, 14, 24, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 14px;
  padding: 0.85rem;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  transition: border-color 0.25s ease;
}

.hud-card:hover {
  border-color: rgba(0, 240, 255, 0.4);
}

.hud-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  margin-bottom: 0.45rem;
}

.hud-mini-canvas-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
}

.hud-mini-canvas-box.next-box {
  height: 330px;
}

#canvas-hold,
#canvas-next {
  display: block;
}

.hud-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.hud-sublabel {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Contenedor central del tablero */
.board-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.2);
  border-radius: 12px;
  border: 2px solid rgba(0, 240, 255, 0.3);
  background: #0a0e18;
}

#canvas-board {
  display: block;
  width: 300px;
  height: 600px;
  border-radius: 10px;
}

/* Overlay animado (Cuenta atrás, Pausa, Mensajes) */
.board-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 8, 15, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 10px;
  text-align: center;
  padding: 1.5rem;
}

.overlay-text {
  font-size: 3.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  text-shadow: 0 0 25px currentColor;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  animation: pulseZoom 0.8s infinite alternate ease-in-out;
}

.overlay-subtext {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

@keyframes pulseZoom {
  0% { transform: scale(0.96); }
  100% { transform: scale(1.04); }
}

/* --------------------------------------------------------------------------
   Panel de controles táctiles Arcade (Móvil / Tablet)
   -------------------------------------------------------------------------- */
.touch-arcade-panel {
  display: none; /* Se activa en media queries móvil */
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.touch-controls-layout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.touch-group-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 180px;
  flex: 1;
}

.touch-group-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-width: 180px;
  flex: 1;
}

.btn-touch-arcade {
  min-height: 52px;
  height: 52px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--glass-border-glow);
  color: var(--text-primary);
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  transition: background 0.1s, transform 0.08s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-touch-arcade:active,
.btn-touch-arcade.is-pressed {
  background: var(--neon-cyan);
  color: #06080f;
  transform: scale(0.94);
  box-shadow: 0 0 15px var(--neon-cyan-glow);
}

.btn-touch-arcade.btn-touch-primary {
  border-color: var(--neon-purple);
}

.btn-touch-arcade.btn-touch-primary:active,
.btn-touch-arcade.btn-touch-primary.is-pressed {
  background: var(--neon-purple);
  color: #ffffff;
  box-shadow: 0 0 15px var(--neon-purple-glow);
}

.btn-touch-arcade svg {
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Modales Canónicos (Game Over, Controles)
   -------------------------------------------------------------------------- */
.canonic-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 14, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.canonic-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.canonic-modal-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--neon-cyan-glow);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 240, 255, 0.2);
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.canonic-modal-backdrop.is-open .canonic-modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.modal-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.modal-badge-record {
  display: inline-block;
  background: linear-gradient(135deg, #ffe600, #ff9100);
  color: #06080f;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  margin-bottom: 1rem;
  box-shadow: 0 0 15px rgba(255, 230, 0, 0.5);
  animation: pulseZoom 1.2s infinite alternate ease-in-out;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.modal-stat-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.75rem;
}

.modal-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.modal-stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-primary-action {
  width: 100%;
  min-height: 48px;
  background: linear-gradient(135deg, var(--neon-cyan), #00a8ff);
  color: #06080f;
  border: none;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--neon-cyan-glow);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 240, 255, 0.6);
}

.btn-secondary-action {
  width: 100%;
  min-height: 44px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-action:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Tabla de atajos en modal de controles */
.controls-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.86rem;
  text-align: left;
}

.controls-table th,
.controls-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
}

.controls-table th {
  color: var(--neon-cyan);
  font-weight: 700;
  font-family: var(--font-heading);
}

.kbd-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #ffffff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   Responsive y Ajustes para Móvil
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .stage-inner-layout {
    gap: 0.75rem;
    padding: 1rem 0.5rem;
  }

  .hud-column {
    width: 100px;
  }

  .hud-mini-canvas-box {
    height: 60px;
  }

  .hud-mini-canvas-box.next-box {
    height: 250px;
  }

  #canvas-board {
    width: 250px;
    height: 500px;
  }
}

@media (max-width: 640px) {
  .tool-layout {
    margin: 0.75rem auto 2rem;
    padding: 0 0.5rem;
  }

  .game-top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-tabs-group {
    justify-content: center;
  }

  .top-bar-actions {
    justify-content: space-between;
  }

  .stage-inner-layout {
    flex-direction: column;
    align-items: center;
  }

  /* En móvil, reorganizamos el HUD en dos bloques horizontales */
  .hud-column {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
  }

  .hud-column.hud-left {
    order: 1;
  }

  .board-container {
    order: 2;
  }

  .hud-column.hud-right {
    order: 3;
  }

  .hud-card {
    flex: 1 1 0%;
    min-width: 0;
    padding: 0.5rem;
  }

  .hud-mini-canvas-box.next-box {
    height: 70px;
  }

  #canvas-board {
    width: 280px;
    height: 560px;
  }

  /* Activación del panel arcade táctil */
  .touch-arcade-panel {
    display: block;
  }
}
