:root {
  color-scheme: dark;
  --bg: #081521;
  --panel: #102333;
  --line: #264153;
  --fg: #e4f2f6;
  --muted: #91aebb;
  --accent: #61d7df;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  padding: 18px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(12, 64, 81, .3), transparent 62%),
    var(--bg);
  color: var(--fg);
  font: 13px/1.5 "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.demo { max-width: 1120px; margin: auto; }

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 12px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .16em;
}

h1 { margin: 0; font-size: 22px; font-weight: 600; }

.formula {
  margin: 0 0 3px;
  color: #b7dbe2;
  font: 14px/1.4 Georgia, "Times New Roman", serif;
}

.scene {
  position: relative;
  height: clamp(350px, 48vw, 510px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #0b2233, #071522);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .22);
}

canvas { display: block; width: 100%; height: 100%; }
canvas { cursor: grab; touch-action: none; }
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.scene-caption, .scene-stats {
  position: absolute;
  top: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(98, 148, 166, .2);
  border-radius: 7px;
  background: rgba(5, 20, 31, .75);
  color: #b6d2dc;
  font-size: 11px;
  pointer-events: none;
}

.scene-caption { left: 12px; }
.scene-stats { right: 12px; display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--accent); }
.navigation-hint, .scene-position {
  position: absolute;
  bottom: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(98, 148, 166, .2);
  border-radius: 7px;
  background: rgba(5, 20, 31, .75);
  color: #b6d2dc;
  font-size: 11px;
  pointer-events: none;
}
.navigation-hint { left: 12px; }
.scene-position { right: 12px; font-variant-numeric: tabular-nums; }

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr)) auto;
  align-items: end;
  gap: 14px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 35, 51, .88);
}

.control { min-width: 0; }
.control label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: var(--muted); white-space: nowrap; }
.control output { color: var(--fg); font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; accent-color: var(--accent); }
select, button { min-height: 30px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; background: #142b3c; color: var(--fg); font: inherit; }
select { width: 100%; }
button { cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--accent); }
.actions { display: flex; gap: 7px; }
#toggle { border-color: #3c9ba7; background: #123744; }
.error { margin: 8px 0 0; color: #ff9a9a; }

@media (max-width: 850px) {
  .controls { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
  .actions { grid-column: span 3; }
}

@media (max-width: 520px) {
  body { padding: 12px; }
  .intro { align-items: start; flex-direction: column; gap: 5px; }
  h1 { font-size: 20px; }
  .formula { font-size: 12px; }
  .scene { height: 350px; }
  .scene-position { display: none; }
  .navigation-hint { max-width: calc(100% - 24px); font-size: 10px; }
  .controls { grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 12px; padding: 12px; }
  .actions { grid-column: span 2; }
  .actions button { flex: 1; }
}
