/* =========================================================
   Unnati's Explorer — styles
   Palette from inspiration/colorpallete.jpg + the plaid/envelope
   ========================================================= */
:root {
  --ivory: #f8f3ea;
  --beige: #e6d8c7;
  --beige-deep: #d8c6ae;
  --navy: #0b1957;
  --ink: #2b3d6b;
  --dusty: #8fa9c9;
  --pale: #9eccfa;
  --cyan-card: #34497a;
  --gold: #c9a96e;
  --shadow: rgba(11, 25, 87, 0.28);

  --script: "Pinyon Script", "Snell Roundhand", "Apple Chancery", cursive;
  --type: "Special Elite", "Courier Prime", "Courier New", ui-monospace, monospace;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;

  --ease-spring: cubic-bezier(.2, .9, .25, 1.15);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--type);
  color: var(--navy);
  background: #3d5378;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* plaid background (fixed layer — works on iOS unlike background-attachment: fixed) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #3d5378 url("../assets/plaid.jpg") center / cover no-repeat;
}
body.no-scroll { overflow: hidden; }

img { -webkit-user-drag: none; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--pale); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.script { font-family: var(--script); font-weight: 400; }
.type { font-family: var(--type); letter-spacing: .06em; }
.hand { font-family: var(--hand); }

.screen { display: none; }
.screen.is-active { display: block; }

.btn {
  font-family: var(--type);
  font-size: .95rem;
  letter-spacing: .08em;
  padding: .7em 1.3em;
  border-radius: 999px;
  background: var(--ivory);
  color: var(--navy);
  box-shadow: 0 3px 0 var(--beige-deep), 0 8px 18px rgba(0,0,0,.25);
  transition: transform .15s, box-shadow .15s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--beige-deep), 0 4px 10px rgba(0,0,0,.25); }

/* =========================================================
   Screen 1 — envelope
   ========================================================= */
#screen-envelope {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vh, 26px);
  padding: 16px;
  background:
    radial-gradient(ellipse at center, rgba(248,243,234,.18), rgba(11,25,87,.35) 75%),
    #3d5378 url("../assets/plaid.jpg") center / cover no-repeat;
  transition: opacity .7s ease, transform .9s var(--ease-out);
}
#screen-envelope.is-active { display: flex; }
#screen-envelope.is-leaving { opacity: 0; transform: scale(1.08); pointer-events: none; }

.env-to {
  margin: 0;
  font-family: var(--type);
  color: var(--ivory);
  font-size: 1rem;
  letter-spacing: .12em;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.env-to .script { font-size: 2.6rem; letter-spacing: 0; margin-left: .2em; vertical-align: -.15em; }

.envelope {
  position: relative;
  width: min(86vw, 520px, 70vh);
  aspect-ratio: 632 / 610;
  animation: envFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 18px 24px rgba(11,25,87,.35));
}
.env-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.env-open { opacity: 0; z-index: 1; }
.env-closed { z-index: 3; transition: opacity .35s ease; }
/* the little card that slides out of the open envelope */
.env-card-clip {
  position: absolute;
  z-index: 2;
  left: 9%;
  right: 9%;
  top: -48%;
  height: calc(48% + 39%);   /* bottom edge = envelope opening line */
  overflow: hidden;
  pointer-events: none;
}
.env-card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 62%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3em;
  background:
    radial-gradient(circle, rgba(143,169,201,.25) 1px, transparent 1.4px) 0 0 / 14px 14px,
    var(--ivory);
  border-radius: 6px;
  box-shadow: 0 -4px 14px rgba(0,0,0,.12);
  transform: translateY(102%);
  transition: transform 1s var(--ease-out);
}
.env-card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed var(--dusty);
  border-radius: 4px;
}
.env-card-title { font-size: clamp(1.9rem, 8vw, 3.2rem); color: var(--navy); line-height: 1; }
.env-card-sub { font-size: clamp(.6rem, 2.4vw, .8rem); color: var(--ink); text-transform: uppercase; }

.env-hint {
  margin: 0;
  color: var(--ivory);
  font-size: 1.05rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0,0,0,.45);
  animation: pulse 1.8s ease-in-out infinite;
  transition: opacity .3s;
}

.envelope.is-shaking { animation: envShake .38s ease-in-out; }
.envelope.is-open { animation: none; }
.envelope.is-open .env-closed { opacity: 0; }
.envelope.is-open .env-open { opacity: 1; }
.envelope.is-open .env-card { transform: translateY(-6%); transition-delay: .25s; }
#screen-envelope.is-opening .env-hint,
#screen-envelope.is-opening .env-to { opacity: 0; }
.env-to { transition: opacity .3s; }

@keyframes envFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}
@keyframes envShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-3deg) scale(1.02); }
  40% { transform: rotate(3deg) scale(1.03); }
  60% { transform: rotate(-2deg) scale(1.02); }
  80% { transform: rotate(1.5deg); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.06); opacity: 1; }
}

/* =========================================================
   Screen 2 — home
   ========================================================= */
#screen-home {
  min-height: 100vh;
  min-height: 100svh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
#screen-home.is-active { display: flex; flex-direction: column; align-items: center; }

.banner-wrap { text-align: center; margin-top: 6px; }
.banner {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: .12em 1.35em .2em;
  font-size: clamp(2.5rem, 10.5vw, 4.6rem);
  line-height: 1.15;
  color: var(--navy);
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 40%, rgba(160,130,90,.10)),
    var(--beige);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.3));
  white-space: nowrap;
}
.banner::before {           /* stitched edges */
  content: "";
  position: absolute;
  left: 5%; right: 5%; top: 7px; bottom: 7px;
  border-top: 1.5px dashed rgba(43,61,107,.45);
  border-bottom: 1.5px dashed rgba(43,61,107,.45);
  pointer-events: none;
}
.banner-sub {
  margin: .7em 0 0;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .25em;
  color: var(--ivory);
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
}

.unlock-label {
  margin: 18px 0 4px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  color: var(--ivory);
  text-shadow: 0 2px 10px rgba(11,25,87,.7), 0 0 2px rgba(11,25,87,.6);
  animation: pulse 2.4s ease-in-out infinite;
}

/* ---------- map of cutouts ---------- */
.map {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
  padding: 12px 0 8px;
}
.friend {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px 4px;
  transform: translateY(var(--dy, 0));
  animation: popIn .6s var(--ease-spring) backwards;
  animation-delay: var(--in-delay, 0s);
}
.friend-bob {
  position: relative;
  display: block;
  width: 100%;
  animation: bob var(--bob-dur, 3.4s) ease-in-out infinite;
  animation-delay: var(--bob-delay, 0s);
  transition: transform .25s var(--ease-spring);
}
.friend:hover .friend-bob,
.friend:focus-visible .friend-bob { transform: scale(1.06); }
.friend:active .friend-bob { transform: scale(.97); }
.friend-pic {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: clamp(130px, 38vw, 175px);
  transform: rotate(var(--r, 0deg));
}
.friend-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* uniform sticker outline + soft shadow so all cutouts match */
  filter:
    drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff)
    drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff)
    drop-shadow(0 8px 10px rgba(11,25,87,.35));
  transition: filter .9s ease, opacity .9s ease;
}
.friend.is-locked .friend-img {
  filter:
    grayscale(.92) sepia(.12) brightness(1.04)
    drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff)
    drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff)
    drop-shadow(0 8px 10px rgba(11,25,87,.25));
  opacity: .72;
}
/* placeholder when a cutout file is missing */
.friend-ph {
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ivory);
  border: 4px solid #fff;
  box-shadow: 0 8px 14px rgba(11,25,87,.3);
  font-family: var(--script);
  font-size: 3.4rem;
  color: var(--ink);
}

/* luggage-tag style lock tag */
.friend-tag {
  position: absolute;
  top: -2px;
  right: 8%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 42px;
  padding-top: 8px;
  font-family: var(--type);
  font-size: 1.15rem;
  color: var(--navy);
  background: var(--beige);
  clip-path: polygon(22% 0, 78% 0, 100% 16%, 100% 100%, 0 100%, 0 16%);
  box-shadow: 0 3px 6px rgba(0,0,0,.25);
  transform: rotate(10deg);
  transform-origin: 50% 0;
  animation: tagSwing 2.6s ease-in-out infinite;
  transition: opacity .4s, transform .5s;
}
.friend-tag::before {       /* eyelet */
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 7px; height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: #6b7fa6;
  box-shadow: inset 0 0 0 2px var(--ivory);
}
.friend:not(.is-locked) .friend-tag { opacity: 0; transform: rotate(40deg) translateY(30px); }
@keyframes tagSwing {
  0%, 100% { transform: rotate(10deg); }
  50% { transform: rotate(2deg); }
}

.friend-mini-stamp {
  position: absolute;
  right: 4%;
  bottom: 2%;
  width: 30%;
  max-width: 62px;
  transform: rotate(9deg) scale(0);
  opacity: 0;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.3));
  transition: transform .5s var(--ease-spring), opacity .3s;
}
.friend-mini-stamp img, .friend-mini-stamp .stamp-ph { width: 100%; display: block; }
.friend:not(.is-locked) .friend-mini-stamp { transform: rotate(9deg) scale(1); opacity: 1; }

.friend-name {
  margin-top: 8px;
  padding: .2em .7em;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  background: var(--ivory);
  border-radius: 3px;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  transform: rotate(calc(var(--r, 0deg) * -.5));
}
.friend.is-locked .friend-name { background: #e9e4dc; color: #5d6787; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-7px) rotate(1.4deg); }
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(calc(var(--dy, 0px) + 30px)) scale(.7); }
}

/* ---------- passport strip ---------- */
.passport {
  position: relative;
  width: 100%;
  max-width: 1080px;
  margin-top: 18px;
  padding: 14px 14px 16px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(115deg, rgba(143,169,201,.10) 0 2px, transparent 2px 9px),
    radial-gradient(ellipse at 30% 0%, rgba(255,255,255,.55), transparent 60%),
    var(--beige);
  box-shadow: 0 10px 24px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.4);
  transition: box-shadow .6s;
}
.passport::before {   /* stitching */
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed rgba(43,61,107,.35);
  border-radius: 7px;
  pointer-events: none;
}
.passport-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 2px 6px 10px;
  font-size: .78rem;
  color: var(--ink);
}
.progress { font-size: .85rem; color: var(--navy); }
.passport-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 10px;
}
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: default;
}
.slot.is-collected { cursor: pointer; }
.slot-box {
  position: relative;
  width: 100%;
  max-width: 96px;
  aspect-ratio: 5 / 6;
  border: 2px dashed rgba(43,61,107,.45);
  border-radius: 6px;
  background: rgba(248,243,234,.45);
  display: grid;
  place-items: center;
  transition: border-color .4s, background .4s;
}
.slot-box::after {            /* faint "?" when empty */
  content: "?";
  font-family: var(--type);
  font-size: 1.3rem;
  color: rgba(43,61,107,.3);
}
.slot.is-collected .slot-box { border-color: transparent; background: transparent; }
.slot.is-collected .slot-box::after { content: none; }
.slot-stamp {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
  object-fit: contain;
  transform: rotate(var(--sr, -3deg));
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.25));
}
.slot-ink {
  position: absolute;
  width: 105%;
  left: -18%;
  bottom: -12%;
  color: rgba(43,61,107,.6);
  opacity: .5;
  transform: rotate(-14deg);
  pointer-events: none;
  mix-blend-mode: multiply;
}
.slot-name {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink);
}
.slot.is-shaking .slot-box { animation: shakeX .35s; }
.passport.is-thump { animation: thump .35s ease-out; }
.passport.is-complete {
  box-shadow: 0 0 0 3px rgba(255,248,232,.95), 0 0 30px 10px rgba(255,236,190,.7), 0 10px 24px rgba(0,0,0,.3);
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,248,232,.85), 0 0 22px 6px rgba(255,236,190,.55), 0 10px 24px rgba(0,0,0,.3); }
  50% { box-shadow: 0 0 0 4px rgba(255,250,238,1), 0 0 48px 18px rgba(255,236,190,.95), 0 10px 24px rgba(0,0,0,.3); }
}
@keyframes thump {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 3px); }
  40% { transform: translate(3px, -1px); }
  60% { transform: translate(-2px, 1px); }
  80% { transform: translate(1px, 0); }
  100% { transform: translate(0, 0); }
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- finish button ---------- */
.finish-wrap { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.finish {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  padding: .85em 2em;
  font-family: var(--type);
  font-size: 1.15rem;
  letter-spacing: .25em;
  border-radius: 999px;
  background: var(--ivory);
  color: var(--navy);
  box-shadow: 0 4px 0 var(--beige-deep), 0 10px 22px rgba(0,0,0,.3);
  transition: background .5s, color .5s, box-shadow .5s, transform .15s;
}
.finish.is-locked {
  background: #cfcabf;
  color: #77736b;
  box-shadow: 0 4px 0 #aaa498, 0 8px 16px rgba(0,0,0,.2);
  cursor: not-allowed;
}
.finish.is-unlocked { animation: finishGlow 2.2s ease-in-out infinite; }
.finish.is-unlocked:active { transform: translateY(3px); }
.finish.is-denied { animation: shakeX .35s; }
@keyframes finishGlow {
  0%, 100% { box-shadow: 0 4px 0 var(--beige-deep), 0 0 6px 1px rgba(255,236,190,.5), 0 10px 22px rgba(0,0,0,.3); }
  50% { box-shadow: 0 4px 0 var(--beige-deep), 0 0 32px 12px rgba(255,236,190,.95), 0 10px 22px rgba(0,0,0,.3); }
}
.finish-note {
  margin: 0;
  font-size: .8rem;
  color: var(--ivory);
  text-shadow: 0 1px 5px rgba(0,0,0,.6);
  transition: opacity .4s;
}

/* lock icon */
.lock { position: relative; width: 16px; height: 20px; display: inline-block; }
.lock-shackle {
  position: absolute;
  left: 3px; top: 0;
  width: 10px; height: 11px;
  border: 2.4px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  transform-origin: 100% 100%;
  transition: transform .45s var(--ease-spring);
}
.lock-body {
  position: absolute;
  left: 0; bottom: 0;
  width: 16px; height: 11px;
  border-radius: 3px;
  background: currentColor;
}
.finish.is-unlocking .lock-shackle { transform: translateY(-4px) rotate(35deg); }
.finish.is-unlocking .lock { animation: lockAway .7s .45s ease-in forwards; }
.finish.is-unlocked .lock { display: none; }
@keyframes lockAway {
  to { transform: translateY(26px) rotate(25deg); opacity: 0; }
}

/* made with love footer */
.made-with-love { margin-top: 26px; display: flex; justify-content: center; }
.made-with-love img {
  width: min(200px, 52vw);
  display: block;
  transform: rotate(-3deg);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

/* =========================================================
   Screen 3 — postcard modal
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.pc-backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #1d2a4a;
}
.pc-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(11,25,87,.25), rgba(8,14,40,.72));
}
.bg-media {
  position: absolute;
  inset: -60px;
  width: calc(100% + 120px);
  height: calc(100% + 120px);
  object-fit: cover;
  filter: blur(24px) brightness(.55) saturate(1.1);
  opacity: 0;
  transition: opacity .8s ease;
}
.bg-media.in { opacity: 1; }
.modal.is-open .pc-backdrop { animation: fadeIn .4s ease both; }
.modal.is-closing .pc-backdrop { animation: fadeOut .35s ease both; }

.pc-close {
  position: fixed;
  z-index: 3;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  line-height: 1;
  color: var(--navy);
  background: var(--ivory);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.modal.is-closing .pc-close { opacity: 0; transition: opacity .2s; }

.pc-layout {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: max(56px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
  --cw: min(94vw, 560px, calc((100svh - 150px) * .75));
}
.pc-name {
  margin: 0;
  font-size: clamp(3rem, 15vw, 5.6rem);
  line-height: 1;
  color: var(--ivory);
  text-shadow: 0 4px 18px rgba(0,0,0,.55);
  transform: rotate(-4deg);
}
.modal.is-open .pc-name { animation: nameIn .8s .15s var(--ease-out) both; }
.modal.is-closing .pc-name { animation: fadeOut .25s ease both; }

.pc-stack {
  width: var(--cw);
  display: flex;
  flex-direction: column;
  gap: calc(var(--cw) * .035);
}
.card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  container-type: inline-size;
  box-shadow: 0 14px 30px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.2);
}
.card-front {
  --rest: rotate(-1.6deg);
  transform: var(--rest);
  background: #2c3f6e;
}
.card-back {
  --rest: rotate(1.3deg);
  transform: var(--rest);
}
.modal.is-open .card-front { animation: cardIn .8s var(--ease-spring) both; --from: translateY(85vh) rotate(-14deg); }
.modal.is-open .card-back  { animation: cardIn .8s .12s var(--ease-spring) both; --from: translateY(95vh) rotate(12deg); }
.modal.is-closing .card-front { animation: cardOut .4s ease-in both; }
.modal.is-closing .card-back { animation: cardOut .4s .05s ease-in both; }
@keyframes cardIn { from { transform: var(--from); opacity: 0; } 40% { opacity: 1; } to { transform: var(--rest); } }
@keyframes cardOut { to { transform: translateY(70vh) rotate(8deg); opacity: 0; } }
@keyframes nameIn { from { opacity: 0; transform: translateX(-30px) rotate(-4deg); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

/* front: lace frame with video window */
.front-window {
  position: absolute;
  left: 15.5%;
  top: 21%;
  width: 69%;
  height: 57%;
  overflow: hidden;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at center, #4c629a, #2c3f6e 75%);
}
.front-window.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.12) 50%, transparent 70%) -100% 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: 100% 0; } }
.front-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s ease;
}
.front-window.has-video .front-video { opacity: 1; }
.front-window.is-portrait .front-video { object-fit: contain; }
/* videoRotate: turn sideways clips upright (window is 69cqw x 38cqw of the card) */
.front-video.rot-90, .front-fill.rot-90 {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 38cqw;
  height: 69cqw;
  transform: translate(-50%, -50%) rotate(var(--vrot));
}
.front-fill.rot-90 { width: 46cqw; height: 83cqw; }
.front-video.rot-180, .front-fill.rot-180 { transform: rotate(180deg); }
.bg-media.rot-90 {
  inset: auto;
  left: 50%;
  top: 50%;
  width: calc(100vh + 120px);
  height: calc(100vw + 120px);
  transform: translate(-50%, -50%) rotate(var(--vrot));
}
.bg-media.rot-180 { transform: rotate(180deg); }
.front-fill {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(14px) brightness(.7);
}
.front-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1cqw;
  color: var(--ivory);
  text-align: center;
  animation: fadeIn .5s ease;
}
.front-ph .script { font-size: 9cqw; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.35); }
.front-ph .type { font-size: 2.1cqw; text-transform: uppercase; letter-spacing: .22em; opacity: .85; }
.lace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  pointer-events: none;
}

/* back: like a real postcard back */
.card-back {
  background: #2f4374;
  padding: 3%;
}
.card-back::before {      /* ivory dotted panel inside the cyanotype edge */
  content: "";
  position: absolute;
  inset: 3.2%;
  border-radius: 1.6cqw;
  background:
    radial-gradient(circle, rgba(43,61,107,.16) .28cqw, transparent .34cqw) 0 0 / 4cqw 4cqw,
    linear-gradient(160deg, #fcf8f1, #f4ece0);
}
.card-back > * { position: absolute; }
.back-title {
  left: 30%;
  top: 4%;
  transform: translateX(-50%);
  font-size: 10cqw;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.back-divider {
  left: 51%;
  top: 25%;
  bottom: 9%;
  width: 0;
  border-left: max(1px, .25cqw) solid rgba(43,61,107,.7);
}
.back-photos {
  left: 5%;
  top: 23%;
  width: 43%;
  height: 70%;
}
.back-stamp {
  right: 6%;
  top: 7%;
  width: 15%;
}
.back-lines {
  left: 55%;
  right: 6%;
  top: 37%;
  bottom: 13%;
  --lh: 6.6cqw;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--lh) - max(1px, .2cqw)),
    rgba(43,61,107,.45) calc(var(--lh) - max(1px, .2cqw)),
    rgba(43,61,107,.45) var(--lh)
  );
  overflow: hidden;
}
.back-quote {
  margin: 0;
  font-size: calc(var(--lh) * .82);
  line-height: var(--lh);
  font-weight: 500;
  color: #1f2c5c;
  overflow-wrap: anywhere;
  padding-top: calc(var(--lh) * .06);
}
.back-quote .greet, .back-quote .msg { display: block; }
.back-quote .sign { display: block; text-align: right; padding-right: 3%; }
.back-to {
  left: 55%;
  bottom: 5.2%;
  font-size: 1.75cqw;
  letter-spacing: .12em;
  color: var(--ink);
  opacity: .8;
  white-space: nowrap;
}

/* cutout as perforated postage stamp */
.perf {
  display: block;
  padding: 5px;
  background: #fffdf8;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 3px, transparent 95%, #000) -5px -5px / 10px 10px round;
          mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 3px, transparent 95%, #000) -5px -5px / 10px 10px round;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}
.back-stamp .perf { transform: rotate(3deg); }
.perf-inner {
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: linear-gradient(180deg, #cfe3fb, #a9c4e6);
}
.perf-inner img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; display: block; }
.perf-inner .initial {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-family: var(--script);
  font-size: 9cqw;
  color: var(--navy);
}
.postmark {
  position: absolute;
  width: 200%;
  right: 52%;
  top: 4%;
  color: rgba(35,48,96,.72);
  transform: rotate(-12deg);
  pointer-events: none;
  mix-blend-mode: multiply;
}
.postmark text { font-family: var(--type); fill: currentColor; }

/* photo collage */
.polaroid {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  padding: 1.1cqw 1.1cqw 3.4cqw;
  background: #fff;
  box-shadow: 0 .6cqw 1.4cqw rgba(0,0,0,.25);
  transform: rotate(var(--rot));
}
.polaroid::before {      /* washi tape */
  content: "";
  position: absolute;
  top: -1.4cqw;
  left: 50%;
  width: 40%;
  height: 3cqw;
  margin-left: -20%;
  background: rgba(158,204,250,.55);
  transform: rotate(calc(var(--rot) * -1.5));
  box-shadow: 0 0 0 .1cqw rgba(255,255,255,.4) inset;
}
.polaroid:nth-child(2)::before { background: rgba(230,216,199,.75); }
.polaroid-img {
  display: block;
  width: 100%;
  height: var(--h);
  overflow: hidden;
  background: linear-gradient(135deg, #e9e1d4, #d9e5f3);
}
.polaroid-img img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fadeIn .4s ease; }
.photo-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6cqw;
  text-align: center;
  color: var(--ink);
}
.photo-ph .script { font-size: 4.6cqw; line-height: 1; }
.photo-ph .type { font-size: 1.5cqw; text-transform: uppercase; letter-spacing: .14em; opacity: .7; }

/* =========================================================
   Stamp unlock moment
   ========================================================= */
.stamp-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(14, 22, 52, .55);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
  transition: background .4s, backdrop-filter .4s;
  animation: fadeIn .3s ease;
}
.stamp-overlay.is-clear {
  background: rgba(14, 22, 52, 0);
  -webkit-backdrop-filter: none;
          backdrop-filter: none;
}
.stamp-caption {
  position: fixed;
  left: 0; right: 0;
  top: calc(50% + min(31vw, 150px) + 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ivory);
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  animation: captionIn .5s .25s var(--ease-out) both;
  transition: opacity .25s;
}
.stamp-caption .type { font-size: .9rem; text-transform: uppercase; letter-spacing: .3em; }
.stamp-caption .script { font-size: clamp(2.6rem, 11vw, 4rem); line-height: 1.1; }
.stamp-overlay.is-clear .stamp-caption { opacity: 0; }
@keyframes captionIn { from { opacity: 0; transform: translateY(14px); } }

.flying-stamp {
  position: fixed;
  z-index: 61;
  left: 50%;
  top: 50%;
  width: min(54vw, 250px);
  margin-left: calc(min(54vw, 250px) / -2);
  margin-top: calc(min(54vw, 250px) * -.62);
  pointer-events: none;
  filter: drop-shadow(0 16px 22px rgba(0,0,0,.45));
  transform-origin: 50% 50%;
}
.flying-stamp img, .flying-stamp .stamp-ph { width: 100%; display: block; }

/* stamp fallback when a stamp file is missing */
.stamp-ph {
  aspect-ratio: 5 / 6;
  display: grid;
  place-items: center;
  background: var(--ivory);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 4px, transparent 95%, #000) -6px -6px / 12px 12px round;
          mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 4px, transparent 95%, #000) -6px -6px / 12px 12px round;
  padding: 6px;
  color: var(--navy);
  font-family: var(--script);
  font-size: 2.2rem;
}
.stamp-ph span {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  border: 2px solid var(--dusty);
  background: #dbe8f7;
}

.ink-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150%;
  aspect-ratio: 1;
  margin: -75% 0 0 -75%;
  border-radius: 50%;
  border: 5px double rgba(43,61,107,.55);
  pointer-events: none;
  animation: inkRing .9s ease-out forwards;
}
@keyframes inkRing {
  0% { transform: scale(.45); opacity: .9; }
  100% { transform: scale(1.15); opacity: 0; }
}
.slot-stamp.is-landing { animation: landBounce .5s var(--ease-spring); }
@keyframes landBounce {
  0% { transform: rotate(var(--sr)) scale(1.18); }
  45% { transform: rotate(var(--sr)) scale(.93); }
  100% { transform: rotate(var(--sr)) scale(1); }
}
.slot-ink.is-new { animation: inkIn 1.1s ease-out both; }
@keyframes inkIn {
  0% { opacity: 0; transform: rotate(-14deg) scale(1.35); }
  25% { opacity: .95; transform: rotate(-14deg) scale(1); }
  100% { opacity: .5; transform: rotate(-14deg) scale(1); }
}

/* =========================================================
   Screen 4 — passport complete
   ========================================================= */
.complete {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(14,22,52,.35);
  animation: fadeIn .4s ease;
}
.complete-card {
  width: min(420px, 100%);
  padding: 26px 22px 24px;
  text-align: center;
  border: 7px solid transparent;
  border-radius: 4px;
  background:
    linear-gradient(var(--ivory), var(--ivory)) padding-box,
    repeating-conic-gradient(#8fa9c9 0 25%, #f3ece0 0 50%) 0 0 / 10px 10px border-box;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  animation: cardPop .6s var(--ease-spring) both;
}
.complete-card .type { margin: 0; font-size: .75rem; letter-spacing: .25em; color: var(--ink); }
.complete-card h2 { margin: .1em 0 0; font-size: clamp(2.8rem, 12vw, 3.6rem); line-height: 1.1; color: var(--navy); }
.complete-q { margin: .2em 0 1em; font-size: 1.8rem; color: var(--ink); }
@keyframes cardPop { from { opacity: 0; transform: scale(.7) rotate(-4deg); } }

/* =========================================================
   Screen 5 — finale
   ========================================================= */
.finale {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #070c22;
  display: flex;
  flex-direction: column;
  animation: fadeIn .5s ease;
}
.finale-stage { position: relative; flex: 1; min-height: 0; }
.finale-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.finale-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 12px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.5));
}
.finale-missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(ellipse at center, rgba(248,243,234,.12), rgba(11,25,87,.55) 75%),
    #3d5378 url("../assets/plaid.jpg") center / cover no-repeat;
}
.finale.is-missing .finale-stage { flex: 0; }
.finale-missing-card {
  width: min(460px, 100%);
  padding: 30px 22px;
  text-align: center;
  border: 7px solid transparent;
  border-radius: 4px;
  background:
    linear-gradient(var(--ivory), var(--ivory)) padding-box,
    repeating-conic-gradient(#8fa9c9 0 25%, #f3ece0 0 50%) 0 0 / 10px 10px border-box;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  animation: cardPop .6s var(--ease-spring) both;
}
.finale-missing-card .type { margin: 0; font-size: .78rem; letter-spacing: .3em; color: var(--ink); }
.finale-missing-card h2 { margin: .2em 0; font-size: clamp(2.4rem, 10vw, 3.3rem); line-height: 1.1; color: var(--navy); }
.finale-missing-card .hand { margin: 0; font-size: 1.6rem; color: var(--ink); }
.finale.is-missing .finale-controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; background: none; }

/* =========================================================
   Laptop / tablet layout
   ========================================================= */
@media (min-width: 760px) {
  .map {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 26px;
    padding: 18px 10px 10px;
  }
  .friend-pic { height: 190px; }
  .friend-name { font-size: .85rem; }
  .passport { padding: 16px 22px 20px; }
  .passport-slots { grid-template-columns: repeat(8, 1fr); gap: 14px; }
  .passport-head { font-size: .85rem; }
  .progress { font-size: .95rem; }

  /* name beside the postcards */
  .pc-layout {
    flex-direction: row;
    gap: clamp(16px, 4vw, 56px);
    padding: 32px 76px 32px 32px;
    --cw: min(560px, 56vw, calc((100vh - 70px) * .75));
  }
  .pc-name {
    max-width: 30vw;
    text-align: center;
    font-size: clamp(4rem, 8vw, 7rem);
    transform: rotate(-8deg);
  }
  @keyframes nameIn { from { opacity: 0; transform: translateX(-40px) rotate(-8deg); } }
}

/* short laptop screens: keep both cards on screen */
@media (min-width: 760px) and (max-height: 700px) {
  .friend-pic { height: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  .friend-bob, .friend-tag, .envelope, .unlock-label, .env-hint, .finish.is-unlocked, .passport.is-complete { animation: none !important; }
}
