:root {
  --bg-top: #11163a;
  --bg-bottom: #252e63;
  --text: #f4ecdc;
  --muted: #a9acc9;
  --accent: #f6c76e;
  --ok: #5ad18a;
  --err: #e0675c;
  --dim-bg: #000;
  --dim-text: #3b3f55;
  --card: rgba(255, 255, 255, .07);
  --card-border: rgba(255, 255, 255, .12);
  --ghost: rgba(255, 255, 255, .08);
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg-top); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%) fixed;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 12% 14%, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1px 1px at 82% 9%, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.5px 1.5px at 30% 32%, rgba(255, 255, 255, .4), transparent),
    radial-gradient(1px 1px at 68% 26%, rgba(255, 255, 255, .5), transparent),
    radial-gradient(1.5px 1.5px at 90% 45%, rgba(255, 255, 255, .35), transparent),
    radial-gradient(1px 1px at 8% 58%, rgba(255, 255, 255, .45), transparent),
    radial-gradient(1px 1px at 52% 7%, rgba(255, 255, 255, .5), transparent);
}

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
}

.screen.center { align-items: center; justify-content: center; text-align: center; gap: 16px; }

h1 { font-size: 22px; margin: 8px 0 0; text-align: center; }
.help { color: var(--muted); font-size: 14px; line-height: 1.45; text-align: center; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 0 0 12px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: var(--err); text-align: center; font-size: 14px; margin: 8px 0 0; }

.logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 34px; font-weight: 700; letter-spacing: .3px; margin-top: 56px;
}
.tagline { text-align: center; color: var(--muted); font-size: 15px; margin: 8px 0 48px; }

button {
  font: inherit;
  color: var(--text);
  width: 100%;
  min-height: 56px;
  border-radius: var(--radius);
  border: 0;
  cursor: pointer;
}

.role-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px 18px; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--card-border);
}
.role-btn b { display: block; font-size: 17px; }
.role-btn small { display: block; font-size: 13px; opacity: .75; margin-top: 3px; }
.ico {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(246, 199, 110, .18);
}

.primary { background: var(--accent); color: #1b1e3a; font-weight: 700; font-size: 17px; margin-bottom: 10px; }
.ghost { background: var(--ghost); font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.screen.center .primary { max-width: 320px; }

.preview {
  height: 220px; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3a3f5c, #1b1e30);
}
.preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mirrored { transform: scaleX(-1); }

.big-code { font-size: 48px; letter-spacing: 8px; font-weight: 700; text-align: center; color: var(--accent); margin: 14px 0 4px; }

.code-boxes { position: relative; display: flex; gap: 8px; justify-content: center; margin: 28px 0 12px; }
.code-box {
  width: 46px; height: 60px; border-radius: 12px;
  background: var(--ghost); border: 1px solid rgba(255, 255, 255, .18);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.code-box.on { border-color: var(--accent); }
.code-boxes input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; background: transparent; color: transparent; font-size: 16px;
}

.watch { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 10px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot.lost { background: var(--err); }
.dot.pending { background: var(--muted); }
.video-wrap {
  position: relative; flex: 1; min-height: 240px; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3a3f5c, #1b1e30);
}
/* The video fills the frame box and object-fit centres the picture in it (landscape feeds sit mid-frame). */
.video-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; display: block; }
.video-wrap video.lost { filter: grayscale(1) brightness(.6); }
.banner {
  position: absolute; top: 14px; left: 14px; right: 14px; padding: 12px;
  background: var(--err); color: #fff; border-radius: 14px; text-align: center; font-weight: 700;
}
.banner small { display: block; font-weight: 500; opacity: .9; margin-top: 2px; }
.banner-btn { margin-top: 10px; min-height: 44px; background: rgba(0, 0, 0, .25); font-weight: 600; }
.tap-sound { position: absolute; left: 14px; right: 14px; bottom: 14px; background: rgba(0, 0, 0, .55); font-weight: 600; }

.meter { display: flex; gap: 4px; align-items: flex-end; height: 30px; margin: 14px 0 6px; justify-content: center; }
.meter i { display: block; width: 8px; border-radius: 4px; background: var(--accent); opacity: .4; }
.meter i.on { opacity: 1; }
.meter i:nth-child(1) { height: 6px; }
.meter i:nth-child(2) { height: 10px; }
.meter i:nth-child(3) { height: 14px; }
.meter i:nth-child(4) { height: 18px; }
.meter i:nth-child(5) { height: 22px; }
.meter i:nth-child(6) { height: 26px; }
.meter i:nth-child(7) { height: 30px; }

.actions { display: flex; gap: 10px; }
.actions .ghost { margin-bottom: 0; }

/* The whole black section is the tap target; moon, status and hint sit together in the middle. */
.screen[data-screen="baby-dark"] {
  position: fixed; inset: 0; z-index: 10; background: var(--dim-bg); color: var(--dim-text);
  align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding:
    calc(20px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right))
    calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  max-width: none; font-size: 13px;
}
.dark-hint { opacity: .7; }

.toast {
  position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: 90vw; padding: 12px 18px; border-radius: 14px; z-index: 20;
  background: rgba(244, 236, 220, .95); color: #1b1e3a; font-size: 14px; font-weight: 600;
}
