:root {
  color-scheme: dark;
  --oro: #e8c887;
  --texto: #f6e8d0;
  --suave: #cdbbd5;
  --borde: #9c715172;
  font: 16px system-ui, sans-serif;
  color: var(--texto);
  background: #100819;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: radial-gradient(ellipse at 50% 35%, #321047, #100819 72%); }
button, .volver, .accion {
  font: inherit;
  color: var(--texto);
  background: #21112c;
  border: 1px solid var(--borde);
  border-radius: .55rem;
  padding: .55rem .8rem;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
a { color: inherit; }
button:hover, a:hover { border-color: var(--oro); }
:focus-visible { outline: 3px solid #fff0a5; outline-offset: 3px; }
button:disabled { opacity: .48; cursor: default; }
.cabecera {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .6rem;
  padding: max(.6rem, env(safe-area-inset-top)) max(1.3rem, env(safe-area-inset-right)) .6rem max(1.3rem, env(safe-area-inset-left));
  border-bottom: 1px solid #bf8d513a;
  background: #100819e8;
}
.volver { justify-self: start; text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
#efectos { justify-self: end; }
#efectos[aria-pressed="true"] { border-color: var(--oro); }
.marca { font: bold 1.15rem Georgia, serif; color: var(--oro); letter-spacing: .24em; white-space: nowrap; }
.marca span { font-size: .68rem; }
main { width: min(94%, 1280px); margin: 0 auto; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.titulo { text-align: center; padding: clamp(.6rem, 2.4vh, 1.7rem) 0 .85rem; }
.ruta { margin: 0; color: var(--oro); font-size: .73rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { font-family: Georgia, serif; font-weight: 400; color: #ffe8ac; }
h1 { margin: .35rem 0 0; font-size: clamp(1.5rem, 4.2vw, 3.2rem); text-wrap: balance; }
.marco { border: 1px solid #ba8f5f; border-radius: .75rem; background: #100819; box-shadow: 0 0 48px #9328cb42; overflow: hidden; }
#mapa {
  isolation: isolate;
  position: relative;
  height: clamp(210px, calc(100dvh - 220px), 790px);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background: radial-gradient(ellipse, #3e155a, #120a1a 72%);
}
#mapa.moviendo { cursor: grabbing; }
#mapa:focus-visible { outline-offset: -4px; }
#lienzo { position: absolute; transform-origin: 0 0; visibility: hidden; }
#lienzo.listo { visibility: visible; }
#lienzo img { display: block; width: 100%; height: 100%; pointer-events: none; }
#lienzo::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 85px #13071974; pointer-events: none; }
.marcador {
  position: absolute;
  z-index: 1;
  width: var(--blanco, 44px);
  height: var(--blanco, 44px);
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%) scale(var(--escala-marcador, 1));
  color: #ffe2a1;
}
.marcador::before {
  content: '';
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: currentColor;
  border: 1px solid #6b3e20;
  box-shadow: 0 0 5px #ffe2a1ad, 0 0 0 1px #351623;
}
.marcador.principal::before { width: 13px; height: 13px; }
.marcador:hover::before, .marcador:focus-visible::before { background: #fff3cc; }
#particulas { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#particulas i { position: absolute; left: var(--x); top: var(--y); width: 3px; height: 3px; border-radius: 50%; color: #dc7cff; background: currentColor; box-shadow: 0 0 10px 3px currentColor; opacity: .5; animation: deriva var(--duracion) ease-in-out infinite alternate; animation-delay: var(--demora); }
#particulas i:nth-child(3n) { color: #ffce75; }
#mapa.entrada::after { content: ''; position: absolute; z-index: 3; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, #f8caff66, #21052d 85%); animation: abrir .7s ease-out both; }
@keyframes abrir { from { opacity: 1; } to { opacity: 0; } }
@keyframes deriva { to { opacity: .16; transform: translate(17px, -30px); } }
.mandos { display: flex; padding: .52rem; gap: .6rem; align-items: center; justify-content: space-between; }
.mandos p { margin: 0; color: var(--suave); font-size: .79rem; text-align: center; }
.zoom { display: flex; gap: .28rem; }
.zoom button { min-width: 44px; padding: .3rem; font-size: 1.2rem; }
#estado { color: var(--suave); font-size: .85rem; }
#estado:empty { display: none; }
dialog { width: min(91vw, 510px); max-height: 87dvh; overflow-y: auto; padding: 1.5rem; border: 1px solid #d5aa73; border-radius: .85rem; color: var(--texto); background: radial-gradient(ellipse at 15% 0, #3a1c51, #170d22 74%); box-shadow: 0 0 65px #14041b; }
dialog::backdrop { background: #090410af; }
dialog h2 { margin: .5rem 2.5rem .7rem 0; font-size: clamp(1.45rem, 4vw, 2rem); }
dialog p:not(.ruta) { color: #e7d8ed; line-height: 1.55; }
.cerrar { float: right; min-width: 44px; font-size: 1.1rem; }
.accion { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; border-color: var(--oro); color: #ffe7b0; }
#lugares ul { list-style: none; padding: 0; display: grid; gap: .4rem; }
#lugares li > button { width: 100%; text-align: left; }
.efectos-reducidos :is(#particulas, #mapa::before, #mapa.entrada::after) { display: none; }
@media (prefers-reduced-motion: reduce) {
  #particulas, #mapa.entrada::after { animation: none; }
  #mapa.entrada::after { display: none; }
}
@media (pointer: coarse), (max-width: 680px), (max-height: 520px) {
  body {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }
  .cabecera {
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
    font-size: .76rem;
    gap: .3rem;
  }
  .cabecera button, .volver { padding-inline: .5rem; border-color: transparent; background: transparent; }
  .marca { font-size: .8rem; letter-spacing: .12em; }
  main {
    width: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    position: relative;
    padding: 0 max(0px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0px, env(safe-area-inset-left));
  }
  .titulo { padding: .24rem .3rem .4rem; }
  .titulo .ruta { display: none; }
  h1 { margin: 0; font-size: clamp(1.05rem, 3.8vw, 1.5rem); }
  .marco {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  #mapa { height: auto; min-height: 0; }
  #mapa::before {
    content: '';
    position: absolute;
    inset: -14px;
    background: linear-gradient(#1b092c9e, #1b092c9e), var(--ambiente) center / cover;
    filter: blur(12px);
    opacity: .53;
    pointer-events: none;
  }
  .mandos {
    justify-self: center;
    width: min(100%, 28rem);
    padding: 4px 8px;
    background: #100819e8;
  }
  .mandos p {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
  }
  .mandos button { background: #21112caa; }
  #estado {
    position: absolute;
    z-index: 4;
    bottom: calc(60px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    margin: 0;
    padding: .5rem;
    border-radius: .4rem;
    background: #21112cee;
    pointer-events: none;
  }
}
