/* =========================================================
   MILLIONAIRE GAME - DESIGN SYSTEM & GLOBAL STYLES
   Identidad 2D "concurso de televisión":
   - Azul noche (fondo / escenario)
   - Azul eléctrico / neón (luces, marcos, bordes, reflejos)
   - Morado / violeta (detalles decorativos y fondos de logo)
   - Dorado / amarillo (premios, monedas, temporizador, cantidades)
   - Blanco de alto contraste (textos y diálogos)
   ========================================================= */

:root {
  /* Escenario y Superficies */
  --blue-night: #050a1f;
  --blue-midnight: #081230;
  --bg-dark: #050a1f;
  --bg-secondary: #0a1230;
  --bg-card: rgba(10, 18, 48, 0.86);
  --bg-card-hover: rgba(15, 27, 66, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.04);

  /* Azul eléctrico / neón (luces y marcos) */
  --blue-electric: #1e9fff;
  --blue-neon: #35e0ff;
  --blue-neon-soft: rgba(53, 224, 255, 0.55);
  --neon-frame: rgba(53, 224, 255, 0.65);
  --neon-glow: 0 0 14px rgba(53, 224, 255, 0.7), 0 0 30px rgba(30, 159, 255, 0.35);

  /* Morado / Violeta (decorativo) */
  --purple: #8b5cf6;
  --violet: #a855f7;

  /* Acentos de Dinero (Dorado) */
  --gold-primary: #f5b041;
  --gold-secondary: #f39c12;
  --gold-light: #fef5d1;
  --gold-glow: 0 0 20px rgba(243, 156, 18, 0.45);
  --gold-gradient: linear-gradient(135deg, #f39c12 0%, #f1c40f 50%, #f39c12 100%);

  /* Botones de Acción (Rosa / Morado) */
  --btn-purple: #8b5cf6;
  --btn-pink: #ec4899;
  --btn-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --btn-glow: 0 0 20px rgba(236, 72, 153, 0.4);
  --btn-gradient-hover: linear-gradient(135deg, #9333ea 0%, #db2777 100%);

  /* Estados de Validación */
  --success-green: #10b981;
  --success-glow: 0 0 25px rgba(16, 185, 129, 0.7);
  --danger-red: #ef4444;
  --danger-glow: 0 0 25px rgba(239, 68, 68, 0.7);

  /* Texto */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-gold: #facc15;

  /* Bordes & Sombras */
  --border-subtle: 1px solid rgba(255, 255, 255, 0.08);
  --border-gold: 1px solid rgba(241, 196, 15, 0.35);
  --border-purple: 1px solid rgba(168, 85, 247, 0.4);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-lg: 0 12px 40px 0 rgba(0, 0, 0, 0.6);

  --font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--blue-night);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   FONDO DE ESCENARIO LIMPIO (sin blur, sin filtros oscuros)
   Se usa la ilustración pura del set de TV vacío
   ═══════════════════════════════════════════════════════════ */
.stage-backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  /* WebP ligero; JPEG de respaldo para navegadores sin soporte WebP */
  background-image: url('../assets/images/fondo-escenario-2d.jpg');
  background-image: image-set(
    url('../assets/images/escenario-tv-limpio.webp') type('image/webp'),
    url('../assets/images/fondo-escenario-2d.jpg') type('image/jpeg')
  );
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Overlay sutil para legibilidad */
.stage-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(53, 224, 255, 0.05) 0%, transparent 65%),
    linear-gradient(180deg, rgba(5, 10, 31, 0.05) 0%, rgba(5, 10, 31, 0.20) 100%);
  pointer-events: none;
}

/* Pantalla de inicio: el escenario se ve nítido, colorido y limpio */
.home-screen .stage-backdrop {
  background-position: center;
}

.home-screen .stage-backdrop::after {
  display: none; /* Sin superposiciones oscuras en la portada */
}

/* En la pantalla de juego: overlay sutil para legibilidad de tarjetas de preguntas */
.game-screen .stage-backdrop::after {
  background:
    radial-gradient(ellipse at 50% 20%, rgba(53, 224, 255, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, rgba(5, 10, 31, 0.15) 0%, rgba(5, 10, 31, 0.35) 100%);
}

/* Portada limpia: el escenario queda como protagonista, sin tarjeta central. */
.home-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 4vw, 3.5rem);
}

.welcome-stage {
  width: min(100%, 920px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.welcome-emblem {
  display: grid;
  place-items: center;
  width: clamp(4.25rem, 10vw, 6.5rem);
  aspect-ratio: 1;
  margin-bottom: 1.2rem;
  border: 2px solid rgba(255, 220, 110, 0.82);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(113, 53, 164, 0.9), rgba(8, 18, 52, 0.8) 70%);
  color: #ffe47c;
  font-size: clamp(2.3rem, 6vw, 4rem);
  line-height: 1;
  text-shadow: 0 0 22px rgba(255, 216, 80, 0.9);
  box-shadow: 0 0 24px rgba(53, 224, 255, 0.55), inset 0 0 24px rgba(168, 85, 247, 0.45);
}

.welcome-title {
  display: flex;
  flex-direction: column;
  margin: 0 0 clamp(2rem, 5vw, 3.25rem);
  font-size: clamp(2.25rem, 7vw, 5.5rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  /* Sombra de texto fuerte para legibilidad sobre el fondo colorido */
  text-shadow:
    0 2px 8px rgba(1, 5, 24, 0.95),
    0 4px 22px rgba(1, 5, 24, 0.85),
    0 0 40px rgba(1, 5, 24, 0.6);
}

.welcome-title .logo-gold,
.welcome-title .logo-pink {
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.9));
}

.welcome-title .logo-gold {
  background-image: var(--gold-gradient);
}

.welcome-title .logo-pink {
  background-image: var(--btn-gradient);
}

.welcome-actions {
  width: min(100%, 720px);
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(145px, 1fr));
  align-items: center;
  gap: 1rem;
}

.welcome-play {
  min-height: 74px;
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  letter-spacing: 0.13em;
}

.welcome-secondary {
  min-height: 58px;
  padding-inline: 1rem;
  border-color: rgba(72, 217, 255, 0.72);
  background: rgba(5, 15, 48, 0.85);
  box-shadow: 0 0 18px rgba(35, 174, 255, 0.24);
  font-size: 0.9rem;
  backdrop-filter: blur(6px);
}

.modal-intro {
  margin: -0.45rem 0 1.4rem;
  color: var(--text-muted);
}

.player-form,
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-action {
  width: 100%;
}

.settings-actions {
  align-items: stretch;
}

.settings-sound {
  justify-content: space-between;
  text-transform: none;
  letter-spacing: 0.02em;
}

.settings-sound-icon {
  font-size: 1.25rem;
}

.rules-details {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.rules-details summary {
  color: var(--gold-light);
  font-weight: 700;
  cursor: pointer;
}

.rules-details p {
  margin: 0.8rem 0 0;
  color: var(--text-muted);
}

/* Haces de luz animados (spotlight-sweep) */
.spotlight-sweep {
  position: fixed;
  top: -20%;
  left: -30%;
  width: 60%;
  height: 160%;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(53, 224, 255, 0.14) 48%, rgba(53, 224, 255, 0.24) 50%, rgba(53, 224, 255, 0.14) 52%, transparent 70%);
  filter: blur(4px);
  transform: rotate(14deg);
  animation: spotlightSweep 14s ease-in-out infinite alternate;
}

.spotlight-sweep.sweep-2 {
  top: -30%;
  left: 55%;
  width: 55%;
  animation-duration: 18s;
  animation-delay: -6s;
  background: linear-gradient(105deg, transparent 30%, rgba(168, 85, 247, 0.14) 48%, rgba(168, 85, 247, 0.22) 50%, rgba(168, 85, 247, 0.14) 52%, transparent 70%);
  transform: rotate(-12deg);
}

/* Layout Principal */
.app-container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* Tarjeta Glassmorphism */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.glass-card.gold-border {
  border: var(--border-gold);
}

/* Marco de neón azul eléctrico (paneles de concurso) */
.neon-frame {
  border: 1px solid var(--neon-frame);
  box-shadow: var(--neon-glow), inset 0 0 22px rgba(53, 224, 255, 0.08);
  animation: ambientGlow 4s ease-in-out infinite;
}

.neon-frame--gold {
  border: 1px solid rgba(243, 156, 18, 0.55);
  box-shadow: var(--gold-glow), inset 0 0 22px rgba(243, 156, 18, 0.1);
}

/* Botones Principales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 1.8rem;
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  outline: none;
  user-select: none;
}

.btn-primary {
  background: var(--btn-gradient);
  color: #ffffff;
  box-shadow: var(--btn-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(236, 72, 153, 0.65);
}

.btn-gold {
  background: var(--gold-gradient);
  color: #0b0f19;
  box-shadow: var(--gold-glow);
}

.btn-gold:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(243, 156, 18, 0.7);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* Botón destacado JUGAR con pulso */
.btn-play-pulse {
  animation: buttonPulse 2s ease-in-out infinite;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
  border-color: #ef4444;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Iconos circulares de navegación / comodines (neón) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(10, 18, 48, 0.85);
  border: 1.5px solid var(--neon-frame);
  color: var(--blue-neon);
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 12px rgba(53, 224, 255, 0.35);
  text-decoration: none;
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(53, 224, 255, 0.15);
  box-shadow: var(--neon-glow);
  transform: translateY(-2px);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: none;
}

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
  width: 100%;
}

.input-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-field {
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(10, 16, 35, 0.8);
  border: 1px solid rgba(53, 224, 255, 0.35);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 500;
  outline: none;
  transition: var(--transition);
}

.input-field:focus {
  border-color: var(--blue-neon);
  box-shadow: 0 0 18px rgba(53, 224, 255, 0.35);
}

.input-field::placeholder {
  color: #64748b;
}

/* Encabezado y Marca */
.header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 1.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 1.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  animation: logoFloat 4.5s ease-in-out infinite;
}

.brand-logo .logo-gold {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(243, 156, 18, 0.25);
}

.brand-logo .logo-pink {
  background: var(--btn-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Sistema de Alertas & Notificaciones Flotantes (Toasts) */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100% - 3rem);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 18, 48, 0.95);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 4px solid var(--btn-pink);
  animation: slideInRight 0.3s ease-out forwards;
}

.toast.toast-error {
  border-left-color: var(--danger-red);
  background: rgba(40, 10, 15, 0.95);
}

.toast.toast-success {
  border-left-color: var(--success-green);
  background: rgba(10, 35, 20, 0.95);
}

.toast.toast-warning {
  border-left-color: var(--gold-primary);
  background: rgba(35, 25, 10, 0.95);
}

/* Modales Base */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid rgba(53, 224, 255, 0.45);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(53, 224, 255, 0.18);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-dialog--wide {
  max-width: 620px;
}

/* ── Selector de Personajes / Presentador ────────────────── */
.settings-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(53, 224, 255, 0.15);
}

.settings-subtitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 0.2rem;
}

.settings-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0.4rem;
  background: rgba(14, 24, 56, 0.65);
  border: 1.5px solid rgba(53, 224, 255, 0.25);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-family: inherit;
}

.character-card:hover {
  background: rgba(53, 224, 255, 0.12);
  border-color: rgba(53, 224, 255, 0.6);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.character-card.active {
  background: rgba(53, 224, 255, 0.2);
  border-color: var(--blue-neon);
  box-shadow: 0 0 16px rgba(53, 224, 255, 0.45);
  transform: translateY(-2px);
}

.character-avatar-wrap {
  width: 68px;
  height: 94px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.character-avatar-wrap picture {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.character-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  transition: transform 0.25s ease;
}

.character-card:hover .character-avatar-img {
  transform: scale(1.06);
}

.character-card.active .character-avatar-img {
  transform: scale(1.08);
}

.character-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  width: 100%;
}

.character-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.character-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(53, 224, 255, 0.2);
  color: var(--blue-neon);
  border: 1px solid rgba(53, 224, 255, 0.35);
}

.badge-cyber {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.badge-spartan {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

.badge-gold {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

@media (max-width: 580px) {
  .characters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.modal-backdrop.active .modal-dialog {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gold-light);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: #fff;
  transform: scale(1.15);
}

/* Pie de página */
.footer-bar {
  margin-top: auto;
  padding: 1.5rem 0 0.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Reflejo animado sobre paneles de cristal (stage-shimmer) */
.shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  transform: skewX(-20deg);
  animation: stageShimmer 6s ease-in-out infinite;
  pointer-events: none;
}

/* Brillo suave en "pantallas" del escenario (screen-glow) */
.screen-glow {
  animation: screenGlow 5s ease-in-out infinite;
}

/* Responsive helpers */
@media (max-width: 640px) {
  .header-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-actions {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .welcome-play {
    grid-column: 1 / -1;
  }

  .welcome-secondary {
    min-height: 54px;
    padding-inline: 0.5rem;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
  }

  .home-shell {
    padding: 1rem;
  }

  .welcome-stage {
    padding: 0.5rem;
  }

  .modal-dialog {
    padding: 1.35rem;
  }
}
