:root {
  /* Colours picked from the reference drawing: brown ink, white paper, ginger fur,
     and the washed-out pink, sage, blue and lavender of the props. */
  --ink: #2f241d;
  --page: #fffcf6;
  --paper: #fffefa;
  --paper-2: #f6eee2;
  --ginger: #d9893e;
  --butter: #f6e3b4;
  --pink: #eaa5ad;
  --leaf: #b5cf95;
  --sky: #9db3d4;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
  --round: 'Patrick Hand SC', 'Patrick Hand', 'Comic Sans MS', cursive;
  /* Uneven corner radii make boxes look drawn by hand rather than ruled. */
  --sketch: 18px 8px 20px 10px / 10px 20px 8px 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  background: #c8df9f;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 21px;
  line-height: 1.35;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; height: 100vh; }
h1, h2 { font-family: var(--round); font-weight: 400; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* cover */
#cover {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  padding: 16px;
  perspective: 1600px;
  background:
    repeating-linear-gradient(0deg, rgba(234,165,173,.18) 0 26px, transparent 26px 52px),
    repeating-linear-gradient(90deg, rgba(234,165,173,.18) 0 26px, transparent 26px 52px),
    var(--page);
  transition: opacity .8s ease, visibility .8s;
}
#cover.gone { opacity: 0; visibility: hidden; }
.book {
  position: relative;
  width: min(84vw, 400px);
  aspect-ratio: .74;
  transform-style: preserve-3d;
  animation: arrive .9s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes arrive { from { transform: translateY(40px) rotate(-5deg) scale(.86); opacity: 0; } }
.page-under, .front {
  position: absolute; inset: 0;
  border: 2.5px solid var(--ink);
  border-radius: 8px 20px 20px 8px;
}
.page-under {
  background: var(--paper);
  display: grid; place-items: center;
  box-shadow: 0 14px 0 -6px rgba(47,36,29,.12);
}
.under-note { font-size: 34px; margin: 0; }
.front {
  background:
    radial-gradient(circle at 20% 15%, rgba(234,165,173,.35), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(181,207,149,.35), transparent 45%),
    var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 26px 26px 26px 42px;
  text-align: center;
  transform-origin: left center;
  transition: transform 1.2s cubic-bezier(.6,.05,.3,1);
  backface-visibility: hidden;
}
.book.open .front { transform: rotateY(-165deg); }
.stitch {
  position: absolute; left: 14px; top: 16px; bottom: 16px;
  border-left: 2.5px dashed rgba(47,36,29,.45);
}
.tape {
  position: absolute; top: -16px; left: 50%; width: 130px; height: 34px;
  transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, var(--paper) 0 9px, var(--pink) 9px 18px);
  border: 2px solid var(--ink);
}
.tab {
  position: absolute; right: -24px; width: 22px; height: 56px;
  border: 2.5px solid var(--ink); border-left: 0; border-radius: 0 10px 10px 0;
}
.t1 { top: 12%; background: var(--pink); }
.t2 { top: 34%; background: var(--leaf); }
.t3 { top: 56%; background: var(--sky); }
.for { margin: 0; font-size: 24px; }
#coverName {
  font-size: clamp(50px, 14vw, 72px);
  line-height: 1;
  display: flex; flex-wrap: wrap; justify-content: center;
}
#coverName span { display: inline-block; animation: pop .55s cubic-bezier(.2,1.7,.4,1) both; }
@keyframes pop { from { transform: scale(0) rotate(-20deg); opacity: 0; } }
/* multiply drops the drawing's white background so the cat sits on the cover like a sticker */
.cover-cat {
  width: 58%; aspect-ratio: 1; object-fit: contain;
  mix-blend-mode: multiply;
  transform: rotate(-3deg);
  animation: wiggle 3s ease-in-out infinite;
}
@keyframes wiggle { 50% { transform: rotate(3deg); } }
.pill {
  font-family: var(--round); font-size: 22px;
  padding: 8px 28px;
  background: var(--pink); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pill.small { font-size: 19px; padding: 5px 20px; }
.pill.ghost { background: var(--paper); color: var(--ink); }

/* layout */
#app { position: relative; z-index: 2; }
/* The tabs and the sound button share one sticky bar; only the tabs scroll sideways. */
.topbar {
  position: sticky; top: 8px; z-index: 12;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 8px 12px 0;
}
#tabs {
  display: flex; gap: 6px;
  min-width: 0; max-width: 100%;
  padding: 6px;
  overflow-x: auto; scrollbar-width: none;
  background: rgba(255,254,250,.94);
  border: 2.5px solid var(--ink); border-radius: var(--sketch);
}
#tabs::-webkit-scrollbar { display: none; }
#tabs a {
  flex: none;
  font-family: var(--round); font-size: 17px;
  padding: 4px 12px; border-radius: 12px;
  color: var(--ink); text-decoration: none;
}
#tabs a.on { background: var(--butter); }

/* garden */
#grass { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.scene { min-height: calc(100vh - 60px); position: relative; }
.sound-toggle {
  position: relative; flex: none;
  width: 44px; height: 44px; padding: 0;
  font-size: 22px; line-height: 1;
  background: rgba(255,254,250,.94);
  border: 2.5px solid var(--ink); border-radius: 50%;
}
.sound-toggle.off { opacity: .6; }
.sound-toggle.off::after {
  content: ''; position: absolute; left: 9px; right: 9px; top: 50%;
  border-top: 2.5px solid var(--ink); transform: rotate(-45deg);
}
.garden-title {
  position: absolute; left: 0; right: 0; top: 26px; z-index: 3;
  text-align: center; pointer-events: none;
  text-shadow: 0 2px 0 rgba(255,254,250,.8);
  padding: 0 16px;
}
.garden-title h2 { font-size: clamp(34px, 7vw, 52px); }
.garden-title p { margin: 4px 0 0; font-size: 21px; }
#bubbles { position: absolute; inset: 0; overflow: hidden; }
.bubble {
  position: absolute; left: 0; top: 0;
  width: var(--s); height: var(--s);
  padding: 0;
  border: 3px solid var(--ink); border-radius: 50%;
  background: #fff center / 88% no-repeat;
  box-shadow: 0 0 0 5px #fffefa, 0 10px 18px rgba(47,36,29,.22);
  will-change: transform;
}
.bubble:hover { filter: brightness(1.04); }
.scroll-tip {
  position: absolute; left: 50%; bottom: 22px; z-index: 3;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 6px 18px; white-space: nowrap;
  font-size: 20px; color: var(--ink); text-decoration: none;
  background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: 99px;
  box-shadow: 0 4px 0 rgba(47,36,29,.18);
  transition: opacity .4s;
}
.scroll-tip i { font-style: normal; display: inline-block; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }
.scroll-tip.gone { opacity: 0; pointer-events: none; }

/* the day loop */
/* The loop sits on a box with the drawing's own proportions.
   container-type lets the labels scale with the box (cqw units).
   The solid background matters: the box is its own stacking context, so the multiply
   blend on the cats needs a backdrop inside it for the white around each drawing to vanish. */
.day {
  position: relative;
  container-type: inline-size;
  width: min(100%, 560px);
  aspect-ratio: 1122 / 1402;
  margin: 0 auto;
  background: var(--paper);
}
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arrows path { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.arrows > path { marker-end: url(#head); }
.day-cat {
  position: absolute; padding: 0;
  background: none; border: 0;
  mix-blend-mode: multiply;
  animation: bob 3.6s ease-in-out infinite;
  transition: scale .2s;
}
.day-cat img { display: block; width: 100%; height: auto; }
.day-cat:hover, .day-cat:focus-visible { scale: 1.05; }
@keyframes bob { 50% { transform: translateY(-1.6%) rotate(-1deg); } }
.day-label {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--round); font-size: max(17px, 5cqw); line-height: 1;
  letter-spacing: .04em; white-space: nowrap; pointer-events: none;
}
.day-label.small { font-size: max(12px, 2.5cqw); }
.day-title {
  position: absolute; left: 50.8%; top: 52%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
#lifeTitle { font-size: max(30px, 8.6cqw); line-height: .95; }
#lifeTitle span { display: block; }
/* Wavy peach underline, like the brush stroke under the title in the drawing. */
.day-title::after {
  content: ''; display: block; width: 80%; height: 10px; margin: 6px auto 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 10'%3E%3Cpath d='M2 6Q30 2 60 5T118 4' fill='none' stroke='%23f2c29a' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.doodle { position: absolute; font-style: normal; font-size: max(14px, 3cqw); line-height: 1; }
.d1 { left: -18%; top: 4%; } .d2 { right: -12%; top: -14%; } .d3 { right: -22%; top: 6%; }
.d4 { left: -24%; top: 40%; } .d5 { right: -18%; top: 70%; }

.card {
  position: relative;
  width: min(calc(100vw - 32px), 640px);
  margin: 0 auto 40px;
  padding: 24px 20px;
  text-align: center;
  background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: var(--sketch);
  box-shadow: 0 6px 0 rgba(47,36,29,.1);
}
.card h2 { font-size: 38px; }
.hint { margin: 2px 0 12px; opacity: .78; }

/* letter */
.envelope {
  position: relative;
  width: min(100%, 420px); aspect-ratio: 1.5;
  margin: 34px auto 14px;
  cursor: pointer;
}
.env-back, .env-front, .env-flap, .paper { position: absolute; }
.env-back { inset: 0; background: #e9cdb4; border: 2.5px solid var(--ink); border-radius: 12px; }
.env-front {
  inset: 0; z-index: 3;
  background: var(--pink);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  border-radius: 12px;
}
.env-flap {
  left: 0; right: 0; top: 0; height: 58%; z-index: 4;
  background: #e3939d;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform .6s;
}
.seal {
  position: absolute; z-index: 5; left: 50%; top: 52%;
  width: 48px; height: 48px; margin: -24px;
  display: grid; place-items: center;
  background: var(--ginger); color: #fff;
  border: 2.5px solid var(--ink); border-radius: 50%;
  transition: opacity .3s, transform .3s;
}
.paper {
  left: 6%; right: 6%; bottom: 8%; height: 84%; z-index: 2;
  padding: 16px 18px;
  overflow: hidden;
  text-align: left;
  background: var(--paper);
  border: 2px solid var(--ink); border-radius: 8px;
  transition: transform .9s .25s cubic-bezier(.3,1.2,.5,1), height .9s .25s;
}
.paper p { margin: 0 0 10px; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .seal { opacity: 0; transform: scale(0); }
.envelope.open .paper { transform: translateY(-46%); z-index: 6; }
.envelope.read { aspect-ratio: auto; margin: 16px auto 4px; cursor: default; }
.envelope.read .env-back, .envelope.read .env-front, .envelope.read .env-flap, .envelope.read .seal { display: none; }
.envelope.read .paper {
  position: static; height: auto; min-height: 230px;
  transform: none; transition: none; overflow: visible;
  background: repeating-linear-gradient(var(--paper) 0 33px, #efe4d3 33px 35px);
  animation: pop .4s cubic-bezier(.2,1.4,.4,1);
}
.caret::after { content: '|'; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* photos */
.pile { position: relative; height: 420px; margin: 0 auto 10px; touch-action: none; }
.polaroid {
  position: absolute; left: 50%; top: 50%;
  width: 190px; margin: -124px 0 0 -95px; padding: 9px 9px 0;
  background: #fff;
  border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: 0 6px 14px rgba(47,36,29,.18);
  cursor: grab; user-select: none; touch-action: none;
  transition: box-shadow .15s;
}
.polaroid.drag { cursor: grabbing; box-shadow: 0 16px 26px rgba(47,36,29,.3); }
.polaroid.fly { transition: transform .6s cubic-bezier(.3,1.3,.5,1); }
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; pointer-events: none; }
.polaroid p { margin: 0; padding: 6px 2px 8px; text-align: center; font-size: 19px; line-height: 1.1; }

/* bouquet */
.bouquet-stage { width: min(100%, 340px); margin: 0 auto; }
#flowers { display: block; width: 100%; height: auto; overflow: visible; }
.bloom { animation: grow .55s cubic-bezier(.2,1.7,.4,1) both; transform-box: fill-box; transform-origin: center; }
@keyframes grow { from { transform: scale(0) rotate(-40deg); } }
.sway { animation: sway 4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes sway { 50% { transform: rotate(1.6deg); } }
.palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 10px 0 14px; }
.palette button {
  width: 58px; height: 58px; padding: 4px;
  background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: var(--sketch);
  transition: transform .15s;
}
.palette button:hover { transform: rotate(-6deg) scale(1.08); }
.palette svg { width: 100%; height: 100%; display: block; }

/* songs */
.cassette {
  position: relative;
  width: min(100%, 320px); height: 150px;
  margin: 12px auto 14px;
  display: flex; align-items: center; justify-content: center; gap: 60px;
  background: var(--butter);
  border: 2.5px solid var(--ink); border-radius: 16px;
}
.cassette p {
  position: absolute; left: 12px; right: 12px; top: 8px; margin: 0;
  padding: 2px 8px;
  background: var(--paper);
  border: 2px solid var(--ink); border-radius: 6px;
  font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reel {
  width: 58px; height: 58px; margin-top: 34px;
  border: 2.5px solid var(--ink); border-radius: 50%;
  background: conic-gradient(var(--ink) 0 12%, #fff 0 33%, var(--ink) 0 45%, #fff 0 66%, var(--ink) 0 78%, #fff 0);
}
.cassette.playing .reel { animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#songList { list-style: none; margin: 0; padding: 0; text-align: left; }
#songList li + li { margin-top: 8px; }
.song {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 12px; text-align: left;
  background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: var(--sketch);
}
.song.on { background: var(--butter); }
.song b { font-family: var(--round); font-weight: 400; display: block; font-size: 20px; }
.song small { font-size: 18px; opacity: .75; }
.song i { flex: none; font-style: normal; }

/* map */
.map {
  position: relative; aspect-ratio: 10 / 7;
  background: #dce6f2;
  border: 2.5px solid var(--ink); border-radius: var(--sketch); overflow: hidden;
}
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.land { fill: #f3e6c8; stroke: var(--ink); stroke-width: .7; vector-effect: non-scaling-stroke; }
.route { fill: none; stroke: var(--ginger); stroke-width: 3; stroke-dasharray: 8 8; vector-effect: non-scaling-stroke; }
.pin {
  position: absolute; width: 38px; height: 38px; margin: -38px 0 0 -19px; padding: 0;
  background: none; border: 0; font-size: 0;
  transition: transform .18s;
}
.pin::before {
  content: ''; position: absolute; inset: 2px;
  background: var(--pink);
  border: 2.5px solid var(--ink); border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}
.pin::after {
  content: ''; position: absolute; left: 13px; top: 11px; width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
}
.pin:hover, .pin.on { transform: scale(1.22) translateY(-3px); }
.place-card {
  display: flex; gap: 12px; align-items: center; text-align: left;
  margin-top: 12px; padding: 10px;
  background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: var(--sketch);
  animation: pop .4s cubic-bezier(.2,1.5,.4,1);
}
.place-card img { width: 92px; height: 92px; object-fit: contain; background: #fff; border: 2px solid var(--ink); border-radius: 10px; }
.place-card b { font-family: var(--round); font-weight: 400; display: block; }

/* voice */
.voice { display: flex; align-items: center; gap: 14px; margin: 14px 0 6px; }
.round {
  flex: none; width: 62px; height: 62px;
  background: var(--pink); color: var(--ink); font-size: 22px;
  border: 2.5px solid var(--ink); border-radius: 50%;
}
.wave { flex: 1; display: flex; align-items: center; gap: 3px; height: 64px; overflow: hidden; }
.wave i { flex: 1; min-width: 3px; background: var(--ink); border-radius: 3px; opacity: .3; transition: opacity .15s; }
.wave i.on { opacity: 1; background: var(--ginger); }

/* quiz */
#quiz p.q { font-size: 26px; margin: 12px 0; }
.options { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.opt {
  width: min(100%, 340px); padding: 8px 14px;
  background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: var(--sketch);
  transition: transform .15s;
}
.opt:hover { transform: scale(1.03) rotate(-1deg); background: var(--butter); }
.reply { color: #a85a22; min-height: 30px; margin: 12px 0 0; }
.final { position: relative; min-height: 190px; }
.final .pill { margin: 6px; }
#runaway { position: relative; background: var(--paper); color: var(--ink); transition: transform .2s; }

#signoff { padding: 10px 16px 60px; text-align: center; font-size: 26px; }

/* lightbox and sparks */
#lightbox {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 16px;
  background: rgba(47,36,29,.45);
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
#lightbox figure {
  margin: 0; padding: 12px 12px 4px;
  width: min(100%, 420px);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 6px;
  transform: rotate(-2deg);
  animation: pop .4s cubic-bezier(.2,1.5,.4,1);
}
#lightbox img { display: block; width: 100%; max-height: 66vh; object-fit: contain; }
#lightbox figcaption { padding: 10px 4px; text-align: center; font-size: 24px; }
#sparks { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.spark {
  position: absolute; font-size: 26px;
  animation: burst 1.3s ease-out forwards;
}
@keyframes burst {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(.6); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover-cat, .day-cat, .sway, .cassette.playing .reel, .scroll-tip i { animation: none; }
}
