:root {
  --jungle: #153b2f;
  --jungle-dark: #0d2a21;
  --lime: #c9ff62;
  --banana: #ffd84d;
  --cream: #fff8e8;
  --paper: rgba(255, 255, 255, 0.94);
  --ink: #17201d;
  --muted: #66746e;
  --line: rgba(23, 32, 29, 0.12);
  --shadow: 0 24px 70px rgba(11, 45, 34, 0.22);
  --radius: 32px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--jungle-dark);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(201, 255, 98, 0.27), transparent 30rem),
    radial-gradient(circle at 92% 90%, rgba(255, 216, 77, 0.22), transparent 34rem),
    linear-gradient(145deg, #174b38 0%, #0d2a21 100%);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(255, 216, 77, 0.75);
  outline-offset: 4px;
}

.shell {
  position: relative;
  z-index: 2;
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
  color: white;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.2);
  font-size: 30px;
  backdrop-filter: blur(12px);
}

.brand-name {
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  font-weight: 950;
  letter-spacing: 0.1em;
}

.brand-tag {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}

.card {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stage {
  display: none;
}

.stage.active {
  display: block;
  animation: stage-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes stage-in {
  from {
    transform: translateY(10px) scale(0.99);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.hero-card {
  display: none;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  align-items: center;
  min-height: 650px;
}

.hero-card.active {
  display: grid;
}

.hero-copy {
  padding: clamp(34px, 6vw, 72px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--jungle);
  background: rgba(201, 255, 98, 0.78);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

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

h1 {
  max-width: 680px;
  margin: 22px 0 18px;
  font-size: clamp(2.65rem, 6vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.lede {
  max-width: 540px;
  margin-bottom: 30px;
  color: #52605a;
  font-size: clamp(1.06rem, 2vw, 1.32rem);
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

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

.button.primary {
  color: #10251e;
  background: var(--banana);
  box-shadow: 0 10px 28px rgba(169, 123, 0, 0.23);
}

.button.primary:hover {
  background: #ffe16b;
}

.button.secondary {
  color: var(--jungle);
  background: #edf2ef;
  box-shadow: inset 0 0 0 1px rgba(21, 59, 47, 0.1);
}

.button.giant {
  min-height: 66px;
  padding: 0 28px;
  font-size: 1.08rem;
}

.button-icon {
  font-size: 1.4rem;
}

.text-button {
  display: block;
  margin-top: 14px;
  padding: 8px 0;
  border: 0;
  color: var(--jungle);
  background: transparent;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-color: rgba(21, 59, 47, 0.28);
  text-underline-offset: 4px;
  cursor: pointer;
}

.microcopy,
.guardian-note {
  max-width: 560px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.microcopy {
  margin: 24px 0 8px;
}

.guardian-note {
  margin-bottom: 0;
  font-weight: 750;
}

.hero-art {
  position: relative;
  display: grid;
  height: 100%;
  min-height: 650px;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.85), transparent 11rem),
    linear-gradient(145deg, #b5f14e, #7fcf5a);
}

.hero-art::before,
.hero-art::after {
  position: absolute;
  width: 300px;
  height: 300px;
  border: 45px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  content: "";
}

.hero-art::before {
  top: -190px;
  right: -110px;
}

.hero-art::after {
  bottom: -210px;
  left: -120px;
}

.monkey-orbit {
  position: relative;
  display: grid;
  width: min(340px, 78vw);
  aspect-ratio: 1;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(21, 59, 47, 0.2);
  border-radius: 50%;
  animation: orbit 18s linear infinite;
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

.big-monkey {
  filter: drop-shadow(0 22px 20px rgba(44, 86, 48, 0.22));
  font-size: clamp(9rem, 22vw, 14rem);
  transform: rotate(-4deg);
  animation: monkey-bob 3.8s ease-in-out infinite;
}

@keyframes monkey-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}

.banana {
  position: absolute;
  z-index: 2;
  font-size: 3.2rem;
  filter: drop-shadow(0 10px 10px rgba(44, 86, 48, 0.18));
}

.banana-left {
  top: 19%;
  left: 10%;
  transform: rotate(-24deg);
}

.banana-right {
  right: 12%;
  bottom: 18%;
  transform: rotate(28deg);
}

.camera-card,
.loading-card,
.result-card,
.error-card {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
}

.stage-heading {
  margin-bottom: 22px;
}

.stage-heading p,
.loading-message,
.error-card p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.camera-frame {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 8px solid #102f25;
  border-radius: 28px;
  background: #071c16;
  box-shadow: 0 18px 40px rgba(13, 42, 33, 0.25);
}

#camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.face-guide {
  position: absolute;
  inset: 14% 21%;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 48% 48% 44% 44%;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.camera-badge {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  color: white;
  background: rgba(8, 30, 23, 0.66);
  font-size: 0.75rem;
  font-weight: 800;
  backdrop-filter: blur(10px);
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: clamp(6rem, 30vw, 11rem);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.countdown.flash::after {
  position: absolute;
  inset: 0;
  background: white;
  content: "";
  animation: flash 220ms ease-out both;
}

@keyframes flash {
  from { opacity: 0.95; }
  to { opacity: 0; }
}

.camera-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.loader-monkey,
.error-monkey {
  margin: 4px 0 18px;
  font-size: 6rem;
}

.loader-monkey {
  animation: monkey-spin 1.1s ease-in-out infinite alternate;
}

@keyframes monkey-spin {
  from { transform: rotate(-8deg) scale(0.96); }
  to { transform: rotate(8deg) scale(1.04); }
}

.loading-card h2,
.result-card h2,
.error-card h2 {
  margin-top: 18px;
}

.progress-track {
  width: min(420px, 88%);
  height: 12px;
  margin: 24px auto;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebe8;
}

.progress-bar {
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fdc59, var(--banana));
  animation: progress 1.7s ease-in-out infinite alternate;
}

@keyframes progress {
  from { transform: translateX(-25%); }
  to { transform: translateX(145%); }
}

.captured-preview {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: 5px solid white;
  border-radius: 24px;
  box-shadow: 0 10px 26px rgba(13, 42, 33, 0.16);
}

.result-frame {
  position: relative;
  width: min(100%, 590px);
  margin: 24px auto 0;
}

#resultImage {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 8px solid white;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(13, 42, 33, 0.2);
}

.result-stamp {
  position: absolute;
  right: -10px;
  bottom: 20px;
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 3px solid var(--jungle);
  border-radius: 50%;
  color: var(--jungle);
  background: var(--lime);
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1.05;
  letter-spacing: 0.05em;
  transform: rotate(-9deg);
  box-shadow: 0 10px 24px rgba(13, 42, 33, 0.18);
}

.error-card {
  max-width: 660px;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 22px 14px 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.75rem;
  text-align: center;
}

.leaf {
  position: fixed;
  z-index: 1;
  width: 360px;
  height: 520px;
  border-radius: 100% 0 100% 0;
  background: rgba(139, 226, 85, 0.09);
  pointer-events: none;
}

.leaf-one {
  top: -220px;
  left: -120px;
  transform: rotate(22deg);
}

.leaf-two {
  right: -160px;
  bottom: -260px;
  transform: rotate(198deg);
}

.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 780px) {
  :root {
    --radius: 25px;
  }

  .shell {
    width: min(100% - 18px, 680px);
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .brand {
    margin-bottom: 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 26px;
  }

  .hero-card.active {
    display: block;
  }

  .hero-copy {
    padding: 34px 24px 30px;
    text-align: center;
  }

  .hero-copy .eyebrow,
  .hero-copy .button,
  .hero-copy .text-button {
    margin-right: auto;
    margin-left: auto;
  }

  .hero-copy .lede,
  .hero-copy .microcopy,
  .hero-copy .guardian-note {
    margin-right: auto;
    margin-left: auto;
  }

  h1 {
    margin-top: 18px;
    font-size: clamp(2.55rem, 13.5vw, 4.4rem);
  }

  .button.giant {
    width: 100%;
  }

  .hero-art {
    min-height: 260px;
  }

  .monkey-orbit {
    width: 230px;
  }

  .big-monkey {
    font-size: 9rem;
  }

  .banana {
    font-size: 2.4rem;
  }

  .camera-card,
  .loading-card,
  .result-card,
  .error-card {
    padding: 26px 18px;
  }

  .camera-frame {
    border-width: 5px;
    border-radius: 22px;
  }

  .result-stamp {
    right: 6px;
    bottom: 12px;
    width: 78px;
    height: 78px;
    font-size: 0.62rem;
  }

  .result-actions .button {
    flex: 1 1 190px;
  }
}

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