:root {
  --ink: #f4efe6;
  --ink-dim: #b9b2a6;
  --panel: rgba(18, 22, 26, 0.62);
  --panel-line: rgba(244, 239, 230, 0.16);
  --accent: #e8b06a;
  --accent-soft: rgba(232, 176, 106, 0.18);
  --f2: #e9e2d4;
  --f3: #e3a86a;
  --f4: #c4664f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b1015;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

#stage { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene.is-dragging { cursor: grabbing; }
#scene.is-picking { cursor: pointer; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(0,0,0,0) 45%, rgba(6,10,14,0.42) 100%),
    linear-gradient(to bottom, rgba(8,12,16,0.34), rgba(8,12,16,0) 22%, rgba(8,12,16,0) 72%, rgba(8,12,16,0.42));
}

.hud { position: absolute; z-index: 5; }

/* title */
.title-card { top: clamp(16px, 3.4vw, 40px); left: clamp(16px, 3.4vw, 44px); max-width: min(46ch, 60vw); pointer-events: none; }
.eyebrow {
  margin: 0 0 8px; font-size: 11px; letter-spacing: 0.34em; color: var(--accent);
  text-transform: uppercase; opacity: 0.9;
}
.title-card h1 {
  margin: 0; font-size: clamp(30px, 4.6vw, 56px); line-height: 1.02; font-weight: 600;
  letter-spacing: 0.04em; text-shadow: 0 2px 24px rgba(0,0,0,0.45);
}
.title-card .sub {
  margin: 12px 0 0; font-size: clamp(12px, 1.15vw, 14px); line-height: 1.7;
  color: var(--ink-dim); max-width: 34ch;
}

/* panels */
.panel {
  top: clamp(16px, 3.4vw, 40px); right: clamp(16px, 3.4vw, 44px); width: 246px;
  background: var(--panel); backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 16px 16px 14px; box-shadow: 0 18px 44px rgba(0,0,0,0.34);
}
.panel-body section { margin-bottom: 14px; }
.panel-body h2 {
  margin: 0 0 8px; font-size: 10.5px; letter-spacing: 0.24em; color: var(--ink-dim);
  font-weight: 500; text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  flex: 1 1 auto; min-width: 52px; padding: 7px 8px; font-size: 12.5px; color: var(--ink);
  background: rgba(255,255,255,0.06); border: 1px solid transparent; border-radius: 9px;
  cursor: pointer; transition: background .2s, color .2s, border-color .2s;
  font-family: inherit;
}
.chip:hover { background: rgba(255,255,255,0.12); }
.chip.is-on { background: var(--accent-soft); border-color: rgba(232,176,106,0.62); color: #ffe9c9; }

.switches { display: grid; gap: 7px; }
.switch { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-dim); cursor: pointer; }
.switch input { appearance: none; width: 30px; height: 17px; border-radius: 99px; background: rgba(255,255,255,0.14); position: relative; transition: background .2s; margin: 0; cursor: pointer; }
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: #cfc8bb; transition: transform .2s, background .2s;
}
.switch input:checked { background: rgba(232,176,106,0.45); }
.switch input:checked::after { transform: translateX(13px); background: #ffe3bd; }
.switch span { user-select: none; }
.foot-note { margin: 6px 0 0; font-size: 10.5px; line-height: 1.65; color: rgba(244,239,230,0.42); }
.panel-toggle { display: none; }

/* info */
.info-card {
  left: clamp(16px, 3.4vw, 44px); bottom: clamp(52px, 7vh, 78px); width: min(300px, 76vw);
  background: var(--panel); backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--panel-line); border-radius: 16px; padding: 16px 18px 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.34);
}
.info-card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; letter-spacing: 0.03em; }
.info-card dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.info-card dl > div { min-width: 0; }
.info-card dt { font-size: 10px; letter-spacing: 0.16em; color: var(--ink-dim); text-transform: uppercase; }
.info-card dd { margin: 3px 0 0; font-size: 13.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.info-card .hint { margin: 12px 0 0; font-size: 11px; line-height: 1.7; color: rgba(244,239,230,0.5); }
.info-card .code { margin: 0 0 2px; font-size: 10.5px; letter-spacing: 0.26em; color: var(--accent); }
.info-detail .close {
  position: absolute; top: 10px; right: 12px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--panel-line); background: rgba(255,255,255,0.06); color: var(--ink);
  font-size: 15px; line-height: 1; cursor: pointer; font-family: inherit;
}
.info-detail { position: relative; }

/* legend */
.legend {
  left: clamp(16px, 3.4vw, 44px); bottom: clamp(14px, 2.4vh, 24px);
  display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-dim);
  flex-wrap: wrap; max-width: 70vw;
}
.legend .dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.legend .f2 { background: var(--f2); }
.legend .f3 { background: var(--f3); }
.legend .f4 { background: var(--f4); }
.legend .lbl { margin-right: 6px; }
.legend .sep { width: 1px; height: 11px; background: var(--panel-line); margin: 0 6px; }
.legend .dim { opacity: 0.6; }

#tip {
  position: absolute; z-index: 8; pointer-events: none; transform: translate(-50%, -140%);
  padding: 5px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap;
  background: rgba(14,18,22,0.82); border: 1px solid var(--panel-line); color: var(--ink);
  backdrop-filter: blur(6px);
}

#loader {
  position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 16px;
  background: radial-gradient(circle at 50% 45%, #16202a, #090d11 70%);
  transition: opacity .7s ease, visibility .7s;
}
#loader p { margin: 0; font-size: 12px; letter-spacing: 0.18em; color: var(--ink-dim); }
#loader .ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(232,176,106,0.22); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
#loader.is-hidden { opacity: 0; visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 840px) {
  .title-card { max-width: 64vw; }
  .title-card .sub { display: none; }
  .panel { width: min(228px, 62vw); top: clamp(72px, 11vh, 104px); bottom: auto; right: 12px; padding: 12px 12px 10px; }
  .panel-body { display: none; }
  .panel.is-open .panel-body { display: block; }
  .panel-toggle {
    display: block; width: 100%; padding: 8px; font-size: 12px; color: var(--ink);
    background: rgba(255,255,255,0.07); border: 1px solid var(--panel-line); border-radius: 9px;
    cursor: pointer; font-family: inherit;
  }
  .panel.is-open .panel-toggle { margin-bottom: 10px; }
  .info-card { width: min(300px, 84vw); bottom: clamp(46px, 8vh, 64px); left: 12px; padding: 12px 14px; }
  .info-card dl { grid-template-columns: 1fr 1fr; }
  .legend { max-width: 92vw; font-size: 10px; gap: 6px; left: 12px; bottom: 10px; }
  .legend .sep, .legend .dim { display: none; }
}
@media (max-height: 560px) {
  .info-card { display: none; }
}
