:root {
  --bg: #0b0b0f;
  --panel: rgba(18, 18, 24, 0.72);
  --panel-solid: #14141b;
  --stroke: rgba(255, 255, 255, 0.12);
  --text: #f4f4f8;
  --muted: #a4a4b4;
  --accent: #6d5efc;
  --accent-2: #00d4a0;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

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

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 0%, #16161f 0%, #08080b 70%);
}

#camera { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

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

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b));
}
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud-bottom { display: flex; flex-direction: column; gap: 10px; align-items: center; }

.brand {
  pointer-events: none;
  font-weight: 650;
  font-size: 14px;
  letter-spacing: 0.2px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  padding: 7px 11px;
  border-radius: 999px;
}
.brand .tag { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 4px; }

.stats {
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 9px;
  white-space: pre;
  text-align: right;
  min-width: 120px;
}

.controls, .actions {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 8px;
  max-width: min(680px, 96vw);
}

.ctrl { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.ctrl select {
  appearance: none;
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 13px;
  min-width: 108px;
}
.ctrl.toggle { flex-direction: row; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text); padding-top: 14px; }
.ctrl.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid var(--stroke);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 11px;
  transition: transform 0.06s ease, background 0.15s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8b7dff); border-color: transparent; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { font-size: 16px; padding: 14px 28px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- Capture overlay ---------- */
.capture {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(6, 6, 9, 0.9);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.capture img { max-width: min(92vw, 480px); max-height: 68vh; border-radius: var(--radius); border: 1px solid var(--stroke); }
.capture-actions { display: flex; gap: 10px; }

/* ---------- Start gate ---------- */
.gate {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 20%, #1a1a26 0%, #08080b 75%);
}
.gate-card {
  max-width: 380px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 28px 24px;
  backdrop-filter: blur(12px);
}
.gate-card h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: -0.4px; }
.gate-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.gate-card .fineprint { font-size: 11.5px; margin-top: 14px; margin-bottom: 0; }
.gate-error { margin-top: 14px; color: #ff8080; font-size: 13px; }

.hidden { display: none !important; }

@media (max-width: 520px) {
  .ctrl select { min-width: 92px; }
  .stats { font-size: 10.5px; min-width: 104px; }
}
