:root {
  --bg: #000;
  --panel: #0d120e;
  --card: #151d17;
  --line: #24342a;
  --text: #e8f5ea;
  --muted: #8fa894;
  --green: #50ff50;
  --gold: #ffc800;
  --red: #ff4d4d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  display: block;
}

/* The camera feed is drawn onto the canvas; the video itself stays invisible. */
#camera {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#safe-probe {
  position: fixed;
  visibility: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --- start screen --- */
#start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #0b2310, #000 70%);
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
#start[hidden] { display: none; }
.start-inner { max-width: 420px; }
#start h1 {
  font: 800 clamp(26px, 8vw, 40px)/1.1 ui-monospace, Menlo, monospace;
  color: var(--green);
  letter-spacing: 0.04em;
  margin: 0;
  text-shadow: 0 0 18px rgba(80, 255, 80, 0.45);
}
.version { color: var(--muted); font-family: ui-monospace, Menlo, monospace; margin: 6px 0 36px; }
#start-button {
  font: 800 20px ui-monospace, Menlo, monospace;
  color: #000;
  background: var(--green);
  border: 0;
  border-radius: 14px;
  padding: 20px 28px;
  width: 100%;
  box-shadow: 0 0 30px rgba(80, 255, 80, 0.35);
}
#start-button:disabled { opacity: 0.5; }
#start-status, #start-hint, #install-hint { color: var(--muted); font-size: 14px; margin: 16px 0 0; }
button.link {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 15px;
  margin-top: 22px;
  padding: 10px;
}

/* --- settings --- */
#settings {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  padding: max(16px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  -webkit-user-select: text;
  user-select: text;
  z-index: 10;
}
#settings[hidden] { display: none; }
#settings.busy { pointer-events: none; }
#settings.busy::after {
  content: "Working...";
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--gold);
  color: #000;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
}
#settings header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: calc(-1 * max(16px, env(safe-area-inset-top)));
  background: var(--panel);
  padding: 8px 0;
  z-index: 1;
}
#settings h2 { margin: 0; font-size: 26px; }
#settings h3 { margin: 0 0 6px; font-size: 19px; }
#settings section { border-top: 1px solid var(--line); padding: 18px 0; }
#settings section.warning h3 { color: var(--gold); }
.note { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.empty { color: var(--muted); font-style: italic; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.card-head { display: flex; justify-content: space-between; gap: 8px; }
.card-head span { color: var(--muted); font-size: 14px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.thumbs img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row input { flex: 1 1 160px; }
#settings button, #settings input {
  font: inherit;
  border-radius: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: #1e2a22;
  color: var(--text);
}
#settings input { background: #0a0f0b; user-select: text; -webkit-user-select: text; }
#settings button.primary { background: var(--green); color: #000; border-color: var(--green); font-weight: 700; }
#settings button.danger { color: var(--red); }
.segmented { display: flex; gap: 8px; }
.segmented button.on { background: var(--green); color: #000; font-weight: 700; }
.results { padding-left: 18px; font-size: 14px; }
.results .ok { color: var(--green); }
.results .bad { color: var(--red); }
.controls { padding-left: 18px; }
.controls li { margin: 6px 0; }
.slider { width: 100%; margin: 6px 0 12px; accent-color: var(--green); }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
