:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #0c100d;
  --surface: #121713;
  --surface-2: #171d18;
  --line: #273128;
  --text: #eef4ef;
  --muted: #96a198;
  --accent: #72df91;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; }
button, select, input { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
}

.icon-button,
.close-button,
.instruction-toast button {
  border: 1px solid var(--line);
  background: rgba(12, 16, 13, .88);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 17px;
  font-weight: 650;
}
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:active, .close-button:active, .instruction-toast button:active { background: #1b241d; }

.back { position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); z-index: 8; }
.top-actions { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 8; display: flex; gap: 8px; }

.reticle {
  --guide-spacing: 88px;
  position: fixed;
  left: 50%;
  top: 50%;
  width: var(--guide-spacing);
  height: 8px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
  mix-blend-mode: difference;
  opacity: .88;
}
.reticle span { position: absolute; top: 1px; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.reticle span:first-child { left: -3px; }
.reticle span:last-child { right: -3px; }

.panel {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(370px, 92vw);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  transform: translateX(100%);
  transition: transform 170ms ease;
}
.panel.open { transform: translateX(0); }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h1 { margin: 0 0 4px; font-size: 18px; font-variant: small-caps; letter-spacing: .12em; font-weight: 650; }
.panel-header p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.close-button { flex: none; width: 34px; height: 34px; border-radius: 10px; font-size: 24px; line-height: 1; }

.toolbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 4px; }
.toolbar button, select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.toolbar button { padding: 0 9px; cursor: pointer; }
select { width: 100%; padding: 0 10px; }

.group { display: grid; gap: 13px; padding: 15px 0; border-top: 1px solid var(--line); }
.group:first-of-type { margin-top: 14px; }
.group label { display: grid; gap: 7px; color: #d8e0da; font-size: 12px; }
.group label > span { display: flex; justify-content: space-between; gap: 8px; }
.scene-description { margin: -4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.projection-control[hidden] { display: none; }
output { color: var(--muted); font-variant-numeric: tabular-nums; }

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  appearance: none;
  background: transparent;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 8px; background: #2c3830; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 8px; background: #2c3830; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 20px; height: 20px; margin-top: -8px; border: 0; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 999px; background: var(--accent); }

.toggles { gap: 11px; }
.toggles label { grid-template-columns: 18px 1fr; align-items: center; gap: 9px; }
.toggles label > span { justify-content: flex-start; }
.toggles input { accent-color: var(--accent); }

.instruction-toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(12, 16, 13, .92);
  transition: opacity 150ms ease, transform 150ms ease;
}
.instruction-toast.hidden { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
.instruction-toast strong { display: block; margin-bottom: 2px; font-size: 12px; font-variant: small-caps; letter-spacing: .12em; }
.instruction-toast p { margin: 0; color: #b5c0b7; font-size: 11px; line-height: 1.45; }
.instruction-toast button { flex: none; width: 28px; height: 28px; border-radius: 9px; font-size: 19px; line-height: 1; }

@media (max-width: 620px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 54dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  }
  .panel.open { transform: translateY(0); }
  .instruction-toast { bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .instruction-toast { transition: none; }
}
