@font-face {
  font-family: Caveat;
  src: url("./assets/caveat.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
:root {
  color-scheme: light;
  --canvas: #fcf6f5;
  --ink: #4f2531;
  --muted: #734f58;
  --line: #d4b8bf;
  --button: #73223e;
  --on-button: #fff5f6;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --paper: #fff3ee;
  --writing: #5d1c32;
  font: 100%/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #261a20;
  --ink: #f8e2e6;
  --muted: #d9b6c0;
  --line: #6b4753;
  --button: #f1b8c8;
  --on-button: #451526;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--canvas, #fcf6f5);
  color: var(--ink, #4f2531);
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100svh);
  display: grid;
  align-items: safe center;
  padding: max(1.25rem, var(--tg-content-safe-area-inset-top, 0px), env(safe-area-inset-top))
    max(1.1rem, var(--tg-content-safe-area-inset-right, 0px), env(safe-area-inset-right))
    max(1.5rem, var(--tg-content-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom))
    max(1.1rem, var(--tg-content-safe-area-inset-left, 0px), env(safe-area-inset-left));
}
.gift { width: min(100%, 39rem); margin: 0 auto; }
.letterhead { display: flex; align-items: center; gap: 1rem; margin-bottom: clamp(1rem, 3.5vh, 2rem); }
.letterhead #label { font-family: Georgia, serif; font-size: 1rem; color: var(--muted); }
.rule { flex: 1; border-top: 1px solid var(--line); }
.stage {
  isolation: isolate;
  position: relative;
  width: 100%;
  aspect-ratio: 3/2;
  container-type: inline-size;
  outline: 1px solid rgba(92, 32, 53, .09);
  outline-offset: -1px;
  background: #dfaaa0;
  box-shadow: 0 14px 24px -18px rgba(89, 37, 47, .4);
}
.envelope { display: block; width: 100%; height: 100%; object-fit: cover; }
.address, .recipient {
  font-family: Caveat, "Segoe Print", cursive;
  font-weight: 500;
  line-height: 1.1;
}
.address {
  margin: 0; position: absolute; left: 15%; top: 45%;
  font-size: clamp(2.5rem, 10cqw, 4.6rem);
  transform: rotate(-6deg); color: var(--writing);
}
.card {
  position: absolute; inset: 7% 7.5%;
  display: grid; place-items: center; text-align: center;
  color: var(--writing); background: var(--paper);
  box-shadow: 1px 5px 12px rgba(88,32,49,.2);
  transform: rotate(-2deg);
}
.card::before { content: ""; position: absolute; inset: 5%; border: 1px solid #c19aa0; pointer-events: none; }
.card h1 { margin: 0; font: 400 1rem/1 Georgia, "Times New Roman", serif; }
.card h1:focus { outline: none; }
.card h1 span { display: block; }
.face-value { font-size: clamp(3rem, 19cqw, 7.35rem); line-height: .86; letter-spacing: -.07em; padding-right: .07em; }
.service { font-size: clamp(1.4rem, 6cqw, 2.4rem); margin: .1em 0 .24em; }
.recipient { font-size: clamp(1.35rem, 5.8cqw, 2.3rem); }
.controls { display: grid; justify-items: center; text-align: center; padding-top: clamp(1.4rem, 4.5vh, 2.5rem); }
.actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .5rem; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: .7rem 1.7rem; border: 1px solid transparent;
  border-radius: 2rem; background: var(--button); color: var(--on-button);
  font: 600 1rem/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform 120ms var(--ease-out), opacity 120ms ease;
}
button:disabled { opacity: .65; cursor: progress; }
button.quiet { color: var(--ink); background: transparent; border-color: var(--line); }
:where(a, button):focus-visible { outline: 3px solid var(--muted); outline-offset: 4px; }
:where(a,button):active:not(:disabled) { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { :where(a,button):hover:not(:disabled) { opacity: .88; } }
.balance, #notice { margin: 0 0 .85rem; }
.balance { font: 400 1.25rem/1.3 Georgia, serif; }
#notice { color: var(--muted); max-width: 32ch; }
#notice:empty { display: none; }
@keyframes open-card {
  from { opacity: 0; transform: translateY(9%) rotate(-4deg); }
  to { opacity: 1; transform: translateY(0) rotate(-2deg); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card.opening { animation: open-card 240ms var(--ease-out) both; }
@media (prefers-reduced-motion: reduce) {
  .card.opening { animation: fade 160ms ease both; }
  :where(a,button):active:not(:disabled) { transform: none; }
}
