:root {
  --red: #b3122e;
  --red-dark: #8c0d23;
  --green: #1b5e3f;
  --gold: #e9b949;
  --cream: #fff8ee;
  --ink: #2b1d1a;
  --muted: #7a6a63;
  --card: #ffffff;
  --border: #ecdccb;
  --bg: radial-gradient(circle at 20% 0%, #24543f 0%, #12321f 55%, #0b2116 100%);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #0b2116;
  background-image: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); }

/* ---------- Snow ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow span {
  position: absolute; top: -20px; color: #fff;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate(30px, 110vh) rotate(360deg); }
}

/* ---------- Layout ---------- */
.topbar {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; max-width: 900px; margin: 0 auto;
}
.topbar a { color: #fff; text-decoration: none; font-weight: 500; }
.topbar nav { display: flex; gap: 18px; }
.brand { font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 20px; }

.container {
  position: relative; z-index: 1;
  max-width: 900px; margin: 0 auto; padding: 12px 16px 60px;
}

.center { text-align: center; }
.center a, .hint a { color: #f3e6d0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Flash ---------- */
.flash {
  max-width: 520px; margin: 0 auto 16px; padding: 12px 16px;
  border-radius: 12px; font-weight: 500; text-align: center;
}
.flash-error { background: #ffe3e3; color: #8a1020; }
.flash-success { background: #e2f6ea; color: #14532d; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  color: var(--ink); padding: 10px 16px; border-radius: 12px; font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-lg { padding: 14px 28px; font-size: 18px; }

button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--red);
  cursor: pointer; text-decoration: underline;
}
button.link.danger { color: #a00; }

input, textarea {
  width: 100%; font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: block; font-size: 14px; font-weight: 600; }
label input, label textarea { margin-top: 4px; font-weight: 400; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ---------- Home ---------- */
.hero { text-align: center; color: #fff; padding-top: 8vh; }
.hero h1 {
  font-family: "Fraunces", Georgia, serif; font-weight: 800;
  font-size: clamp(36px, 8vw, 60px); margin: 0 0 12px;
}
.lead { font-size: 18px; color: #e6dccd; line-height: 1.5; margin: 0 0 28px; }
.hint { margin-top: 24px; }

.code-form {
  display: flex; gap: 10px; max-width: 420px; margin: 0 auto;
  background: rgba(255,255,255,.08); padding: 10px; border-radius: 18px;
  backdrop-filter: blur(6px);
}
.code-form input {
  text-align: center; text-transform: uppercase; letter-spacing: 4px;
  font-family: ui-monospace, Menlo, monospace; font-size: 22px; font-weight: 700;
  border: 0;
}

/* ---------- Voucher card ---------- */
.voucher-card {
  position: relative; overflow: hidden;
  max-width: 460px; margin: 4vh auto 24px; padding: 40px 28px 32px;
  background: var(--cream); border-radius: 22px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  border: 2px dashed var(--gold);
  outline: 10px solid var(--cream);
}
.voucher-card.is-new { animation: unwrap .7s cubic-bezier(.2,1.4,.4,1); }
@keyframes unwrap {
  from { transform: scale(.6) rotate(-6deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.ribbon {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 22px; margin-left: -11px;
  background: var(--red); opacity: .08;
}
.day-badge {
  position: absolute; top: 14px; left: 14px;
  background: var(--green); color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.voucher-emoji { font-size: 72px; line-height: 1; margin-bottom: 8px; position: relative; }
.voucher-kicker { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.voucher-title {
  font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 32px;
  margin: 0 0 10px; color: var(--red-dark); position: relative;
}
.voucher-desc { font-size: 16px; line-height: 1.5; margin: 0 0 18px; position: relative; }
.voucher-code {
  display: inline-block; font-family: ui-monospace, Menlo, monospace; font-weight: 700;
  letter-spacing: 3px; padding: 6px 12px; border-radius: 8px; background: #f3e6d0;
  margin-bottom: 22px; position: relative;
}
.voucher-card form { position: relative; }

.stamp {
  position: absolute; top: 26px; right: 8px;
  transform: rotate(14deg);
  border: 4px solid var(--green); color: var(--green);
  font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 22px;
  text-transform: uppercase; letter-spacing: 3px;
  padding: 2px 12px; border-radius: 8px; opacity: .85;
}

/* ---------- Confetti ---------- */
.confetti {
  position: fixed; top: 40vh; width: 9px; height: 14px; z-index: 10;
  border-radius: 2px; pointer-events: none;
  animation: burst 3s cubic-bezier(.15,.6,.35,1) forwards;
}
@keyframes burst {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  30%  { transform: translate(calc(var(--dx) * .6), -35vh) rotate(calc(var(--rot) * .4)); }
  100% { transform: translate(var(--dx), 70vh) rotate(var(--rot)); opacity: 0; }
}

/* ---------- My vouchers ---------- */
.page-title {
  font-family: "Fraunces", Georgia, serif; font-weight: 800; color: #fff;
  font-size: 32px; margin: 12px 0 20px;
}
.panel .page-title, .narrow .page-title { color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.mini-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  background: var(--cream); border-radius: 16px; text-decoration: none; color: var(--ink);
  border: 2px dashed var(--gold); transition: transform .12s ease;
}
.mini-card:hover { transform: translateY(-3px); }
.mini-card.is-claimed { opacity: .6; border-style: solid; border-color: var(--border); }
.mini-emoji { font-size: 36px; }
.mini-title { font-weight: 600; }
.mini-status { font-size: 13px; color: var(--green); font-weight: 600; }
.is-claimed .mini-status { color: var(--muted); }

.empty { text-align: center; color: #e6dccd; padding: 40px 0; }

/* ---------- Admin ---------- */
.panel {
  background: var(--cream); border-radius: 16px; padding: 18px 20px; margin-bottom: 18px;
}
.panel summary { cursor: pointer; font-weight: 600; }
.panel summary + form { margin-top: 14px; }
.narrow { max-width: 440px; margin: 6vh auto; }

.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-actions { display: flex; gap: 8px; }

.stats { display: flex; gap: 12px; margin-bottom: 18px; color: #e6dccd; }
.stats > div { background: rgba(255,255,255,.08); padding: 10px 14px; border-radius: 12px; }
.stats strong { color: #fff; font-size: 20px; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: 16px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1e7dc; vertical-align: top; }
.admin-table th { background: #faf3ea; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.admin-table code { font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.row-actions form { margin: 0; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eee; color: #555; }
.pill-revealed { background: #fff1c9; color: #7a5800; }
.pill-claimed { background: #d9f2e3; color: #14532d; }

@media (max-width: 520px) {
  .code-form { flex-direction: column; }
  .voucher-title { font-size: 26px; }
  .stats { flex-wrap: wrap; }
}
