:root {
  color-scheme: light;
  --butter: #fff4a8;
  --butter-deep: #ffe47a;
  --cream: #fffbe4;
  --ink: #3a2b24;
  --soft-ink: #755f54;
  --rose: #ff7f9c;
  --rose-deep: #ec567a;
  --shadow: 0 22px 70px rgba(114, 79, 28, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--butter);
  color: var(--ink);
  font-family: "Lora", Georgia, serif;
}

button,
video {
  font: inherit;
}

.app,
.screen {
  min-height: 100svh;
  width: 100%;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  opacity: 0;
  transition: opacity 420ms ease;
}

.screen.is-active {
  display: grid;
  opacity: 1;
}

.start-screen {
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.68), transparent 28%),
    radial-gradient(circle at 82% 74%, rgba(255, 127, 156, 0.14), transparent 26%),
    linear-gradient(145deg, var(--cream), var(--butter) 58%, #ffe99a);
}

.start-copy {
  display: grid;
  justify-items: center;
  gap: 26px;
  text-align: center;
}

.spark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: var(--shadow);
  color: var(--rose-deep);
  font-family: "Chewy", system-ui, sans-serif;
  font-size: 42px;
  line-height: 1;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(4rem, 13vw, 9rem);
  font-weight: 400;
  line-height: 0.92;
  color: var(--ink);
  text-wrap: balance;
  text-shadow: 0 5px 0 rgba(255, 255, 255, 0.42);
}

.start-button {
  min-height: 58px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--rose);
  color: white;
  box-shadow: 0 15px 34px rgba(236, 86, 122, 0.34);
  cursor: pointer;
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(1.35rem, 3.8vw, 1.85rem);
  letter-spacing: 0;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.start-button:hover {
  background: var(--rose-deep);
  box-shadow: 0 18px 42px rgba(236, 86, 122, 0.42);
  transform: translateY(-2px);
}

.start-button:active {
  transform: translateY(1px) scale(0.99);
}

.start-button:focus-visible,
.camera-start:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.38);
  outline-offset: 5px;
}

.camera-screen,
.reveal-screen {
  place-items: center;
  background: #111;
}

.camera-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  transition: filter 420ms ease;
}

.camera-canvas {
  display: none;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 18px;
  padding: max(24px, env(safe-area-inset-top)) 18px 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.48), transparent 31%);
  transition: opacity 240ms ease;
}

.camera-title {
  margin: 0;
  text-align: center;
  color: white;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.camera-title {
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(2.2rem, 7vw, 5rem);
  line-height: 0.95;
}

.smile-meter {
  --smile-progress: 0;
  --meter-track: rgba(255, 255, 255, 0.34);
  --meter-ring: #ff7f9c;
  width: clamp(92px, 18vw, 132px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--meter-ring) calc(var(--smile-progress) * 1turn), var(--meter-track) 0),
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(16px);
  transition: background 160ms linear;
}

.smile-meter-core {
  width: 72%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 50%;
  background: rgba(255, 251, 228, 0.95);
  color: var(--ink);
  box-shadow:
    inset 0 0 0 1px rgba(58, 43, 36, 0.08),
    inset 0 0 22px rgba(255, 228, 122, 0.32);
}

.smile-meter-value {
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1;
}

.smile-meter-label {
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  font-weight: 700;
  color: var(--soft-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reveal-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.camera-screen.is-revealing .camera-feed {
  filter: blur(9px) brightness(0.68);
}

.camera-screen.is-waiting .camera-feed {
  filter: blur(10px) brightness(0.7);
}

.camera-screen.is-revealing .camera-overlay {
  opacity: 0;
}

.camera-screen.is-waiting .camera-overlay {
  opacity: 0;
}

.camera-screen.is-revealing .reveal-layer {
  opacity: 1;
  pointer-events: auto;
}

.camera-start {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: none;
  place-items: center;
  border: 0;
  background: rgba(12, 10, 8, 0.18);
  color: white;
  cursor: pointer;
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(2.7rem, 11vw, 7rem);
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 26px rgba(0, 0, 0, 0.62);
}

.camera-screen.is-waiting .camera-start {
  display: grid;
}

.denied-screen {
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, 0.64), transparent 28%),
    linear-gradient(145deg, var(--cream), var(--butter-deep));
}

.denied-screen p {
  max-width: 760px;
  margin: 0;
  color: var(--ink);
  font-family: "Chewy", system-ui, sans-serif;
  font-size: clamp(2.2rem, 9vw, 5.6rem);
  line-height: 1;
  text-align: center;
  text-wrap: balance;
}

.reveal-screen {
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(255, 244, 168, 0.35), transparent 44%),
    #0c0a08;
}

.reveal-video {
  width: min(92vw, 980px);
  max-height: 88svh;
  border-radius: 18px;
  box-shadow: 0 22px 90px rgba(0, 0, 0, 0.48);
  background: #000;
}

@media (max-width: 560px) {
  .start-screen {
    padding: 22px;
  }

  .spark {
    width: 58px;
    height: 58px;
    font-size: 36px;
  }

  .start-button {
    width: min(100%, 330px);
  }

  .reveal-screen {
    padding: 12px;
  }

  .reveal-layer {
    padding: 12px;
  }

  .reveal-video {
    width: 100%;
    border-radius: 12px;
  }
}
