:root {
  --ink: #23312f;
  --ink-soft: #46524c;
  --paper: #f6f1e5;
  --paper-glass: rgba(248, 244, 234, 0.84);
  --gold: #b08a4e;
  --gold-soft: #d2b47b;
  --cinnabar: #8c3b2a;
  --line: rgba(70, 70, 56, 0.16);
  --shadow: 0 20px 50px rgba(24, 38, 36, 0.16);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #dfe4e1;
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 42%, rgba(255, 255, 255, 0) 52%, rgba(24, 36, 34, 0.16) 100%),
    linear-gradient(180deg, rgba(255, 250, 238, 0.16), rgba(255, 255, 255, 0) 26%);
  z-index: 1;
}

/* ---------------- brand ---------------- */

.brand {
  position: fixed;
  top: 30px;
  left: 36px;
  z-index: 4;
  padding-left: 18px;
  border-left: 2px solid var(--gold);
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.36em;
  color: #7d6a4a;
  margin-bottom: 7px;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 3.1vw, 44px);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.12;
}

.brand p {
  margin: 9px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: #5e655d;
}

/* ---------------- buttons ---------------- */

.actions {
  position: fixed;
  top: 30px;
  right: 32px;
  z-index: 6;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  appearance: none;
  border: 1px solid rgba(60, 66, 58, 0.16);
  background: var(--paper-glass);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(30, 42, 40, 0.08);
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease,
    transform 0.22s ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(140, 59, 42, 0.4);
}

.chip.active {
  background: var(--ink);
  color: #f7f2e6;
  border-color: transparent;
}

/* ---------------- legend ---------------- */

.legend {
  position: fixed;
  right: 36px;
  bottom: 30px;
  width: 300px;
  z-index: 5;
  padding: 16px 18px 13px;
  border-radius: 15px;
  background: var(--paper-glass);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.legend-title {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.24em;
  color: #5f553f;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.legend-title .legend-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: #9a907b;
}

.chev {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 5px solid #9a907b;
  transform: translateY(1px);
  transition: transform 0.2s ease;
}

.legend.collapsed .chev {
  transform: rotate(-90deg) translateY(1px);
}

.legend.collapsed #stop-list,
.legend.collapsed .hint {
  display: none;
}

.legend.collapsed {
  padding-bottom: 14px;
}

#stop-list {
  list-style: none;
  margin: 9px 0 4px;
  padding: 0;
  max-height: min(42vh, 292px);
  overflow-y: auto;
  scrollbar-width: thin;
}

#stop-list li + li {
  border-top: 1px dashed rgba(85, 78, 60, 0.14);
}

#stop-list button {
  appearance: none;
  width: 100%;
  background: none;
  border: 0;
  padding: 6px 6px 6px 3px;
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  align-items: baseline;
  gap: 0 4px;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  border-radius: 7px;
  transition: background 0.18s ease;
}

#stop-list button:hover {
  background: rgba(176, 138, 78, 0.12);
}

#stop-list .idx {
  grid-row: 1 / 3;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--gold);
  align-self: center;
}

#stop-list .nm {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.09em;
}

#stop-list .nt {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #8b877a;
  line-height: 1.5;
}

.hint {
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px solid rgba(85, 78, 60, 0.1);
  font-size: 10px;
  letter-spacing: 0.09em;
  color: #918b7c;
}

/* ---------------- labels ---------------- */

#labels {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#labels.hidden {
  opacity: 0;
}

#labels.hidden .label {
  pointer-events: none;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(214, 184, 126, 0.34);
  background: rgba(28, 41, 38, 0.76);
  color: #f5efdf;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(20, 30, 28, 0.18);
  transition: background 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}

.label:hover {
  background: rgba(122, 60, 43, 0.9);
  border-color: rgba(232, 206, 158, 0.6);
}

.label-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 0 3px rgba(210, 180, 123, 0.18);
  flex: none;
}

.label-name {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.label-note {
  display: none;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  opacity: 0.62;
  padding-left: 4px;
  border-left: 1px solid rgba(245, 239, 223, 0.22);
}

.label:hover .label-note {
  display: inline;
}

/* ---------------- info ---------------- */

.info-panel {
  position: fixed;
  left: 36px;
  top: 148px;
  width: 342px;
  max-height: 48vh;
  overflow-y: auto;
  z-index: 5;
  padding: 20px 22px 16px;
  border-radius: 15px;
  background: rgba(248, 244, 234, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.info-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.info-panel h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: #5f553f;
}

.info-panel p {
  margin: 0;
  font-size: 12px;
  line-height: 2;
  letter-spacing: 0.02em;
  color: #3f4a44;
  text-align: justify;
}

.info-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(85, 78, 60, 0.12);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: #9a907b;
}

/* ---------------- compass ---------------- */

.compass {
  position: fixed;
  left: 36px;
  bottom: 32px;
  z-index: 5;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--paper-glass);
  border: 1px solid rgba(60, 66, 58, 0.16);
  box-shadow: 0 8px 24px rgba(30, 42, 40, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}

.compass-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.compass-face::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px dashed rgba(140, 120, 80, 0.35);
}

.compass-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13px;
  text-align: center;
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #8a7e66;
}

.needle {
  position: absolute;
  left: 50%;
  top: 16px;
  bottom: 24px;
  width: 2px;
  margin-left: -1px;
  transform-origin: 50% 50%;
  transition: transform 0.12s linear;
}

.needle::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -1px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 19px solid var(--cinnabar);
}

.needle::after {
  content: "";
  position: absolute;
  left: -3px;
  bottom: -1px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 15px solid rgba(84, 92, 84, 0.42);
}

/* ---------------- loading ---------------- */

#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f3eee2;
  transition: opacity 1s ease, visibility 1s ease;
}

#loading.done {
  opacity: 0;
  visibility: hidden;
}

.seal {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 32px;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 4px #f3eee2, inset 0 0 0 5px rgba(140, 59, 42, 0.4);
}

.loading-text {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.42em;
  color: #6b6150;
  padding-left: 0.42em;
}

.loading-bar {
  margin-top: 14px;
  width: 120px;
  height: 1px;
  background: rgba(140, 120, 80, 0.25);
  overflow: hidden;
}

.loading-bar i {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gold);
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(270%);
  }
}

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .brand {
    top: 20px;
    left: 20px;
    padding-left: 14px;
  }

  .brand p {
    display: none;
  }

  .actions {
    top: 20px;
    right: 18px;
    gap: 6px;
  }

  .chip {
    padding: 7px 12px;
    font-size: 11px;
  }

  .legend {
    right: 18px;
    left: auto;
    bottom: 18px;
    width: 260px;
    padding: 13px 14px 11px;
  }

  .info-panel {
    left: 18px;
    top: 128px;
    width: min(340px, calc(100vw - 36px));
  }

  .compass {
    left: 18px;
    bottom: 22px;
    width: 62px;
    height: 62px;
  }
}

@media (max-width: 720px) {
  .brand h1 {
    font-size: 26px;
  }

  .eyebrow {
    font-size: 9px;
    letter-spacing: 0.26em;
  }

  .actions {
    top: auto;
    bottom: 20px;
    left: 18px;
    right: 18px;
    justify-content: center;
  }

  .chip {
    background: rgba(248, 244, 234, 0.92);
  }

  .legend,
  .compass {
    display: none;
  }

  .info-panel {
    top: 84px;
    right: 18px;
    left: 18px;
    width: auto;
    max-height: 54vh;
    overflow-y: auto;
  }

  .label-note {
    display: none !important;
  }
}
