:root {
  --night: #0b1d3a;
  --night-deep: #06122a;
  --forest: #14532d;
  --red: #c8102e;
  --red-dark: #9b0c23;
  --gold: #f2c14e;
  --gold-dark: #a8770a;
  --snow: #fdfbf7;
  --paper: #fffaf0;
  --ink: #2b2118;
  --ink-soft: #6b5b4b;
  --radius: 18px;
  --display: "Mountains of Christmas", "Georgia", serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

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

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--snow);
  background-color: var(--night-deep);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(242, 193, 78, 0.18), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(20, 83, 45, 0.55), transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--night-deep) 100%);
}

#snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

body > :not(#snow):not(dialog) {
  position: relative;
  z-index: 1;
}

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

h1,
h2 {
  margin: 0;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 26px;
  max-width: 1280px;
  margin: 0 auto;
}

.top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 18px;
  background:
    radial-gradient(circle at 12px 11px, var(--gold) 4px, transparent 5px) 0 0 / 96px 18px repeat-x,
    radial-gradient(circle at 36px 13px, #e63946 4px, transparent 5px) 0 0 / 96px 18px repeat-x,
    radial-gradient(circle at 60px 11px, #4ade80 4px, transparent 5px) 0 0 / 96px 18px repeat-x,
    radial-gradient(circle at 84px 13px, #7dd3fc 4px, transparent 5px) 0 0 / 96px 18px repeat-x,
    linear-gradient(transparent 6px, rgba(253, 251, 247, 0.25) 6px, rgba(253, 251, 247, 0.25) 7px, transparent 7px);
  animation: twinkle 2.4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from {
    filter: brightness(0.8);
  }
  to {
    filter: brightness(1.25) drop-shadow(0 0 4px rgba(242, 193, 78, 0.6));
  }
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  line-height: 1.1;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--red-dark);
}

.who-am-i {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.who-am-i span {
  display: none;
}

@media (min-width: 520px) {
  .who-am-i span {
    display: inline;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 20px;
  border: 2px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible,
.tab:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.btn[disabled] {
  cursor: progress;
  opacity: 0.85;
}

.btn-red {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 var(--red-dark);
}

.btn-gold {
  background: var(--gold);
  color: var(--night);
  box-shadow: 0 4px 0 var(--gold-dark);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: currentColor;
}

.btn-small {
  min-height: 38px;
  padding: 6px 14px;
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 18px;
  padding: 5px;
  width: max-content;
  max-width: calc(100% - 32px);
  background: rgba(253, 251, 247, 0.1);
  border: 1px solid rgba(253, 251, 247, 0.2);
  border-radius: 999px;
}

.tab {
  min-height: 42px;
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--snow);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--snow);
  color: var(--night);
}

.lists {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.js .list[data-active="false"] {
  display: none;
}

@media (min-width: 960px) {
  .tabs {
    display: none;
  }

  .lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
  }

  .js .list[data-active="false"] {
    display: block;
  }
}

.list-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1.1;
  color: var(--gold);
  text-align: center;
  margin-bottom: 14px;
  text-shadow: 0 2px 0 var(--red-dark), 0 0 24px rgba(242, 193, 78, 0.25);
}

.hint {
  margin: 0 auto 18px;
  max-width: 36em;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.8;
}

.add {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 16px;
  border: 2px dashed rgba(242, 193, 78, 0.6);
  border-radius: var(--radius);
  background: rgba(253, 251, 247, 0.07);
}

@media (min-width: 600px) {
  .add {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

.add .when-busy,
.add[aria-busy="true"] .when-idle {
  display: none;
}

.add[aria-busy="true"] .when-busy {
  display: inline;
  animation: wiggle 0.9s ease-in-out infinite;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 2px solid rgba(43, 33, 24, 0.18);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.field textarea {
  resize: vertical;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
}

.form-error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fde2e4;
  color: var(--red-dark);
  font-weight: 600;
}

.gifts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 18px;
}

.gift {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 0 0 3px rgba(242, 193, 78, 0.45);
  scroll-margin: 24px;
}

.gift-ribbon {
  position: absolute;
  top: 18px;
  left: -38px;
  width: 140px;
  height: 18px;
  z-index: 2;
  background: var(--red);
  border-top: 2px dashed var(--gold);
  border-bottom: 2px dashed var(--gold);
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.gift-image {
  margin: 0;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: #fff;
  border-bottom: 3px solid rgba(242, 193, 78, 0.45);
}

.gift-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
}

.gift-placeholder {
  font-size: 4.5rem;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.15));
}

.gift-body {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 14px 16px 10px;
}

.gift-name {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.gift-price {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--red);
}

.gift-note {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.gift-shop {
  justify-self: start;
  margin-top: 4px;
  color: var(--forest);
  font-weight: 700;
  font-size: 0.9rem;
}

.gift-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.gift-actions .btn {
  flex: 1;
}

.gift.is-taken .gift-image img,
.gift.is-taken .gift-placeholder {
  filter: grayscale(0.6) opacity(0.65);
}

.stamp {
  position: absolute;
  top: 26%;
  left: 50%;
  z-index: 3;
  margin: 0;
  max-width: 86%;
  padding: 6px 14px;
  border: 3px solid var(--red);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.92);
  color: var(--red);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -50%) rotate(-10deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  overflow-wrap: anywhere;
}

.gift.pop {
  animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes pop {
  0% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}

.empty {
  padding: 36px 16px;
  text-align: center;
  border-radius: var(--radius);
  background: rgba(253, 251, 247, 0.06);
}

.empty-emoji {
  font-size: 3.5rem;
  animation: bob 3s ease-in-out infinite;
}

.empty p {
  margin: 8px 0 0;
  font-weight: 600;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.modal {
  width: min(100% - 32px, 460px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal::backdrop {
  background: rgba(6, 18, 42, 0.72);
  backdrop-filter: blur(3px);
}

.modal[open] {
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 22px 20px 20px;
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 2rem;
  color: var(--red);
}

.modal-lead {
  margin: -6px 0 0;
  font-weight: 700;
}

.modal-card .field > span {
  color: var(--ink-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .btn-ghost {
  color: var(--ink-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--snow);
  color: var(--night);
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
  text-align: center;
}

.landing {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.landing-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: min(100%, 440px);
  padding: 30px 24px;
  border-radius: 26px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 4px rgba(242, 193, 78, 0.5);
}

.landing-card h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 9vw, 2.6rem);
  line-height: 1.1;
  color: var(--red);
}

.landing-card p {
  margin: 0;
  color: var(--ink-soft);
}

.landing-emoji {
  font-size: 4rem;
  animation: bob 3s ease-in-out infinite;
}

.login {
  justify-items: stretch;
}

.login .landing-emoji,
.login h1 {
  justify-self: center;
}

.who {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.who-option {
  position: relative;
}

.who-option input {
  position: absolute;
  opacity: 0;
}

.who-option span {
  display: block;
  padding: 12px;
  border: 2px solid rgba(43, 33, 24, 0.18);
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
}

.who-option input:checked + span {
  border-color: var(--red);
  background: #fde2e4;
  color: var(--red-dark);
}

.who-option input:focus-visible + span {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.link-quiet {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
