:root {
  --ink: #f7f3ea;
  --ink-dim: rgba(247, 243, 234, 0.64);
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(10, 14, 24, 0.58);
  --gold: #e8c98a;
  --accent: #ff8f6b;
  --caption-main: #ffe9c7;
  --caption-glow: rgba(190, 140, 255, 0.72);
  --caption-line: rgba(255, 233, 168, 0.55);
}

* { box-sizing: border-box; }

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

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

.filenotice {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 190, 120, 0.42);
  background: rgba(28, 20, 12, 0.9);
  backdrop-filter: blur(14px);
  color: #ffe6c4;
  font-size: 12.5px;
  line-height: 1.75;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.filenotice strong { color: #ffd79a; margin-right: 6px; }
.filenotice b { color: #ffd79a; font-weight: 600; }
.filenotice code {
  padding: 1px 6px;
  margin: 0 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #fff3dc;
}

/* 居中圣诞字幕（零重绘纯 CSS 层） */
.caption {
  position: fixed;
  left: 50%;
  bottom: clamp(86px, 10.5vh, 118px);
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}
.caption__sub {
  margin: 0 0 4px;
  font-size: clamp(11px, 0.95vw, 12.5px);
  letter-spacing: 0.16em;
  color: rgba(247, 243, 234, 0.42);
}
.caption__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.2vw, 28px);
}
.caption__title {
  font-family: Cinzel, "Times New Roman", Georgia, serif;
  font-size: clamp(22px, 3.1vw, 44px);
  font-weight: 600;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--caption-main), #ffffff 50%, var(--caption-main));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px var(--caption-glow)) drop-shadow(0 0 36px var(--caption-glow));
  transition: filter 0.6s ease;
}
.caption__line {
  width: clamp(36px, 6vw, 88px);
  height: 1px;
}
.caption__line--l {
  background: linear-gradient(90deg, transparent, var(--caption-line));
}
.caption__line--r {
  background: linear-gradient(270deg, transparent, var(--caption-line));
}

.hud {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px clamp(16px, 3vw, 40px) 18px;
  pointer-events: none;
  z-index: 10;
}
.hud > * { pointer-events: none; }
.hud button, .hud .chip, .hud .help, .hud .debug-panel { pointer-events: auto; }

.hud__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; gap: 14px; align-items: flex-start; }
.brand__dot {
  width: 10px; height: 10px; margin-top: 8px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px 4px rgba(232, 201, 138, 0.55);
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
.brand h1 {
  margin: 0 0 4px;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 600;
  letter-spacing: 0.12em;
}
.brand p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.btn:hover { border-color: rgba(232, 201, 138, 0.55); background: rgba(24, 30, 44, 0.72); }
.btn:active { transform: scale(0.97); }
.btn.is-on {
  border-color: rgba(232, 201, 138, 0.78);
  background: rgba(232, 201, 138, 0.22);
}
.btn--primary {
  border-color: rgba(232, 201, 138, 0.6);
  background: linear-gradient(135deg, rgba(232, 201, 138, 0.24), rgba(255, 143, 107, 0.12));
}
.btn--primary.is-on { border-color: rgba(120, 255, 190, 0.6); }
.linkbtn {
  appearance: none; background: none; border: 0; color: var(--ink-dim);
  font-size: 12px; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; padding: 0;
}

.hud__mid {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.hud__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.gesture {
  min-width: 214px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  display: grid;
  gap: 6px;
  transition: border-color 0.35s, box-shadow 0.35s, background 0.35s;
}
.gesture.is-live {
  border-color: rgba(232, 201, 138, 0.42);
  background: rgba(16, 20, 31, 0.66);
  box-shadow: 0 0 34px rgba(232, 201, 138, 0.14), inset 0 0 24px rgba(232, 201, 138, 0.05);
}
.gesture.is-live strong {
  background: linear-gradient(100deg, #ffeccb, #ffb98a 45%, #ffeccb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gesture__label { font-size: 11px; letter-spacing: 0.2em; color: var(--ink-dim); }
.gesture strong { font-size: 19px; font-weight: 600; letter-spacing: 0.06em; }
.gesture__meter { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.gesture__meter i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width 0.16s linear;
}
.gesture__hint { font-size: 11.5px; color: var(--ink-dim); line-height: 1.5; }

/* 实时 FPS & Draw Call 调试面板 */
.debug-panel {
  width: 292px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(232, 201, 138, 0.28);
  background: rgba(8, 12, 21, 0.84);
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}
.debug-panel[hidden] { display: none; }
.debug-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.debug-panel__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.dbg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52e59f;
  box-shadow: 0 0 10px rgba(82, 229, 159, 0.75);
}
.dbg-dot.is-warn {
  background: #ffbf5e;
  box-shadow: 0 0 10px rgba(255, 191, 94, 0.75);
}
.dbg-dot.is-low {
  background: #ff626e;
  box-shadow: 0 0 10px rgba(255, 98, 110, 0.85);
}
.debug-panel__close {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-dim);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.debug-panel__close:hover { background: rgba(255, 255, 255, 0.16); color: var(--ink); }

.debug-panel__hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.dbg-metric {
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  gap: 2px;
}
.dbg-metric__label {
  font-size: 10.5px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}
.dbg-metric__val {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  color: #fff6e5;
}
.dbg-metric__sub {
  font-size: 10.5px;
  color: rgba(247, 243, 234, 0.48);
}

.debug-panel__grid {
  display: grid;
  gap: 5px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
}
.dbg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.dbg-row span { color: var(--ink-dim); }
.dbg-row b {
  font-weight: 600;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11.5px;
}

.debug-panel__controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.dbg-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  padding: 6px 4px;
  border-radius: 9px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s;
}
.dbg-btn:hover { border-color: rgba(232, 201, 138, 0.55); color: var(--ink); }
.dbg-btn.is-on {
  border-color: rgba(232, 201, 138, 0.72);
  background: rgba(232, 201, 138, 0.2);
  color: #fff4dd;
}

.preview {
  width: 220px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(8, 10, 16, 0.8);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  position: relative;
}
.preview video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.01;
  pointer-events: none;
}
.preview canvas { display: block; width: 100%; height: auto; }

.hud__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.legend { display: flex; flex-wrap: wrap; gap: 7px; max-width: 74vw; }
.chip {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 20, 0.52);
  color: var(--ink-dim);
  transition: all 0.22s;
  white-space: nowrap;
}
.chip[data-g] { cursor: pointer; }
.chip[data-g]:hover { border-color: rgba(232, 201, 138, 0.5); color: var(--ink); }
.chip.is-active {
  color: #0a0d14;
  background: linear-gradient(135deg, #f2dcae, #ffb38a);
  border-color: transparent;
  box-shadow: 0 0 22px rgba(232, 201, 138, 0.4);
}
.stats {
  display: flex; gap: 12px; align-items: center;
  font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(520px, calc(100vw - 40px));
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 120, 0.4);
  background: rgba(30, 20, 12, 0.92);
  color: #ffdfb8;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.toast[hidden] { display: none; }

.select {
  width: 100%;
  margin: 6px 0 2px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 12.5px;
  outline: none;
}
.select:focus { border-color: rgba(232, 201, 138, 0.55); }
.select option {
  background: #0f1420;
  color: var(--ink);
}

.help {
  position: fixed;
  right: clamp(16px, 3vw, 40px);
  top: 96px;
  width: min(370px, calc(100vw - 32px));
  max-height: calc(100vh - 140px);
  overflow: auto;
  z-index: 25;
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 21, 0.92);
  backdrop-filter: blur(22px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.help h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: 0.1em; }
.help h3 { margin: 16px 0 6px; font-size: 12px; letter-spacing: 0.16em; color: var(--gold); }
.help ul { margin: 0; padding-left: 18px; }
.help li { font-size: 12.5px; line-height: 1.85; color: var(--ink-dim); }
.help b { color: var(--ink); font-weight: 600; }
.help__note { font-size: 11.5px; color: rgba(247, 243, 234, 0.42); line-height: 1.7; margin: 14px 0 16px; }
.help code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11.5px;
  color: var(--ink);
}

@media (max-width: 720px) {
  .brand p, .legend { display: none; }
  .gesture { min-width: 168px; }
  .preview { width: 132px; }
  .debug-panel { width: 230px; }
}
