:root {
  --panel-bg: rgba(14, 16, 24, 0.62);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.92);
  --text-dim: rgba(255, 255, 255, 0.55);
  --accent: #f2a3c3;
  --accent2: #8fb8ff;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 50% 35%, #241b2e 0%, #171222 45%, #0b0d16 100%);
  user-select: none;
}

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.45) 100%);
}

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 28px;
  background: radial-gradient(120% 90% at 50% 35%, #241b2e 0%, #171222 45%, #0b0d16 100%);
  z-index: 30;
  transition: opacity 0.6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }

.loader-ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loader-text { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader-title { font-size: 22px; letter-spacing: 4px; font-weight: 600; }
.loader-status { font-size: 13px; color: var(--text-dim); }

.loader-bar {
  width: 280px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%; width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 0.25s ease;
}

/* ---------- 右上角菜单按钮 ---------- */
.menu-btn {
  position: fixed;
  right: 18px; top: 18px;
  width: 42px; height: 42px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(14, 16, 24, 0.6);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  z-index: 25;
  transition: background 0.2s, transform 0.1s;
}
.menu-btn:hover { background: rgba(30, 24, 38, 0.85); }
.menu-btn:active { transform: scale(0.94); }

/* ---------- UI panel（☰ 展开） ---------- */
#ui {
  display: none;
  position: fixed;
  right: 18px; top: 68px;
  width: 250px;
  padding: 18px 18px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  z-index: 20;
  font-size: 13px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
#ui.open { display: block; }
#ui::-webkit-scrollbar { width: 4px; }
#ui::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.panel-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: 1px;
}

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

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

.btn-primary {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #d9689a, #b04a78);
  cursor: pointer;
  letter-spacing: 2px;
  transition: filter 0.2s, transform 0.1s;
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:active { transform: scale(0.97); }

.chk {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim);
  cursor: pointer; white-space: nowrap;
}
.chk input { accent-color: var(--accent); }

.ctrl { display: block; margin-bottom: 12px; }
.ctrl > span {
  display: flex; justify-content: space-between;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.ctrl em { color: var(--text); font-style: normal; font-weight: 600; }

select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }
select option { background: #1a1424; color: #fff; }

input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.14);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}

.stats {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  display: flex; flex-direction: column; gap: 4px;
  color: var(--text-dim);
  font-size: 12px;
}
.stats em { color: var(--text); font-style: normal; }

.hint {
  margin-top: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
}

@media (max-width: 700px) {
  #ui { right: 10px; left: 10px; width: auto; top: 62px; max-height: calc(100vh - 74px); }
}
