:root {
  --bg: #faf6f0;
  --bg-glow: rgb(200 16 46 / 0.07);
  --surface: #f3ede4;
  --card: #ffffff;
  --border: #e6ded2;
  --text: #1d1d1f;
  --muted: #6c6862;
  --red: #b3122e;
  --red-hover: #9a0f27;
  --red-soft: rgb(179 18 46 / 0.08);
  --green: #1b7446;
  --green-soft: rgb(27 116 70 / 0.1);
  --gold: #946c0a;
  --gold-soft: rgb(212 167 44 / 0.16);
  --warn-bg: #fff6e0;
  --warn-border: #f0d9a0;
  --snow: #c9d6e6;
  --shadow: 0 1px 2px rgb(40 20 10 / 0.04), 0 10px 30px rgb(40 20 10 / 0.06);
  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1311;
    --bg-glow: rgb(220 50 70 / 0.1);
    --surface: #151c19;
    --card: #19211e;
    --border: #2b3632;
    --text: #f3efe8;
    --muted: #9ba49f;
    --red: #e23d55;
    --red-hover: #f0566c;
    --red-soft: rgb(226 61 85 / 0.14);
    --green: #4cc68a;
    --green-soft: rgb(76 198 138 / 0.14);
    --gold: #e6bd50;
    --gold-soft: rgb(230 189 80 / 0.14);
    --warn-bg: #2a2414;
    --warn-border: #4d4220;
    --snow: #ffffff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -200px, var(--bg-glow), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--red); }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 750; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-bottom: 48px; position: relative; z-index: 1; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- top bar */

.topbar { position: relative; z-index: 2; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand-mark { font-size: 1.5rem; line-height: 1; }
.lang {
  font: inherit; font-size: 0.85rem; font-weight: 650;
  min-width: 44px; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
}
.lang:hover { border-color: var(--muted); }

.footer { padding: 28px 16px 40px; text-align: center; color: var(--muted); font-size: 0.875rem; position: relative; z-index: 1; }
.footer a { color: inherit; }

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

.hero { text-align: center; padding: 40px 0 32px; }
.hero h1 { font-size: clamp(2.1rem, 6.5vw, 3.4rem); max-width: 14ch; margin: 10px auto 16px; }
.hero .lead { max-width: 56ch; margin: 0 auto 28px; }
.eyebrow { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); }
.lead { font-size: 1.1rem; color: var(--muted); }

.steps { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
.step { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.step h3 { margin: 12px 0 6px; }
.step p { font-size: 0.9rem; color: var(--muted); }
.step-n {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--red-soft); color: var(--red); font-weight: 700; font-size: 0.9rem;
}

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 0 0 16px;
}
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card.note { background: var(--surface); box-shadow: none; }

.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.hint-icon { display: flex; gap: 8px; align-items: flex-start; margin: 16px 0 0; }
.hint-icon svg { flex: none; margin-top: 2px; }

/* ------------------------------------------------------------------- forms */

.form h2 { font-size: 1.45rem; margin-bottom: 8px; }
fieldset { border: 0; padding: 0; margin: 24px 0 0; min-width: 0; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: 10px; }
legend em, .field em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.count { color: var(--muted); font-weight: 500; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.people-inputs { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.person-row { display: flex; align-items: center; gap: 8px; }
.person-n { flex: none; width: 26px; text-align: right; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.rules { display: grid; gap: 8px; margin-bottom: 12px; }
.rules:empty { display: none; }
.rule-row { display: flex; align-items: center; gap: 8px; }
.rule-row select { flex: 1; min-width: 0; }
.rule-sep { color: var(--muted); font-size: 1.1rem; }

.form-error {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
  font-size: 0.95rem;
}
.form #submit { margin-top: 24px; }
.fineprint { margin-top: 12px; text-align: center; color: var(--muted); font-size: 0.8rem; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 0.95rem;
  min-height: 44px; padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .lang:focus-visible, a:focus-visible, .reveal-front:focus-visible {
  outline: 3px solid var(--red-soft);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--red);
}
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.85rem; gap: 6px; }
.btn-small svg { width: 16px; height: 16px; }
.btn-wa:hover { color: #1a9e4f; border-color: #25d366; }
.btn-viber:hover { color: #7360f2; border-color: #7360f2; }

.icon-btn {
  flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--red-soft); color: var(--red); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.link { color: var(--muted); font-size: 0.9rem; }
.link:hover { color: var(--red); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 80px 0; color: var(--muted); }

/* ------------------------------------------------------------- my groups */

.group-list { list-style: none; margin: 0; padding: 0; }
.group-list li + li { border-top: 1px solid var(--border); }
.group-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; color: var(--text); text-decoration: none; font-weight: 600; }
.group-list a:hover { color: var(--red); }
.flip-x { transform: scaleX(-1); color: var(--muted); }

/* ---------------------------------------------------------------- organizer */

.crumbs { padding: 8px 0 0; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.crumbs a:hover { color: var(--red); }

.page-head { padding: 20px 0 24px; }
.page-head h1 { margin: 8px 0 0; overflow-wrap: anywhere; }
.page-head .lead { margin-top: 10px; }
.page-head.center { text-align: center; }
.page-head.center .chips { justify-content: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 0.875rem; font-weight: 600;
}
.chip svg { width: 15px; height: 15px; color: var(--red); }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid;
}
.notice > svg { flex: none; margin-top: 2px; }
.notice p { margin-bottom: 10px; }
.notice-success { background: var(--green-soft); border-color: transparent; color: var(--green); font-weight: 650; }
.notice-success p { margin: 0; }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice-warn > svg { color: var(--gold); }

.progress { height: 6px; border-radius: 999px; background: var(--surface); overflow: hidden; margin: 0 0 16px; }
.progress span { display: block; height: 100%; width: 0; background: var(--green); border-radius: inherit; transition: width 0.4s; }

.people-list { list-style: none; padding: 0; margin: 0; }
.person { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; padding: 14px 0; }
.person + .person { border-top: 1px solid var(--border); }
.avatar {
  grid-row: span 2;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red-soft); color: var(--red); font-weight: 750;
  align-self: start;
}
.person-main { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.person-name { font-weight: 650; overflow-wrap: anywhere; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  background: var(--surface); color: var(--muted);
}
.pill svg { width: 12px; height: 12px; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }
.share { display: flex; flex-wrap: wrap; gap: 6px; }

.details { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0; }
.details .full { grid-column: 1 / -1; }
.details dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.details dd { margin: 0; font-weight: 550; }

.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; }
.action-row + .action-row { border-top: 1px solid var(--border); }
.action-row p { margin-top: 2px; }

.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.save-status { display: inline-flex; align-items: center; gap: 4px; margin-right: auto; }
.save-status svg { width: 15px; height: 15px; color: var(--green); }

/* -------------------------------------------------------------- participant */

.reveal { margin: 0 0 16px; }
.reveal-front, .reveal-back {
  width: 100%;
  border-radius: 28px;
  min-height: 300px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 32px 20px;
  text-align: center;
}
.reveal-front {
  font: inherit; cursor: pointer; color: #fff;
  border: 0;
  background:
    radial-gradient(circle at 20% 20%, rgb(255 255 255 / 0.14), transparent 40%),
    linear-gradient(160deg, #c8172f, #8e0c21);
  box-shadow: 0 20px 50px rgb(150 15 35 / 0.3);
  transition: transform 0.2s;
}
.reveal-front:hover { transform: translateY(-2px); }
.reveal-cta { font-weight: 700; font-size: 1.15rem; }

.giftbox { position: relative; width: 120px; height: 110px; display: block; }
.giftbox-body, .giftbox-lid { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 8px; }
.giftbox-body {
  bottom: 0; width: 104px; height: 74px;
  background: linear-gradient(90deg, transparent 43%, #f2c94c 43%, #f2c94c 57%, transparent 57%), #1f8a52;
}
.giftbox-lid {
  top: 14px; width: 120px; height: 28px;
  background: linear-gradient(90deg, transparent 43%, #f2c94c 43%, #f2c94c 57%, transparent 57%), #23a061;
  z-index: 1;
}
.giftbox-lid::before, .giftbox-lid::after {
  content: ""; position: absolute; top: -20px; width: 30px; height: 22px;
  border: 6px solid #f2c94c; border-radius: 50% 50% 0 50%;
}
.giftbox-lid::before { left: 28px; transform: rotate(-20deg); border-radius: 50% 50% 0 50%; }
.giftbox-lid::after { right: 28px; transform: rotate(20deg); border-radius: 50% 50% 50% 0; }

.reveal-front:not(.opening) .giftbox { animation: wiggle 3.5s ease-in-out infinite; }
.reveal-front.opening .giftbox { animation: shake 0.5s ease-in-out; }
.reveal-front.opening .giftbox-lid { transition: transform 0.35s 0.35s ease-in; transform: translate(-50%, -60px) rotate(-18deg); }

@keyframes wiggle {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-6deg); }
  90% { transform: rotate(6deg); }
  94% { transform: rotate(-3deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-6px) rotate(-5deg); }
  40% { transform: translateX(6px) rotate(5deg); }
  60% { transform: translateX(-4px) rotate(-3deg); }
  80% { transform: translateX(4px) rotate(3deg); }
}

.reveal-back {
  background: var(--card);
  border: 2px dashed var(--red);
  gap: 8px;
}
.reveal-back.pop { animation: pop 0.5s cubic-bezier(.2, 1.4, .4, 1); }
.giftee { font-size: clamp(2.2rem, 9vw, 3.6rem); font-weight: 800; color: var(--red); letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.wish { background: var(--surface); padding: 14px 16px; border-radius: var(--radius-sm); }

.empty-state { text-align: center; padding: 48px 24px; margin-top: 32px; }
.empty-state h1 { font-size: 1.6rem; margin: 12px 0 8px; }
.empty-state p { margin-bottom: 24px; }
.empty-emoji { font-size: 3rem; }

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

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 20;
  transform: translate(-50%, 20px);
  padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-weight: 650; font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------- snow and confetti */

.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow span {
  position: absolute; top: -10px;
  border-radius: 50%;
  background: var(--snow);
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes fall {
  to { transform: translate(var(--drift, 0), 105vh); }
}
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
.confetti span { position: absolute; width: 8px; height: 12px; border-radius: 2px; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  .steps { grid-template-columns: 1fr; }
  .step { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; padding: 16px; }
  .step-n { grid-row: span 2; }
  .step h3 { margin: 2px 0 0; }
  .card { padding: 20px 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; align-items: stretch; }
  .person { grid-template-columns: auto 1fr; }
  .share { grid-column: 1 / -1; }
  /* Icon-only share buttons on phones; the label stays for screen readers. */
  .share .btn:not(:first-child) span {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .share .btn { min-width: 44px; min-height: 40px; }
  .hero { padding-top: 24px; }
}

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