:root {
  --bg0: #04060f;
  --bg1: #0a1028;
  --ink: #e8ecff;
  --muted: #8b94b8;
  --line: rgba(255, 255, 255, 0.09);
  --panel: rgba(9, 13, 34, 0.78);
  --gold: #ffc766;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg1) 0%, var(--bg0) 62%) fixed;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.loading { opacity: 0; }
body.ready { opacity: 1; transition: opacity 0.7s ease; }

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

/* ---------- brand ---------- */
#brand {
  position: fixed;
  top: 18px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20;
  pointer-events: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #160f02;
  background: linear-gradient(140deg, #ffe2a6, #f4b64c);
  box-shadow: 0 0 26px rgba(255, 199, 102, 0.45);
}
.brand-cn { font-size: 15px; font-weight: 600; letter-spacing: 0.12em; }
.brand-en { font-size: 10px; letter-spacing: 0.28em; color: var(--muted); margin-top: 2px; }

/* ---------- search ---------- */
#search {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(320px, 52vw);
}
#search-input {
  width: 100%;
  height: 42px;
  padding: 0 16px;
  border-radius: 21px;
  border: 1px solid var(--line);
  outline: none;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  -webkit-user-select: text;
  user-select: text;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#search-input::placeholder { color: #677092; }
#search-input:focus {
  border-color: rgba(255, 199, 102, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 199, 102, 0.12);
}
#search-results {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 12, 30, 0.92);
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#search-results.open { display: block; }
.sr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: rgba(255, 199, 102, 0.08); }
.sr-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sr-name { font-size: 13px; }
.sr-en { font-size: 11px; color: var(--muted); margin-left: auto; }

/* ---------- legend ---------- */
#legend {
  position: fixed;
  left: 20px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.legend-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, #fff);
  box-shadow: 0 0 10px var(--c, #fff);
}

/* ---------- info panel ---------- */
#panel {
  position: fixed;
  top: 74px;
  right: 18px;
  width: 300px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  z-index: 25;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 18px;
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
#panel.open {
  transform: translateX(0);
  opacity: 1;
}
.p-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.p-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 20px;
  color: var(--c, var(--ink));
  border: 1px solid color-mix(in srgb, var(--c, #fff) 55%, transparent);
  background: color-mix(in srgb, var(--c, #fff) 12%, transparent);
}
.p-close {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  flex: none;
}
.p-close:hover { color: var(--ink); background: rgba(255, 255, 255, 0.12); }
#panel h2 {
  margin-top: 14px;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.p-en { font-size: 11px; color: var(--muted); letter-spacing: 0.14em; font-weight: 400; }
.p-desc { margin-top: 10px; font-size: 13px; line-height: 1.75; color: #b9c2e6; }
.p-rel { margin-top: 16px; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.p-chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.p-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.p-chip:hover {
  background: rgba(255, 199, 102, 0.12);
  border-color: rgba(255, 199, 102, 0.5);
  transform: translateY(-1px);
}

/* ---------- controls & stats ---------- */
#controls {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#controls button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.2s ease, transform 0.15s ease;
}
#controls button:hover { background: rgba(255, 199, 102, 0.14); transform: scale(1.06); }

#stats {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 20;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-align: right;
  pointer-events: none;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 15;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.8s ease;
  white-space: nowrap;
}
#hint.faded { opacity: 0; }

@media (max-width: 640px) {
  #panel {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-height: 42vh;
    transform: translateY(calc(100% + 30px));
  }
  #panel.open { transform: translateY(0); }
  #brand { top: 12px; left: 14px; }
  .brand-mark { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
  .brand-cn { font-size: 13px; }
  #search { top: 12px; width: min(300px, 46vw); }
  #stats { top: 12px; right: 14px; }
  #legend { left: 14px; bottom: 12px; }
  #hint { bottom: 14px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
