/* ==========================================================================
   FAMILY JOURNEY - RETRO 16-BIT PLATFORMER
   Archivo Central de Estilos CSS (Sin duplicados, modular y reutilizable)
   ========================================================================== */

:root {
  --bg-dark: #0a0c16;
  --bg-card: rgba(20, 24, 45, 0.85);
  --bg-card-hover: rgba(35, 42, 75, 0.95);
  --border-neon: #38bdf8;
  --gold: #facc15;
  --gold-glow: rgba(250, 204, 21, 0.4);
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;
  --accent-green: #22c55e;
  --font-retro: 'Press Start 2P', 'Courier New', monospace;
  --game-width: 1440px;
  --game-height: 720px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background: radial-gradient(circle at center, #171b30 0%, var(--bg-dark) 100%);
  color: var(--text-main);
  font-family: var(--font-retro);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  padding: 6px;
}

/* Contenedor Principal del Juego / Cabina Arcade (Pantalla Amplia) */
.arcade-wrapper {
  position: relative;
  width: 98vw;
  max-width: var(--game-width);
  max-height: 98vh;
  background: #111827;
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.3), 0 25px 50px rgba(0, 0, 0, 0.85);
  border: 3px solid #1f2937;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Encabezado Arcade Superior */
.arcade-header {
  background: linear-gradient(90deg, #1e1b4b, #311042, #1e1b4b);
  border-bottom: 3px solid #3730a3;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.arcade-title {
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  display: flex;
  align-items: center;
  gap: 10px;
}

.arcade-controls-top {
  display: flex;
  gap: 10px;
}

.arcade-btn-mini {
  background: #1e293b;
  border: 2px solid #475569;
  color: #f1f5f9;
  font-family: var(--font-retro);
  font-size: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.arcade-btn-mini:hover {
  background: #334155;
  border-color: var(--border-neon);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

/* Área de Pantalla de Juego (Viewport) */
.game-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #38b6ff;
}

/* Filtro CRT Scanlines opcional */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 20;
  opacity: 0.7;
}

/* ==========================================================================
   PANTALLAS INTERACTIVAS (Overlay sobre el canvas)
   ========================================================================== */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(10, 12, 22, 0.88);
  backdrop-filter: blur(4px);
  padding: 24px;
  text-align: center;
  transition: opacity 0.3s ease;
}

.screen-overlay.hidden {
  display: none !important;
}

/* Pantalla de Título */
.title-logo-container {
  margin-bottom: 24px;
  animation: floatTitle 3s ease-in-out infinite;
}

.title-sub {
  font-size: 11px;
  color: var(--border-neon);
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

.title-main {
  font-size: 26px;
  line-height: 1.4;
  color: #fff;
  text-shadow: 
    3px 3px 0px #be123c, 
    6px 6px 0px #0f172a,
    0 0 20px rgba(244, 63, 94, 0.6);
}

.title-tagline {
  font-size: 10px;
  color: var(--gold);
  margin-top: 10px;
  letter-spacing: 1px;
}

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

/* Botones Retro Principales */
.btn-arcade {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #111827;
  border: 3px solid #fef08a;
  border-radius: 8px;
  font-family: var(--font-retro);
  font-size: 13px;
  padding: 14px 28px;
  cursor: pointer;
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 0 #92400e, 0 10px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
  margin-top: 15px;
}

.btn-arcade:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #92400e, 0 12px 25px rgba(245, 158, 11, 0.5);
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-arcade:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #92400e;
}

.btn-secondary {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: #93c5fd;
  color: #fff;
  box-shadow: 0 6px 0 #1e3a8a, 0 10px 20px rgba(0,0,0,0.4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}
.btn-secondary:hover {
  box-shadow: 0 8px 0 #1e3a8a, 0 12px 25px rgba(59, 130, 246, 0.5);
}
.btn-secondary:active {
  box-shadow: 0 2px 0 #1e3a8a;
}

/* ==========================================================================
   PANTALLA DE SELECCIÓN DE PERSONAJE
   ========================================================================== */
.char-select-title {
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-shadow: 0 0 10px var(--gold-glow);
}

.char-select-subtitle {
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 840px;
  margin-bottom: 18px;
}

.char-card {
  background: var(--bg-card);
  border: 3px solid #334155;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.char-card:hover {
  background: var(--bg-card-hover);
  border-color: #60a5fa;
  transform: translateY(-6px);
  box-shadow: 0 10px 20px rgba(96, 165, 250, 0.3);
}

.char-card.selected {
  border-color: var(--gold);
  background: rgba(30, 41, 75, 0.95);
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 0 25px var(--gold-glow), 0 15px 30px rgba(0, 0, 0, 0.7);
}

.char-card.selected::after {
  content: "¡ELEGIDO!";
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gold);
  color: #111;
  font-size: 7px;
  font-weight: bold;
  padding: 3px 6px;
  border-radius: 4px;
}

.char-avatar-frame {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  border: 3px solid #475569;
  background: #020617;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.char-card.selected .char-avatar-frame {
  border-color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
}

.char-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: transform 0.3s ease;
}

.char-card:hover .char-avatar-img {
  transform: scale(1.08);
}

.char-name {
  font-size: 13px;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.char-ability-badge {
  font-size: 7px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 10px;
  line-height: 1.3;
  width: 100%;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 7px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  color: var(--text-dim);
}

.stat-bar-bg {
  width: 65px;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
}
.stat-speed { background: #38bdf8; }
.stat-jump { background: #4ade80; }
.stat-power { background: #f43f5e; }

/* Pie de pantalla y Controles */
.arcade-footer {
  background: #0f172a;
  border-top: 3px solid #1f2937;
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: var(--text-dim);
}

.key-badge {
  background: #334155;
  color: #f8fafc;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #475569;
  font-size: 8px;
  margin: 0 2px;
}

/* Modales de Pausa y Victoria */
.modal-box {
  background: #1e293b;
  border: 4px solid var(--gold);
  border-radius: 12px;
  padding: 24px 32px;
  box-shadow: 0 0 30px rgba(0,0,0,0.9);
  max-width: 480px;
  width: 90%;
}

.modal-title {
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 14px;
}

.modal-desc {
  font-size: 9px;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ==========================================================================
   CONTROLES TÁCTILES VIRTUALES PARA MÓVIL Y TABLET
   ========================================================================== */
.touch-controls-container {
  position: absolute;
  bottom: 14px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
  pointer-events: none;
  z-index: 25;
}

/* En ordenadores de escritorio se ocultan por defecto salvo que se pulse el botón "TÁCTIL" */
@media (min-width: 1025px) and (pointer: fine) {
  .touch-controls-container:not(.force-visible) {
    display: none !important;
  }
}

.touch-dpad, .touch-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-family: var(--font-retro);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.1);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.touch-btn:active, .touch-btn.active {
  transform: scale(0.90);
  background: rgba(56, 189, 248, 0.45);
  border-color: var(--border-neon);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.9);
}

.touch-btn-jump {
  background: rgba(34, 197, 94, 0.35);
  border-color: #4ade80;
  color: #bbf7d0;
  width: 70px;
  height: 70px;
  font-size: 10px;
}

.touch-btn-attack, .touch-btn-sprint {
  background: rgba(239, 68, 68, 0.45);
  border-color: #f87171;
  color: #fee2e2;
  font-size: 8px;
  width: 68px;
  height: 68px;
  margin-bottom: 2px;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
}

.touch-btn-attack:active, .touch-btn-attack.active {
  background: rgba(239, 68, 68, 0.75);
  border-color: #ef4444;
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.95);
}

/* Botón activo en header */
.arcade-btn-mini.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

/* Responsividad */
@media (max-width: 768px) {
  body {
    padding: 0;
  }
  .arcade-wrapper {
    border-radius: 0;
    border: none;
  }
  .arcade-header {
    padding: 8px 12px;
  }
  .arcade-title {
    font-size: 11px;
  }
  .arcade-btn-mini {
    font-size: 8px;
    padding: 4px 6px;
  }
  .char-grid {
    grid-template-columns: 1fr;
    max-height: 280px;
    overflow-y: auto;
  }
  .char-card {
    flex-direction: row;
    gap: 12px;
    text-align: left;
    padding: 8px;
  }
  .char-avatar-frame {
    width: 64px;
    height: 64px;
    margin-bottom: 0;
  }
  .char-stats {
    display: none;
  }
  .title-main {
    font-size: 20px;
  }
  .arcade-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 8px;
  }
  .touch-btn {
    width: 52px;
    height: 52px;
    font-size: 13px;
  }
  .touch-btn-jump {
    width: 60px;
    height: 60px;
    font-size: 9px;
  }
}

