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

body {
  font-family: var(--fuente-texto);
  background: var(--tinta);
  color: var(--panel);
  overflow: hidden;
  user-select: none;
}

#canvas-3d {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ── HUD ── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud-nav {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  pointer-events: all;
}

.btn-nav {
  background: rgba(21,50,68,.85);
  border: 2px solid var(--amarillo);
  color: var(--amarillo);
  font-family: var(--fuente-display);
  font-size: 1.4rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
  line-height: 1;
}
.btn-nav:hover:not(:disabled) {
  background: var(--amarillo);
  color: var(--azul);
}
.btn-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

#hud-estacion {
  font-family: var(--fuente-texto);
  font-size: .85rem;
  font-weight: 600;
  color: var(--panel);
  background: rgba(21,50,68,.8);
  padding: .35rem .9rem;
  border-radius: var(--radio);
  min-width: 9rem;
  text-align: center;
  letter-spacing: .04em;
}

#hud-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,.12);
}
#hud-progress-bar {
  height: 100%;
  background: var(--amarillo);
  transition: width .5s ease;
}

#btn-index {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  pointer-events: all;
  background: rgba(21,50,68,.85);
  border: 1.5px solid rgba(255,255,255,.25);
  color: var(--panel);
  font-family: var(--fuente-texto);
  font-size: .8rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: var(--radio);
  cursor: pointer;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: border-color .2s, color .2s;
}
#btn-index:hover {
  border-color: var(--aqua);
  color: var(--aqua);
}

#hud-hint {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: .75rem;
  color: rgba(247,245,240,.5);
  pointer-events: none;
  white-space: nowrap;
  animation: fadeHint 4s ease 2s forwards;
  opacity: 1;
}
@keyframes fadeHint {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#btn-modo-libre {
  position: absolute;
  bottom: 5.5rem;
  left: 1.25rem;
  pointer-events: all;
  background: rgba(21,50,68,.85);
  border: 1.5px solid rgba(255,255,255,.25);
  color: var(--panel);
  font-family: var(--fuente-texto);
  font-size: .8rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: var(--radio);
  cursor: pointer;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: border-color .2s, color .2s;
}
#btn-modo-libre:hover { border-color: var(--aqua); color: var(--aqua); }
#btn-modo-libre.activo { border-color: var(--amarillo); color: var(--amarillo); }

/* crosshair */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 18px;
  height: 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
#crosshair.visible { opacity: 1; }
#crosshair::before,
#crosshair::after {
  content: '';
  position: absolute;
  background: var(--aqua);
  border-radius: 2px;
}
#crosshair::before { width: 2px; height: 100%; left: 50%; transform: translateX(-50%); }
#crosshair::after  { height: 2px; width: 100%; top: 50%; transform: translateY(-50%); }

/* ── Panel de índice ── */
#panel-index {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16,34,46,.96);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
#panel-index.visible { display: flex; }

#panel-index h2 {
  font-family: var(--fuente-display);
  font-size: 1.3rem;
  color: var(--amarillo);
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
#index-lista {
  list-style: none;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.index-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(21,50,68,.7);
  border: 1.5px solid rgba(141,226,214,.15);
  border-radius: var(--radio);
  padding: .75rem 1rem;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.index-item:hover, .index-item:focus {
  border-color: var(--aqua);
  background: rgba(21,50,68,.95);
  outline: none;
}
.index-item.activo {
  border-color: var(--amarillo);
}
.index-num {
  font-family: var(--fuente-display);
  font-size: 1.4rem;
  color: var(--amarillo);
  min-width: 2rem;
  text-align: center;
}
.index-info { flex: 1; }
.index-titulo {
  font-weight: 600;
  font-size: .95rem;
  color: var(--panel);
}
.index-estacion {
  font-size: .75rem;
  color: rgba(141,226,214,.7);
  margin-top: .15rem;
  font-variant: small-caps;
  letter-spacing: .06em;
}
#btn-cerrar-index {
  margin-top: 1.5rem;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.3);
  color: var(--panel);
  font-size: .85rem;
  padding: .5rem 1.5rem;
  border-radius: var(--radio);
  cursor: pointer;
  transition: border-color .2s;
}
#btn-cerrar-index:hover { border-color: var(--aqua); }

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16,34,46,.92);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#modal-overlay.visible {
  display: flex;
}
#modal {
  background: #176081;
  color: #ffffff;
  border-radius: var(--radio-l);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sombra);
  position: relative;
  outline: none;
}
#modal-header {
  background: var(--azul);
  border-radius: var(--radio-l) var(--radio-l) 0 0;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
#modal-num {
  font-family: var(--fuente-display);
  font-size: 2.5rem;
  color: var(--amarillo);
  line-height: 1;
  min-width: 2.5rem;
}
#modal-header-texto { flex: 1; }
#modal-estacion {
  font-family: var(--fuente-display);
  font-size: 1rem;
  font-weight: 900;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .25rem;
}
#modal-titulo {
  font-family: var(--fuente-display);
  font-size: 1.35rem;
  color: #ffffff;
  line-height: 1.2;
}
#btn-cerrar-modal {
  background: transparent;
  border: none;
  color: rgba(247,245,240,.5);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 .25rem;
  transition: color .15s;
  align-self: flex-start;
}
#btn-cerrar-modal:hover { color: var(--panel); }

#modal-body {
  padding: 1.5rem;
}
#modal-imagen-wrap {
  margin-bottom: 1.25rem;
  border-radius: var(--radio);
  overflow: hidden;
  border: 3px solid #ffcc00;
  background: #176081;
  line-height: 0;
}
#modal-imagen {
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  display: block;
}

/* ── Modal carrusel de boletas ── */
#modal-carrusel {
  margin-bottom: 1.25rem;
}
#modal-car-wrap {
  border-radius: var(--radio);
  overflow: hidden;
  border: 3px solid #ffcc00;
  background: #176081;
  line-height: 0;
  margin-bottom: .75rem;
}
#modal-car-img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  display: block;
}
#modal-car-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
#modal-car-counter {
  font-family: var(--fuente-texto);
  font-size: .9rem;
  font-weight: 600;
  color: #ffffff;
  min-width: 4.5rem;
  text-align: center;
}
.btn-car {
  background: var(--azul);
  border: none;
  color: var(--amarillo);
  font-size: 1.15rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  line-height: 1;
}
.btn-car:hover { background: var(--tinta); }
#modal-subtitulo {
  font-style: italic;
  color: rgba(255,255,255,0.9);
  font-size: .95rem;
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 4px solid #ffcc00;
  line-height: 1.5;
}
.modal-cita {
  font-style: italic;
  font-size: .95rem;
  color: rgba(255,255,255,0.9);
  padding: .75rem 1rem;
  border-left: 4px solid #ffcc00;
  background: rgba(255,255,255,.06);
  border-radius: 0 var(--radio) var(--radio) 0;
  margin-bottom: 1rem;
  line-height: 1.55;
}
.modal-cita-atribucion {
  display: block;
  font-style: normal;
  font-size: .78rem;
  font-weight: 600;
  color: #ffcc00;
  margin-top: .5rem;
  font-variant: small-caps;
  letter-spacing: .05em;
}
#modal-parrafos p {
  font-size: .95rem;
  line-height: 1.65;
  color: rgba(255,255,255,0.9);
  margin-bottom: .85rem;
}
#modal-parrafos p:last-child { margin-bottom: 0; }
#modal-parrafos strong {
  font-weight: 700;
  color: #ffcc00;
}
#modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
#modal-fuente {
  font-size: .75rem;
  color: rgba(255,255,255,.55);
  font-variant: small-caps;
  letter-spacing: .04em;
}
#modal-fuente a {
  color: #ffcc00;
  text-underline-offset: 2px;
}

/* ── Reducción de movimiento ── */
@media (prefers-reduced-motion: reduce) {
  .btn-nav, #btn-index, #btn-modo-libre, .index-item,
  #btn-cerrar-index, #btn-cerrar-modal, .btn-car {
    transition: none;
  }
  #hud-progress-bar { transition: none; }
  #hud-hint { animation: none; opacity: 0; }
}

/* ── Canvas: prevenir gestos del navegador en touch ── */
#canvas-3d { touch-action: none; }

/* ── Modal trivia (iframe externo) ── */
#trivia-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16,34,46,.88);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
}
#trivia-overlay.visible { display: flex; }

#trivia-modal {
  background: #153244;
  border-radius: 16px;
  padding: 10px;
  width: 90vw;
  height: 88vh;
  position: relative;
  display: flex;
  box-shadow: 0 8px 48px rgba(0,0,0,.65);
}

#btn-cerrar-trivia {
  position: absolute;
  top: -14px;
  right: -14px;
  background: #153244;
  border: 2px solid #8de2d6;
  color: #8de2d6;
  font-size: 1.3rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 1;
  transition: background .15s, color .15s;
  padding: 0;
}
#btn-cerrar-trivia:hover { background: #8de2d6; color: #153244; }

#trivia-iframe {
  flex: 1;
  border: 0;
  border-radius: 12px;
  display: block;
}

/* ── Tablet (≤ 1024 px): nav y btn-modo-libre más chicos y más abajo ── */
@media (max-width: 1024px) {
  #btn-modo-libre {
    font-size: .72rem;
    padding: .35rem .8rem;
    bottom: 4rem;
  }
  #hud-nav {
    bottom: 0.75rem;
    gap: .6rem;
  }
  .btn-nav {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.1rem;
  }
  #hud-estacion {
    font-size: .75rem;
    min-width: 7.5rem;
    padding: .28rem .7rem;
  }
}

/* ── Mobile (≤ 768 px): btn-modo-libre todavía más compacto ── */
@media (max-width: 768px) {
  #btn-modo-libre {
    font-size: .68rem;
    padding: .3rem .65rem;
    bottom: 3.5rem;
  }
  #hud-nav {
    bottom: 0.5rem;
  }
  .btn-nav {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1rem;
  }
  #hud-estacion {
    font-size: .7rem;
    min-width: 6.5rem;
  }
}

/* ── Touch overlay (inyectado por JS, solo mobile/tablet) ── */
#touch-overlay {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
#touch-overlay.visible { display: block; }

/* D-pad — bottom left */
#dpad {
  position: absolute;
  bottom: 6rem;
  left: 1rem;
  display: grid;
  grid-template-areas:
    ". fwd ."
    "lft  .  rgt"
    ". bck .";
  grid-template-columns: repeat(3, 3rem);
  grid-template-rows:    repeat(3, 3rem);
  gap: .25rem;
  pointer-events: none;
  touch-action: none;
}
.dpad-btn {
  pointer-events: all;
  touch-action: none;
  background: rgba(21,50,68,.6);
  border: 1.5px solid rgba(255,255,255,.3);
  color: rgba(247,245,240,.92);
  border-radius: .5rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s, border-color .1s;
}
.dpad-btn:active {
  background: rgba(21,50,68,.92);
  border-color: var(--aqua);
}
#dpad-fwd   { grid-area: fwd; }
#dpad-left  { grid-area: lft; }
#dpad-right { grid-area: rgt; }
#dpad-back  { grid-area: bck; }

/* Botones de giro — bottom right */
#turn-btns {
  position: absolute;
  bottom: 6rem;
  right: 1rem;
  display: flex;
  gap: .5rem;
  pointer-events: none;
  touch-action: none;
}
.turn-btn {
  pointer-events: all;
  touch-action: none;
  background: rgba(21,50,68,.6);
  border: 1.5px solid rgba(255,255,255,.3);
  color: rgba(247,245,240,.92);
  border-radius: .5rem;
  width: 3.5rem;
  height: 3rem;
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s, border-color .1s;
}
.turn-btn:active {
  background: rgba(21,50,68,.92);
  border-color: var(--aqua);
}

/* ── Botón mute ── */
#btn-mute {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  pointer-events: all;
  background: rgba(21,50,68,.85);
  border: 1.5px solid rgba(255,255,255,.25);
  color: var(--panel);
  font-size: 1.1rem;
  padding: .45rem .75rem;
  border-radius: var(--radio);
  cursor: pointer;
  line-height: 1;
  transition: border-color .2s;
}
#btn-mute:hover        { border-color: var(--aqua); }
#btn-mute.activo       { border-color: var(--amarillo); opacity: .7; }

/* ── Splash ── */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--tinta);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .45s ease;
}
#splash.saliendo {
  opacity: 0;
  pointer-events: none;
}
#splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 440px;
}
#splash-logo {
  height: 80px;
  width: auto;
}
#splash-titulo {
  font-family: var(--fuente-display);
  font-size: 1.75rem;
  color: #ffffff;
  line-height: 1.2;
}
#splash-bajada {
  font-size: .9rem;
  color: rgba(247,245,240,.6);
  line-height: 1.55;
  margin-top: -.5rem;
}
#btn-ingresar {
  background: var(--amarillo);
  color: var(--tinta);
  border: none;
  font-family: var(--fuente-display);
  font-size: 1rem;
  font-weight: 900;
  padding: .85rem 2.5rem;
  border-radius: var(--radio);
  cursor: pointer;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: .5rem;
  transition: opacity .2s;
}
#btn-ingresar:hover { opacity: .85; }
