/* ==========================================================================
   PONG (1972) - ATARI ARCADE CLASSIC
   Estilos CSS Puros - Diseño Retro Arcade Cabinet con Filtro CRT
   ========================================================================== */

:root {
  /* Paleta Base Clásica B&W 1972 */
  --bg-cabinet: #0d0e12;
  --bg-bezel: #161820;
  --bg-screen: #050608;
  --screen-border: #282c37;
  
  --phosphor-color: #f4f6fa;
  --phosphor-glow: rgba(244, 246, 250, 0.45);
  --phosphor-faint: rgba(244, 246, 250, 0.15);
  
  --accent-gold: #e5a93b;
  --accent-red: #e63946;
  --accent-blue: #457b9d;
  
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --panel-bg: rgba(22, 24, 32, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);

  --font-retro: 'Press Start 2P', monospace;
  --font-crt: 'VT323', monospace;
  --font-tech: 'Orbitron', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --scanline-opacity: 0.18;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
}

/* ==========================================================================
   Temas de Color de Fósforo (Phosphor Color Schemes)
   ========================================================================== */
body.theme-bw {
  --phosphor-color: #f8fafc;
  --phosphor-glow: rgba(255, 255, 255, 0.5);
  --phosphor-faint: rgba(255, 255, 255, 0.15);
}

body.theme-green {
  --phosphor-color: #33ff66;
  --phosphor-glow: rgba(51, 255, 102, 0.55);
  --phosphor-faint: rgba(51, 255, 102, 0.15);
  --bg-screen: #020d04;
}

body.theme-amber {
  --phosphor-color: #ffb703;
  --phosphor-glow: rgba(255, 183, 3, 0.55);
  --phosphor-faint: rgba(255, 183, 3, 0.15);
  --bg-screen: #0f0801;
}

body.theme-cyber {
  --phosphor-color: #00f5d4;
  --phosphor-glow: rgba(0, 245, 212, 0.6);
  --phosphor-faint: rgba(0, 245, 212, 0.18);
  --bg-screen: #070314;
}

/* ==========================================================================
   Resets & Base Layout
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-cabinet);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(40, 44, 55, 0.6) 0%, transparent 75%),
    linear-gradient(180deg, #0a0b0e 0%, #12141a 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Efecto CRT & Scanlines
   ========================================================================== */
.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, var(--scanline-opacity)) 0px,
    rgba(0, 0, 0, var(--scanline-opacity)) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 1;
  transition: opacity 0.3s ease;
}

.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.85);
  background: radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.65) 100%);
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Si el usuario apaga CRT */
body:not(.crt-active) .crt-scanlines,
body:not(.crt-active) .crt-overlay {
  opacity: 0;
}

/* ==========================================================================
   Contenedor Principal de la Máquina Arcade
   ========================================================================== */
.arcade-wrapper {
  width: 100%;
  max-width: 980px;
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
}

/* Header & Marquee */
.arcade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #1f232d 0%, #141720 100%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 16px;
}

.atari-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #000;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(229, 169, 59, 0.4);
}

.atari-icon {
  display: inline-block;
  width: 14px;
  height: 18px;
  background: var(--accent-red);
  clip-path: polygon(
    40% 0%, 60% 0%, 60% 100%, 40% 100%, 40% 60%, 
    15% 100%, 0% 100%, 25% 45%, 0% 0%, 15% 0%, 35% 40%, 
    40% 0%, 60% 0%, 65% 40%, 85% 0%, 100% 0%, 75% 45%, 
    100% 100%, 85% 100%, 60% 60%
  );
}

.brand-text {
  font-family: var(--font-tech);
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 0.9rem;
  color: #fff;
}

.title-container .game-title {
  font-family: var(--font-retro);
  font-size: 1.35rem;
  color: var(--phosphor-color);
  text-shadow: 0 0 10px var(--phosphor-glow);
  letter-spacing: 6px;
  margin-bottom: 2px;
}

.title-container .game-subtitle {
  font-family: var(--font-tech);
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

/* Quick Controls Toolbar */
.quick-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.retro-btn {
  background: #1a1d26;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.retro-btn:hover {
  background: #252a37;
  border-color: var(--phosphor-color);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

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

.retro-btn.active {
  border-color: var(--phosphor-color);
  box-shadow: inset 0 0 8px var(--phosphor-glow), 0 0 8px var(--phosphor-glow);
}

/* ==========================================================================
   Cabinet Chassis & CRT Frame
   ========================================================================== */
.cabinet-chassis {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-frame {
  position: relative;
  background: linear-gradient(135deg, #1b1e28 0%, #0d0f15 50%, #151821 100%);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 2px solid #2d3342;
  box-shadow: 
    0 12px 36px rgba(0, 0, 0, 0.75),
    inset 0 2px 4px rgba(255, 255, 255, 0.15),
    inset 0 -2px 6px rgba(0, 0, 0, 0.8);
}

.canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 858 / 525;
  background: var(--bg-screen);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 
    inset 0 0 45px rgba(0, 0, 0, 0.95),
    0 0 1px rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(0, 0, 0, 0.8);
  cursor: ns-resize; /* Cursor visual claro para movimiento vertical */
}

.canvas-container.dragging {
  cursor: grabbing !important;
}

/* Curvatura sutil de pantalla CRT */
body.crt-active .canvas-container::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.8);
  background: radial-gradient(
    circle at 50% 50%,
    transparent 60%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

canvas#pongCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: inherit;
}

/* ==========================================================================
   Overlays de Juego (Start, Pause, Game Over)
   ========================================================================== */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.screen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.screen-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.retro-card {
  background: rgba(18, 20, 28, 0.95);
  border: 2px solid var(--phosphor-color);
  box-shadow: 0 0 25px var(--phosphor-glow), inset 0 0 15px rgba(0, 0, 0, 0.6);
  padding: 30px 40px;
  border-radius: var(--radius-md);
  text-align: center;
  max-width: 580px;
  width: 100%;
  animation: cardFadeIn 0.3s ease-out;
}

@keyframes cardFadeIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-heading {
  font-family: var(--font-retro);
  font-size: 1.3rem;
  color: var(--phosphor-color);
  text-shadow: 0 0 12px var(--phosphor-glow);
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.overlay-heading.blink {
  animation: textBlink 1.2s infinite ease-in-out;
}

@keyframes textBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.overlay-desc {
  font-family: var(--font-tech);
  font-size: 0.78rem;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.mode-selection {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.primary-btn, .secondary-btn {
  font-family: var(--font-retro);
  font-size: 0.78rem;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.primary-btn {
  background: var(--phosphor-color);
  color: #050608;
  border: 2px solid var(--phosphor-color);
  font-weight: 900;
  box-shadow: 0 4px 15px var(--phosphor-glow);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--phosphor-glow);
  filter: brightness(1.1);
}

.secondary-btn {
  background: transparent;
  color: var(--phosphor-color);
  border: 2px solid var(--phosphor-color);
}

.secondary-btn:hover {
  background: var(--phosphor-faint);
  transform: translateY(-2px);
}

.key-hint {
  font-family: var(--font-tech);
  font-size: 0.7rem;
  opacity: 0.8;
}

.control-hints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  border-top: 1px dashed var(--phosphor-faint);
  padding-top: 16px;
  font-size: 0.75rem;
}

.hint-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hint-col strong {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: var(--phosphor-color);
  margin-bottom: 2px;
}

.hint-col kbd {
  background: #2b3040;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-tech);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.touch-note {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Match Stats en Game Over */
.match-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
  background: rgba(0, 0, 0, 0.4);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--phosphor-faint);
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-family: var(--font-tech);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.stat-val {
  font-family: var(--font-crt);
  font-size: 1.5rem;
  color: var(--phosphor-color);
  font-weight: 700;
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Touch Controls Zones */
.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  z-index: 10;
}

.touch-zone {
  flex: 1;
  pointer-events: none; /* No bloquear eventos de ratón */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.3s;
}

@media (hover: none) and (pointer: coarse) {
  .touch-zone {
    pointer-events: auto;
    opacity: 0.25;
  }
  .touch-zone:active {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.05);
  }
}

.touch-indicator {
  font-family: var(--font-retro);
  font-size: 0.75rem;
  color: var(--phosphor-color);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  border: 1px dashed var(--phosphor-color);
}

/* ==========================================================================
   Control Dashboard (Panel de Configuración)
   ========================================================================== */
.control-dashboard {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.dashboard-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-title {
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.btn-group {
  display: flex;
  background: #11131a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.dash-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-tech);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dash-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.dash-btn.active {
  background: var(--phosphor-color);
  color: #000;
  font-weight: 900;
  box-shadow: 0 0 10px var(--phosphor-glow);
}

.dashboard-actions {
  display: flex;
  gap: 8px;
}

.dash-action-btn {
  background: #202430;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dash-action-btn:hover {
  background: #2c3244;
  border-color: var(--phosphor-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Stats Ticker */
.stats-ticker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
  background: #090b10;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  gap: 12px;
}

.ticker-item {
  font-family: var(--font-tech);
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ticker-label {
  color: var(--text-dim);
  font-weight: 600;
}

.ticker-data {
  color: var(--phosphor-color);
  font-weight: 700;
  font-family: var(--font-crt);
  font-size: 1.15rem;
}

/* ==========================================================================
   Modal Histórico (Retro Dialog)
   ========================================================================== */
.retro-dialog {
  margin: auto;
  padding: 0;
  background: transparent;
  border: none;
  max-width: 620px;
  width: 90%;
  color: var(--text-main);
}

.retro-dialog::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
}

.dialog-content {
  background: #14161f;
  border: 2px solid var(--phosphor-color);
  border-radius: var(--radius-md);
  box-shadow: 0 0 35px var(--phosphor-glow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--phosphor-faint);
  padding-bottom: 12px;
}

.dialog-header h2 {
  font-family: var(--font-retro);
  font-size: 0.95rem;
  color: var(--phosphor-color);
  text-shadow: 0 0 8px var(--phosphor-glow);
}

.close-x {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.close-x:hover {
  color: #fff;
}

.dialog-body {
  font-size: 0.88rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.dialog-body h3 {
  font-family: var(--font-tech);
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 6px;
}

.dialog-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px dashed var(--phosphor-faint);
  padding-top: 14px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.arcade-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 8px 0;
}

.hotkeys-guide {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 0.7rem;
}

.hotkeys-guide kbd {
  background: #1c202c;
  color: var(--phosphor-color);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: var(--font-tech);
}

/* ==========================================================================
   Media Queries & Mobile Responsiveness
   ========================================================================== */
@media (max-width: 768px) {
  .arcade-wrapper {
    padding: 10px;
  }

  .arcade-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    text-align: center;
  }

  .header-branding {
    justify-content: center;
  }

  .quick-controls {
    justify-content: center;
    flex-wrap: wrap;
  }

  .title-container .game-title {
    font-size: 1.1rem;
  }

  .dashboard-row {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .btn-group {
    width: 100%;
  }

  .dash-btn {
    flex: 1;
    text-align: center;
  }

  .retro-card {
    padding: 20px;
  }

  .overlay-heading {
    font-size: 1rem;
  }

  .match-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stats-ticker {
    font-size: 0.65rem;
  }
}
