:root {
  --pine: #0c1f17;
  --pine-2: #13301f;
  --pine-3: #1d4430;
  --berry: #b3232f;
  --berry-hi: #d63b45;
  --gold: #f2c867;
  --gold-deep: #b9862b;
  --cream: #fbf6ec;
  --paper: #fffdf8;
  --ink: #2a2118;
  --ink-soft: #6f6253;
  --line: #e8dcc6;
  --title: 'Mountains of Christmas', Georgia, serif;
  --body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 16px/1.45 var(--body);
  color: var(--cream);
  background: var(--pine);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
[hidden] { display: none !important; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- title screen ---------- */
.title {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0d2350 url('/assets/title.jpg') center / cover;
  transition: opacity 0.7s, visibility 0.7s;
  cursor: pointer;
}
.title.gone { opacity: 0; visibility: hidden; }
.title-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.title-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 14, 40, 0.55) 0%, rgba(5, 14, 40, 0.1) 45%, rgba(0, 0, 0, 0.35) 100%); }
.title-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 13vh 16px 0;
  text-align: center;
}
.title-logo {
  margin: 0;
  font: 700 clamp(64px, 13vw, 168px)/1 var(--title);
  color: var(--gold);
  -webkit-text-stroke: clamp(4px, 0.7vw, 8px) #7a1620;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #4d0b12, 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 60px rgba(255, 210, 120, 0.35);
  letter-spacing: 1px;
}
.title-sub { margin-top: 22px; font-weight: 800; font-size: clamp(13px, 1.6vw, 18px); letter-spacing: 5px; color: #fff3d6; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 16px rgba(0, 0, 0, 0.5); }
.title-press {
  margin-top: 9vh;
  font-weight: 800;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 20px rgba(255, 220, 150, 0.8);
  animation: blink 1.2s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.gate {
  margin-top: 6vh;
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 20px;
  background: rgba(10, 24, 18, 0.72);
  border: 1px solid rgba(242, 200, 103, 0.35);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  cursor: default;
  animation: rise 0.4s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.gate h2 { margin: 0 0 4px; font: 700 34px/1.1 var(--title); color: var(--gold); }
.gate p { margin: 0 0 16px; color: #e9dfcb; font-size: 15px; }
.gate form { display: flex; gap: 8px; }
.gate input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 14px; }
.face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cream);
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.face:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.12); }
.face span { font-weight: 800; }

.bauble {
  --c: var(--berry);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.75) 0 8%, transparent 30%), var(--c);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.35);
  flex: none;
}
.bauble.sm { width: 26px; height: 26px; font-size: 12px; }

.btn {
  padding: 11px 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, var(--berry-hi), var(--berry));
  box-shadow: 0 3px 0 #6e1219, 0 6px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.08s, filter 0.12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e1219; }
.btn.gold { color: #3a2400; background: linear-gradient(180deg, #ffd983, var(--gold-deep)); box-shadow: 0 3px 0 #7a5410, 0 6px 14px rgba(0, 0, 0, 0.2); }
.btn.ghost { color: var(--ink-soft); background: transparent; box-shadow: none; }
.btn.ghost:hover { color: var(--ink); filter: none; }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; transform: none; }

/* ---------- app ---------- */
.app {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(8, 22, 15, 0.82), rgba(8, 22, 15, 0.94) 40%, var(--pine)),
    url('/assets/title.jpg') center top / cover fixed;
}
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(9, 24, 17, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(242, 200, 103, 0.18);
}
.bar-logo { font: 700 30px/1 var(--title); color: var(--gold); white-space: nowrap; text-shadow: 0 2px 0 #4d0b12; }
.people { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px; }
.people::-webkit-scrollbar { display: none; }
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--cream);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); }
.chip.on { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.chip .n { font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.chip.shop { padding-left: 12px; }
.who { border: 0; background: none; color: #d9ceb8; font-weight: 600; cursor: pointer; white-space: nowrap; }
.who b { color: var(--gold); }
.who:hover { color: #fff; }

.main { max-width: 1120px; margin: 0 auto; padding: 28px 18px 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h2 { margin: 0; font: 700 clamp(40px, 6vw, 58px)/1 var(--title); color: var(--gold); text-shadow: 0 3px 0 #4d0b12, 0 10px 24px rgba(0, 0, 0, 0.4); }
.head .hint { color: #cbbfa7; font-size: 15px; }
.countdown { font-weight: 800; color: #fff3d6; letter-spacing: 1px; font-size: 14px; font-variant-numeric: tabular-nums; }

.adder {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 22px;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.adder input { flex: 1; min-width: 0; border: 0; outline: 0; padding: 10px 12px; background: none; color: var(--ink); font-size: 17px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  animation: rise 0.3s ease-out both;
}
.card .pic { aspect-ratio: 1; background: #fff; border-bottom: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.card .pic img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.card .pic .gift { font-size: 64px; filter: saturate(0.9); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .t { font-weight: 800; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .t a { color: inherit; text-decoration: none; }
.card .t a:hover { text-decoration: underline; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.price { padding: 2px 9px; border-radius: 999px; background: #fdf0cf; color: #7a5410; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.store { color: var(--ink-soft); font-size: 13px; text-decoration: none; }
.store:hover { text-decoration: underline; }
.note { color: var(--ink-soft); font-style: italic; font-size: 14px; }
.actions { margin-top: auto; padding-top: 8px; display: flex; gap: 6px; align-items: center; }
.actions .btn { padding: 8px 12px; font-size: 14px; }
.actions .grow { flex: 1; }

.card.claimed .pic, .card.claimed .t { opacity: 0.45; }
.ribbon {
  position: absolute;
  top: 12px;
  left: 0;
  z-index: 1;
  padding: 5px 14px 5px 12px;
  background: var(--berry);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  border-radius: 0 999px 999px 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
.ribbon.mine { background: #1f7a45; }
.ribbon.gone { background: #6b5d4c; }

.editor {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  padding: 16px;
  margin-bottom: 22px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: rise 0.25s ease-out;
}
.editor .pic { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; overflow: hidden; }
.editor .pic img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.editor .pic .gift { font-size: 56px; }
.editor .pic.loading { background: linear-gradient(100deg, #fff 30%, #f4ead6 50%, #fff 70%) 0 0 / 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 800; color: var(--ink-soft); letter-spacing: 0.5px; text-transform: uppercase; }
.fields label.wide { grid-column: 1 / -1; }
.fields input, .fields textarea {
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.fields input:focus, .fields textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.fields textarea { resize: vertical; min-height: 44px; }
.editor .row { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.editor .status { margin-right: auto; color: var(--ink-soft); font-size: 14px; }

.empty { padding: 40px 20px; text-align: center; color: #cbbfa7; border: 2px dashed rgba(242, 200, 103, 0.25); border-radius: 18px; }
.empty .big { font-size: 46px; }
.group { margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; font: 700 30px/1 var(--title); color: var(--gold); }

.mute {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 55;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(242, 200, 103, 0.4);
  border-radius: 50%;
  background: rgba(9, 24, 17, 0.75);
  backdrop-filter: blur(8px);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}
.mute:hover { background: rgba(29, 68, 48, 0.9); }
.credit { padding: 0 18px 28px; text-align: center; font-size: 12px; color: #8f8573; }
.credit a { color: inherit; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .bar-logo { font-size: 26px; }
  .people { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .main { padding: 20px 14px 60px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .body { padding: 10px; }
  .editor { grid-template-columns: 1fr; }
  .editor .pic { width: 140px; margin: 0 auto; }
  .fields { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .title-press { animation: none; }
}
