:root {
  --bg: #000;
  --fg: #f4f4f8;
  --accent: #8a6cff;
  --panel: rgba(18, 16, 30, 0.82);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Composited output fills the screen; crops like a camera app. */
#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  display: block;
  background: #000;
}

/* Source video is never shown — it only feeds the pipeline. */
#cam {
  position: fixed;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
  top: -10px;
  left: -10px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 30%, #1a1430 0%, #05040a 70%);
  z-index: 10;
  transition: opacity 0.4s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  max-width: 22rem;
  margin: 1.5rem;
  padding: 1.75rem 1.5rem;
  background: var(--panel);
  border: 1px solid rgba(138, 108, 255, 0.35);
  border-radius: 1.25rem;
  text-align: center;
  backdrop-filter: blur(8px);
}
.panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #8a6cff, #ff6cc4, #6cf0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.panel p { margin: 0.5rem 0; line-height: 1.4; font-size: 0.95rem; opacity: 0.9; }
.panel .hint { font-size: 0.8rem; opacity: 0.6; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  color: #fff;
}
#startBtn {
  margin-top: 0.75rem;
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(90deg, #7a54ff, #b04cff);
  box-shadow: 0 6px 24px rgba(122, 84, 255, 0.5);
}
#startBtn:disabled { opacity: 0.5; }

.status { font-size: 0.85rem; opacity: 0.8; min-height: 1.1em; }
.error {
  display: none;
  color: #ff9d9d;
  font-size: 0.85rem;
  background: rgba(120, 20, 20, 0.35);
  border-radius: 0.6rem;
  padding: 0.5rem;
}

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0) + 0.75rem);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 0.75rem;
  z-index: 5;
}
.ctl {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  background: rgba(20, 18, 32, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
}
.ctl:active { background: rgba(138, 108, 255, 0.5); }

.slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  width: 40vw;
  max-width: 200px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    hsl(0,90%,55%), hsl(60,90%,55%), hsl(120,90%,55%),
    hsl(180,90%,55%), hsl(240,90%,55%), hsl(300,90%,55%), hsl(360,90%,55%));
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,0.4);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.fps {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 0.5rem);
  right: 0.75rem;
  font-size: 0.75rem;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  z-index: 5;
}
