:root {
  --indigo: #3D35E8;
  --violet: #6A35EE;
  --pink: #FF3D81;
  --lilac: #C9B8FA;
  --page: #f3f2f7;
  --ink: #17142b;
  --soft-ink: #5f5c7a;
  --white: #ffffff;
  --glow: #e9e4fb;
  --glow-2: #f7eff6;
  --logo: linear-gradient(110deg, var(--indigo), var(--violet) 45%, var(--pink));
  --font: Figtree, ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 28px;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(60rem 40rem at 10% -10%, var(--glow), transparent 60%),
    radial-gradient(50rem 40rem at 110% 110%, var(--glow-2), transparent 60%),
    var(--page);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body[data-screen="live"] { overflow: hidden; }

h1 { margin: 0; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
p { margin: 0; }
img, canvas, video, svg { display: block; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px;
  border: 0; border-radius: 999px;
  font: 800 17px/1 var(--font);
  text-decoration: none; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible, .wordmark-link:focus-visible {
  outline: 3px solid var(--pink); outline-offset: 3px;
}
.btn-primary {
  color: var(--white);
  background: var(--logo);
  box-shadow: 0 10px 24px -10px rgba(106, 53, 238, .7), inset 0 -2px 0 rgba(23, 20, 43, .15);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(106, 53, 238, .8); }
.btn-primary:active { transform: translateY(1px) scale(.98); }
.btn-primary:disabled { opacity: .7; cursor: progress; transform: none; }
.btn-ghost { color: var(--ink); background: var(--white); box-shadow: inset 0 0 0 2px #e0dcf3; }
.btn-ghost:hover { box-shadow: inset 0 0 0 2px var(--lilac); }
.btn-big { min-height: 64px; padding: 0 34px; font-size: 20px; width: 100%; max-width: 340px; }

.link-btn {
  background: none; border: 0; padding: 6px 4px;
  font: 700 15px/1.3 var(--font); color: var(--violet);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--violet) 35%, transparent);
  cursor: pointer;
}
.link-btn:hover { text-decoration-color: var(--violet); }

.privacy {
  font-size: 14px; font-weight: 600; color: var(--soft-ink); line-height: 1.45;
}
.privacy svg { display: inline-block; vertical-align: -2px; margin-right: 6px; color: var(--violet); }

.wordmark-link { display: inline-block; border-radius: 8px; }
.wordmark { height: 33px; width: auto; }

/* ---------- start ---------- */
.screen { min-height: 100vh; min-height: 100dvh; }
.start {
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.start-card {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px;
}
.hero-face {
  width: 128px; height: 128px; margin-top: 18px;
  filter: drop-shadow(0 18px 26px rgba(106, 53, 238, .35));
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
.start h1 { font-size: clamp(48px, 15vw, 76px); margin-top: 6px; }
.lede { font-size: clamp(20px, 5.6vw, 26px); font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.lede, .fb-msg { text-wrap: balance; }
.start .privacy { max-width: 340px; text-wrap: balance; }
.start-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 4px; }

/* ---------- live ---------- */
.live {
  display: grid; place-items: center;
  padding: 2vh 16px;
  background:
    radial-gradient(40rem 30rem at 20% 0%, var(--glow), transparent 70%),
    radial-gradient(40rem 30rem at 80% 100%, var(--glow-2), transparent 70%),
    var(--page);
}
.stage {
  position: relative;
  height: min(92dvh, 900px);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 36px;
  overflow: hidden;
  background: var(--ink);
  box-shadow: 0 40px 80px -30px rgba(61, 53, 232, .45), 0 0 0 8px var(--white);
  isolation: isolate;
}
.view { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

.topbar {
  position: absolute; z-index: 2; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 0;
}
.icon-btn {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  color: var(--ink); background: rgba(255, 255, 255, .88);
  box-shadow: 0 6px 16px -6px rgba(23, 20, 43, .4);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.icon-btn .snd-off, .icon-btn.is-off .snd-on { display: none; }
.icon-btn.is-off .snd-off { display: block; }
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); color: var(--ink);
  font: 800 15px/1.1 var(--font);
  box-shadow: 0 6px 16px -6px rgba(23, 20, 43, .35);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.best { font-variant-numeric: tabular-nums; }
.status {
  position: absolute; z-index: 2; left: 16px; right: 16px; top: 42%;
  width: fit-content; margin: 0 auto; text-align: center;
  font-size: 16px; padding: 12px 20px;
}
.controls {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 0 16px max(22px, calc(env(safe-area-inset-bottom) + 12px));
}
.btn-shutter { min-height: 60px; padding: 0 30px; font-size: 18px; box-shadow: 0 12px 30px -8px rgba(23, 20, 43, .55), 0 0 0 4px rgba(255, 255, 255, .85); }
.stage.is-glee { box-shadow: 0 40px 80px -30px rgba(255, 61, 129, .6), 0 0 0 8px var(--white), 0 0 0 14px var(--lilac); transition: box-shadow .3s ease; }
.flash { position: absolute; inset: 0; z-index: 3; background: var(--white); opacity: 0; pointer-events: none; }
.stage.is-flash .flash { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
.debug {
  position: absolute; z-index: 4; left: 8px; right: 8px; bottom: 96px;
  font: 600 12px/1.3 ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.55);
  padding: 6px 8px; border-radius: 8px;
}

/* Phones: the camera fills the screen */
@media (max-width: 600px), (max-height: 520px) and (pointer: coarse) {
  .live { padding: 0; }
  .stage {
    position: fixed; inset: 0;
    width: 100%; height: 100%; max-width: none; aspect-ratio: auto;
    border-radius: 0; box-shadow: none;
  }
  .stage.is-glee { box-shadow: inset 0 0 0 6px var(--pink); }
}

/* ---------- fallback ---------- */
.fallback {
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}
.fb-card {
  width: 100%; max-width: 460px;
  display: grid; gap: 20px;
  grid-template-areas: "copy" "demo" "foot";
}
.fb-copy { grid-area: copy; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.fb-foot { grid-area: foot; display: flex; flex-direction: column; gap: 14px; }
.fallback h1 { margin-top: 8px; font-size: clamp(30px, 8.6vw, 52px); line-height: 1.04; }
.fb-msg { font-size: 16px; line-height: 1.5; font-weight: 500; color: var(--soft-ink); }
.fb-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.fb-actions .btn { flex: 1 1 auto; }
.demo-frame {
  grid-area: demo;
  position: relative; justify-self: center;
  width: 100%; aspect-ratio: 4 / 5; max-height: 52dvh;
  border-radius: var(--radius); overflow: hidden;
  background: var(--glow);
  box-shadow: 0 30px 60px -30px rgba(61, 53, 232, .45), 0 0 0 6px var(--white);
}
.demo { width: 100%; height: 100%; }

@media (min-width: 900px) {
  .fb-card {
    max-width: 1040px; column-gap: 72px; row-gap: 24px; align-items: center;
    grid-template-columns: 1fr auto;
    grid-template-areas: "copy demo" "foot demo";
  }
  .fb-copy { align-self: end; }
  .fb-foot { align-self: start; }
  .demo-frame { width: min(400px, 40vw); aspect-ratio: 9 / 16; max-height: 84dvh; }
  .fallback h1 { font-size: 56px; }
  .fb-msg { font-size: 17px; max-width: 34em; }
}

/* ---------- photo sheet ---------- */
.sheet {
  width: fit-content; min-width: min(320px, calc(100% - 32px)); max-width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--white); color: var(--ink);
  box-shadow: 0 40px 90px -20px rgba(23, 20, 43, .5);
  overflow: auto;
}
.sheet::backdrop { background: rgba(23, 20, 43, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet[open]:not(:modal) { position: fixed; inset: 16px; margin: auto; z-index: 10; }
.sheet-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card-img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(64dvh, 700px); margin: 0 auto; border-radius: 18px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sheet-actions .btn { flex: 1 1 130px; padding: 0 16px; white-space: nowrap; }
.sheet .privacy { text-align: center; font-size: 13px; }

.noscript { padding: 24px 16px; text-align: center; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- ?embed: only the demo stage, filling the frame ---------- */
html.is-embed, html.is-embed body {
  margin: 0; width: 100%; height: 100%; min-height: 0;
  overflow: hidden; background: #ece6fa;
}
html.is-embed body > :not(.embed-demo) { display: none !important; }
html.is-embed .embed-demo { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ?app: inside the home page's phone, which has its own Back, so no logo or links home */
.is-app .wordmark-link,
.is-app .start-links a[href="/"],
.is-app .fb-actions a[href="/"] {
  display: none;
}

/* ?app start screen: laid out like the home page's Glee Meter poster */
.is-app .start {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
}

.is-app .app-demo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.is-app .start::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #17142bf2 0%, #17142bcc 30%, #17142b00 58%);
  pointer-events: none;
}

.is-app .start-card {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  max-width: none;
  gap: 14px;
  padding: 0 36px 70px;
  color: #fff;
}

.is-app .hero-face,
.is-app .start .privacy,
.is-app .start-links {
  display: none;
}

.is-app .start h1 {
  margin: 0;
  color: #fff;
  font-size: 62px;
  line-height: 1;
}

.is-app .start.is-off h1 { font-size: 44px; line-height: 1.05; white-space: pre-line; }
.is-app .lede {
  max-width: 300px;
  margin: 0;
  color: #fff;
  opacity: 0.9;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.35;
}

.is-app #startBtn {
  width: auto;
  min-height: 0;
  margin-top: 18px;
  padding: 20px 36px;
  background: #fff;
  box-shadow: 0 10px 24px -8px rgba(23, 20, 43, 0.6);
  color: var(--ink);
  font-size: 23px;
}

.is-app #startBtn:hover {
  box-shadow: 0 0 0 4px #ffffff4d, 0 10px 24px -8px rgba(23, 20, 43, 0.6);
  transform: none;
}

/* Replaces the old Take photo button: the photo is snapped automatically at 100% */
.live .hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 3;
  translate: -50% 0;
  white-space: nowrap;
}

/* The photo card: a small close in the corner; Share and Download carry icons */
.sheet-body { position: relative; }
.sheet-close {
  position: absolute;
  top: 26px;
  right: 26px;
  z-index: 1;
}
.sheet-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.sheet-actions .btn svg { flex: none; }
