:root {
  --ink: #57303c;
  --ink-soft: #7d5563;
  --sky: #d9e8f3;
  --butter: #fdf2d8;
  --peach: #fbe2cf;
  --blush: #f7cfc9;
  --blush-deep: #eeb3ae;
  --blush-light: #fbdcd6;
  --rose-dark: #d98a8e;
  --coral: #e2604f;
  --paper: #fffaf0;
  --sage: #8fab78;
  --sage-deep: #5f8058;
  --w: min(80vw, 54vh, 420px);
  --display: "Fraunces", Georgia, serif;
  --hand: "Nanum Pen Script", "Segoe Print", cursive;
}

@supports (height: 1svh) {
  :root { --w: min(80vw, 54svh, 420px); }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  overscroll-behavior: none;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background: var(--butter);
  font-family: var(--hand);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 2.5px dashed var(--coral);
  outline-offset: 5px;
}

/* ---------- sky ---------- */

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 84% 6%, rgba(255, 249, 226, .95), rgba(255, 244, 214, .45) 9%, rgba(255, 240, 210, 0) 30%),
    linear-gradient(var(--sky) 0%, #eef0e6 38%, var(--butter) 66%, var(--peach) 100%);
  overflow: hidden;
}

.cloud {
  position: absolute;
  width: 150px;
  height: 44px;
  border-radius: 40px;
  background: #fffdf8;
  opacity: .85;
  animation: cloud 70s linear infinite alternate;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.cloud::before { width: 66px; height: 66px; left: 24px; top: -32px; }
.cloud::after { width: 48px; height: 48px; left: 78px; top: -20px; }
.c1 { top: 10%; left: 5%; }
.c2 { top: 21%; right: -2%; transform: scale(.72); animation-duration: 95s; animation-direction: alternate-reverse; }
.c3 { top: 4%; left: 58%; transform: scale(.5); animation-duration: 120s; }

@keyframes cloud { to { translate: 90px 0; } }

/* ---------- drifting petals ---------- */

#petals {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.petal {
  position: absolute;
  top: -30px;
  border-radius: 75% 5% 75% 5%;
  animation: fall linear infinite;
  opacity: .9;
}

@keyframes fall {
  0%   { transform: translate(0, -5vh) rotate(0deg) rotateY(0deg); }
  25%  { transform: translate(5vw, 25vh) rotate(90deg) rotateY(150deg); }
  50%  { transform: translate(-2vw, 55vh) rotate(170deg) rotateY(330deg); }
  75%  { transform: translate(6vw, 82vh) rotate(260deg) rotateY(470deg); }
  100% { transform: translate(1vw, 112vh) rotate(350deg) rotateY(640deg); }
}

/* ---------- meadow ---------- */

#meadow {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
}

.hill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  display: block;
}
.hill.rear { z-index: 0; }
.fields {
  position: absolute;
  left: 0;
  bottom: 5vh;
  z-index: 0;
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  animation: fields-in 1.6s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes fields-in {
  from { opacity: 0; transform: translateY(14px); }
}
.hill.front { z-index: 30; }

.plant {
  position: absolute;
  bottom: 2vh;
  transform-origin: 50% 100%;
  animation: grow 1.1s cubic-bezier(.3, 1.35, .5, 1) var(--grow, 0s) both;
}
.plant img {
  display: block;
  transform-origin: 50% 100%;
  animation: sway var(--sway, 5s) ease-in-out var(--sway-delay, 0s) infinite alternate;
  user-select: none;
}
.bush img { animation: none; }

@keyframes grow {
  from { transform: scale(.5, 0); }
  to   { transform: none; }
}

@keyframes sway {
  from { transform: rotate(-2.2deg); }
  to   { transform: rotate(2.2deg); }
}

.stem {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.3s cubic-bezier(.3, .7, .4, 1) var(--grow, 0s) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.pop {
  transform: scale(0);
  transform-origin: 0 0;
  animation: pop .75s cubic-bezier(.3, 1.7, .5, 1) var(--pop, 0s) forwards;
}
@keyframes pop { to { transform: scale(1); } }

/* ---------- butterflies ---------- */

#butterflies {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.butterfly {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 30px;
  animation: flutter-a 34s ease-in-out infinite;
}
.butterfly.two {
  width: 25px;
  height: 22px;
  animation: flutter-b 43s ease-in-out -14s infinite;
}
.butterfly img { position: absolute; top: 0; display: block; width: 50%; height: 100%; }
.wing { animation: flap .24s ease-in-out infinite alternate; }
.wing.l { left: 0; transform-origin: 100% 50%; }
.wing.r { right: 0; transform-origin: 0% 50%; }
.butterfly .bug { left: 25%; }

@keyframes flap { to { transform: scaleX(.3); } }

@keyframes flutter-a {
  0%   { transform: translate(-8vw, 58vh) rotate(14deg); }
  18%  { transform: translate(14vw, 42vh) rotate(-8deg); }
  36%  { transform: translate(34vw, 12vh) rotate(16deg); }
  54%  { transform: translate(66vw, 24vh) rotate(-12deg); }
  72%  { transform: translate(90vw, 8vh) rotate(10deg); }
  100% { transform: translate(110vw, 44vh) rotate(-6deg); }
}
@keyframes flutter-b {
  0%   { transform: translate(108vw, 18vh) rotate(-12deg); }
  25%  { transform: translate(78vw, 60vh) rotate(10deg); }
  50%  { transform: translate(48vw, 6vh) rotate(-16deg); }
  75%  { transform: translate(12vw, 34vh) rotate(12deg); }
  100% { transform: translate(-8vw, 66vh) rotate(-8deg); }
}

/* ---------- password lock ---------- */

.lock {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 58px 0 40px;
}

.paper.lock-card {
  width: min(92vw, 470px);
  margin: auto;
  padding: 58px clamp(24px, 6vw, 46px) 62px;
}

.lock-card .corner { transform: none; }
.lock-card .corner.tr { width: clamp(92px, 26vw, 128px); }
.lock-card .corner.bl { width: clamp(80px, 22vw, 108px); }

.padlock {
  position: absolute;
  z-index: 2;
  top: -40px;
  left: 50%;
  width: 72px;
  height: 86px;
  margin-left: -36px;
  overflow: visible;
  filter: drop-shadow(0 4px 5px rgba(87, 48, 60, .28));
}
.shackle {
  transform-box: fill-box;
  transform-origin: 100% 100%;
  transition: transform .55s cubic-bezier(.3, 1.6, .5, 1);
}
.unlocked .shackle { transform: translateY(-13px) rotate(24deg); }

.poem-title {
  position: relative;
  margin: 0 0 14px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.6rem, 6.4vw, 2.1rem);
  line-height: 1.1;
  color: var(--coral);
}

.poem { position: relative; }
/* Wrapped lines hang under the first word, so first letters always stay in a clean column. */
.poem p {
  margin: 0;
  padding-left: .9em;
  text-indent: -.9em;
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  line-height: 1.3;
}
.poem p.gap { height: .8em; }

.lock-form { position: relative; margin-top: 22px; }

.lock-prompt {
  display: block;
  margin-bottom: 6px;
  font-family: var(--display);
  font-style: italic;
  font-size: .98rem;
  color: var(--ink-soft);
}

.lock-row { display: flex; gap: 10px; align-items: stretch; }

.lock-input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 2px 12px;
  border: 1.5px solid rgba(87, 48, 60, .35);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.6rem;
}
.lock-input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(226, 96, 79, .22);
}

.lock-button {
  flex: none;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  background: #c8432f;
  color: #fffaf0;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  transition: background .2s, scale .15s;
}
.lock-button:hover { background: #ad3524; }
.lock-button:active { scale: .96; }

.lock-msg {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 1.4rem;
  line-height: 1.2;
  color: #b23a2a;
}

.lock-hint {
  margin: 2px 0 0;
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--ink-soft);
}

/* ---------- first screen ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vh, 24px);
  padding: 0 16px 6vh;
  pointer-events: none;
}
.stage > * { pointer-events: auto; }

.kicker {
  margin: 0;
  max-width: 90vw;
  text-align: center;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.25rem, 3.4vh, 2rem);
  line-height: 1.2;
  text-wrap: balance;
  transition: opacity .5s;
}

.hint {
  position: relative;
  z-index: 40;
  margin: 0;
  padding: 2px 18px 3px;
  border-radius: 999px;
  background: rgba(255, 250, 240, .92);
  box-shadow: 0 3px 10px -3px rgba(87, 48, 60, .3);
  font-size: clamp(1.5rem, 3.4vh, 1.9rem);
  line-height: 1.3;
  color: var(--ink);
  animation: nudge 1.8s ease-in-out infinite;
  transition: opacity .3s;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.envelope {
  position: relative;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 1.15);
  transition: transform .9s cubic-bezier(.4, 0, .3, 1), opacity .7s;
}

.float {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  animation: float 4.5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-.8deg); }
  50%      { transform: translateY(-7px) rotate(.8deg); }
}

.spinner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(.55, -.12, .3, 1.15);
}

.face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.front {
  border-radius: 10px;
  box-shadow: 0 14px 30px -10px rgba(87, 48, 60, .42), 0 2px 4px rgba(87, 48, 60, .14);
  transition: scale .25s;
}
.front:hover { scale: 1.015; }
.front-base,
.front-wreath {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  pointer-events: none;
  user-select: none;
}

.frame {
  position: absolute;
  overflow: hidden;
  border-radius: 50%;
  clip-path: url(#frameClip);
  -webkit-clip-path: url(#frameClip);
}
.frame-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
#brush {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
/* While the flowers are up, every touch on the envelope brushes; none of it scrolls or navigates. */
.front.brushing {
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
img { -webkit-user-drag: none; }
#fx {
  position: fixed;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.back { transform: rotateY(180deg); }

/* The flip is finished: drop the 3D context so z-index stacks the flap and letter. */
[data-state="back"] .spinner { transform: none; transition: none; transform-style: flat; }
[data-state="back"] .back { transform: none; backface-visibility: visible; -webkit-backface-visibility: visible; }
[data-state="back"] .front { display: none; }
[data-state="flipping"] .spinner { transform: rotateY(180deg); }

.env-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 10px;
  background: var(--rose-dark);
  box-shadow: 0 14px 30px -10px rgba(87, 48, 60, .42), 0 2px 4px rgba(87, 48, 60, .14);
}

.peek {
  position: absolute;
  z-index: 2;
  left: 7%;
  right: 7%;
  top: 3%;
  bottom: 3%;
  display: flex;
  justify-content: center;
  padding-top: 7%;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 252, 245, 0) 55%, rgba(246, 222, 196, .22) 100%),
    url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27n%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.85%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270%200%200%200%20.34%200%200%200%200%20.19%200%200%200%200%20.24%200%200%200%20.05%200%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27100%25%27%20height%3D%27100%25%27%20filter%3D%27url(%23n)%27%2F%3E%3C%2Fsvg%3E"),
    var(--paper);
  border-radius: 4px;
  color: var(--coral);
  font-size: calc(var(--w) * .11);
  line-height: 1;
  transition: transform 1s cubic-bezier(.3, .8, .3, 1);
}

.pocket {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}
.pocket svg { display: block; width: 100%; height: 100%; overflow: visible; }

.flap {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: 100%;
  height: 58%;
  transform: perspective(1100px) rotateX(0deg);
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  pointer-events: none;
  transition: transform .85s cubic-bezier(.45, .05, .35, 1), z-index 0s .36s;
}
.flap svg,
.flap img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flap .inside { transform: rotateX(180deg); }
.flap .outside { filter: drop-shadow(0 2px 3px rgba(87, 48, 60, .28)); }

.seal {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 58%;
  width: 25%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  animation: seal-glow 2.2s ease-in-out infinite;
}
.seal:hover { scale: 1.06; }
.seal-half {
  position: absolute;
  inset: 0;
  transition: transform .6s cubic-bezier(.3, .3, .5, 1), opacity .5s .12s;
}
.seal-half img { display: block; width: 100%; height: 100%; filter: drop-shadow(0 3px 3px rgba(87, 24, 40, .45)); }
.seal::before {
  content: "";
  position: absolute;
  inset: -24%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(226, 96, 79, .75), rgba(226, 96, 79, 0));
  animation: halo 1.1s ease-in-out infinite alternate;
}
@keyframes halo {
  from { opacity: .15; transform: scale(.85); }
  to   { opacity: .95; transform: scale(1.05); }
}
.breaking .seal::before { display: none; }
.seal-half.l { clip-path: polygon(-20% -20%, 55% -20%, 44% 26%, 58% 52%, 43% 120%, -20% 120%); }
.seal-half.r { clip-path: polygon(55% -20%, 120% -20%, 120% 120%, 43% 120%, 58% 52%, 44% 26%); }

@keyframes seal-glow {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

/* opening sequence */
.breaking .float,
.opening .float,
.rising .float { animation: none; }
.breaking .seal { animation: none; pointer-events: none; }
.breaking .seal-half.l { transform: translate(-46%, 130%) rotate(-52deg); opacity: 0; }
.breaking .seal-half.r { transform: translate(46%, 140%) rotate(48deg); opacity: 0; }
.opening { transform: translateY(calc(var(--w) * .3)); }
.opening .flap { z-index: 1; transform: perspective(1100px) rotateX(180deg); }
.rising .peek { transform: translateY(-60%); }
.leaving { transform: translateY(110vh) rotate(5deg); opacity: 0; }
.no-anim, .no-anim * { transition: none !important; }

/* ---------- the letter ---------- */

.reading {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(28px, 7vh, 68px) 0 34vh;
  outline: none;
}

.paper {
  position: relative;
  width: min(90vw, 640px);
  margin: 0 auto;
  padding: clamp(42px, 8vw, 72px) clamp(24px, 7vw, 68px) clamp(36px, 6vw, 56px);
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 252, 245, 0) 55%, rgba(246, 222, 196, .22) 100%),
    url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27n%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.85%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270%200%200%200%20.34%200%200%200%200%20.19%200%200%200%200%20.24%200%200%200%20.05%200%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27100%25%27%20height%3D%27100%25%27%20filter%3D%27url(%23n)%27%2F%3E%3C%2Fsvg%3E"),
    var(--paper);
  border-radius: 4px;
  box-shadow: 0 24px 50px -22px rgba(87, 48, 60, .5), 0 2px 6px rgba(87, 48, 60, .1);
  transform-origin: 0 0;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1.5px dashed rgba(226, 96, 79, .36);
  border-radius: 3px;
  pointer-events: none;
}

.ink {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .3, 1);
}
.ink.in { opacity: 1; transform: none; }

.date {
  position: relative;
  margin: 0 0 8px;
  padding-right: 72px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: .98rem;
  color: var(--ink-soft);
}

.dear {
  position: relative;
  margin: 0 0 22px;
  padding-right: 48px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1.08;
  color: var(--coral);
}

.body p {
  position: relative;
  margin: 0 0 1em;
  font-size: clamp(1.55rem, 5.6vw, 1.85rem);
  line-height: 1.32;
}

.polaroid {
  position: relative;
  width: min(66%, 270px);
  margin: 34px auto 30px;
  padding: 11px 11px 0;
  background: #fff;
  box-shadow: 0 10px 22px -8px rgba(87, 48, 60, .45), 0 1px 3px rgba(87, 48, 60, .18);
  rotate: -3deg;
}
.polaroid-photo {
  aspect-ratio: 4 / 5;
  background-size: cover;
  background-color: #f2e7d5;
}
.polaroid figcaption {
  padding: 9px 2px 12px;
  text-align: center;
  font-size: 1.5rem;
  line-height: 1.1;
}
.tape {
  position: absolute;
  z-index: 1;
  top: -14px;
  left: 50%;
  width: 92px;
  height: 27px;
  translate: -50% 0;
  rotate: 4deg;
  background: rgba(242, 179, 61, .62);
  box-shadow: 0 1px 2px rgba(87, 48, 60, .16);
}

.signature {
  position: relative;
  margin-top: 8px;
  text-align: right;
}
.signature p {
  margin: 0;
  font-size: clamp(1.55rem, 5.6vw, 1.85rem);
}
.signature .name {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.7rem, 6.4vw, 2.3rem);
  color: var(--coral);
}

.ps {
  position: relative;
  margin: 32px 0 10px;
  font-size: 1.45rem;
  line-height: 1.3;
  color: var(--ink-soft);
}

.fold {
  position: relative;
  display: block;
  margin: 18px auto 0;
  padding: 10px 18px;
  min-height: 44px;
  font-family: var(--display);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  text-decoration: underline wavy rgba(226, 96, 79, .55) 1.5px;
  text-underline-offset: 5px;
}
.fold:hover { color: var(--coral); }

.corner {
  position: absolute;
  pointer-events: none;
  transform: scale(0);
  transition: transform .9s cubic-bezier(.3, 1.6, .5, 1) .25s;
}
.corner img { position: absolute; left: -20%; top: -20%; display: block; width: 140%; height: 140%; }
.paper.open .corner { transform: none; }
.corner.tr {
  top: -24px;
  right: -14px;
  width: clamp(112px, 30vw, 176px);
  aspect-ratio: 1;
  transform-origin: 100% 0;
}
.corner.bl {
  bottom: -26px;
  left: -14px;
  width: clamp(96px, 26vw, 150px);
  aspect-ratio: 1;
  transform-origin: 0 100%;
}

/* ---------- tap to bloom ---------- */

#blooms {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 5;
  pointer-events: none;
}
#blooms img { position: absolute; }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .cloud, .plant, .plant img, .float, .hint, .seal, .seal::before, .wing { animation: none !important; }
  #petals, #butterflies { display: none; }
  .stem { animation-duration: .01s; animation-delay: 0s; }
  .pop { animation-duration: .01s; animation-delay: 0s; }
  .spinner, .envelope, .flap, .peek, .seal-half, .ink, .corner { transition-duration: .01s !important; transition-delay: 0s !important; }
}

/* ---------- pressed flowers on the letter ---------- */

.pressed {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
  opacity: .92;
  filter: saturate(.8) drop-shadow(0 1px 1px rgba(87, 48, 60, .22));
}
.pressed.sprig {
  left: -6px;
  top: 50%;
  translate: 0 -55%;
  rotate: -8deg;
}

/* ---------- the mosaic polaroid ---------- */

.polaroid.has-mosaic {
  cursor: zoom-in;
  transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .3, 1), rotate .35s cubic-bezier(.3, 1.4, .5, 1), scale .35s cubic-bezier(.3, 1.4, .5, 1);
}
.polaroid.has-mosaic:hover { rotate: -1deg; scale: 1.03; }
.polaroid.has-mosaic:focus-visible { outline: 2.5px dashed var(--coral); outline-offset: 7px; }
.look-closer {
  margin: -16px 0 30px;
  text-align: center;
  font-size: 1.4rem;
  color: var(--ink-soft);
  animation: nudge 2.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(255, 248, 236, 0);
  transition: background .45s ease;
  overscroll-behavior: contain;
  touch-action: none;
}
.viewer.open { background: rgba(255, 248, 236, .97); }
.viewer-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.mosaic-img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  max-width: none;
  transform-origin: 0 0;
  box-shadow: 0 30px 60px -30px rgba(87, 48, 60, .55);
  pointer-events: none;
}
.mosaic-img.moving { will-change: transform; }
.tile-ring {
  position: absolute;
  left: 0;
  top: 0;
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1.5px rgba(226, 96, 79, .85), 0 6px 14px rgba(87, 48, 60, .35);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.viewer-hint {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% 0;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 250, 240, .94);
  box-shadow: 0 4px 14px -4px rgba(87, 48, 60, .3);
  font-size: 1.3rem;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s .2s;
}
.viewer.open .viewer-hint { opacity: 1; }
.viewer.open .memory:not([hidden]) ~ .viewer-hint,
.viewer.open:has(.memory:not([hidden])) .viewer-hint { opacity: 0; transition-delay: 0s; }
.viewer-close {
  position: absolute;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 250, 240, .94);
  box-shadow: 0 4px 14px -4px rgba(87, 48, 60, .35);
  font-family: var(--display);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--ink);
  opacity: 0;
  transition: opacity .3s;
}
.viewer.open .viewer-close { opacity: 1; }

.memory {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(87, 48, 60, .62);
  touch-action: none;
}
.memory-card {
  margin: 0;
  padding: 12px;
  background: #fff;
  box-shadow: 0 28px 60px -20px rgba(30, 10, 20, .65);
  transition: transform .25s ease-out;
}
.memory-card img {
  display: block;
  background: #efe3d2;
  user-select: none;
  -webkit-user-drag: none;
}
.memory-card.loading img { animation: shimmer 1.1s ease-in-out infinite alternate; }
@keyframes shimmer {
  from { background: #efe3d2; }
  to   { background: #f8efe3; }
}
.memory-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}
.memory-nav button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 250, 240, .94);
  font-size: 1.5rem;
  color: var(--ink);
}
.memory-count {
  min-width: 6.5em;
  margin: 0;
  text-align: center;
  font-size: 1.45rem;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .look-closer { animation: none; }
  .viewer, .viewer-hint, .viewer-close, .memory-card { transition: none; }
}

/* ---------- the flower park: walk the fields to find the pieces ---------- */

.park {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: #dcebf4;
  font-family: var(--hand);
  color: var(--ink);
}
.park canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
.park canvas:active { cursor: grabbing; }
body.in-park .sky,
body.in-park #meadow,
body.in-park #petals,
body.in-park #butterflies { display: none; }
body.in-park #blooms { z-index: 12; }

.park-title {
  position: absolute;
  top: 18px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 4px 22px 6px;
  border-radius: 999px;
  background: rgba(255, 250, 240, .92);
  box-shadow: 0 4px 14px -4px rgba(87, 48, 60, .3);
  font-family: var(--display);
  font-style: italic;
  font-size: 1.3rem;
  white-space: nowrap;
  pointer-events: none;
}
.park-help {
  position: absolute;
  left: 18px;
  bottom: 18px;
  margin: 0;
  padding: 2px 14px 4px;
  border-radius: 999px;
  background: rgba(255, 250, 240, .8);
  font-size: 1.35rem;
  pointer-events: none;
  transition: opacity 1s 4s;
}
.park.moved .park-help { opacity: .55; }

.park-tray {
  position: absolute;
  right: 18px;
  bottom: 16px;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 250, 240, .9);
  box-shadow: 0 8px 20px -8px rgba(87, 48, 60, .4);
  pointer-events: none;
}
.park-tray .slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px dashed rgba(226, 96, 79, .4);
  border-radius: 12px;
  background: #fffaf0;
}
.park-tray .slot img {
  max-width: 54px;
  max-height: 54px;
  object-fit: contain;
  filter: grayscale(1) brightness(1.6) opacity(.25);
  transition: filter .6s, transform .6s cubic-bezier(.3, 1.7, .5, 1);
}
.park-tray .slot.found { border-style: solid; border-color: rgba(242, 179, 61, .9); }
.park-tray .slot.found img { filter: none; transform: scale(1.12) rotate(-4deg); }

.park-toast {
  position: absolute;
  top: 74px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 4px 20px 6px;
  border-radius: 999px;
  background: #fffaf0;
  box-shadow: 0 6px 18px -6px rgba(87, 48, 60, .4);
  font-size: 1.7rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px) scale(.95);
  transition: opacity .35s, transform .45s cubic-bezier(.3, 1.6, .5, 1);
}
.park-toast.show { opacity: 1; transform: none; }

.park-intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 248, 236, .35);
  transition: opacity .6s;
}
.park-intro.gone { opacity: 0; pointer-events: none; }
.park-card {
  width: min(92vw, 460px);
  text-align: center;
}
.park-card h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.9rem;
  line-height: 1.15;
  color: var(--coral);
}
.park-card p {
  margin: 0 0 12px;
  font-size: 1.55rem;
  line-height: 1.25;
}
.park-card .park-keys { font-size: 1.35rem; color: var(--ink-soft); }
.park-card .park-keys b { font-weight: normal; color: var(--ink); }
.park-card .lock-button { margin-top: 8px; padding: 0 28px; }

.park-fade {
  position: absolute;
  inset: 0;
  background: #fffaf0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .9s ease;
}
.park-fade.on { opacity: 1; }

.park-pause {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  margin: 0;
  padding: 6px 24px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 240, .94);
  box-shadow: 0 8px 22px -8px rgba(87, 48, 60, .5);
  font-size: 1.7rem;
  white-space: nowrap;
  pointer-events: none;
}

.lock-button:disabled { opacity: .75; cursor: progress; }

/* The loading screen: already sunset, with a bar of real progress on the card. */
.park { background: linear-gradient(#2c4489, #8a7fbb 45%, #ef9f7c 74%, #f9c48d); }
.park.loading .park-title,
.park.loading .park-help,
.park.loading .park-tray { visibility: hidden; }
.park-loading { margin-top: 14px; }
.park-bar {
  height: 16px;
  padding: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(87, 48, 60, .28);
  overflow: hidden;
}
.park-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f63c8, #7d9ce6 60%, #f4a6b7);
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform .25s linear;
}
.park-card .park-load-text {
  margin: 8px 0 0;
  font-size: 1.35rem;
  color: var(--ink-soft);
}
