:root {
  --yellow: #fcf419;
  --ink: #111111;
  --cream: #f8f6ef;
  --grey: #6b6b6b;
  --he: 'Rubik', system-ui, sans-serif;
  --round: 'Fredoka', 'Rubik', system-ui, sans-serif;
  --script: 'Mrs Saint Delafield', cursive;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: #000; }

body {
  font: 400 17px/1.4 var(--he);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

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

#app { max-width: 480px; margin: 0 auto; }

.screen {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- shared pieces ---------- */

.pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: min(100% - 2.5rem, 21rem);
  min-height: 3.6rem;
  margin: 0 auto;
  padding: .5rem 1.25rem;
  border: 0;
  border-radius: 999px;
  font: 700 1.3rem/1.1 var(--he);
  color: var(--ink);
  transition: transform .1s;
}
.pill:active:not(:disabled) { transform: scale(.97); }
.pill:disabled { opacity: .45; }
.pill.yellow { background: var(--yellow); }
.pill.shadow { box-shadow: 0 10px 22px -6px rgb(0 0 0 / .3); }
.pill.outline { background: #fff; border: 3px solid var(--yellow); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
}
.icon-btn svg { width: 100%; height: 100%; }

.polaroid {
  margin: 0;
  padding: 4.5% 4.5% 0;
  background: #fff;
}
.polaroid .photo {
  position: relative;
  aspect-ratio: 67 / 85; /* the magnet's photo window, 6.7 × 8.5 cm */
  overflow: hidden;
  background: #1d1d1d;
}
.polaroid.landscape .photo { aspect-ratio: 92 / 59; } /* 9.2 × 5.9 cm */
.polaroid .photo img,
.polaroid .photo video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.polaroid .caption {
  direction: ltr;
  min-height: 1.35em;
  padding: .12em .2em .18em;
  font: 400 2.4rem/1.1 var(--script);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  color: var(--ink);
}
.polaroid.small .caption { font-size: 1.55rem; }

.mirror { transform: scaleX(-1); }

/* ---------- 1. welcome ---------- */

.welcome { color: #fff; background: #0b0704; }

/* Default background: warm string lights. Replaced by the event photo when one is set. */
.hero {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 17%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 27% 12%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 43% 9%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 59% 9%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 75% 12%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 90% 18%, #ffe7a8 0 3px, rgb(255 205 110 / .45) 5px, transparent 22px),
    radial-gradient(circle at 6% 36%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 20% 31%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 35% 28%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 66% 28%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 81% 31%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 95% 36%, #ffe2a0 0 2px, rgb(255 205 110 / .35) 4px, transparent 16px),
    radial-gradient(circle at 22% 52%, rgb(255 196 92 / .28), transparent 60px),
    radial-gradient(circle at 78% 47%, rgb(255 196 92 / .22), transparent 80px),
    radial-gradient(circle at 50% 70%, rgb(255 170 70 / .18), transparent 150px),
    radial-gradient(ellipse at 50% 20%, #3b2a14, #150e07 60%, #070403);
}
.hero.photo-bg {
  background-size: cover;
  background-position: center;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgb(0 0 0 / .45), transparent 32%, transparent 52%, rgb(0 0 0 / .55) 80%, rgb(0 0 0 / .75));
}

.welcome-top {
  position: relative;
  padding: calc(var(--safe-top) + 1.75rem) 1rem 0;
  text-align: center;
}

.arc {
  display: block;
  width: min(21rem, 92%);
  margin: 0 auto -.35rem;
  overflow: visible;
  font: 600 27px var(--round);
  fill: var(--yellow);
}

.title {
  margin: 0;
  font: 800 clamp(3rem, 15.5vw, 4.25rem)/1 var(--he);
  letter-spacing: -.01em;
  text-shadow: 0 2px 18px rgb(0 0 0 / .35);
}
.title .amp {
  display: inline-block;
  margin: 0 .3em;
  font-size: .42em;
  vertical-align: .35em;
}

.welcome-bottom {
  position: relative;
  margin-top: auto;
  padding: 1rem 1rem calc(var(--safe-bottom) + .6rem);
}

.steps {
  position: relative;
  z-index: 1; /* in front of the sample magnets */
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  margin: 0 0 1rem;
  padding: .6rem .75rem .55rem;
  list-style: none;
  color: var(--ink);
}
/* the card itself, drawn separately so only its edge gets roughened */
.steps::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 1.1rem;
  background: var(--cream);
  filter: url(#rough);
}
.steps li:not(.dash) {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .35rem;
  line-height: 1.05;
}
.steps b { font: 700 .9rem/1.05 var(--he); }
.steps small { font: 500 .68rem/1 var(--he); margin-bottom: -.15rem; }
/* sized to each drawing's proportions */
.step-icon { width: 1.5rem; height: 2.5rem; }
.step-icon.plane-step { width: 2.5rem; height: 2.2rem; }
.step-icon.wide { width: 3.2rem; height: 2.4rem; }
.dash {
  flex: 1;
  min-width: .75rem;
  align-self: center;
  margin: 0 .4rem 1.4rem;
  border-top: 2px dashed #555;
}

/* Two sample magnets peeking out from behind the steps card, as in the design */
.sample-magnets {
  display: block;
  width: 44%;
  height: auto;
  margin: -.5rem -.25rem -1.7rem auto;
  pointer-events: none;
}

.welcome .go {
  width: min(100% - 4rem, 17rem);
  min-height: 2.9rem;
  font-size: 1.1rem;
}
.sparks { width: 1.35rem; height: 1.35rem; fill: var(--ink); flex: none; }

.used-up { margin: .75rem 0 0; text-align: center; font-weight: 500; }

.closed-only { text-align: center; padding-bottom: 1rem; }
.ended-icon { display: block; width: 6.7rem; height: 5rem; margin: 0 auto .5rem; }
.closed-only h2 { margin: 0 0 .35rem; font: 800 2rem/1.1 var(--he); }
.closed-only p { margin: 0 0 1rem; }
.welcome.closed .open-only,
.welcome:not(.closed) .closed-only { display: none; }

.brand-row {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 3.4rem;
  margin-top: 1rem;
}

.logo { display: block; width: 7rem; aspect-ratio: 170 / 87; }

.help {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font: 700 .72rem var(--he);
}
.help.admin-link { left: auto; right: 0; text-decoration: none; }
.help-dot svg { width: 1.15rem; height: 1.15rem; }
.help-dot {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font: 800 1.05rem var(--he);
}

/* ---------- 2. camera ---------- */

.camera { background: #000; color: #fff; }

.cam-top {
  position: relative;
  display: flex;
  justify-content: center;
  padding: calc(var(--safe-top) + .75rem) 1rem .75rem;
}
.cam-top .close { position: absolute; right: .75rem; color: #fff; width: 2.5rem; height: 2.5rem; padding: .45rem; }
.flash { position: relative; background: #fff; border-radius: 50%; padding: .5rem; }
.flash-dot {
  position: absolute;
  right: .1rem;
  bottom: .1rem;
  width: .8rem;
  height: .8rem;
  border-radius: 50%;
  background: #c9c9c9;
  border: 2px solid #fff;
}
.flash[aria-pressed='true'] .flash-dot { background: var(--yellow); }

.cam-frame {
  width: min(100%, calc((100dvh - 15.5rem) * .72));
  margin: 0 auto;
  padding: 2.5% 2.5% 0;
}
.cam-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  font-weight: 500;
  color: #fff;
}

.cam-controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: auto;
  padding: 1.25rem 1.5rem calc(var(--safe-bottom) + 1.75rem);
}
.shutter {
  width: 5.3rem;
  height: 5.3rem;
  border-radius: 50%;
  border: .55rem solid #3b3a12;
  background: var(--yellow);
  background-clip: padding-box;
  transition: transform .1s;
}
.shutter:active:not(:disabled) { transform: scale(.92); }
.flip { color: var(--yellow); width: 3rem; height: 3rem; }
.gallery { background: #fff; border-radius: 50%; width: 3.4rem; height: 3.4rem; padding: .45rem; }

.screen-flash { position: fixed; inset: 0; z-index: 20; background: #fff; }

/* ---------- 3. preview ---------- */

.preview {
  background: #fff;
  padding: calc(var(--safe-top) + 1.75rem) 0 calc(var(--safe-bottom) + 1.5rem);
}

.reel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.reel::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  padding: 0 1.25rem 1.1rem;
}
.slide .polaroid {
  width: min(100%, calc((100dvh - 21rem) * .76));
  margin: 0 auto;
  box-shadow: 0 12px 26px -6px rgb(0 0 0 / .35);
}
.slide .polaroid.landscape { width: min(100%, calc((100dvh - 21rem) * 1.45)); }

.reel-count, .preview-note {
  margin: 0 1rem;
  text-align: center;
  font: 500 .9rem var(--he);
  color: var(--grey);
}

.tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 2.25rem 0;
}
.tools .icon-btn { width: 2.6rem; height: 2.6rem; }

.filter-tray {
  display: flex;
  gap: .6rem;
  overflow-x: auto;
  padding: .6rem 1.25rem .2rem;
  scrollbar-width: none;
}
.chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 0;
  border: 0;
  background: none;
  font: 500 .8rem var(--he);
}
.chip img {
  width: 3.6rem;
  height: 3.6rem;
  object-fit: cover;
  border-radius: .6rem;
  border: 3px solid transparent;
}
.chip[aria-pressed='true'] img { border-color: var(--yellow); }
.chip[aria-pressed='true'] { font-weight: 700; }

.preview-text {
  margin: auto 1rem 1.1rem;
  padding-top: 1rem;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.3;
}
.preview-text p { margin: 0; }
.preview-text b { font-size: 1.15rem; }

/* ---------- 4. sending ---------- */

.sending { background: #fff; }

.send-art { position: relative; flex: 1; min-height: 25rem; }
.burst { position: absolute; top: calc(var(--safe-top) + 4%); left: 54%; width: 34%; color: var(--ink); }
.tilt-left { transform: rotate(-8deg); }
.tilt-right { transform: rotate(6deg); }
.send-art .polaroid {
  position: absolute;
  top: calc(var(--safe-top) + 14%);
  left: 16%;
  width: 60%;
  box-shadow: 0 10px 24px -6px rgb(0 0 0 / .35);
}
.flight { position: absolute; bottom: 0; left: 18%; width: 82%; color: var(--ink); overflow: visible; }
.trail { animation: trail 1.2s linear infinite; }
.plane { animation: bob 1.6s ease-in-out infinite; transform-origin: center; }

.send-text, .send-error {
  padding: 0 1rem calc(var(--safe-bottom) + 2.5rem);
  text-align: center;
}
.send-text h2, .send-error h2 { margin: 0; font: 800 2.7rem/1.1 var(--he); }
.send-text p, .send-error p { margin: .2rem 0 0; font-size: 1.1rem; }
.send-error p { margin-bottom: 1.25rem; }
.send-error .pill + .pill { margin-top: .9rem; }

@keyframes trail { to { stroke-dashoffset: -38; } }
@keyframes bob { 50% { transform: translate(6px, -8px); } }

/* ---------- 5. success ---------- */

.success { background: #fff; }

.success-art {
  position: relative;
  width: min(62%, calc((100dvh - 27rem) * .68));
  margin: calc(var(--safe-top) + 3rem) auto 0;
}
.success-art .polaroid { box-shadow: 0 12px 26px -6px rgb(0 0 0 / .35); }
.success-art .polaroid .caption { font-size: 1.6rem; }
.badge {
  position: absolute;
  top: -9%;
  left: 78%;
  display: grid;
  place-items: center;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) .15s both;
}
.badge svg { width: 62%; height: 62%; }
.star { position: absolute; fill: var(--ink); }
.star.s1 { width: 22%; aspect-ratio: 1; top: -12%; left: -16%; }
.star.s2 { width: 20%; aspect-ratio: 1; bottom: -15%; right: -14%; }

.hurray {
  margin: 2.1rem 0 .15rem;
  text-align: center;
  font: 800 clamp(3.5rem, 18vw, 4.75rem)/1 var(--he);
}
.success-line { margin: 0 1rem 1.75rem; text-align: center; font-size: 1rem; text-wrap: balance; }
.success .pill + .pill { margin-top: 1.1rem; }
.success #done { margin-bottom: 3.5rem; }

.remaining {
  position: relative;
  margin-top: auto;
  padding: 1.9rem 1rem calc(var(--safe-bottom) + 1.9rem);
  background: var(--cream);
  box-shadow: inset 0 7px 8px -6px rgb(0 0 0 / .22);
  text-align: center;
}
.remaining p { margin: 0; font: 800 1.6rem/1.2 var(--he); }
.remaining-icon { position: absolute; left: 1rem; top: -2.9rem; width: 5.7rem; height: 4.25rem; }

@keyframes pop { from { transform: scale(0); } }

/* ---------- help dialog ---------- */

.help-dialog {
  width: min(100% - 2rem, 22rem);
  padding: 1.5rem 1.25rem 1.25rem;
  border: 0;
  border-radius: 1.25rem;
  font-family: var(--he);
}
.help-dialog::backdrop { background: rgb(0 0 0 / .6); }
.help-dialog h2 { margin: 0 0 .75rem; font: 800 1.6rem var(--he); }
.help-dialog ol { margin: 0 0 .75rem; padding-inline-start: 1.25rem; }
.help-dialog li { margin-bottom: .4rem; }
.limit-note { margin: 0 0 1.25rem; color: var(--grey); }
.help-dialog .pill { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .trail, .plane, .badge { animation: none; }
  .pill, .shutter { transition: none; }
}
