:root {
  --ink: #e8eef4;
  --panel: rgba(10, 14, 20, 0.82);
  --line: rgba(232, 238, 244, 0.16);
  --accent: #6fd6e8;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05070a;
  color: var(--ink);
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- boot card ---------- */

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.35rem;
  text-align: center;
  padding: 2rem;
  background: radial-gradient(60% 60% at 50% 45%, #0b1a2a 0%, #05070a 100%);
  z-index: 10;
}

#boot[hidden] { display: none; }

#boot h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}

#boot p {
  margin: 0 0 0.9rem;
  max-width: 34rem;
  line-height: 1.5;
  color: rgba(232, 238, 244, 0.72);
}

#boot .fine {
  font-size: 0.78rem;
  color: rgba(232, 238, 244, 0.42);
  margin: 0.9rem 0 0;
}

button {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #04151b;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease;
}

button:hover { filter: brightness(1.1); }

button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button.ghost:hover { border-color: rgba(232, 238, 244, 0.4); }
button.small { font-size: 0.8rem; padding: 0.35rem 0.8rem; }

/* ---------- control panel ---------- */

#panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9;
  width: 272px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 0.75rem 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  font-size: 0.82rem;
  line-height: 1.35;
}

#panel[hidden] { display: none; }

#panel .row.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

#panel .hint {
  font-size: 0.68rem;
  color: rgba(232, 238, 244, 0.4);
}

#panel .group {
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

#panel label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

#panel label .sub {
  font-size: 0.68rem;
  color: rgba(232, 238, 244, 0.4);
}

#panel label.sl,
#panel label.sel {
  display: grid;
  grid-template-columns: 6.6rem 1fr;
  align-items: center;
  gap: 0.5rem;
}

#panel label.sel { grid-template-columns: 1fr; gap: 0.25rem; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

select {
  font: inherit;
  font-size: 0.8rem;
  width: 100%;
  padding: 0.3rem 0.4rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
}

select:disabled { opacity: 0.4; }

#maskview {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  image-rendering: pixelated;
  background: #000;
}

#maskview[hidden] { display: none; }

.stat {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 238, 244, 0.45);
}

/* ---------- phones ---------- */

/* Camera frames come from here; it has to be in the page for iOS to keep
   delivering them, but nobody needs to see it. */
video.feed {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

#btn-panel {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 11;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

#btn-panel[hidden] { display: none; }

@media (max-width: 520px) {
  #panel {
    left: 8px;
    right: 8px;
    top: 8px;
    width: auto;
    max-height: calc(100dvh - 72px);
    font-size: 0.9rem;
  }
}

#toast {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 12;
  width: max-content;
  max-width: min(420px, calc(100vw - 24px));
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

#toast[hidden] { display: none; }
#toast.actionable { cursor: pointer; border-color: var(--accent); }
