: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;
  place-items: center;
  isolation: isolate;
  padding: max(18px, env(safe-area-inset-top)) 0 var(--safe-bottom);
  background: #100b06;
}

.intro-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0704;
}

.intro-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 1;
  transform: none;
  filter: none;
}

.intro-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 4, 2, 0.06), transparent 24%, transparent 76%, rgba(6, 4, 2, 0.18));
}

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

.intro-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(67%, 330px);
  margin: clamp(110px, 15svh, 160px) auto 0;
  padding: 20px 0;
  text-align: center;
  animation: rise 700ms 120ms both;
}

.intro-copy { max-width: 100%; }

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

.intro-content .eyebrow { line-height: 1.45; }

.intro-content .primary-button {
  width: min(86%, 260px);
  margin-right: auto;
  margin-left: auto;
}

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(2.6rem, 12vw, 4rem); }
h2 { font-size: clamp(2.5rem, 10vw, 4.5rem); }

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

.intro-copy > p {
  max-width: 28ch;
  margin-bottom: 16px;
  margin-left: auto;
  margin-right: auto;
  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; }

.instagram-callout {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(255, 202, 92, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 191, 63, 0.11), rgba(192, 91, 9, 0.07)),
    rgba(255, 255, 255, 0.035);
}

.instagram-callout svg {
  grid-row: 1 / 3;
  width: 34px;
  fill: var(--amber);
}

.instagram-callout p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.instagram-callout strong {
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.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;
}

.save-button {
  border-color: rgba(244, 165, 28, 0.52);
  color: #211202;
  background: linear-gradient(135deg, #ffd15a, var(--amber));
}

.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) {
  .intro-content { width: min(66%, 310px); margin-top: 90px; padding: 8px 0; }
  .intro-content h1 { font-size: clamp(2.25rem, 10.5vw, 3.35rem); }
  .intro-content .eyebrow { margin-bottom: 6px; font-size: 0.57rem; }
  .intro-copy > p { margin-bottom: 10px; font-size: 0.78rem; line-height: 1.35; }
  .intro-content .primary-button { min-height: 48px; padding: 10px 14px; }
  .privacy-note { margin-top: 8px !important; font-size: 0.58rem !important; }
  .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; }
}
