:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #6b716c;
  --green: #1f4d3a;
  --green-dark: #163828;
  --green-soft: #e7efe9;
  --red: #a8423a;
  --red-soft: #f6e7e4;
  --gray: #b9b5ad;
  --gray-soft: #efece6;
  --line: #e8e3da;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(31, 42, 36, 0.04), 0 8px 24px rgba(31, 42, 36, 0.06);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(40px, 9vh, 88px) 20px 64px;
}

/* ---------- Views & transitions ---------- */
.view { display: none; }
.view.is-active { display: block; animation: view-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.view.is-leaving { animation: view-out 0.2s ease-in both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes view-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---------- Header ---------- */
.hero { text-align: center; margin-bottom: 32px; }

h1, h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--green);
  margin: 0;
}
h1 { font-size: clamp(2.4rem, 8vw, 3.6rem); line-height: 1.05; }
h2 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.2; font-weight: 600; }

.subtitle { margin: 14px auto 0; max-width: 30ch; color: var(--muted); font-size: 1.1rem; }

/* ---------- Progress ---------- */
.progress { max-width: 420px; margin: 0 auto 32px; }
.progress-label {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}
.progress-track {
  height: 10px;
  background: var(--gray-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), #2f6b51);
  border-radius: inherit;
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Names grid ---------- */
.names {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.name-btn {
  width: 100%;
  min-height: 76px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-direction: column;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--green);
  font: 600 1.15rem/1.2 var(--font-body);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.name-btn:hover {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 2px 4px rgba(31, 77, 58, 0.06), 0 12px 28px rgba(31, 77, 58, 0.12);
}
.name-btn:active { transform: translateY(0) scale(0.98); }
.name-btn:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

.name-btn[disabled] {
  cursor: not-allowed;
  background: var(--gray-soft);
  border-color: transparent;
  box-shadow: none;
  color: var(--gray);
  transform: none;
}
.name-btn .status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #8f8b83;
}
.check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9a968e;
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
}

/* ---------- Cards ---------- */
.card {
  max-width: 520px;
  margin: 0 auto;
  padding: clamp(32px, 7vw, 52px) clamp(22px, 6vw, 44px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.card-icon { font-size: 2.6rem; margin-bottom: 14px; }
.accent { color: var(--red); }
.muted { color: var(--muted); margin: 14px 0 0; font-size: 1.05rem; }

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 500;
}

.recipient {
  margin: 18px 0 28px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 13vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--red);
  word-break: break-word;
}
.recipient.is-shown { animation: pop 0.9s cubic-bezier(0.18, 1.4, 0.4, 1) both, glow 2.4s ease-in-out 0.9s infinite; }

@keyframes pop {
  0% { opacity: 0; transform: scale(0.4) rotate(-6deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes glow {
  0%, 100% { text-shadow: 0 0 0 rgba(168, 66, 58, 0); }
  50% { text-shadow: 0 0 28px rgba(168, 66, 58, 0.25); }
}

.warning {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--red-soft);
  color: #7a2f29;
  font-size: 0.98rem;
}
.warning strong { display: block; margin-bottom: 2px; }

.notice {
  margin: 18px auto 0;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--red-soft);
  color: #7a2f29;
  text-align: center;
  font-size: 0.98rem;
}

/* ---------- Buttons ---------- */
.actions { display: grid; gap: 12px; margin-top: 30px; }

.btn {
  width: 100%;
  min-height: 60px;
  padding: 16px 24px;
  border: 0;
  border-radius: 999px;
  font: 600 1.1rem/1 var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 18px rgba(31, 77, 58, 0.25);
}
.btn-primary:hover { background: var(--green-dark); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--gray-soft); color: var(--ink); }

/* ---------- Snow ---------- */
.snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.flake {
  position: absolute;
  top: -12px;
  border-radius: 50%;
  background: #cfd8d3;
  opacity: 0.7;
  animation: fall linear infinite;
}
@keyframes fall {
  from { transform: translate3d(0, -10vh, 0); }
  to { transform: translate3d(var(--drift, 20px), 110vh, 0); }
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

@media (max-width: 420px) {
  .names { grid-template-columns: 1fr 1fr; gap: 10px; }
  .name-btn { min-height: 70px; font-size: 1.05rem; padding: 14px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
  .view.is-active, .view.is-leaving, .recipient.is-shown { animation: none; }
  .progress-fill, .name-btn, .btn { transition: none; }
}
