* { box-sizing: border-box; }

:root {
  --bg: #141311;
  --ink: #f5f0e6;
  --muted: #cfc6b6;
  --gold: #d9b87c;
  --gold-bright: #f2d59b;
  --glass: rgba(18, 17, 15, 0.78);
  --glass-strong: rgba(18, 17, 15, 0.92);
  --border: rgba(217, 184, 124, 0.24);
  --border-soft: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

html, body, #museum, #view {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#view {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }
#view.pointing { cursor: pointer; }
#view canvas {
  display: block;
  width: 100%;
  height: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  cursor: pointer;
  padding: 0.48rem 0.78rem;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.14s ease, box-shadow 0.2s ease;
}
button:hover, button:focus-visible {
  border-color: var(--gold);
  background: rgba(217, 184, 124, 0.14);
  outline: none;
}
button:active { transform: translateY(1px); }

/* ---------- Pantalla de bienvenida ---------- */
.intro {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(16, 15, 13, 0.45), rgba(10, 9, 8, 0.86));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.intro.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.intro-card {
  width: min(560px, 100%);
  padding: 34px 30px 28px;
  text-align: center;
  background: linear-gradient(160deg, rgba(28, 25, 21, 0.92), rgba(16, 15, 13, 0.94));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
}
.intro-crest {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold);
  font: 400 2rem Georgia, "Times New Roman", serif;
  border-radius: 4px;
  box-shadow: inset 0 0 18px rgba(217, 184, 124, 0.15);
}
.intro-eyebrow {
  margin: 0 0 8px;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--gold);
}
.intro-card h1 {
  margin: 0 0 12px;
  font: 400 clamp(1.6rem, 3.6vw, 2.3rem) Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}
.intro-desc {
  margin: 0 auto 24px;
  max-width: 44ch;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}
.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}
.btn-primary {
  background: var(--gold);
  color: #191611;
  border-color: var(--gold-bright);
  font-weight: 600;
  padding: 0.72rem 1.35rem;
}
.btn-primary:hover {
  background: var(--gold-bright);
  color: #14120e;
}
.btn-gold {
  background: rgba(217, 184, 124, 0.14);
  color: var(--gold-bright);
  border-color: var(--gold);
  font-weight: 500;
  padding: 0.72rem 1.25rem;
}
.btn-gold:hover {
  background: rgba(217, 184, 124, 0.25);
}
.intro-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  font-size: 0.74rem;
  color: #b4aa98;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}
.intro-hints kbd {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 3px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--ink);
}

/* ---------- HUD Superior ---------- */
.mast, .hud-left, .minimap-wrap, .nearby, .audiobar, .navigation, .pad {
  position: absolute;
  z-index: 3;
}

.mast {
  inset: 16px 18px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.monogram {
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold);
  font: 1.45rem Georgia, serif;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  flex: none;
}
.mast small, .guide small, dialog small, .nearby small, .audiobar small {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--gold);
  display: block;
}
.mast h1 {
  font: 400 clamp(0.98rem, 1.8vw, 1.42rem) Georgia, serif;
  margin: 0.08rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mast-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0.35rem 0.78rem;
  font-size: 0.84rem;
  white-space: nowrap;
}
.pill.icon-only {
  width: 40px;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
}
.pill[aria-pressed="true"] {
  background: rgba(217, 184, 124, 0.22);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.light-btn {
  text-align: left;
  padding: 0.3rem 0.82rem;
}
.light-labels {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.light-labels strong {
  font-size: 0.8rem;
  font-weight: 600;
}
.light-labels small {
  font-size: 0.6rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: #ffe39c;
  box-shadow: 0 0 10px rgba(255, 224, 130, 0.85);
  flex: none;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.light-btn[aria-pressed="true"] .dot {
  background: #6ea8ff;
  box-shadow: 0 0 12px rgba(110, 168, 255, 0.95);
}

/* ---------- Guía de sala ---------- */
.hud-left {
  bottom: 84px;
  left: 18px;
  pointer-events: none;
}
.guide {
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 14px;
  max-width: min(410px, calc(100vw - 36px));
  box-shadow: var(--shadow);
}
.guide strong {
  font: 400 1.2rem Georgia, serif;
}
.guide p {
  margin: 0.28rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- Minimapa ---------- */
.minimap-wrap {
  right: 18px;
  bottom: 84px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#minimap {
  display: block;
  width: 148px;
  height: 148px;
  border-radius: 6px;
  cursor: pointer;
}
.minimap-label {
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  color: var(--gold);
}

/* ---------- Tarjeta de obra cercana ---------- */
.nearby {
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.55);
  max-width: min(520px, calc(100vw - 36px));
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.nearby.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}
.nearby-meta strong {
  font: 400 1.05rem Georgia, serif;
  display: block;
  margin-top: 2px;
}
.nearby-actions {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
}
.btn-gold-sm {
  background: var(--gold);
  color: #191611;
  border-color: var(--gold-bright);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.42rem 0.78rem;
}
.btn-gold-sm:hover { background: var(--gold-bright); color: #14120e; }
.btn-ghost-sm {
  font-size: 0.8rem;
  padding: 0.42rem 0.72rem;
}

/* ---------- Reproductor de Audioguía ---------- */
.audiobar {
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 32px));
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 12px 15px 10px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.6);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.audiobar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
}
.audiobar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.audiobar-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.audiobar-badge strong {
  font: 400 1.02rem Georgia, serif;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eq {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  width: 18px;
  flex: none;
}
.eq i {
  display: block;
  width: 4px;
  height: 6px;
  border-radius: 2px;
  background: var(--gold);
  animation: eqBar 0.85s ease-in-out infinite alternate;
}
.eq i:nth-child(2) { animation-delay: 0.22s; height: 14px; }
.eq i:nth-child(3) { animation-delay: 0.44s; height: 9px; }
.audiobar.paused .eq i { animation-play-state: paused; height: 4px; }
@keyframes eqBar {
  from { height: 4px; }
  to { height: 18px; }
}
.audiobar-btns {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.audiobar-btns button {
  padding: 0.3rem 0.54rem;
  font-size: 0.85rem;
}
.audiobar-btns .rate-btn {
  font-size: 0.72rem;
  min-width: 44px;
  color: var(--gold-bright);
}
.audiobar-sub {
  margin: 8px 0 8px;
  font-size: 0.83rem;
  line-height: 1.45;
  color: #efe7d8;
  max-height: 4.5em;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 184, 124, 0.45) transparent;
}
.audiobar-sub::-webkit-scrollbar { width: 5px; }
.audiobar-sub::-webkit-scrollbar-track { background: transparent; }
.audiobar-sub::-webkit-scrollbar-thumb {
  background: rgba(217, 184, 124, 0.45);
  border-radius: 3px;
}
.audiobar-progress {
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
#audioProgressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width 0.25s linear;
}

/* ---------- Navegación inferior ---------- */
.navigation {
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 11px;
  width: max-content;
  max-width: calc(100vw - 36px);
  box-shadow: var(--shadow);
}
.navigation button {
  font-size: 0.84rem;
  padding: 0.42rem 0.75rem;
}
.navigation .selected {
  background: var(--gold);
  color: #191611;
  border-color: var(--gold-bright);
  font-weight: 600;
}
.navigation #catalog { margin-left: 4px; }
.navigation #catalog span {
  color: var(--gold);
  margin-left: 0.25rem;
  font-weight: 600;
}

/* ---------- Controles táctiles ---------- */
.pad {
  display: none;
  right: 16px;
  bottom: 92px;
  text-align: center;
}
.pad button {
  touch-action: none;
  background: var(--glass);
  width: 42px;
  height: 42px;
  margin: 2px;
  padding: 0;
}

/* ---------- Retícula sutil ---------- */
.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(217, 184, 124, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.reticle.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.45);
  border-color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(217, 184, 124, 0.7);
}

#status:empty { display: none; }
#status {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 90vw;
  background: rgba(24, 22, 18, 0.94);
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* ---------- Modal de obra y catálogo ---------- */
dialog {
  width: min(860px, 94vw);
  max-height: 90dvh;
  background: #1a1916;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  overflow: auto;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.75);
}
dialog::backdrop {
  background: rgba(8, 8, 7, 0.78);
  backdrop-filter: blur(6px);
}
dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
dialog h2 {
  font: 400 1.55rem Georgia, serif;
  margin: 0.2em 0 0;
}
#close {
  font-size: 1.5em;
  padding: 0 0.55em;
  line-height: 1.2;
}
#artBody { padding: 14px 0 0; }
.art-stage {
  position: relative;
  background: #0f0e0c;
  border: 1px solid rgba(217, 184, 124, 0.35);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}
.art-stage img {
  max-width: 100%;
  max-height: 54dvh;
  display: block;
  object-fit: contain;
  margin: auto;
  border-radius: 3px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.65);
}
.art-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.art-specs {
  font-size: 0.8rem;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.art-actions {
  display: flex;
  gap: 8px;
}
.art-narrative {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #e4dccd;
  margin: 0;
}

.catalogGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
}
.catalogGrid button {
  width: 100%;
  text-align: left;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
}
.catalogGrid img {
  width: 100%;
  height: 104px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 4px;
}
.catalogGrid strong {
  font: 400 0.92rem Georgia, serif;
  color: var(--ink);
}
.catalogGrid small {
  letter-spacing: 0.06em;
  font-size: 0.66rem;
}
.missing {
  padding: 2rem;
  border: 1px dashed #9e886b;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (pointer: coarse), (max-width: 820px) {
  .pad { display: block; }
  .minimap-wrap { display: none; }
  .hud-left { bottom: 96px; left: 10px; }
  .guide { max-width: calc(100vw - 170px); padding: 8px 11px; }
  .guide p { display: none; }
  .mast { inset: 10px 10px auto; padding: 8px 10px; gap: 8px; }
  .monogram { width: 32px; height: 32px; font-size: 1.2rem; }
  .pill .ico + span { display: none; }
  .brand > div:last-child { min-width: 0; }
  .mast small { white-space: nowrap; overflow: hidden; }
  .navigation {
    left: 10px;
    right: 10px;
    width: auto;
    max-width: calc(100vw - 20px);
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 4px;
  }
  .navigation button { font-size: 0.76rem; padding: 0.38rem 0.5rem; }
  .audiobar { top: 72px; padding: 10px 12px; }
  .nearby { bottom: 162px; flex-direction: column; align-items: stretch; gap: 8px; }
}
@media (max-width: 480px) {
  .mast small { display: none; }
  .mast h1 { font-size: 0.86rem; white-space: normal; line-height: 1.15; }
  .mast-controls { gap: 5px; }
  .monogram, #btnFullscreen { display: none; }
  .pill.icon-only, #btnTour { width: 38px; padding: 0; justify-content: center; }
  .light-labels small { display: none; }
}
@media (max-width: 480px) {
  .navigation { padding: 5px; gap: 3px; }
  .navigation button { font-size: 0.69rem; padding: 0.42rem 0.34rem; }
  .navigation #catalog { margin-left: 0; }
  .navigation #catalog span { margin-left: 0.1rem; }
}

/* ---------- Bienvenida cinematográfica ---------- */
.intro {
  background: linear-gradient(90deg, rgba(5, 5, 6, 0.86) 0%, rgba(5, 5, 6, 0.55) 40%, rgba(5, 5, 6, 0) 70%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.intro-load {
  margin: 14px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  transition: opacity 0.6s ease;
}
.intro-load.done { opacity: 0; }
@media (min-width: 921px) {
  .intro { justify-items: start; padding-left: 4vw; }
  .intro-card { width: min(500px, 42vw); }
}
@media (max-width: 920px) {
  .intro { place-items: end center; background: linear-gradient(0deg, rgba(5, 5, 6, 0.9) 0%, rgba(5, 5, 6, 0.5) 55%, rgba(5, 5, 6, 0) 85%); }
  .intro-card { max-height: 74dvh; overflow: auto; padding: 22px 18px 18px; background: rgba(18, 16, 14, 0.82); }
  .intro-crest { display: none; }
}

body.on-intro .hud-left,
body.on-intro .minimap-wrap,
body.on-intro .navigation,
body.on-intro .pad,
body.on-intro .mast { opacity: 0; pointer-events: none; }
.hud-left, .minimap-wrap, .navigation, .pad, .mast { transition: opacity 0.7s ease; }

/* ---------- Contemplación 360° ---------- */
.inspect {
  position: absolute;
  z-index: 5;
  left: 18px;
  top: 92px;
  width: min(330px, calc(100vw - 36px));
  max-height: calc(100% - 112px);
  overflow: auto;
  padding: 16px 18px;
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.inspect[hidden] { display: none; }
.inspect small, .inspect-label { font-size: 0.62rem; letter-spacing: 0.18em; color: var(--gold); }
.inspect h2 { margin: 4px 0 8px; font: 400 1.7rem Georgia, serif; }
.inspect p { margin: 0 0 14px; font-size: 0.8rem; line-height: 1.5; color: var(--muted); }
.inspect-label { display: block; margin-bottom: 7px; text-transform: uppercase; }
.finishes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.finishes button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.7rem; padding: 0.55rem 0.2rem; }
.sw { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.sw-bronce { background: radial-gradient(circle at 32% 28%, #e2b676, #5a3d26 48%, #16261f); }
.sw-verde { background: radial-gradient(circle at 32% 28%, #b9d8c8, #5d9480 48%, #233229); }
.sw-marmol { background: radial-gradient(circle at 32% 28%, #ffffff, #e2dcd0 55%, #9d988f); }
.inspect button[aria-pressed="true"] { border-color: var(--gold); background: rgba(217, 184, 124, 0.22); color: var(--gold-bright); }
.inspect-tools, .inspect-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.inspect-tools button { flex: 1; font-size: 0.8rem; }
.inspect .inspect-credit { margin: 4px 0 0; font-size: 0.64rem; opacity: 0.8; }
.inspect-credit a { color: var(--gold); }
body.inspecting .hud-left,
body.inspecting .minimap-wrap,
body.inspecting .navigation,
body.inspecting .pad,
body.inspecting .reticle { display: none; }
body.inspecting .audiobar { top: auto; bottom: 16px; left: auto; right: 16px; transform: none; width: min(520px, calc(100vw - 390px)); }
body.inspecting .audiobar.hidden { transform: translateY(10px); }

@media (max-width: 820px) {
  .hud-left { display: none; }
  .navigation { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .navigation button { white-space: nowrap; flex: none; }
  .pad { right: 10px; bottom: 74px; }
  .nearby { left: 10px; bottom: 74px; transform: none; max-width: calc(100vw - 180px); }
  .nearby.hidden { transform: translateY(10px); }
  #status { bottom: 180px; }
  .inspect { top: auto; bottom: 10px; left: 10px; width: calc(100vw - 20px); max-height: 44%; padding: 12px 14px; }
  .inspect h2 { font-size: 1.25rem; margin-bottom: 8px; }
  .inspect h2 + p { display: none; }
  .finishes button { flex-direction: row; justify-content: center; }
  .sw { width: 16px; height: 16px; }
  body.inspecting .audiobar { top: 72px; bottom: auto; left: 10px; right: 10px; width: auto; }
}
