:root {
  --bg: #0b0d12;
  --fg: #e9eef7;
  --muted: #aab4c5;
  --btn: #1f2430;
  --btn2: #141824;
  --good: #1ee56b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial; }
html, body { overscroll-behavior: none; }
button {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--fg);
  background: var(--btn);
}
button:disabled { opacity: 0.55; }
button.primary { background: #2a3143; }
button.secondary { background: var(--btn2); }
button.big { padding: 16px 18px; font-size: 18px; }

body.splashLock { overflow: hidden; }

.splash{
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  opacity: 1;
  transition: opacity 420ms ease;
}
.splash.hidden{ opacity: 0; pointer-events:none; }
.splashVideo{ width:100%; height:100%; object-fit:cover; display:block; }

/* Home */
.home {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}
.homeInner {
  width: min(92vw, 520px);
  display: grid;
  gap: 14px;
  text-align: center;
}
.homeTitle { margin: 0; font-size: 34px; letter-spacing: 0.2px; }
.homeSub { margin: 0; color: var(--muted); }

/* Capture */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.top .topRow {
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.titleSmall { margin: 0; font-size: 18px; }
#status { margin: 0; color: var(--muted); }

.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: #000;
  min-height: 420px;
}
#video {
  width: 100%;
  height: min(72vh, 640px);
  object-fit: cover;
  display: block;
}
#hud {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(86vw, 520px);
  height: min(86vw, 520px);
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.6));
}
.controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr;
}
button.capture { background: #2a3143; }
button.capture.ready { background: rgba(30,229,107,0.20); border-color: rgba(30,229,107,0.65); }

/* Viewer modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9998;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 12px;
  gap: 10px;
}
.modalTop {
  position: relative;
  z-index: 5;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.modalTitle { font-weight: 600; }
.modalBtns { display:flex; gap:10px; align-items:center; }
.viewerArea {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 60vh;
}
.viewerCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* critical iOS fix */
  background: #000;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
}
.viewerGestures {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
}
