:root {
  color-scheme: dark;
  --ink: #f7edda;
  --muted: #cbbb9d;
  --earth: #120d07;
  --panel: #21170d;
  --amber: #f4a51c;
  --acid: #c4dc55;
  --line: rgba(255, 239, 204, 0.18);
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--earth);
}

body {
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, rgba(166, 83, 7, 0.3), transparent 35%),
    linear-gradient(155deg, #261609, var(--earth) 55%);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.015);
  transition: opacity 240ms ease, transform 350ms ease, visibility 240ms;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.intro-screen {
  display: grid;
  align-items: end;
  isolation: isolate;
  padding: max(22px, env(safe-area-inset-top)) 22px var(--safe-bottom);
}

.intro-art {
  position: absolute;
  inset: 0;
  z-index: -3;
  overflow: hidden;
}

.intro-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
  transform: scale(1.08);
  filter: saturate(0.8) contrast(1.08);
}

.intro-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 4, 2, 0.12) 10%, rgba(10, 7, 3, 0.48) 50%, #100b06 84%);
}

.ambient-glow {
  position: absolute;
  z-index: -2;
  width: 70vw;
  height: 70vw;
  left: -20vw;
  top: 20vh;
  border-radius: 50%;
  background: rgba(226, 121, 17, 0.23);
  filter: blur(60px);
}

.intro-content {
  width: min(100%, 480px);
  margin: 0 auto;
  animation: rise 700ms 120ms both;
}

.eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--acid);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p { margin-top: 0; }

h1,
h2 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.87;
}

h1 { font-size: clamp(3.5rem, 17vw, 6.4rem); }
h2 { font-size: clamp(2.5rem, 10vw, 4.5rem); }

h1 em {
  color: var(--amber);
  font-weight: 400;
}

.intro-content > p {
  max-width: 30ch;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  color: #1b1004;
  background: linear-gradient(135deg, #ffd15a, var(--amber) 72%);
  box-shadow: 0 14px 38px rgba(238, 130, 15, 0.23), inset 0 1px rgba(255, 255, 255, 0.55);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}

.primary-button:active { transform: scale(0.985); }
.primary-button svg { width: 23px; fill: currentColor; }

.privacy-note {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 13px auto 0 !important;
  color: rgba(247, 237, 218, 0.56) !important;
  font-size: 0.69rem !important;
  text-align: center;
}

.privacy-note span { color: var(--acid); }

.camera-screen { background: #000; }

.camera-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100%, calc(100svh * 9 / 16));
  height: min(100%, calc(100vw * 16 / 9));
  overflow: hidden;
  background: #090705;
  transform: translate(-50%, -50%);
}

#cameraVideo,
.story-frame,
.camera-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cameraVideo {
  object-fit: cover;
  transition: opacity 200ms ease;
}

#cameraVideo.is-mirrored { transform: scaleX(-1); }

.story-frame {
  z-index: 2;
  object-fit: contain;
  pointer-events: none;
}

.camera-shade {
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 18%, transparent 75%, rgba(0, 0, 0, 0.5));
}

.camera-status {
  position: absolute;
  z-index: 4;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 8, 4, 0.58);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.camera-status span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 10px var(--acid);
}

.camera-controls {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: 52px 84px 52px;
  align-items: center;
  justify-content: center;
  gap: clamp(26px, 10vw, 44px);
}

.round-button {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  color: #fff;
  background: rgba(10, 8, 4, 0.6);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.round-button svg { width: 23px; fill: currentColor; }

.shutter {
  display: grid;
  width: 84px;
  height: 84px;
  padding: 5px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.shutter span {
  width: 66px;
  height: 66px;
  border-radius: inherit;
  background: #fff;
  transition: transform 100ms ease, background 100ms ease;
}

.shutter:active span { transform: scale(0.88); background: var(--amber); }

.review-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: max(20px, env(safe-area-inset-top)) 20px var(--safe-bottom);
  overflow-y: auto;
  background:
    radial-gradient(circle at 80% 15%, rgba(195, 115, 20, 0.2), transparent 30%),
    linear-gradient(155deg, #24170b, #0e0a06 70%);
}

.review-header { width: min(100%, 390px); margin: 0 auto; }
.review-header h2 { margin-bottom: 0; }

.photo-result {
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 9 / 16;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 210, 128, 0.26);
  border-radius: 22px;
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.48);
}

.photo-result img { display: block; width: 100%; height: 100%; object-fit: cover; }

.review-actions { width: min(100%, 390px); margin: auto auto 0; }

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.text-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.share-hint {
  width: min(100%, 390px);
  min-height: 18px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
  text-align: center;
}

.permission-panel {
  position: absolute;
  z-index: 20;
  inset: 0;
  padding: 24px;
  place-content: center;
  text-align: center;
  background: rgba(12, 8, 4, 0.96);
}

.permission-panel:not([hidden]) { display: grid; }

.error-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  place-items: center;
  border: 1px solid var(--amber);
  border-radius: 50%;
  color: var(--amber);
  font: 700 2rem Georgia, serif;
}

.permission-panel h2 { font-size: 2.5rem; }
.permission-panel p { max-width: 34ch; margin: 0 auto 24px; color: var(--muted); line-height: 1.5; }
.permission-panel .primary-button { width: min(100%, 360px); margin: 0 auto; }

@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 700px) {
  .app-shell {
    width: min(100%, 480px);
    height: min(100svh, 900px);
    min-height: 680px;
    margin: max(0px, calc((100svh - 900px) / 2)) auto 0;
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  }
}

@media (max-height: 720px) {
  .review-screen { gap: 9px; padding-top: 14px; }
  .review-header .eyebrow { margin-bottom: 5px; }
  .review-header h2 { font-size: 2.35rem; }
  .photo-result { width: min(100%, 245px); }
  .primary-button { min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
