@font-face {
  font-family: "Mont";
  src: url("../assets/fonts/mont-heavy.otf") format("opentype");
  font-display: block;
}

@font-face {
  font-family: "Wistha";
  src: url("../assets/fonts/wistha-belle.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "Jane";
  src: url("../assets/fonts/jane-austen.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.55);
  /* player stage width: the whole player scales from this one value */
  --stage: min(92vw, 560px, max(130px, calc(100svh - 290px)));   /* stage + shelf always fit the screen */
  --slot: clamp(52px, min(20vw, 22svh), 124px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-snap-type: y mandatory;      /* every section snaps to the centre of the screen */
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden;
  touch-action: pan-y pinch-zoom;     /* the site only scrolls up and down */
}
body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
body > section { overflow-x: clip; }   /* nothing inside a section can widen the page */

/* Scroll lock while the 22 grows (JS also blocks touchmove for iOS Safari) */
html.is-locked, html.is-locked body {
  overflow: hidden;
  overscroll-behavior: none;
}

img { display: block; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }

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

/* ───────── Section 1 ───────── */
.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  background: var(--bg);
  overflow: hidden;
}
#bloom { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ───────── Section 2 ───────── */
.player {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 5svh, 48px) 0 calc(clamp(16px, 5svh, 48px) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.scene {
  position: relative;
  isolation: isolate;          /* own stacking context: disc 3 < arm 5 */
  width: var(--stage);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The platter ring in the player art is 2.8% taller than wide, so the art is squashed
   vertically by 1/1.0281 (aspect 1024:996) to make the ring a true circle. */
.stage { position: relative; width: var(--stage); aspect-ratio: 1024 / 996; }
.stage__body { width: 100%; height: 100%; object-fit: fill; }

/* centre of the platter's recessed ring in player.png (621, 612.4 of the 1254-unit art; fitted ring centre) —
   the printed spindle is ~4px lower, so we centre on the ring */
.platter-anchor {
  position: absolute; left: 49.52%; top: 48.84%;
  width: 1px; height: 1px; pointer-events: none;
}

/* Tonearm. Pivot (hub) of header.png sits at (1050,205) of the 1254 player art —
   far enough out that the round base never touches the record's edge. */
.stage__arm {
  position: absolute;
  z-index: 5;
  width: 36.7%;
  left: 65.4%;
  top: 6.67%;
  transform-origin: 49.8% 17.1%;
  will-change: transform;
  pointer-events: none;
}

.shelf {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: clamp(14px, 4vw, 32px);
  width: 100%;
}

.slot {
  position: relative;
  width: var(--slot);
  height: var(--slot);
  flex: none;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}
/* faint ring so an emptied slot still reads as a place for the record */
.slot::before {
  content: "";
  position: absolute; inset: 4%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.14);
}
.slot:focus-visible::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

/* Disc is laid out at its FULL on-platter size and only ever scaled DOWN for
   the shelf — scaling up a composited layer makes Safari render it blurry. */
.disc {
  --d: calc(var(--stage) * 0.70);   /* record diameter; the ring is 0.716, leaving an even ~0.8% margin */
  position: absolute;
  left: 50%; top: 50%;
  width: var(--d); height: var(--d);
  margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2);
  z-index: 3;
  transform-origin: 50% 50%;
  will-change: transform;
  pointer-events: none;
}
.slot .disc { pointer-events: auto; }
.disc__spin { position: absolute; inset: 0; will-change: transform; }

.disc__art, .disc__ring, .disc__pin { position: absolute; }
/* spindle seen through the hole in the art — centred on the record itself */
.disc__pin {
  left: 50%; top: 50%;
  width: 4.4%; height: 4.4%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, #d5d8dd 0 30%, #2a2a2c 34% 100%);
}
.disc__ring { inset: 0; width: 100%; height: 100%; }
/* album art lives in the transparent centre (32% of the disc) — slightly
   oversized so its edge tucks under the vinyl; small spindle hole in the middle */
.disc__art {
  left: 50%; top: 50%;
  width: 36%; height: 36%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  object-fit: cover;
  -webkit-mask: radial-gradient(circle at center, transparent 0 4.5%, #000 5%);
          mask: radial-gradient(circle at center, transparent 0 4.5%, #000 5%);
}

/* ───────── Big button + status LED (positions measured on player.png, 1254px art) ───────── */
.power {
  position: absolute;
  z-index: 6;
  left: 85.8%; top: 82.7%;
  width: 5.6%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 0; border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
  transition: background-color 0.15s ease-in-out;
}
.power:active { background: radial-gradient(circle, rgba(0, 0, 0, 0.12) 0 60%, transparent 62%); }
.power:focus-visible { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55); }

.led {
  position: absolute;
  z-index: 6;
  left: 85.75%; top: 79%;
  width: max(6px, 1.1%); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  /* stopped = red */
  background: #ff3b30;
  box-shadow: 0 0 3px 0 rgba(255, 59, 48, 0.85), 0 0 6px 1px rgba(255, 59, 48, 0.3);
  transition: background-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}
/* playing = green */
.led.is-on {
  background: #2cff6a;
  box-shadow: 0 0 3px 0 rgba(44, 255, 106, 0.85), 0 0 6px 1px rgba(44, 255, 106, 0.3);
}

/* ───────── Sticky note beside the player ───────── */
.note {
  --note: calc(var(--stage) * 0.5);
  position: absolute;
  z-index: 4;
  width: var(--note);
  left: -44%; top: 2%;
  transform: rotate(-6deg);
  transform-origin: 50% 20%;
  pointer-events: none;
}
.note__paper { width: 100%; height: auto; }
.note__text {
  position: absolute;
  inset: 30% 20% 24% 20%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: "Jane", "Bradley Hand", "Segoe Script", cursive;
  font-size: calc(var(--note) * 0.082);
  line-height: 1.05;
  color: #2b2a4a;
  text-align: center;
  white-space: nowrap;
  transform: rotate(-14deg);   /* whole phrase slants upward, like it was scribbled quickly */
}
/* each line sits at its own slightly-off angle, like quick pen strokes */
.note__text span { display: block; }
.note__text span:nth-child(1) { transform: rotate(-4deg) translateX(-3%); }
.note__text span:nth-child(2) { transform: rotate(3deg) translate(4%, 4%); }
.note__tape {
  position: absolute;
  width: 40%;
  left: 31%; top: 14%;   /* straddles the paper's top edge so it reads as holding the note */
  transform: translateY(-50%) rotate(3deg);
}
/* no room beside the player on narrow screens: tuck it over the top-left corner */
@media (max-width: 900px) {
  .note { --note: calc(var(--stage) * 0.4); left: -6%; top: -11%; }
}
/* portrait screens (phones, iPad upright): the note sits on top, centred, as part of the column so the whole group stays centred */
@media (orientation: portrait) {
  :root { --stage: min(92vw, 560px, max(130px, calc((100svh - 310px) / 1.4))); }   /* leaves room for the note */
  .note { --note: calc(var(--stage) * 0.36); position: relative; order: -1; left: auto; top: auto; margin: 0 0 calc(var(--stage) * 0.03); transform: rotate(-4deg); }
}

/* ───────── Section 3 — letter, roses, camera ───────── */
.letter {
  --lpad: clamp(24px, 6svh, 72px);
  --board: min(80vw, 880px, max(260px, calc((100svh - 2 * var(--lpad)) / 0.77)));   /* letter + roses always fit the screen */
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--lpad) 0 calc(var(--lpad) + var(--board) * 0.21 + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow: hidden;
}
.letter__board {
  position: relative;
  width: var(--board);
  transform: translateX(8%);   /* roses stick out on the left, so nudge right to centre the whole group */
}
.letter__sheet { position: relative; transform: rotate(-2deg); will-change: transform; backface-visibility: hidden; }  /* own stable layer: never re-rasterised when the note finishes */
.letter__paper { width: 100%; height: auto; }

/* pen-written note on the paper (text zone sits left of the polaroid) */
.letter__text {
  position: absolute;
  left: 26%; top: 11%;
  width: 47%;
  font-family: "Wistha", "Jane", "Bradley Hand", cursive;
  font-size: calc(var(--board) * 0.04);
  line-height: 1.3;
  color: rgba(28, 35, 88, 0.93);     /* blue-black ink (plain alpha: no blend mode, so nothing re-composites when the writing ends) */
  text-shadow: 0 0 0.5px rgba(28, 35, 88, 0.55);   /* slight ink bleed */
  transform: rotate(-0.6deg);
  pointer-events: none;
}
.letter__text .w { display: inline-block; transform: translateY(var(--y)) rotate(var(--r)); }
.letter__text .ap { font-family: Georgia, "Times New Roman", serif; font-style: normal; font-size: 0.9em; margin: 0 0.04em 0 0.02em; }
.letter__text .heart-sticker { width: 1.4em; height: auto; vertical-align: -0.42em; margin: -0.5em 0.05em -0.4em; }   /* negative margins: the sticker never stretches the line height */
.letter__text .heart { width: 1em; height: 0.95em; vertical-align: -0.12em; overflow: visible;
  fill: none; stroke: #c0262d; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 600px) {
  .letter { --board: min(88vw, max(260px, calc((100svh - 2 * var(--lpad)) / 0.77))); }
  .letter__board { transform: translateX(5%); }
}
.letter__roses { position: absolute; height: auto; will-change: transform; }
/* roses lean on the bottom-left corner of the letter */
.letter__roses  { width: 38%; left: -13%; bottom: -34%; transform: rotate(-8deg); z-index: 2; }

/* sticker on the player's top-left corner */
.sticker {
  position: absolute;
  z-index: 2;
  left: 8%; top: 8.5%;    /* the art has a black margin: the body's corner is at ~6.4% / 6.8% */
  width: 14%; height: auto;
  transform: rotate(-14deg);
  pointer-events: none;
}

/* ───────── Section 4 — full-screen calendar ───────── */
.calendar {
  --line: rgba(255, 255, 255, 0.28);
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 340px;
  display: flex; flex-direction: column;
  padding: clamp(36px, 9svh, 96px) 0 0;
  background: var(--bg);
  overflow: hidden;
}
.calendar__title {
  flex: none;
  text-align: center;
  font-family: "Jane", "Bradley Hand", "Segoe Script", cursive;
  font-weight: 400;
  font-size: clamp(44px, min(11vw, 14svh), 128px);
  line-height: 1.1;
  padding-bottom: clamp(8px, 2vh, 24px);
  color: var(--fg);
  transform: rotate(-2deg);
}
.calendar__grid {
  flex: 1;
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: var(--fg);
}
.calendar__grid th {
  height: 2.6em;
  font-size: clamp(11px, 1.5vw, 15px);
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.calendar__grid td {
  vertical-align: top;
  text-align: right;
  padding: clamp(6px, 1.2vh, 12px) clamp(8px, 1.6vw, 18px);
  border-top: 1px solid var(--line);
  font-size: clamp(12px, 1.6vw, 17px);
  font-weight: 300;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.calendar__grid tbody tr:first-child td { border-top: 0; }
.calendar__grid td > span { display: inline-block; }   /* so the day numbers can be animated */
.cal__ch { display: inline-block; white-space: pre; }
.calendar__grid th + th, .calendar__grid td + td { border-left: 1px solid var(--line); }

/* a date cell filled with a photo */
.calendar__grid td.has-photo { position: relative; padding: 0; }
.calendar__grid td.has-photo > img:first-child {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 55%;
}
.calendar__grid td.has-photo span {
  position: absolute; z-index: 1;
  top: clamp(6px, 1.2vh, 12px); right: clamp(8px, 1.6vw, 18px);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/* ───────── Section 5 — birthday collage + wish ───────── */
.wish {
  --pad: clamp(16px, 3svh, 32px);
  --wgap: clamp(12px, 3svh, 32px);
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--wgap);
  padding: var(--pad) 16px calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow: hidden;
}
.collage {
  /* The collage art starts ~20% down its box, so the box is pulled up by 22% of its width: the visible content
     (not the empty margin) is what gets centred, keeping equal space above and below. The collage + text
     height budget is therefore 1.0 x width (1.22 - 0.22). --note-h is measured by js/wish.js. */
  --cw: min(88vw, 600px, max(100px, calc(100svh - var(--note-h, 230px) - 2 * var(--pad) - var(--wgap) - env(safe-area-inset-bottom, 0px))));
  position: relative;
  width: var(--cw);
  margin-top: calc(var(--cw) * -0.22);
  aspect-ratio: 1 / 1.22;
  flex: none;
}
.collage img { position: absolute; height: auto; will-change: transform; }
.collage__text  { width: 59.5%; left: 19.7%; top: 19.8%; transform: rotate(0.2deg); z-index: 1; }
.collage__her   { width: 42.9%; left: 29.4%; top: 45.8%; transform: rotate(-3deg); z-index: 2; }
.collage__crown { width: 19.3%; left: 36.2%; top: 42.9%; transform: rotate(-18.3deg); z-index: 3; }
.collage__cow   { width: 12.8%; left: 67.3%; top: 73.5%; transform: rotate(17.8deg); z-index: 5; }
.collage__lip   { width: 5.8%; left: 27.4%; top: 73.8%; transform: rotate(-26.8deg); z-index: 5; }
.collage__cake  { width: 22.7%; left: 41.6%; top: 77.3%; bottom: auto; transform: rotate(4.8deg); z-index: 4; }

.wish__note {
  width: min(88vw, 520px);
  text-align: center;
  font-family: "Wistha", "Jane", "Bradley Hand", "Segoe Script", cursive;
  font-size: clamp(19px, 2.8vw, 26px);
  line-height: 1.15;
  color: var(--fg);
  transform: rotate(-1.5deg);
}
.wish__note span { display: block; }
.wish__note span:first-child { font-size: 1.5em; line-height: 1.2; margin-bottom: 0.15em; }
.wish__note span + span { margin-top: 0.35em; }

/* ───────── Sticker tooltips: pop + bubble, everything else goes black & white ───────── */
.is-tip { cursor: pointer; -webkit-tap-highlight-color: transparent; outline: none; touch-action: manipulation; -webkit-touch-callout: none; }   /* manipulation: taps fire instantly on iPad, no double-tap delay */
.collage img, .wish__note, body > section, .calendar__title, .calendar__grid td > img { transition: filter 0.35s ease; }
html.has-tip body > section:not(.tip-home),
html.has-tip .wish__note,
html.has-tip .collage img:not(.is-active),
html.has-tip .calendar__title,
html.has-tip .calendar__grid td > img:not(.is-active) { filter: grayscale(1); }
.is-active { z-index: 20; }

.bubble {
  position: absolute;
  z-index: 30;
  width: max-content;
  max-width: min(70vw, 220px);
  padding: 9px 14px 10px;
  border-radius: 14px;
  background: #fff;
  color: #111;
  font-family: "Wistha", "Jane", "Bradley Hand", cursive;
  font-size: 22px;
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.bubble::after {                         /* tail pointing at the sticker */
  content: "";
  position: absolute;
  left: var(--tail, 50%); bottom: -5px;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%) rotate(45deg);
}

/* ramen sticker on the 25th: overlaps the photo's bottom-left corner */
.cal__sticker {
  position: absolute;
  z-index: 2;
  width: 44%; height: auto;
  left: -15%; bottom: -20%;
  transform: rotate(-9deg);
  outline: none;
  will-change: transform;
}
/* portrait (iPad / phone upright): cells are narrow, so scale the sticker up */
@media (orientation: portrait) {
  .cal__sticker { width: 80%; left: -28%; bottom: -34%; }
}

/* Wistha Belle draws its apostrophe as a detached accent, so use another script's for that glyph */
.wish__note .ap { font-family: Georgia, "Times New Roman", serif; font-style: normal; font-size: 0.9em; margin: 0 0.04em 0 0.02em; }

/* ───────── Section 6 — scrapbook journal ───────── */
.book {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex; justify-content: center; align-items: center;
  padding: 12px 0;
  background: var(--bg);
  overflow: hidden;
}
.book__stage {
  --bk: min(94vw, 980px, calc((100vh - 24px) / 1.02));
  --bk: min(94vw, 980px, calc((100svh - 24px) / 1.02));   /* the whole spread always fits the screen */
  position: relative;
  width: var(--bk);
  aspect-ratio: 1 / 1.02;
  transform: translateY(6.5%);   /* the content sits high in the box (title at the top, book ends ~86%): nudge down so top and bottom gaps match */
}
.book__pages { position: absolute; left: 7%; top: 22%; width: 86%; height: auto; z-index: 1; }
.book__title {
  position: absolute; z-index: 7; left: 0; right: 0; top: 2.5%;
  text-align: center;
  font-family: "Jane", "Bradley Hand", "Segoe Script", cursive;
  font-weight: 400;
  font-size: calc(var(--bk) * 0.1);
  line-height: 1.1;
  color: var(--fg);
  transform: rotate(-3deg);
  pointer-events: none;
}
.book__title .spark { position: absolute; fill: var(--fg); }
.spark.s1 { width: 0.3em; height: 0.3em; left: 8%;  top: 0; }
.spark.s2 { width: 0.2em; height: 0.2em; left: 12%; top: 0.55em; }
.spark.s3 { width: 0.26em; height: 0.26em; right: 9%; top: 0.1em; }
/* photos live on the paper: the container matches the book image exactly and is masked with the paper's own outline
   (rounded corners and all), so photos are cut precisely where the paper ends. Stickers sit outside it and can pop out. */
.book__clip {
  position: absolute; z-index: 3; left: 7%; top: 22%; width: 86%; aspect-ratio: 1092 / 824;
  -webkit-mask: url("../assets/book/paper-mask.png") center / 100% 100% no-repeat;
          mask: url("../assets/book/paper-mask.png") center / 100% 100% no-repeat;
}
.bk { position: absolute; height: auto; z-index: var(--z, 3); transform: rotate(var(--r, 0deg)); will-change: transform; user-select: none; -webkit-user-select: none; }
.bk-note {                                   /* pen-written note on the journal page */
  position: absolute; z-index: 5; margin: 0; pointer-events: none;
  font-family: "Wistha", "Jane", "Bradley Hand", cursive;
  font-size: calc(var(--bk) * 0.034); line-height: 1.15; text-align: center;
  color: rgba(28, 35, 88, 0.93);               /* blue-black ink, same as the letter */
  text-shadow: 0 0 0.5px rgba(28, 35, 88, 0.55);
  transform: rotate(var(--r, 0deg));
}
.bk-note .w { display: inline-block; }
.book__stage > .bk { outline: none; }
.book__stage > *, .book__stage > .bk { transition: filter 0.35s ease; }
html.has-tip .book__stage > :not(.is-active):not(.bubble) { filter: grayscale(1); }  /* includes .book__clip (all photos) */

/* ───────── Snap + spacing between sections ───────── */
body > section { scroll-snap-align: center; scroll-snap-stop: always; }
body > section + section { margin-top: clamp(40px, 12svh, 140px); }   /* breathing room as you scroll on */

/* ───────── Replay button (flower section) ───────── */
.replay {
  position: absolute;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(28px, 7svh, 64px));
  transform: translateX(-50%);
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.replay[hidden] { display: none; }
.replay svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.replay:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); color: #fff; }
.replay:active { transform: translateX(-50%) scale(0.94); }
.replay:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.8); outline-offset: 3px; }

/* ───────── Section 7 — make your own story (1080×1920 paper collage) ───────── */
.story {
  --title: clamp(34px, 7svh, 76px);     /* "Photobooth" heading (same script font as Memories / November) */
  --bar-h: 64px;
  height: 100svh; min-height: 480px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 18px 0 14px;
}
.story__title {
  flex: none; margin: 0 0 calc(var(--title) * 0.3); text-align: center;   /* extra room under the script heading */
  font-family: "Jane", "Bradley Hand", "Segoe Script", cursive; font-weight: 400;
  font-size: var(--title); line-height: 1.1;
  color: var(--fg); transform: rotate(-3deg);
}
.story__paper {
  position: relative; flex: none;
  aspect-ratio: 9 / 16;
  height: min(calc(100svh - var(--chrome, 132px) - var(--title) * 1.45 - 32px), calc(92vw * 16 / 9));
  background: #f4f1ea;
  overflow: hidden;
  border-radius: 3px;
  container-type: size;
  user-select: none; -webkit-user-select: none;
}
.story__paper > canvas.s-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.st { position: absolute; height: auto; rotate: var(--r, 0deg); z-index: var(--z, 3); }
.st--img { display: block; pointer-events: none; }
button.st { padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-appearance: none; appearance: none; }
button.st canvas { display: block; width: 100%; height: 100%; }
button.st:focus-visible { outline: 2px solid #1b1b1b; outline-offset: 4px; }
.st--frame .hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 500 clamp(11px, 3.2cqw, 16px) / 1.2 -apple-system, "Helvetica Neue", Arial, sans-serif; color: rgba(40, 36, 30, 0.55);
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none; text-align: center;
}
.st--frame.is-filled:hover .hint, .st--frame.is-filled:focus-visible .hint { opacity: 1; background: rgba(255, 255, 255, 0.55); }
.st--frame:not(.is-filled) .hint { opacity: 1; }
.st--frame .hint span { font-family: "Jane", Georgia, serif; font-size: clamp(16px, 5.2cqw, 28px); color: rgba(40, 36, 30, 0.6); }

/* camera: the screen is a canvas placed exactly over the display of the camera image */
.st--cam img { width: 100%; display: block; pointer-events: none; }
.cam__screen {
  position: absolute; left: 13.67%; top: 35.35%; width: 41.28%; height: 46.29%;
  background: #08090a; border-radius: 1.2%; overflow: hidden; border: 0; padding: 0; cursor: pointer;
  touch-action: manipulation; color: rgba(255, 255, 255, 0.82);
}
.cam__screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cam__screen .hint {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1.2cqw; text-align: center;
  font-family: "Jane", Georgia, serif; font-size: clamp(14px, 4.2cqw, 26px); letter-spacing: 0.02em;
}
.cam__screen .hint svg { width: 7cqw; height: 7cqw; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cam__screen[data-state="shot"] .hint { display: none; }
.cam__screen[data-state="shot"]:hover::after, .cam__screen[data-state="shot"]:focus-visible::after {
  content: "Change photo"; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); font-family: "Jane", Georgia, serif; font-size: clamp(14px, 4.4cqw, 26px); color: #fff;
}
.cam__screen:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

.story__bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: min(92vw, 560px); }
.sbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26); background: rgba(255, 255, 255, 0.04); color: rgba(255, 255, 255, 0.85);
  font: 500 14px / 1 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}
.sbtn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sbtn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); color: #fff; }
.sbtn:active { transform: scale(0.96); }
.sbtn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.85); outline-offset: 3px; }
.sbtn--main, .sbtn--go { background: #fff; border-color: #fff; color: #0b0b0b; }
.sbtn--main:hover, .sbtn--go:hover { background: #ececec; border-color: #ececec; color: #000; }
.sbtn[aria-checked="false"] { opacity: 0.6; }
.sbtn b { font-weight: 600; }
.sbtn[disabled] { opacity: 0.45; cursor: progress; }
.story__status { min-height: 16px; font-size: 13px; color: var(--muted); text-align: center; padding: 0 16px; }
@media (max-width: 480px) { .sbtn { padding: 0 11px; font-size: 13px; gap: 6px; } .story__bar { gap: 6px; } }
@media (max-width: 560px) { .story { --chrome: 178px; } }

/* ───────── Loader: black screen with a thin progress line while assets download ───────── */
html.is-loading, html.is-loading body { overflow: hidden; }
#loader {
  position: fixed; inset: 0; z-index: 1000; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 0 24px;
}
.loader__title { margin: 0; font-family: "Jane", "Bradley Hand", "Segoe Script", cursive; font-size: clamp(34px, 8vw, 56px); color: var(--fg); transform: rotate(-3deg); }
.loader__bar { width: min(56vw, 260px); height: 2px; background: rgba(255, 255, 255, 0.18); border-radius: 2px; overflow: hidden; }
.loader__bar i { display: block; height: 100%; background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform 0.2s ease-out; }
.loader__pct { margin: 0; font-size: 12px; letter-spacing: 0.14em; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ───────── Passcode gate (above the loader; custom number pad, no phone keyboard) ───────── */
#gate {
  position: fixed; inset: 0; z-index: 1002; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 3.4svh, 30px); padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  transition: opacity 0.5s ease; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  --key: clamp(54px, min(19vw, 9svh), 80px);
}
#gate.is-gone { opacity: 0; pointer-events: none; }
.gate__title { margin: 0; font-family: "Jane", "Bradley Hand", "Segoe Script", cursive; font-size: clamp(34px, min(9vw, 7svh), 58px); line-height: 1.1; color: var(--fg); transform: rotate(-3deg); }
.gate__boxes { display: flex; gap: clamp(6px, 2vw, 12px); }
.gate__box {
  width: clamp(40px, min(12.4vw, 7.4svh), 58px); aspect-ratio: 5 / 6;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 10px; background: rgba(255, 255, 255, 0.04);
  font-size: clamp(20px, min(6vw, 3.6svh), 28px); font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.28);
  letter-spacing: 0.04em; transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.gate__box.is-next { border-color: rgba(255, 255, 255, 0.7); }
.gate__box.is-filled { color: var(--fg); border-color: rgba(255, 255, 255, 0.8); background: rgba(255, 255, 255, 0.1); animation: gate-pop 0.18s ease-out; }
#gate.is-bad .gate__box { border-color: #ff5a5f; color: #ff5a5f; background: rgba(255, 90, 95, 0.1); animation: gate-shake 0.5s ease-in-out; }
#gate.is-ok .gate__box { border-color: #fff; background: #fff; color: #000; }
@keyframes gate-pop { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }
@keyframes gate-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.gate__pad { display: grid; grid-template-columns: repeat(3, var(--key)); gap: clamp(10px, 2.4svh, 18px) clamp(14px, 4vw, 22px); }
.gate__key {
  width: var(--key); height: var(--key); border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.06); color: var(--fg);
  font: 400 clamp(22px, 3.6svh, 30px) / 1 system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums;
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}
.gate__key:active { background: rgba(255, 255, 255, 0.24); border-color: rgba(255, 255, 255, 0.6); transform: scale(0.93); }
.gate__key:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.gate__key--blank { visibility: hidden; border: 0; background: none; }
.gate__key--back { border-color: transparent; background: none; }
.gate__key--back svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .gate__key:not(.gate__key--blank):hover { background: rgba(255, 255, 255, 0.14); } }
