html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  overscroll-behavior: none;
}

/* la obra cubre toda la pantalla; el lienzo se estira a ella y la escena mide
   este contenedor (no innerHeight, que en Safari de iPhone no coincide con lo
   que se ve cuando aparecen o se esconden sus barras) */
#obra {
  position: fixed;
  inset: 0;
}

#obra canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#aviso {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  text-align: center;
  cursor: pointer;
  transition: opacity 0.8s;
}

#aviso p {
  margin: 4px 0;
}

#aviso .suave,
#rotulo {
  opacity: 0.55;
}

#aviso.oculto {
  opacity: 0;
  pointer-events: none;
}

#rotulo {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 56px);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s;
}

#rotulo.visible {
  opacity: 0.55;
}

/* H esconde los textos; la dirección bajo el QR no, porque es parte del QR */
body.sin-textos #aviso,
body.sin-textos #rotulo,
body.sin-textos .esquina .nombre {
  visibility: hidden;
}

/* las esquinas (y los centros de arriba y abajo): zonas del tamaño de un dedo,
   invisibles salvo su rótulo (con H) */
.esquina {
  position: fixed;
  z-index: 5;
  width: 56px;
  height: 56px;
  padding: 12px;
  box-sizing: border-box;
  display: flex;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.esquina .nombre {
  opacity: 0.55;
  white-space: nowrap;
}

/* al tocar una zona todas muestran su ícono en un círculo: entran rápido y se
   van despacio */
.esquina .icono {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

body.mostrando-ui .esquina .icono {
  opacity: 1;
  transform: none;
  transition-duration: 0.1s;
}

.esquina svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.esquina svg .lleno {
  fill: #fff;
  stroke: none;
}

/* sonido y animación muestran su estado: tachados si están apagados */
.esquina svg .tachado {
  display: none;
}

body.sonido-no #esquina-sonido .tachado,
body.animacion-no #esquina-animacion .tachado,
body.auto-no #esquina-auto .tachado {
  display: inline;
}

#esquina-fondo { top: env(safe-area-inset-top, 0px); left: env(safe-area-inset-left, 0px); }
#esquina-modo { top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px); justify-content: flex-end; }
#esquina-sonido { bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px); align-items: flex-end; }
#esquina-frente { top: env(safe-area-inset-top, 0px); left: 50%; transform: translateX(-50%); justify-content: center; }
#esquina-animacion { bottom: env(safe-area-inset-bottom, 0px); left: 38%; transform: translateX(-50%); align-items: flex-end; justify-content: center; }
#esquina-auto { bottom: env(safe-area-inset-bottom, 0px); left: 62%; transform: translateX(-50%); align-items: flex-end; justify-content: center; }
#esquina-compartir { bottom: env(safe-area-inset-bottom, 0px); right: env(safe-area-inset-right, 0px); align-items: flex-end; justify-content: flex-end; }

/* la capa del código QR: desenfoca toda la obra y muestra la dirección actual */
#qr {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  transition: opacity 0.5s;
}

#qr.oculto {
  opacity: 0;
  pointer-events: none;
}

#qr-codigo svg {
  display: block;
  width: min(60vmin, 340px);
  height: auto;
  border-radius: 6px;
}

#qr-direccion {
  margin: 0;
  max-width: min(90vw, 520px);
  text-align: center;
  word-break: break-all;
  opacity: 0.8;
}
