:root {
  color-scheme: dark;
  --paper: #eee9df;
  --ink: #211f1b;
  --muted: #a7a39a;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #b85d3c;
  --panel: rgba(18, 17, 15, 0.86);
  --serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #171613;
}

body {
  font-family: var(--sans);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.32)),
    radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.3) 115%);
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.crosshair.is-visible {
  opacity: 0.9;
}

.crosshair.is-target {
  transform: scale(1.8);
  background: var(--accent);
  border-color: #fff;
}

.loading,
.start-screen,
.artwork-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.loading {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px);
  gap: 36px;
  align-items: center;
  justify-content: center;
  background: #171613;
  transition: opacity 0.65s ease, visibility 0.65s ease;
}

.loading.is-done {
  opacity: 0;
  visibility: hidden;
}

.loading-mark {
  font-family: var(--serif);
  font-size: clamp(72px, 11vw, 150px);
  line-height: 0.8;
  color: var(--paper);
  letter-spacing: -0.08em;
}

.loading-copy {
  display: grid;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.loading-track {
  height: 1px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.loading-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--paper);
  transition: width 0.25s ease;
}

.start-screen {
  display: grid;
  place-items: center;
  padding: 34px;
  background:
    linear-gradient(90deg, rgba(11, 11, 10, 0.86), rgba(11, 11, 10, 0.56)),
    radial-gradient(circle at 75% 35%, rgba(184, 93, 60, 0.16), transparent 40%),
    #171613;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.start-inner {
  width: min(760px, 92vw);
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.start-inner h1 {
  margin: 22px 0 14px;
  font-family: var(--serif);
  font-size: clamp(58px, 10vw, 128px);
  font-weight: 400;
  line-height: 0.94;
  letter-spacing: -0.07em;
}

.start-inner h1 .title-main,
.start-inner h1 .title-accent {
  display: block;
}

.start-inner h1 .title-accent {
  margin-top: 0.16em;
  font-size: 0.48em;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

@media (max-width: 820px) {
  .start-inner h1 .title-accent {
    font-size: 0.52em;
    letter-spacing: -0.02em;
  }
}

.start-subtitle {
  margin: 0;
  color: #d8d2c7;
  font-family: var(--serif);
  font-size: clamp(18px, 2.6vw, 30px);
  line-height: 1.5;
}

.start-rule {
  width: 76px;
  height: 2px;
  margin: 34px 0;
  background: var(--accent);
}

.start-copy {
  max-width: 620px;
  margin: 0 0 34px;
  color: #bbb5aa;
  font-size: 15px;
  line-height: 1.9;
}

#enter-button,
.close-artwork {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

#enter-button {
  min-width: 178px;
  padding: 0 24px;
  letter-spacing: 0.14em;
}

#enter-button:hover,
#enter-button:focus-visible,
.close-artwork:hover,
.close-artwork:focus-visible {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

.start-help {
  margin: 18px 0 0;
  color: #77736c;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.museum-header {
  position: absolute;
  top: 24px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.museum-header h2 {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.03em;
}

.room-readout {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 178px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(14, 14, 13, 0.34);
  backdrop-filter: blur(10px);
}

.room-readout > span {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  color: #d2c9b9;
}

.room-readout div {
  display: grid;
  gap: 3px;
}

.room-readout strong {
  font-size: 14px;
  font-weight: 500;
}

.room-readout small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.room-nav {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: flex;
  gap: 5px;
  padding: 5px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.room-nav button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #a9a59d;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease;
}

.room-nav button span {
  margin-right: 6px;
  color: #66625d;
  font-family: var(--serif);
}

.room-nav button:hover,
.room-nav button:focus-visible,
.room-nav button.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
}

.room-nav button.is-active span {
  color: var(--accent);
}

.control-note {
  position: absolute;
  right: 28px;
  bottom: 28px;
  display: grid;
  gap: 4px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 10px;
  line-height: 1.45;
  text-align: right;
}

.near-label {
  position: absolute;
  left: 50%;
  bottom: 104px;
  width: min(320px, calc(100vw - 40px));
  padding: 13px 16px;
  transform: translateX(-50%);
  border-left: 2px solid var(--accent);
  background: rgba(17, 16, 14, 0.82);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.near-label small,
.near-label strong,
.near-label span {
  display: block;
}

.near-label small {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.near-label strong {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
}

.near-label span {
  margin-top: 5px;
  color: #aaa59d;
  font-size: 10px;
}

.artwork-modal {
  z-index: 40;
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(8, 8, 7, 0.97);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.artwork-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 48px 7vw 22px;
}

.artwork-stage img {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 820px);
  object-fit: contain;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.46);
}

.artwork-caption {
  display: grid;
  grid-template-columns: minmax(100px, 0.55fr) minmax(180px, 1.3fr) minmax(240px, 2fr);
  gap: 28px;
  align-items: baseline;
  padding: 18px 7vw 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.artwork-caption h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
}

.artwork-caption p:last-child {
  margin: 0;
  color: #aaa59d;
  font-size: 13px;
  line-height: 1.7;
}

.close-artwork {
  position: absolute;
  top: 24px;
  right: 28px;
  z-index: 2;
  min-height: 40px;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.3);
}

.mobile-controls {
  display: none;
}

.touch-copy {
  display: none;
}

.touch-hint {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 68px);
  z-index: 12;
  max-width: calc(100vw - 32px);
  padding: 9px 13px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(17, 16, 14, 0.78);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.04em;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 88px);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #eee9df;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-align: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

@supports (height: 100dvh) {
  html,
  body,
  #app {
    height: 100dvh;
  }
}

@media (max-width: 820px) {
  body {
    overscroll-behavior: none;
  }

  .start-screen {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    padding:
      calc(env(safe-area-inset-top) + 24px)
      max(20px, env(safe-area-inset-right))
      calc(env(safe-area-inset-bottom) + 24px)
      max(20px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }

  .start-inner {
    width: min(680px, 100%);
    min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 48px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .start-inner h1 {
    margin: 16px 0 12px;
    font-size: clamp(44px, 16vw, 78px);
    letter-spacing: -0.06em;
  }

  .start-inner h1 .title-accent {
    margin-top: 0.12em;
    font-size: 0.58em;
  }

  .start-subtitle {
    font-size: clamp(16px, 4.6vw, 22px);
  }

  .start-rule {
    margin: 24px 0;
  }

  .start-copy {
    margin-bottom: 24px;
    font-size: 13px;
    line-height: 1.75;
  }

  #enter-button {
    width: min(280px, 100%);
    min-height: 52px;
  }

  .museum-header {
    top: calc(env(safe-area-inset-top) + 12px);
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    gap: 10px;
  }

  .museum-header h2 {
    font-size: 18px;
  }

  .room-readout {
    min-width: 148px;
    padding: 8px 11px;
    background: rgba(14, 14, 13, 0.58);
  }

  .room-readout > span {
    font-size: 26px;
  }

  .room-readout strong {
    font-size: 13px;
  }

  .room-readout small {
    font-size: 9px;
  }

  .room-nav {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    transform: none;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    touch-action: manipulation;
  }

  .room-nav::-webkit-scrollbar {
    display: none;
  }

  .room-nav button {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0 11px;
    font-size: 11px;
    scroll-snap-align: center;
    touch-action: manipulation;
  }

  .control-note {
    display: none;
  }

  .near-label {
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 204px);
    width: min(360px, calc(100vw - 28px));
    padding: 12px 14px;
    background: rgba(17, 16, 14, 0.88);
  }

  .near-label strong {
    font-size: 18px;
  }

  .artwork-modal {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .artwork-stage {
    padding:
      calc(env(safe-area-inset-top) + 66px)
      max(12px, env(safe-area-inset-right))
      14px
      max(12px, env(safe-area-inset-left));
  }

  .artwork-stage img {
    width: auto;
    max-width: 100%;
    max-height: 66dvh;
  }

  .artwork-caption {
    max-height: 34dvh;
    overflow-y: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    padding:
      14px
      max(20px, env(safe-area-inset-right))
      calc(env(safe-area-inset-bottom) + 20px)
      max(20px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }

  .artwork-caption h2 {
    font-size: 22px;
  }

  .close-artwork {
    top: calc(env(safe-area-inset-top) + 10px);
    right: max(12px, env(safe-area-inset-right));
    min-width: 68px;
    min-height: 46px;
  }

  .touch-hint {
    top: calc(env(safe-area-inset-top) + 72px);
  }
}

@media (max-width: 700px) {
  .museum-header > div:first-child {
    display: none;
  }

  .museum-header {
    justify-content: flex-start;
  }
}

@media (pointer: coarse) {
  .desktop-copy {
    display: none;
  }

  .touch-copy {
    display: inline;
  }

  .mobile-controls {
    position: absolute;
    inset: 0;
    z-index: 14;
    display: block;
    pointer-events: none;
  }

  .mobile-dpad {
    position: absolute;
    left: max(14px, env(safe-area-inset-left));
    bottom: calc(env(safe-area-inset-bottom) + 72px);
    display: grid;
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
    gap: 4px;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }

  .mobile-dpad button {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 50%;
    background: rgba(15, 14, 13, 0.68);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    touch-action: none;
  }

  .mobile-dpad button[data-move="forward"] {
    grid-area: 1 / 2;
  }

  .mobile-dpad button[data-move="left"] {
    grid-area: 2 / 1;
  }

  .mobile-dpad button[data-move="back"] {
    grid-area: 3 / 2;
  }

  .mobile-dpad button[data-move="right"] {
    grid-area: 2 / 3;
  }

  .mobile-dpad button:active,
  .mobile-dpad button.is-pressed {
    border-color: var(--paper);
    background: rgba(238, 233, 223, 0.92);
    color: var(--ink);
    transform: scale(0.96);
  }

  .mobile-view {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 86px);
    min-width: 116px;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 999px;
    background: rgba(184, 93, 60, 0.92);
    color: #fff;
    font-size: 13px;
    letter-spacing: 0.08em;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
    pointer-events: auto;
    touch-action: manipulation;
  }

  .mobile-view:active {
    transform: scale(0.97);
  }

  .crosshair {
    display: none;
  }

  #scene {
    cursor: default;
  }

  .touch-hint {
    display: block;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  .start-screen {
    padding-top: calc(env(safe-area-inset-top) + 14px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 14px);
  }

  .start-inner {
    min-height: 0;
  }

  .start-inner h1 {
    margin: 10px 0 8px;
    font-size: clamp(38px, 9vw, 62px);
  }

  .start-rule {
    margin: 14px 0;
  }

  .start-copy {
    display: none;
  }

  .start-help {
    margin-top: 10px;
  }

  .museum-header {
    top: calc(env(safe-area-inset-top) + 8px);
  }

  .room-readout {
    padding: 6px 9px;
  }

  .room-nav {
    left: 128px;
    right: max(112px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 7px);
    justify-content: center;
  }

  .room-nav button {
    min-height: 40px;
    padding: 0 9px;
    font-size: 10px;
  }

  .mobile-dpad {
    left: max(10px, env(safe-area-inset-left));
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(3, 38px);
    gap: 3px;
  }

  .mobile-dpad button {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .mobile-view {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 13px);
    min-width: 104px;
    min-height: 42px;
  }

  .near-label {
    top: calc(env(safe-area-inset-top) + 54px);
    bottom: auto;
    width: min(300px, calc(100vw - 240px));
    padding: 9px 12px;
  }

  .near-label strong {
    font-size: 16px;
  }

  .touch-hint {
    top: calc(env(safe-area-inset-top) + 50px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
