/* Estilos para NO MIRES ATRÁS - Survival Horror PWA */
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Cinzel:wght@600;900&family=Inter:wght@300;400;600&display=swap');

:root {
  --bg-dark: #07080a;
  --bg-card: rgba(14, 17, 23, 0.88);
  --accent-red: #c9182b;
  --accent-red-glow: rgba(201, 24, 43, 0.6);
  --accent-amber: #e5a93b;
  --accent-cyan: #3bd6e5;
  --text-main: #e6e8eb;
  --text-muted: #8d929b;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --font-title: 'Cinzel', serif;
  --font-mono: 'Share Tech Mono', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
}

/* Canvas del videojuego 3D */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Efectos visuales de terror: Scanlines, Viñeta y Glitch */
.horror-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.92);
  transition: box-shadow 0.3s ease;
}

.horror-overlay.near-monster {
  box-shadow: inset 0 0 140px rgba(180, 10, 20, 0.85);
  animation: pulse-danger 0.8s infinite alternate ease-in-out;
}

@keyframes pulse-danger {
  0% { box-shadow: inset 0 0 100px rgba(180, 10, 20, 0.6); }
  100% { box-shadow: inset 0 0 180px rgba(220, 15, 25, 0.95); }
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  opacity: 0.65;
}

.vhs-noise {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 7;
  opacity: 0.04;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 3px 3px;
}

/* HUD Superior en Juego */
#game-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 24px;
  transition: opacity 0.3s ease;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.status-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  padding: 12px 18px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-red);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  min-width: 240px;
}

.character-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.char-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--accent-amber);
  background-size: cover;
  background-position: center;
}

.char-title-name {
  font-family: var(--font-title);
  font-size: 14px;
  letter-spacing: 1px;
  color: #fff;
}

.char-class {
  font-size: 11px;
  color: var(--accent-amber);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 65px;
  text-transform: uppercase;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.fill-health { background: linear-gradient(90deg, #c9182b, #ff4d61); }
.fill-stamina { background: linear-gradient(90deg, #d49015, #f5c042); }
.fill-sanity { background: linear-gradient(90deg, #1f7a8c, #3bd6e5); }
.fill-battery { background: linear-gradient(90deg, #2a9d8f, #52b788); }

.hud-objective {
  background: var(--bg-card);
  padding: 12px 18px;
  border-radius: 6px;
  border-right: 3px solid var(--accent-amber);
  backdrop-filter: blur(8px);
  text-align: right;
  max-width: 380px;
}

.objective-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-amber);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.objective-text {
  font-size: 13px;
  margin-top: 4px;
  color: #f0f0f0;
  line-height: 1.4;
}

/* Notificación y Tooltips de interacción central */
.interaction-prompt {
  position: absolute;
  bottom: 24%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 12, 16, 0.9);
  border: 1px solid var(--accent-amber);
  padding: 10px 22px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 25px rgba(229, 169, 59, 0.35);
  animation: float-prompt 1.5s infinite alternate ease-in-out;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.interaction-prompt.active {
  opacity: 1;
}

@keyframes float-prompt {
  0% { transform: translate(-50%, 0); }
  100% { transform: translate(-50%, -6px); }
}

.key-badge {
  background: var(--accent-amber);
  color: #000;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 14px;
  padding: 3px 9px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.prompt-text {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
}

/* Indicador de Terror / Latido */
.heartbeat-monitor {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 12, 16, 0.7);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.heart-icon {
  font-size: 14px;
  color: var(--accent-red);
}

.heartbeat-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #d1d5db;
}

/* Notificación flotante de historia o cinta */
#story-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: rgba(11, 13, 17, 0.96);
  border: 1px solid var(--accent-red);
  padding: 28px 36px;
  border-radius: 8px;
  max-width: 540px;
  width: 90%;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 20px rgba(201, 24, 43, 0.35);
  z-index: 50;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

#story-modal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.tape-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 12px;
}

.tape-icon {
  font-size: 26px;
  color: var(--accent-amber);
}

.tape-title {
  font-family: var(--font-title);
  font-size: 18px;
  color: #fff;
  letter-spacing: 1px;
}

.tape-transcript {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #c5cad3;
  margin-bottom: 20px;
  font-style: italic;
  background: rgba(0,0,0,0.4);
  padding: 14px;
  border-radius: 4px;
  border-left: 2px solid var(--accent-red);
}

.tape-btn {
  background: var(--accent-red);
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  float: right;
  transition: background 0.2s;
}

.tape-btn:hover {
  background: #e02438;
}

/* HUD Inferior - Habilidades y Controles */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.ability-dock {
  display: flex;
  gap: 12px;
}

.ability-card {
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.ability-key {
  background: rgba(255, 255, 255, 0.15);
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
}

.ability-info {
  display: flex;
  flex-direction: column;
}

.ability-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.ability-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.cooldown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: rgba(201, 24, 43, 0.4);
  transition: width 0.1s linear;
}

.controls-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 6px;
  display: flex;
  gap: 14px;
}

.hint-item span {
  color: var(--accent-amber);
  font-weight: bold;
}

/* Controles táctiles virtuales para Mobile / PWA */
#mobile-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  width: 100%;
  height: 180px;
  display: none;
  pointer-events: none;
  z-index: 25;
}

.touch-stick-container {
  position: absolute;
  bottom: 20px;
  left: 24px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-actions-container {
  position: absolute;
  bottom: 20px;
  right: 24px;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  background: rgba(20, 24, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  touch-action: none;
}

.touch-btn:active {
  background: var(--accent-red);
  transform: scale(0.92);
}

.touch-btn-special {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* Pantalla de Menú Principal / Selector y Personalizador 3D */
#menu-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  display: flex;
  background: radial-gradient(circle at 70% 50%, rgba(18, 22, 30, 0.4) 0%, rgba(7, 8, 10, 0.95) 85%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#menu-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.menu-sidebar {
  width: 480px;
  max-width: 90vw;
  height: 100%;
  background: rgba(9, 11, 15, 0.94);
  border-right: 1px solid var(--border-subtle);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  backdrop-filter: blur(12px);
  z-index: 32;
  box-shadow: 10px 0 40px rgba(0,0,0,0.8);
}

.menu-logo-box {
  margin-bottom: 24px;
}

.menu-title {
  font-family: var(--font-title);
  font-size: 28px;
  color: #fff;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(201, 24, 43, 0.8);
}

.menu-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-red);
  letter-spacing: 2px;
  margin-top: 4px;
}

.menu-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active, .tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  border-bottom: 2px solid var(--accent-red);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
}

/* Tarjetas de personajes predefinidos */
.char-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.char-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.char-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.char-card.selected {
  border-color: var(--accent-red);
  background: rgba(201, 24, 43, 0.12);
  box-shadow: 0 0 16px rgba(201, 24, 43, 0.3);
}

.char-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-card-name {
  font-family: var(--font-title);
  font-size: 14px;
  color: #fff;
}

.char-card-role {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent-amber);
}

.char-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.3;
}

.char-card-skill {
  font-size: 10px;
  color: var(--accent-cyan);
  margin-top: 6px;
  font-weight: 500;
}

/* Opciones de personalización */
.custom-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.custom-input-text {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.custom-select {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}

.custom-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-slider {
  flex: 1;
  accent-color: var(--accent-red);
}

.color-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.color-dot:hover {
  transform: scale(1.15);
}

.color-dot.active {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
}

/* Botón iniciar partida */
.menu-actions {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary-play {
  background: var(--accent-red);
  color: #fff;
  border: none;
  padding: 14px 20px;
  font-family: var(--font-title);
  font-size: 15px;
  letter-spacing: 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(201, 24, 43, 0.4);
}

.btn-primary-play:hover {
  background: #e02438;
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(201, 24, 43, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 10px 16px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Indicador de giro 360 en visor */
.viewer-360-hint {
  position: absolute;
  bottom: 24px;
  right: 28px;
  background: rgba(10, 12, 16, 0.85);
  border: 1px solid var(--border-subtle);
  padding: 10px 18px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

/* Menú de Pausa / Ajustes */
#pause-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 12, 16, 0.96);
  border: 1px solid var(--border-subtle);
  padding: 30px 40px;
  border-radius: 8px;
  width: 90%;
  max-width: 440px;
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

#pause-modal.active {
  display: flex;
}

.pause-title {
  font-family: var(--font-title);
  font-size: 22px;
  color: #fff;
  letter-spacing: 2px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

/* Pantalla de Fin de Juego / Victoria o Muerte */
#gameover-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 70;
  background: rgba(5, 5, 8, 0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 24px;
}

#gameover-screen.active {
  display: flex;
}

.gameover-title {
  font-family: var(--font-title);
  font-size: 38px;
  color: var(--accent-red);
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(201, 24, 43, 0.8);
}

.gameover-msg {
  font-family: var(--font-mono);
  font-size: 14px;
  color: #c5cad3;
  max-width: 500px;
  line-height: 1.6;
}

/* Media Queries para Mobile & PWA */
@media (max-width: 768px) {
  #menu-screen {
    flex-direction: column;
  }
  .menu-sidebar {
    width: 100%;
    max-width: 100%;
    height: 60%;
    order: 2;
  }
  .viewer-360-hint {
    top: 16px;
    bottom: auto;
    right: 16px;
    font-size: 10px;
  }
  #mobile-controls {
    display: block;
  }
  .controls-hint {
    display: none;
  }
  .hud-top {
    flex-direction: column;
    gap: 8px;
  }
  .status-bars {
    min-width: 100%;
  }
  .hud-objective {
    max-width: 100%;
    text-align: left;
  }
}
