/* Face Check — mobile-first */
:root {
  --bg: #0f1419;
  --card: #1a2332;
  --ink: #e8eef7;
  --muted: #8b9bb4;
  --accent: #3d8bfd;
  --accent2: #22c55e;
  --danger: #f87171;
  --warn: #fbbf24;
  --line: #2a3648;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --pad: 16px;
  --touch: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}

img, video, canvas, svg { max-width: 100%; height: auto; display: block; }

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    max(var(--pad), var(--safe-top))
    max(var(--pad), var(--safe-right))
    max(48px, calc(var(--pad) + var(--safe-bottom)))
    max(var(--pad), var(--safe-left));
}

.top h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 5vw, 1.6rem);
  letter-spacing: -0.02em;
  word-wrap: break-word;
}

.tagline {
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.45;
  font-size: clamp(0.9rem, 3.6vw, 0.95rem);
}

.how {
  background: #121a24;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  width: 100%;
}
.how strong { display: block; margin-bottom: 6px; }
.how ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: 100%;
}
.badge {
  display: inline-block;
  max-width: 100%;
  font-size: 0.72rem;
  line-height: 1.3;
  padding: 6px 10px;
  border-radius: 999px;
  background: #243044;
  color: var(--muted);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.badge.ok { color: #bbf7d0; border-color: #166534; background: #14532d55; }
.badge.bad { color: #fecaca; border-color: #7f1d1d; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
  width: 100%;
}
.mode {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  min-height: var(--touch);
  padding: 12px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}
.mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.panel { display: none; width: 100%; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.card h2 { margin: 0 0 6px; font-size: clamp(1.05rem, 4.2vw, 1.15rem); }
.muted { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; line-height: 1.4; }
.opt { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  width: 100%;
}
.field input {
  width: 100%;
  max-width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1419;
  color: var(--ink);
  font-size: 16px; /* avoid iOS zoom */
  -webkit-appearance: none;
  appearance: none;
}

/* Camera preview — width-driven aspect box that shrinks if max-height binds */
.preview {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 4;
  max-height: min(62dvh, 480px);
  /* when max-height caps, shrink width to keep ratio (avoids overflow) */
  height: auto;
  background: #0a0e14;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 0 auto 12px;
}
@supports not (max-height: 1dvh) {
  .preview { max-height: 62vh; }
}

.preview video,
.preview canvas,
.preview .ph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  background: #0a0e14;
}

/* Front-camera mirror for natural selfie UX (frames sent to server are also mirrored in JS) */
.preview video {
  transform: scaleX(-1);
  -webkit-transform: scaleX(-1);
}

.preview .ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  z-index: 1;
}

.preview .oval {
  position: absolute;
  inset: 12% 18%;
  border: 2px dashed rgba(61, 139, 253, 0.55);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}

.challenge-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(10px, 3vw, 18px);
  background: linear-gradient(transparent 35%, rgba(0, 0, 0, 0.78));
  pointer-events: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.preview .ph[hidden],
.preview video[hidden],
.preview canvas[hidden] { display: none !important; }

.challenge-overlay[hidden] { display: none !important; }

.challenge-overlay .arrow {
  font-size: clamp(2.4rem, 14vw, 3.5rem);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  margin-bottom: 4px;
}
.challenge-overlay .prompt {
  font-size: clamp(1rem, 4.2vw, 1.15rem);
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
  max-width: 100%;
  padding: 0 4px;
  overflow-wrap: anywhere;
}
.bar {
  width: 100%;
  max-width: 100%;
  height: 8px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent2);
  transition: width 0.15s ease;
}
.challenge-overlay .meta {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #cbd5e1;
  text-align: center;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
button.primary,
button.ghost {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 12px;
  min-height: var(--touch);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.status {
  margin-top: 12px;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.status.ok { color: var(--accent2); }
.status.err { color: var(--danger); }
.status.info { color: var(--warn); }

.result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #121a24;
  border: 1px solid var(--line);
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.result h3 { margin: 0 0 8px; font-size: 1.3rem; }
.result h3.pass { color: var(--accent2); }
.result h3.fail { color: var(--danger); }
.result ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin .people { list-style: none; margin: 0; padding: 0; width: 100%; }
.admin .people li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  min-height: var(--touch);
}
.admin .people li:last-child { border-bottom: none; }
.admin .people li > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.admin .people button {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  border: 1px solid #7f1d1d;
  background: #450a0a55;
  color: #fecaca;
  border-radius: 8px;
  min-height: var(--touch);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  touch-action: manipulation;
}

.foot {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  margin-top: 8px;
  text-align: center;
  overflow-wrap: anywhere;
  padding-bottom: var(--safe-bottom);
}

/* Wider phones / tablets: buttons can sit in a row */
@media (min-width: 420px) {
  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .actions button {
    width: auto;
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
  }
}

@media (min-width: 640px) {
  .app { padding-top: 28px; }
  .preview {
    aspect-ratio: 4 / 3;
    max-height: min(70dvh, 520px);
  }
}

/* mobile-fix v20261104m2 */

.secondary-actions { margin-top: 8px; }
.photo-note { font-size: 0.85rem; margin: 8px 0 0; }
.status.warn { color: var(--warn); }
.status.err { color: var(--danger); white-space: pre-wrap; }
.status.ok { color: var(--accent2); }
.status.info { color: var(--muted); }
.err-pre { color: var(--danger); font-size: 0.8rem; overflow-x: auto; }
