:root {
  color-scheme: dark;
  --bg: #070706;
  --surface: #101311;
  --surface-2: #171512;
  --line: rgba(236, 222, 184, 0.18);
  --line-strong: rgba(236, 222, 184, 0.36);
  --text: #f1dfb5;
  --muted: rgba(241, 223, 181, 0.72);
  --gold: #d5a24d;
  --gold-2: #f3c66d;
  --green: #315f57;
  --teal: #6fb2a5;
  --red: #7b2f2c;
  --black: #050403;
  --room: #2b2520;
  --room-open: #3e362b;
  --artifact: #c89545;
  --fact: #6fb2a5;
  --person: #b9695c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(9, 9, 8, 0.96), rgba(8, 7, 6, 0.98)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 9px);
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #090807;
  cursor: pointer;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.app:not(.is-splash) .intro {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.introSky {
  position: absolute;
  inset: 0;
  background:
    var(--intro-photo, none) center / cover no-repeat,
    #17100b;
  transform: scale(1.01);
}

.introSky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.64), rgba(0, 0, 0, 0.16) 38%, rgba(0, 0, 0, 0.26)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.46), transparent 52%);
}

.titleBlock {
  position: absolute;
  z-index: 2;
  left: clamp(18px, 4vw, 60px);
  top: clamp(20px, 6vh, 70px);
  width: min(520px, calc(100vw - 36px));
  pointer-events: none;
}

.kicker,
.eyebrow,
.panelTitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p,
figure {
  margin: 0;
}

h1 {
  max-width: 11ch;
  color: #fff1c9;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(220px, 22vw) minmax(420px, 1fr) minmax(330px, 28vw);
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 16px;
}

.topbar,
.mapPanel,
.detailPanel,
.bottomBar,
.modal {
  border: 1px solid var(--line);
  background: rgba(12, 13, 11, 0.88);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.topbar {
  grid-column: 1 / -1;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 8px;
}

.topbar h2 {
  margin-top: 3px;
  color: #fff1c9;
  font-size: clamp(1.08rem, 2vw, 1.45rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tabButton,
.ghostButton {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 241, 201, 0.84);
  font-size: 0.84rem;
  font-weight: 720;
}

.tabButton {
  padding: 7px 10px;
}

.tabButton.is-active {
  border-color: rgba(243, 198, 109, 0.72);
  background: rgba(213, 162, 77, 0.2);
  color: #fff1c9;
}

.ghostButton {
  padding: 7px 12px;
}

.mapPanel,
.detailPanel {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
}

.mapPanel {
  grid-column: 1;
  grid-row: 2;
}

.roomList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.roomButton {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
}

.roomButton.is-active {
  border-color: rgba(243, 198, 109, 0.74);
  background: rgba(213, 162, 77, 0.14);
}

.roomIndex {
  width: 28px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--green);
  color: #eff7ef;
  font-size: 0.78rem;
  font-weight: 780;
}

.roomName {
  color: #fff1c9;
  font-size: 0.9rem;
  font-weight: 760;
}

.roomSummary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.28;
}

.planStage {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.planCanvas {
  position: relative;
  width: min(100%, 940px);
  aspect-ratio: 1.42;
  min-height: 420px;
  border: 1px solid rgba(236, 222, 184, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    #0b0b09;
  background-size: 34px 34px;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.018);
}

.planLegend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(236, 222, 184, 0.12);
  border-radius: 6px;
  background: rgba(6, 6, 5, 0.78);
  color: var(--muted);
  font-size: 0.75rem;
}

.legendDot {
  width: 9px;
  aspect-ratio: 1;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
}

.roomShape {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  border: 4px solid #16100b;
  border-radius: 4px;
  background: var(--room);
  outline: 1px solid rgba(236, 222, 184, 0.16);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.roomShape.is-active {
  border-color: #4b3720;
  background: var(--room-open);
  transform: translateY(-1px);
}

.roomShape::after {
  content: attr(data-label);
  position: absolute;
  left: 8px;
  top: 8px;
  max-width: calc(100% - 16px);
  color: rgba(255, 241, 201, 0.88);
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  font-weight: 780;
}

.corridorLink {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  border-radius: 3px;
  background: #16100b;
  outline: 1px solid rgba(236, 222, 184, 0.14);
}

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 34px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 241, 201, 0.72);
  border-radius: 50%;
  color: #050403;
  font-size: 0.78rem;
  font-weight: 860;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transition: transform 140ms ease, opacity 140ms ease, filter 140ms ease;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.is-active {
  transform: translate(-50%, -50%) scale(1.12);
  outline: 0;
  filter: brightness(1.15);
}

.hotspot.is-viewed {
  box-shadow: 0 0 0 4px rgba(243, 198, 109, 0.16), 0 8px 18px rgba(0, 0, 0, 0.35);
}

.hotspot[data-kind="artifact"] {
  background: var(--artifact);
}

.hotspot[data-kind="fact"] {
  background: var(--fact);
}

.hotspot[data-kind="person"] {
  background: var(--person);
}

.hotspot.is-hidden {
  display: none;
}

.detailPanel {
  grid-column: 3;
  grid-row: 2;
}

.detailPanel h2 {
  margin-top: 8px;
  color: #fff1c9;
  font-size: clamp(1.18rem, 2vw, 1.52rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.meta,
.sourceLine {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.meta {
  margin-top: 6px;
}

.photoFrame {
  margin-top: 12px;
  border: 1px solid rgba(236, 222, 184, 0.16);
  border-radius: 7px;
  overflow: hidden;
  background: #080807;
}

.photoFrame img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #050403;
}

.photoFrame figcaption {
  padding: 8px 10px;
  color: rgba(241, 223, 181, 0.7);
  font-size: 0.74rem;
  line-height: 1.35;
}

.bodyText {
  margin-top: 12px;
  color: rgba(241, 223, 181, 0.9);
  font-size: 0.94rem;
  line-height: 1.48;
}

.relatedPeople {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.personChip {
  padding: 5px 7px;
  border: 1px solid rgba(185, 105, 92, 0.46);
  border-radius: 6px;
  background: rgba(185, 105, 92, 0.12);
  color: rgba(255, 241, 201, 0.82);
  font-size: 0.76rem;
}

.sourceLine {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.sourceLine a,
.sourceItem a {
  color: var(--gold-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bottomBar {
  grid-column: 1 / -1;
  grid-row: 3;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 8px;
}

#statusText {
  color: rgba(255, 241, 201, 0.82);
  font-size: 0.9rem;
}

.artifactStrip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(680px, 52vw);
}

.artifactSlot {
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(236, 222, 184, 0.18);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(241, 223, 181, 0.48);
  font-size: 0.74rem;
  font-weight: 800;
}

.artifactSlot.is-viewed {
  border-color: rgba(243, 198, 109, 0.72);
  background: rgba(213, 162, 77, 0.22);
  color: #f5d18e;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(3, 3, 2, 0.68);
}

.overlay.is-open {
  display: grid;
}

.modal {
  width: min(1040px, calc(100vw - 36px));
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modalHeader h2 {
  color: #fff1c9;
  font-size: 1.22rem;
  letter-spacing: 0;
}

.sourceGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.sourceItem {
  min-height: 90px;
  padding: 10px;
  border: 1px solid rgba(236, 222, 184, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
}

.sourceItem strong {
  display: block;
  margin-bottom: 5px;
  color: #f5d18e;
  font-size: 0.88rem;
  line-height: 1.25;
}

.sourceItem p {
  color: rgba(241, 223, 181, 0.74);
  font-size: 0.78rem;
  line-height: 1.36;
}

.sourceItem a {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.78rem;
}

noscript {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 40;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11100e;
  color: var(--text);
}

@media (max-width: 1050px) {
  body {
    overflow: auto;
  }

  .workspace {
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
  }

  .topbar,
  .mapPanel,
  .planStage,
  .detailPanel,
  .bottomBar {
    grid-column: 1;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .tabs {
    justify-content: flex-start;
  }

  .mapPanel {
    grid-row: 2;
    max-height: none;
  }

  .planStage {
    grid-row: 3;
  }

  .detailPanel {
    grid-row: 4;
  }

  .bottomBar {
    grid-row: 5;
    grid-template-columns: 1fr;
  }

  .artifactStrip {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 10px;
    gap: 10px;
  }

  .planCanvas {
    width: 100%;
    min-height: 360px;
    aspect-ratio: 0.9;
  }

  .roomShape::after {
    font-size: 0.64rem;
  }

  .hotspot {
    width: 31px;
  }
}
