:root {
  color-scheme: dark;
  --blue: #087bff;
  --green: #22d66f;
  --white: #fff;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
}

.face-screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  overflow: hidden;
  background: #050505;
}

/* Keep the camera feed full-frame. The Canvas overlay below punches out the
   oval so pixels outside it are black even on iOS Safari. */
.face-screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Preserve the camera's portrait source ratio.  The native flow uses a
     portrait 3:4 frame; cover would zoom that frame to the phone's taller
     screen and make the face appear much too large at the same distance. */
  object-fit: contain;
  object-position: center;
  transform: scaleX(-1);
  background: #050505;
  z-index: 0;
}

.camera-mask {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
  z-index: 1;
}

.shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.34) 0%, rgba(0,0,0,.16) 28%, rgba(0,0,0,.22) 78%, rgba(0,0,0,.6) 100%);
  pointer-events: none;
  z-index: 2;
}

.status-dot {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: #20dc68;
  box-shadow: 0 0 9px rgba(32,220,104,.68);
  z-index: 4;
}

.close-button {
  position: absolute;
  top: calc(max(72px, env(safe-area-inset-top) + 52px));
  right: 4.2vw;
  width: 82px;
  height: 82px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #33404d;
  font-size: 54px;
  font-weight: 300;
  line-height: 76px;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.2);
  z-index: 5;
}

.instruction {
  position: absolute;
  top: 23.5%;
  left: 10px;
  right: 10px;
  text-align: center;
  color: #fff;
  font-size: clamp(22px, 5.2vw, 42px);
  font-weight: 700;
  letter-spacing: -.03em;
  text-shadow: 0 1px 3px rgba(0,0,0,.25);
  z-index: 4;
}

.face-oval {
  position: absolute;
  left: 50%;
  top: 32.4%;
  width: 57vw;
  aspect-ratio: .75;
  transform: translateX(-50%);
  border: 11px solid var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 0 24px rgba(0,123,255,.15);
  transition: width .5s ease, border-width .5s ease, top .5s ease;
  z-index: 3;
  pointer-events: none;
}

.face-oval.near {
  width: 70vw;
  border-width: 11px;
  top: 28.5%;
}

.face-oval.done { border-color: var(--green); }

.camera-state {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 13%;
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: 14px;
  opacity: 0;
  transition: opacity .2s;
  z-index: 5;
}

.camera-state.show { opacity: 1; }

.start-button,
.import-button {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  background: rgba(255,255,255,.92);
  color: #101820;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  z-index: 4;
}

.start-button { bottom: 10%; display: none; }

.import-button {
  bottom: 5%;
  display: none;
  background: rgba(0,0,0,.42);
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
}

.complete-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 10%;
  padding: 18px 16px;
  border-radius: 20px;
  background: rgba(15,15,15,.86);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(16px);
  text-align: center;
  z-index: 6;
}

.complete-title { color: #fff; font-size: 21px; font-weight: 700; }
.complete-subtitle { margin-top: 5px; color: rgba(255,255,255,.72); font-size: 13px; }

.complete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.complete-actions button {
  border: 0;
  border-radius: 10px;
  padding: 11px 8px;
  background: #fff;
  color: #111;
  font-weight: 700;
  font-size: 13px;
}

.complete-actions button:last-child {
  grid-column: 1 / -1;
  background: #2a2a2a;
  color: #fff;
}

.brand {
  position: absolute;
  bottom: calc(6.3% + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.08em;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
  z-index: 4;
}

.brand span { font-weight: 600; margin-left: 2px; }

.step-mark {
  position: absolute;
  left: 16px;
  bottom: calc(5.3% + env(safe-area-inset-bottom));
  color: rgba(255,255,255,.72);
  font-size: 12px;
  opacity: 0;
  z-index: 5;
}

.face-screen.idle .start-button,
.face-screen.idle .import-button { display: block; }
.face-screen.idle .camera-state { opacity: 1; }
.face-screen.running .camera-state { opacity: 0; }
.face-screen.complete .instruction,
.face-screen.complete .face-oval,
.face-screen.complete .step-mark { opacity: 0; }
.face-screen.complete .brand { opacity: .7; }

@media (max-width: 600px) {
  .close-button {
    width: 64px;
    height: 64px;
    font-size: 44px;
    line-height: 59px;
    top: calc(max(58px, env(safe-area-inset-top) + 42px));
    right: 5vw;
  }

  .instruction { top: 25.3%; font-size: 24px; }
  .face-oval { border-width: 8px; }
  .face-oval.near { border-width: 8px; }
  .brand { font-size: 27px; bottom: calc(7.1% + env(safe-area-inset-bottom)); }
  .step-mark { bottom: calc(6.1% + env(safe-area-inset-bottom)); }
}
