@font-face {
  font-family: 'Pixelify';
  src: url('assets/pixelify.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  background: #f3e9de;
  color: #753e4b;
  font-family: 'Pixelify', 'Courier New', monospace;
  --ink: #ac656e;
  --rose: #edb4c4;
  --heart: #e6506c;
}

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

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background: radial-gradient(ellipse at 28% 8%, #f6d6dc 0%, transparent 42%),
    radial-gradient(ellipse at 82% 100%, #f2cbd2 0%, transparent 39%), #f3e9de;
}

button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible { outline: 2px dashed #9f4e5e; outline-offset: 6px; }
p, h1 { margin: 0; }

.scene {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(100%, max(270px, 67.74svh), 570px);
  aspect-ratio: 420 / 620;
  overflow: hidden;
  user-select: none;
}

.floaters, .intro, .bursts {
  position: absolute;
  inset: 0;
}

.floaters, .bursts { pointer-events: none; }
.bursts { z-index: 5; }

.heart {
  display: inline-block;
  width: 1em;
  aspect-ratio: 1;
  background: var(--particle-color, currentColor);
  clip-path: polygon(9% 18%, 18% 18%, 18% 9%, 36% 9%, 36% 18%, 45% 18%, 45% 27%, 55% 27%, 55% 18%, 64% 18%, 64% 9%, 82% 9%, 82% 18%, 91% 18%, 91% 27%, 100% 27%, 100% 54%, 91% 54%, 91% 64%, 82% 64%, 82% 73%, 73% 73%, 73% 82%, 64% 82%, 64% 91%, 55% 91%, 55% 100%, 45% 100%, 45% 91%, 36% 91%, 36% 82%, 27% 82%, 27% 73%, 18% 73%, 18% 64%, 9% 64%, 9% 54%, 0% 54%, 0% 27%, 9% 27%);
}

.floaters .heart {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--size);
  opacity: var(--alpha);
  animation: drift var(--duration) var(--delay) ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate(0, 8cqw) rotate(-10deg); }
  to { transform: translate(3cqw, -10cqw) rotate(12deg); }
}

.intro { z-index: 2; touch-action: none; cursor: pointer; }
.intro button { display: block; }
.envelope, .bow, .arrow, .impact {
  position: absolute;
  left: 50%;
  translate: -50% 0;
}

.envelope {
  top: 11.8%;
  width: 46%;
  filter: drop-shadow(0 2.1cqw 1.35cqw #85615a37);
  transition: filter 180ms, scale 180ms;
}

.envelope svg, .bow svg, .arrow svg { display: block; width: 100%; overflow: visible; }
.envelope-flap { transform-box: fill-box; transform-origin: top; }
.envelope:hover { filter: drop-shadow(0 2.5cqw 1.5cqw #85615a48); scale: 1.018; }

.envelope-caption, .hint {
  position: absolute;
  width: 100%;
  text-align: center;
  color: #ba7a80;
  pointer-events: none;
}

.envelope-caption { top: 37.1%; font-size: 4.45cqw; letter-spacing: .035em; }
.hint { top: 89%; font-size: 3.68cqw; line-height: 1.18; padding-inline: 6%; }

.bow {
  top: 65.2%;
  width: 46.5%;
  transform-origin: center 32%;
  transition: transform 140ms ease-out;
  filter: drop-shadow(0 1.15cqw .65cqw #ad6e762f);
}

.drawn-string { opacity: 0; }
.arrow {
  top: 55.2%;
  width: 4.8%;
  pointer-events: none;
  transform-origin: center bottom;
  transform: rotate(var(--aim, 0deg));
  transition: transform 120ms ease-out;
}

[data-phase='aiming'] .bow {
  transform: translateY(2cqw) scaleX(.93) rotate(var(--aim, 0deg));
}
[data-phase='aiming'] .bow-string { opacity: 0; }
[data-phase='aiming'] .drawn-string { opacity: 1; }
[data-phase='aiming'] .arrow { transform: translateY(6cqw) rotate(var(--aim, 0deg)); }
[data-phase='shooting'] .bow { animation: twang 360ms ease-out both; }
[data-phase='shooting'] .arrow { animation: shoot 350ms cubic-bezier(.18,.56,.45,1) both; }
[data-phase='opening'] .arrow { opacity: 0; }
[data-phase='opening'] .envelope { animation: envelope-out 620ms ease-in-out both; }
[data-phase='opening'] .envelope-flap { animation: unfold 440ms ease-in-out both; }
[data-phase='opening'] .seal,
[data-phase='opening'] .seal-shine,
[data-phase='opening'] .envelope-caption,
[data-phase='opening'] .hint,
[data-phase='opening'] .bow { animation: fade-out 300ms ease-out both; }

@keyframes twang {
  0% { transform: translateY(2cqw) scaleX(.93); }
  30% { transform: translateY(-1.4cqw) scaleX(1.055); }
  62% { transform: scaleX(.97); }
  100% { transform: none; }
}

@keyframes shoot {
  0% { opacity: 1; transform: translateY(4cqw) rotate(var(--aim, 0deg)); }
  89% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-49cqw) rotate(0deg); }
}

.impact {
  top: 23.5%;
  width: 7cqw;
  aspect-ratio: 1;
  border: .65cqw solid #e76e86;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

[data-phase='opening'] .impact { animation: impact 440ms ease-out both; }
@keyframes impact {
  0% { transform: scale(.35); opacity: .9; }
  100% { transform: scale(3.4); opacity: 0; }
}
@keyframes unfold { from { transform: scaleY(1); } to { transform: scaleY(-.7); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes envelope-out {
  38% { scale: 1.06; opacity: 1; }
  to { scale: .75; transform: translateY(35cqw); opacity: 0; }
}

.letter {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 17.1%;
  translate: -50% 0;
  width: 89.5%;
  height: 66.5%;
  display: flex;
  flex-direction: column;
  background: var(--rose);
  border: .6cqw solid var(--ink);
  border-radius: 2.3cqw;
  box-shadow: inset 0 0 0 .55cqw #ffd2d6, 0 1.15cqw 0 #c48c8e92, 0 2.8cqw 3cqw #74564e39;
  overflow: hidden;
  transition: top 280ms ease-out, height 280ms ease-out;
}

[data-phase='opening'] .letter { animation: reveal 680ms 100ms cubic-bezier(.22,.78,.24,1) both; }
[data-phase='celebrating'] .letter { top: 18.6%; height: 72%; }

@keyframes reveal {
  0% { transform: translateY(-11cqw) scale(.32,.16); opacity: 0; clip-path: inset(0 0 76%); }
  35% { opacity: 1; }
  73% { transform: translateY(1.4cqw) scale(1.025,1.025); }
  to { opacity: 1; transform: none; clip-path: inset(0); }
}

.title-bar {
  flex: 0 0 11.3cqw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3.5cqw;
  background: repeating-linear-gradient(0deg, #ecb6c6 0 1px, #f1bfce 1px 2px);
  box-shadow: inset 0 .75cqw #ffd0d4;
  border-bottom: .55cqw solid #b46f77;
  color: #a65b69;
}

.window-title {
  display: inline-flex;
  align-items: center;
  gap: 1.15cqw;
  font-size: 4.25cqw;
  font-weight: 700;
  letter-spacing: .095em;
  text-shadow: .2cqw .24cqw #facbd1;
}

.window-title .heart { font-size: 3.1cqw; color: #e56d82; }
.window-marks { display: flex; gap: 1.6cqw; }
.window-marks i {
  position: relative;
  display: block;
  width: 3.6cqw;
  aspect-ratio: 1;
  background: #fad2d8;
  border: .42cqw solid #c58491;
  box-shadow: .34cqw .4cqw #af677360;
}
.window-marks i:first-child::before,
.window-marks i:nth-child(2)::before,
.window-marks i:last-child::before { content: ''; position: absolute; inset: 22%; }
.window-marks i:first-child::before { border-bottom: .32cqw solid #b17480; }
.window-marks i:nth-child(2)::before { border: .32cqw solid #b17480; }
.window-marks i:last-child::before {
  background: linear-gradient(45deg, transparent 43%, #b17480 43% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 43%, #b17480 43% 58%, transparent 58%);
}

.toolbar {
  flex: 0 0 10cqw;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5cqw;
  color: #ce4f68;
  background: #f6d9df;
  border-top: .52cqw solid #fcd6dc;
  border-bottom: .62cqw solid #b67681;
  box-shadow: inset 0 -.65cqw #efb4c1;
}

.toolbar .heart { font-size: 3.9cqw; filter: drop-shadow(0 .4cqw #f7adbf); }
.toolbar .heart:nth-of-type(3) { font-size: 4.8cqw; color: #e5667d; }
.cross { font-size: 3.8cqw; line-height: 1; color: #e6a7bb; font-weight: 700; }

.letter-body {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 .78cqw .85cqw;
  border-right: .42cqw solid #bd7a83;
  border-left: .42cqw solid #c07a85;
  border-bottom: .65cqw solid #b6747d;
  box-shadow: inset 0 0 0 .45cqw #f8c7ce;
  background: #eab0c1 url('assets/pink-tile.svg') repeat;
  background-size: 4.55cqw 4.55cqw;
}

#message {
  position: relative;
  z-index: 2;
  margin: 4.5cqw 2cqw 0;
  font-size: 4.65cqw;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: .015em;
  color: #77394c;
  text-align: center;
  text-shadow: .28cqw .32cqw #f9d1da;
}
#message:focus { outline: none; }
.tiny-heart { color: #be526b; }

.kitten {
  position: absolute;
  left: 50%;
  top: 44%;
  translate: -50% -50%;
  display: block;
  width: 42%;
  height: auto;
  pointer-events: none;
  animation: kitten-bob 2.25s steps(6, end) infinite;
}

[data-phase='celebrating'] .kitten { display: none; }

@keyframes kitten-bob { 50% { transform: translateY(-1.1cqw); } }

.answers { position: absolute; inset: 0; pointer-events: none; }
.answer {
  position: absolute;
  z-index: 2;
  top: 85%;
  translate: -50% -50%;
  min-width: 16cqw;
  min-height: 9.5cqw;
  padding: .75cqw 2cqw;
  background: #fff0ee;
  border: .55cqw solid #ca7d92;
  border-radius: .6cqw;
  box-shadow: inset 0 0 0 .42cqw #fffcf8, 0 .8cqw #ab6578;
  color: #ad5168;
  font-size: 4.4cqw;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .095em;
  pointer-events: auto;
  transition: left 140ms ease-out, top 140ms ease-out, translate 100ms, background 100ms;
}
.answer:active { translate: -50% calc(-50% + .5cqw); }
.yes { left: 36.5%; }
.yes:hover { background: #ffe0e5; }
.no { left: var(--no-x, 63.5%); top: var(--no-y, 85%); }
.dodged .yes { left: 50%; }
[data-phase='opening'] button { pointer-events: none; }

.ending {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 3%;
  color: #7d4252;
  text-align: center;
  font-weight: 600;
  text-shadow: .25cqw .3cqw #f8d2db;
  animation: note-in 420ms ease-out both;
}

.hugging-cats { margin: 0; }

.hugging-cats img {
  display: block;
  width: 48cqw;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  animation: kitten-bob 2.25s steps(6, end) infinite;
}

.hugging-cats figcaption {
  width: fit-content;
  margin: .75cqw auto 0;
  padding: .25cqw 3cqw .45cqw;
  border: .35cqw solid #c58496;
  border-radius: .7cqw;
  background: #f9dce5;
  box-shadow: inset 0 0 0 .3cqw #ffedf1, 0 .5cqw #b77889;
  color: #8f4459;
  font-size: 5.3cqw;
  line-height: 1;
}

.hugging-wish {
  max-width: 34ch;
  margin: 1.6cqw auto 0;
  font-size: 3.8cqw;
  line-height: 1.22;
  text-wrap: balance;
}

.relationship-date { margin: 1.6cqw 0 1.55cqw; font-size: 3.5cqw; line-height: 1.15; }

.relationship-timer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.35cqw;
}

.timer-unit {
  padding: .85cqw .4cqw .9cqw;
  background: #f9d9e2;
  border: .4cqw solid #c27d8f;
  border-radius: .6cqw;
  box-shadow: inset 0 0 0 .35cqw #ffe9ee, 0 .55cqw #b77889;
  font-size: 2.95cqw;
  line-height: 1;
}

.timer-value {
  display: block;
  margin-bottom: .6cqw;
  color: #8f4459;
  font-size: 5.3cqw;
  font-variant-numeric: tabular-nums;
}

@keyframes note-in { from { opacity: 0; transform: translateY(3.5cqw); } to { opacity: 1; transform: none; } }

.bursts .heart {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--size);
  filter: drop-shadow(0 .6cqw .2cqw #9f4a5b2c);
  animation: burst var(--duration) var(--delay) cubic-bezier(.19,.69,.3,1) both;
}

@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.12); }
  14% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--turn)) scale(1.1); }
}

@media (max-width: 460px) {
  .scene { width: min(100%, max(268px, 67.74svh)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
