/* =============================================
   QUIZLE! - MODO AVENTURA
   v3.0 - Optimizado y Consolidado
   ============================================= */

/* ===========================================
   1. CONTENEDORES PRINCIPALES
   =========================================== */

/* Pantalla principal de aventura */
.fs-adventure {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg1);
  z-index: 1000;
  display: none;
  overflow: hidden; /* Sin scroll */
}

/* Contenedor del mapa de aventura */
#adventureMapContainer {
  height: 100%;
  overflow-y: auto; /* Solo scroll vertical si es necesario */
  overflow-x: hidden; /* Sin scroll horizontal */
  padding-bottom: 20px;
}

.adventure-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  padding-top: 96px; /* Más espacio para header fijo (mobile first) */
}

/* En móviles, ajustar el padding */
@media (max-width: 480px) {
  .adventure-container {
    padding: 10px;
    padding-top: 84px; /* asegurar que nada quede debajo del header */
  }
}

@media (min-width: 768px) {
  .adventure-container {
    max-width: 1200px;
    padding: 20px;
    padding-top: 80px;
  }
}

/* Header fijo con logo para modo aventura */
.adventure-fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg1);
  backdrop-filter: blur(10px);
  z-index: 1010;
  padding: 12px 0; /* sin padding lateral, lo pone el inner */
  border-bottom: 1px solid var(--cardBorder);
}

/* Contenedor centrado como el resto de pantallas (.fs .wrap = 520px) */
.adventure-header-inner {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* En móviles, ajustar el header */
@media (max-width: 480px) {
  .adventure-fixed-header { padding: 10px 0; }
  .adventure-header-inner { max-width: 520px; padding: 0 12px; }
  
  .adventure-fixed-header .app-title {
    font-size: 20px;
    gap: 6px;
  }
  
  .adventure-fixed-header .app-logo {
    width: 30px;
    height: 30px;
  }
  
  .adventure-header-buttons {
    gap: 5px;
  }
  
  .adventure-header-buttons .iconbtn {
    width: 32px;
    height: 32px;
    padding: 6px;
  }
}

.adventure-fixed-header .app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.adventure-fixed-header .app-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.adventure-header-buttons {
  display: flex;
  gap: 10px;
  flex-shrink: 0; /* Evitar que se comprima */
}

/* Ajustar el título para que no desborde */
.adventure-fixed-header .app-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px; /* Limitar ancho del texto */
}

@media (max-width: 480px) {
  .adventure-fixed-header .app-title span {
    max-width: 80px;
  }
}

/* Área de juego de aventura */
#adventureGameArea {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg1);
  z-index: 1001;
  overflow-y: auto;
  padding: 20px;
}

.adventure-game-header {
  max-width: 520px;
  margin: 0 auto 20px;
  padding-top: calc(36px + env(safe-area-inset-top, 0px));
}

/* ===========================================
   2. HEADER Y HUD
   =========================================== */

/* Wrapper principal - Pantalla completa */
.region-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  z-index: 1005;
  overflow-y: auto;
  width: 100%;
  height: 100vh;
  padding-top: 60px; /* Reducido para PC - despejar header fijo */
}

/* Contenedor del mapa con position relative */
.map-container {
  flex: 1;
  position: relative;
  width: 100%;
  max-width: 100%; /* Ancho completo para PC */
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Controles debajo del mapa */
.map-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 8px 10px; /* Padding cómodo */
  background: var(--bg1);
  border-top: 1px solid var(--cardBorder);
  flex-shrink: 0;
  z-index: 1010; /* Por encima del banner de publicidad (z-index: 1000) */
  /* Sin margin-bottom para evitar espacio blanco sobre el banner */
  margin-bottom: 0;
  /* Agregar padding-bottom para dar espacio al banner sin crear barra blanca */
  padding-bottom: 100px; /* Espacio suficiente para el banner de 90px + padding */
  position: relative; /* Necesario para que z-index funcione */
}

.btn-control {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--cardBorder);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-control:hover {
  background: var(--cardBorder);
  transform: translateY(-2px);
}

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

#godModeBtn.active {
  background: #27ae60;
  color: white;
  border-color: #27ae60;
}

/* Área del mapa de región - Ocupar todo el espacio disponible */
.region-map {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: #0d1224;
  background-size: auto 100% !important; /* Fit vertical (altura 100%, ancho proporcional) */
  background-position: center center !important;
  background-repeat: no-repeat !important;
  border-radius: 12px;
}

/* Imagen de fondo embebida: ajustarla al contenedor */
.region-map .region-bg {
  position: absolute;
  top: 0;
  left: 50%;
  width: auto;
  height: 100%;
  transform: translateX(-50%);
  object-fit: contain; /* Fit vertical manteniendo proporción */
  pointer-events: none;
  z-index: 1;
}

/* Info del mapa (nombre y vidas) */
.region-wrapper .map-info {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr; /* izquierda título, derecha vidas */
  align-items: center;
  background: var(--bg1);
  border-bottom: 1px solid var(--cardBorder);
  flex-shrink: 0; /* No permitir que se comprima */
  max-width: 100%;
  margin: 0 auto;
  padding: 3px 0; /* Reducido a 3px de padding vertical */
}

.region-wrapper .map-info .map-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-align: left;
  padding-left: 15px !important; /* 15px desde el borde izquierdo */
  justify-self: start;
}

.region-wrapper .map-info .lives {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  padding-right: 15px !important; /* 15px desde el borde derecho */
  justify-self: end;
}

.heart {
  font-size: 18px;
  transition: all 0.3s;
}

.heart.active {
  color: #e74c3c;
}

.heart.lost {
  opacity: 0.3;
  filter: grayscale(1);
}



.region-map .path-svg { 
  display: none;
}
.progress-links {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.progress-links path {
  stroke: #4CAF50;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 6 6;
  animation: dashMove 1.2s linear infinite;
}

@keyframes dashMove {
  to { stroke-dashoffset: -24; }
}

.region-map .nodes-container { 
  position: absolute; 
  z-index: 10; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  pointer-events: auto; 
}

/* Marcador del jugador (avatar en el mapa) */
.player-marker {
  position: absolute;
  z-index: 12;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,0.4);
  overflow: hidden;
  transform: translate(-50%, -50%);
  transition: left 300ms ease, top 300ms ease;
  background: #111;
  cursor: pointer;
}

.player-marker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Header de aventura */
.adventure-header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--card);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.adventure-header h2 {
  margin: 0 0 15px;
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.adventure-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.stat-item {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* HUD del juego */
.adventure-hud {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 24px;
  padding: 12px;
  backdrop-filter: blur(6px);
}

.adventure-hud.urgent {
  color: #e74c3c;
  animation: flash 0.5s infinite;
}

@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.adventure-progress {
  max-width: 600px;
  margin: 0 auto;
}

/* ===========================================
   3. GRID DE REGIONES
   =========================================== */

.regions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.region-card {
  background: var(--card);
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.region-card.unlocked:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.region-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

/* God Mode */
.region-card.god-mode-access {
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(34,211,238,0.2));
  border: 2px dashed var(--accent);
  cursor: pointer !important;
  opacity: 0.9;
}

.region-card.god-mode-access:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(139,92,246,0.3);
}

.god-mode-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 20px;
  animation: pulse 2s infinite;
}

/* Iconos y textos de región */
.region-icon {
  font-size: 48px;
  margin-bottom: 15px;
  filter: grayscale(0);
}

.region-card.locked .region-icon {
  filter: grayscale(1);
}

.region-name {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 15px;
  color: var(--text);
}

.region-progress {
  margin-top: 15px;
}

.progress-bar {
  height: 8px;
  background: var(--cardBorder);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
  transition: width var(--transition-base);
}

.progress-text {
  font-size: 14px;
  color: var(--muted);
}

.locked-text {
  color: var(--muted);
  font-style: italic;
}

.region-complete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #27ae60;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
}



/* ===========================================
   5. NODOS DE AVENTURA
   =========================================== */
/* Fix: Forzar visibilidad de nodos y contenedor */
.region-map .nodes-container, .adventure-node {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 10;
}

.adventure-node {
  position: absolute;
  width: 55px;
  height: 55px;
  background: rgba(28, 40, 51, 0.95);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
  border: 3px solid rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  box-shadow: 0 6px 15px rgba(0,0,0,0.5);
  backdrop-filter: blur(5px);
  z-index: 4; /* por encima del path */
}

.adventure-node.completed {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  border-color: #229954;
  box-shadow: 0 5px 20px rgba(39, 174, 96, 0.4);
}

.adventure-node.current {
  animation: pulse 2s infinite;
  border-color: #f39c12;
  border-width: 4px;
  box-shadow: 0 0 40px rgba(243, 156, 18, 0.8);
  background: rgba(52, 152, 219, 0.95);
}

.adventure-node.locked {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(127, 140, 141, 0.5);
}

.adventure-node.god-mode {
  border-color: #f39c12;
  border-width: 4px;
  box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
  animation: godGlow 2s infinite;
  cursor: pointer !important;
  opacity: 1 !important;
}

@keyframes godGlow {
  0%, 100% { 
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
    border-color: #f39c12;
  }
  50% { 
    box-shadow: 0 0 30px rgba(243, 156, 18, 0.9);
    border-color: #e67e22;
  }
}

.god-indicator {
  position: absolute;
  top: -25px;
  font-size: 20px;
  animation: float 2s ease-in-out infinite;
}

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

.adventure-node.boss {
  width: 75px;
  height: 75px;
  background: linear-gradient(135deg, #8b0000 0%, #dc143c 100%);
  border-color: #ff6b6b;
  border-width: 4px;
  box-shadow: 0 8px 25px rgba(220, 20, 60, 0.5);
}

.adventure-node.timed {
  background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

.adventure-node:not(.locked):hover {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.node-icon {
  font-size: 20px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  line-height: 1;
}

/* Icono de reloj pequeño para nodos con tiempo */
.node-timer-icon {
  position: absolute;
  top: -10px;
  right: -5px;
  font-size: 10px;
  color: #fff;
  background: #3498db;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Número del nivel */
.node-number {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.node-stars {
  position: absolute;
  bottom: -20px;
  font-size: 14px;
  white-space: nowrap;
}

.current-indicator {
  position: absolute;
  top: -25px;
  font-size: 20px;
  color: #f39c12;
  animation: bounce 1s infinite;
}

@keyframes pulse {
  0% { 
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 30px rgba(243, 156, 18, 0.6);
  }
  50% { 
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 0 40px rgba(243, 156, 18, 0.8);
  }
  100% { 
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 30px rgba(243, 156, 18, 0.6);
  }
}

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

/* ===========================================
   6. ÁREA DE JUEGO
   =========================================== */

.question-container {
  max-width: 520px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  padding: 18px;
  border-radius: 24px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.question-image {
  margin-bottom: 20px;
  text-align: center;
}

.question-image img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
}

.question-text {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text);
  margin-top: 8px;
}

.adventure-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.option-btn {
  padding: 14px;
  background: transparent;
  border: 2px solid var(--cardBorder);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text);
  user-select: none;
}

.option-btn:hover:not(:disabled) {
  transform: scale(1.03);
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  pointer-events: none;
}

.option-btn.correct {
  background: var(--good);
  color: white;
  border-color: var(--good);
}

.option-btn.wrong {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
  animation: shake-horizontal 0.4s cubic-bezier(.455,.03,.515,.955) both;
}

/* Botón abandonar nivel */
#adventureGameArea button.btn.secondary.danger {
  max-width: 200px;
  margin: 20px auto;
  display: block;
  background: #e74c3c;
  color: white;
  box-shadow: 0 4px 0 0 #c0392b;
}

#adventureGameArea button.btn.secondary.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 0 #c0392b;
}

/* ===========================================
   7. BOTONES ESPECIALES
   =========================================== */

/* Botones de control God Mode */
.btn.secondary.danger.small {
  background: #e74c3c;
  color: white;
  padding: 8px 12px;
  font-size: 16px;
  min-width: auto;
  border-radius: 8px;
}

.btn.secondary.danger.small:hover {
  background: #c0392b;
}

.btn.secondary.warning.small {
  background: #f39c12;
  color: white;
  padding: 8px 12px;
  font-size: 16px;
  min-width: auto;
  border-radius: 8px;
  transition: all var(--transition-base);
}

.btn.secondary.warning.small:hover {
  background: #e67e22;
}

.btn.secondary.warning.small.active {
  background: #27ae60;
  animation: godPulse 1s infinite;
}

@keyframes godPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Botón de God Mode activo */
#godModeBtn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===========================================
   8. RESULTADOS DE AVENTURA
   =========================================== */

.adventure-results {
  max-width: 600px;
  margin: 50px auto;
  background: var(--card);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.adventure-results h2 {
  margin: 0 0 15px;
  font-size: 36px;
  font-weight: 800;
}

.result-message {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 30px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 30px;
}

.stat-box {
  text-align: center;
}

.stat-label {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 5px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.new-region-unlocked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
}

.result-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* ===========================================
   9. INFO DE REGIÓN
   =========================================== */

.region-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-card, .legend {
  background: var(--card);
  padding: 20px;
  border-radius: 15px;
}

.info-card h3, .legend h4 {
  margin: 0 0 15px;
  font-weight: 800;
}

.region-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.region-stats div {
  padding: 8px;
  background: var(--cardBorder);
  border-radius: 8px;
  font-size: 14px;
}

.legend-item {
  padding: 8px;
  margin-bottom: 8px;
  background: var(--cardBorder);
  border-radius: 8px;
  font-size: 14px;
}

/* ===========================================
   10. RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
  .regions-grid {
    grid-template-columns: 1fr;
  }
  
  .region-info {
    grid-template-columns: 1fr;
  }
  
  .adventure-options {
    grid-template-columns: 1fr;
  }
  
  .adventure-node {
    width: 58px;
    height: 58px;
  }
  
  .adventure-node.boss {
    width: 78px;
    height: 78px;
  }
  
  .node-icon {
    font-size: 20px;
  }
  
  .node-number {
    font-size: 18px;
  }
  
  /* Ajustes para el mapa en móviles */
  .map-info {
    padding: 10px 15px;
  }
  
  .map-title {
    font-size: 18px;
  }
  
  .heart {
    font-size: 16px;
  }
  
  .map-controls {
    padding: 8px 5px;
    gap: 5px;
  }
  
  .btn-control {
    padding: 6px 10px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .region-wrapper {
    padding-top: 84px; /* header móvil */
  }
}

/* Ajuste para pantallas muy pequeñas */
@media (max-height: 600px) {
  .map-info {
    padding: 8px 15px;
  }
  
  .map-controls {
    padding: 8px 10px;
  }
  
  .btn-control {
    padding: 6px 10px;
    font-size: 11px;
  }
}





.adventure-actions {
  text-align: center;
  margin-top: 30px;
}

/* Presentación de jefes */
.boss-dialog-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7,10,18,0.9);
  z-index: 11000;
}

.boss-dialog-box {
  max-width: 800px;
  width: 90%;
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--cardBorder);
}

.boss-dialog-box .boss-name {
  font-weight: 800;
  margin-top: 8px;
  margin-bottom: 10px;
}
