:root {
  --paper: #EFEAE1;
  --card: #FBF8F3;
  --ink: #1F2A44;
  --ink-soft: #5B6378;
  --line: #DED7CA;
  --blue: #3E95D1;
  --blue-soft: #A9D0EC;
  --yellow: #F0B43C;
  --red: #D9472B;
  --pink: #EAB7AE;
  --teal: #7FAEAA;
  --radius: 22px;
  --gutter: 16px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* subtle paper grain, like the card stock */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .4  0 0 0 0 .32  0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  z-index: 0;
}

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

.page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) calc(40px + env(safe-area-inset-bottom));
}

/* ---------- hero ---------- */

.hero-art {
  display: block;
  width: 100%;
  max-width: min(420px, 86vw);
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.hero-word {
  font-family: "Jost", "Futura", sans-serif;
  font-weight: 500;
  letter-spacing: 1px;
}

.balloon {
  transform-origin: 358px 314px;
  animation: sway 6s ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(-1.4deg); }
  50% { transform: rotate(1.4deg); }
}

.intro {
  max-width: 34ch;
  margin: 8px auto 0;
  text-align: center;
}

.lead {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
}

.how {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.tally {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 15px;
  color: var(--ink-soft);
  min-height: 24px;
}

.tally-dots { display: inline-flex; gap: 5px; }
.tally-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.6px var(--ink);
}
.tally-dots i.is-reserved { background: var(--yellow); box-shadow: none; }
.tally-dots i.is-bought { background: var(--teal); box-shadow: none; }

/* ---------- list ---------- */

main { margin-top: 28px; }

.gifts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.gift {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  column-gap: 14px;
  row-gap: 14px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  transition: opacity .25s ease;
}

.gift-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--paper);
  display: grid;
  place-items: center;
}
.gift-icon svg { width: 44px; height: 44px; }

.gift-text { min-width: 0; align-self: center; }

.gift-num {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.gift-title {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.gift-note {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.gift-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 15px;
  color: var(--blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.gift-link svg { width: 12px; height: 12px; flex: none; }
.gift-link:hover { color: var(--ink); }

.gift-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1.5px dashed var(--line);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--ink-soft);
  min-width: 0;
}
.status::before {
  content: "";
  flex: none;
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.6px var(--ink);
}
.status.is-reserved::before { background: var(--yellow); box-shadow: none; }
.status.is-bought::before { background: var(--teal); box-shadow: none; }
.status b { font-weight: 500; color: var(--ink); }

.gift-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.gift.is-taken { opacity: .62; }
.gift.is-taken .gift-title { text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: rgba(31, 42, 68, .45); }
.gift.is-mine { box-shadow: inset 0 0 0 2px var(--yellow); }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  transition: background-color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: progress; }

.btn-primary { background: var(--ink); color: #FFF; }
.btn-primary:hover { background: #2E3B5C; }

.btn-ghost { box-shadow: inset 0 0 0 1.6px var(--ink); }
.btn-ghost:hover { background: rgba(31, 42, 68, .06); }

.btn-text {
  padding: 0 12px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-text:hover { color: var(--red); }

:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }

.footnote {
  margin: 22px auto 0;
  max-width: 44ch;
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ---------- sheet ---------- */

.sheet {
  width: 100%;
  max-width: 460px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--card);
  color: var(--ink);
}
.sheet::backdrop { background: rgba(31, 42, 68, .38); }
.sheet[open] { animation: rise .22s ease-out; }

@keyframes rise {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet-body { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }

.sheet-head { position: relative; padding-right: 44px; margin-bottom: 18px; }
.sheet-kicker { margin: 0; font-size: 14px; color: var(--ink-soft); }
.sheet-title { margin: 2px 0 0; font-size: 22px; font-weight: 500; line-height: 1.25; }

.sheet-close {
  position: absolute; top: -6px; right: -6px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink);
  cursor: pointer;
}
.sheet-close svg { width: 20px; height: 20px; }
.sheet-close:hover { background: rgba(31, 42, 68, .06); }

.field { display: grid; gap: 6px; }
.field span { font-size: 15px; font-weight: 500; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-soft); }
.field small { font-size: 13px; color: var(--ink-soft); }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: #FFF;
  border: 1.6px solid var(--line);
  border-radius: 14px;
}
.field input:focus { outline: none; border-color: var(--blue); }

.sheet-actions { display: grid; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { width: 100%; min-height: 52px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  text-align: center;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: #FFF;
  font-size: 15px;
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  pointer-events: none;
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ---------- larger screens ---------- */

@media (min-width: 560px) {
  .gift { grid-template-columns: 72px 1fr; padding: 18px 20px; }
  .gift-icon { width: 72px; height: 72px; }
  .gift-icon svg { width: 48px; height: 48px; }
}

@media (min-width: 700px) {
  .gift { grid-template-columns: 72px minmax(0, 1fr) auto; column-gap: 18px; }
  .gift-foot {
    grid-column: auto;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    padding: 0 0 0 18px;
    border-top: 0;
    border-left: 1.5px dashed var(--line);
  }
  .gift-actions { margin-left: 0; }
}

@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .page {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 64px;
    align-items: start;
    padding-top: 48px;
  }
  .hero { position: sticky; top: 40px; }
  .intro { text-align: left; margin-left: 0; }
  main { margin-top: 0; }
  .footnote { text-align: left; margin-left: 0; }
  .sheet { margin: auto; border-radius: 26px; }
  .sheet-body { padding: 26px 26px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .balloon, .sheet[open] { animation: none; }
  .toast, .gift, .btn { transition: none; }
}
