:root {
  --bg: #f6f1e7;
  --surface: #ffffff;
  --surface-2: #faf6ee;
  --line: #e6dccb;
  --text: #1f2a24;
  --muted: #66706a;
  --green: #0f4d3a;
  --green-2: #1d7a55;
  --green-soft: #e3f2ea;
  --red: #b3261e;
  --red-2: #d7443a;
  --gold: #e0a526;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31,42,36,.06), 0 6px 20px rgba(31,42,36,.07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--red); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.2rem; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 40px; }
main.narrow { max-width: 460px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; color: var(--muted); margin: 0; }

/* Top bar */
.topbar { background: var(--green); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 1.3rem; }
.tag { background: var(--gold); color: #3a2a00; font-size: .7rem; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }
.topnav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: .95rem; }
.topnav a { color: #d8ece2; text-decoration: none; padding: 4px 2px; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.active { color: #fff; border-color: var(--gold); }
.topnav .who { color: #d8ece2; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.topnav .linkbtn { color: #fff; }
form.inline { display: inline; margin: 0; }
.footer { color: var(--muted); font-size: .85rem; padding-bottom: 24px; text-align: center; }

/* Cards, forms, buttons */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.form { display: grid; gap: 8px; }
.form label { font-weight: 600; font-size: .9rem; margin-top: 6px; }
input[type=email], input[type=search], input[type=text], input[type=tel], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfc4b0; border-radius: 10px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(29,122,85,.35); outline-offset: 1px; border-color: var(--green-2); }
.otp-input { font-size: 1.8rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .1s ease, background .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-2); }
.btn-success { background: var(--green-2); color: #fff; }
.btn-success:hover { background: var(--green); }
.btn-ghost { background: #fff; color: var(--text); border-color: #cfc4b0; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 6px 12px; font-size: .875rem; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: #b5dcc6; color: #0d3f2f; }
.alert-error { background: #fdecea; border-color: #f2b8b3; color: #7f1d17; }
.alert-info { background: #fff7e0; border-color: #f0d89a; color: #5a4300; }
.resend-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; margin-top: 14px; }
.resend-row .linkbtn { color: var(--red); }

/* Sign-in hero */
.hero { text-align: center; margin: 8px 0 20px; }
.hero-gift { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.progress-mini { text-align: center; }
.bar { height: 10px; background: #e9e0cf; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-2), var(--green)); border-radius: 99px; transition: width .6s ease; }

/* Boxes */
.pick-intro { text-align: center; max-width: 680px; margin: 0 auto 20px; }
.legend { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: .9rem; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.sw-open { background: var(--red); }
.sw-taken { background: var(--green-2); }
.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 14px; max-width: 900px; margin: 0 auto; }
.box {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(145deg, var(--red-2), var(--red)); color: #fff;
  box-shadow: 0 4px 0 #7d1a14, 0 8px 16px rgba(0,0,0,.12);
  transition: transform .15s ease, box-shadow .15s ease, background .3s ease; overflow: hidden; padding: 0;
}
.box::before, .box::after { content: ""; position: absolute; background: var(--gold); opacity: .95; }
.box::before { left: 50%; top: 0; bottom: 0; width: 12%; transform: translateX(-50%); }
.box::after { top: 50%; left: 0; right: 0; height: 12%; transform: translateY(-50%); }
.box-lid { position: absolute; left: -4%; right: -4%; top: 0; height: 26%; background: rgba(255,255,255,.12); border-bottom: 2px solid rgba(0,0,0,.12); z-index: 1; }
.box-face { position: relative; z-index: 2; font-size: 1.5rem; font-weight: 800; text-shadow: 0 2px 4px rgba(0,0,0,.35); }
.box:not([disabled]):hover { transform: translateY(-4px) rotate(-2deg); box-shadow: 0 8px 0 #7d1a14, 0 14px 24px rgba(0,0,0,.16); }
.box:not([disabled]):hover .box-lid { transform: translateY(-3px) rotate(-3deg); transition: transform .15s ease; }
.box.taken { background: linear-gradient(145deg, #2a9466, var(--green-2)); box-shadow: 0 4px 0 #0b3a2b; cursor: not-allowed; }
.box.taken::before, .box.taken::after { background: rgba(255,255,255,.35); }
.box.just-taken { animation: pop .5s ease; }
.boxes.closed .box:not(.taken) { filter: grayscale(.6); cursor: not-allowed; }
.box.selected { outline: 4px solid var(--gold); outline-offset: 3px; }
.box.shake { animation: shake .4s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(15,28,22,.6); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s ease; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 18px; padding: 28px 24px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: rise .25s ease; }
.modal-gift { font-size: 48px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(16px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Reveal animation */
.reveal { background: radial-gradient(circle at center, rgba(15,77,58,.92), rgba(8,30,22,.97)); }
.reveal-stage { text-align: center; color: #fff; }
.reveal-box { position: relative; width: 150px; height: 150px; margin: 0 auto; animation: wobble .9s ease-in-out 2; }
.reveal-body { position: absolute; inset: 30px 0 0 0; background: linear-gradient(145deg, var(--red-2), var(--red)); border-radius: 10px; }
.reveal-body::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 18px; margin-left: -9px; background: var(--gold); }
.reveal-lid { position: absolute; left: -10px; right: -10px; top: 0; height: 38px; background: linear-gradient(145deg, #e45a50, var(--red-2)); border-radius: 8px; z-index: 2; transform-origin: 10% 100%; }
.reveal-lid::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 18px; margin-left: -9px; background: var(--gold); }
.reveal-lid::after { content: "🎀"; position: absolute; left: 50%; top: -30px; transform: translateX(-50%); font-size: 38px; }
.reveal.open .reveal-box { animation: none; }
.reveal.open .reveal-lid { animation: lidoff .7s cubic-bezier(.3,1.4,.5,1) forwards; }
.reveal-number { font-size: clamp(4rem, 18vw, 7rem); font-weight: 900; line-height: 1; margin-top: -80px; opacity: 0; transform: scale(.2); color: #fff; text-shadow: 0 6px 30px rgba(224,165,38,.7); position: relative; z-index: 3; }
.reveal.open .reveal-number { animation: numberup .9s .35s cubic-bezier(.2,1.5,.4,1) forwards; }
.reveal-text { font-size: 1.25rem; opacity: 0; margin-top: 18px; padding: 0 12px; }
.reveal.open .reveal-text { animation: fade .6s 1.1s forwards; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } }
@keyframes lidoff { to { transform: translate(60px, -140px) rotate(35deg); opacity: 0; } }
@keyframes numberup { to { opacity: 1; transform: scale(1) translateY(-50px); } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* Friend page */
.friend-hero { text-align: center; margin: 6px 0 24px; }
.friend-number { display: inline-grid; place-items: center; width: 110px; height: 110px; border-radius: 50%; background: var(--green); color: #fff; font-size: 3rem; font-weight: 900; margin: 10px 0 12px; box-shadow: 0 0 0 8px var(--green-soft); }
.celebrate .friend-number { animation: pop .8s ease 2; }
.friend-name { margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 20px; }
.details { display: grid; grid-template-columns: 90px 1fr; gap: 10px 12px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; word-break: break-word; }
.wish { background: #fff7e0; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.wish p { margin: 6px 0 0; }
.inline-form { margin: 0; }
.inline-form .linkbtn { color: var(--red); font-size: .9rem; }
.facts { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.facts li { display: flex; justify-content: space-between; gap: 10px; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; flex-wrap: wrap; }
.facts span { color: var(--muted); }
.gift-ready { margin-bottom: 4px; }
.ok-line { color: var(--green-2); font-weight: 600; margin: 0 0 4px; }
.suggestions { margin-top: 16px; }
.chips { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--green-soft); color: var(--green); padding: 6px 12px; border-radius: 99px; font-weight: 600; font-size: .92rem; opacity: 0; transform: translateY(8px) scale(.9); }
.suggestions.show .chip { animation: chipin .35s ease forwards; }
.chip.hl { background: var(--gold); color: #3a2a00; transform: scale(1.08); }
@keyframes chipin { to { opacity: 1; transform: none; } }
.surprise { font-weight: 700; color: var(--red); min-height: 1.5em; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--green); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar form { margin: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; }
table.data tr:hover td { background: #fcfaf5; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions form { display: inline; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: #fdecea; color: #7f1d17; }
.pill-grey { background: #eee; color: #555; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 8px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; font-size: .92rem; }
.tabs a.active { background: var(--green); color: #fff; border-color: var(--green); }
.secret.blur td.sens { filter: blur(6px); user-select: none; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-row > div { display: grid; gap: 6px; }
.danger-zone { border-color: #f2b8b3; }
.search { max-width: 280px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: auto; }
.health-ok { color: var(--green-2); font-weight: 600; }
.health-bad { color: var(--red); font-weight: 600; }

@media (max-width: 560px) {
  .boxes { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px; }
  .box-face { font-size: 1.2rem; }
  .card { padding: 18px 16px; }
  .details { grid-template-columns: 80px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.reveal.open .reveal-body { animation: bodyout .5s .25s ease forwards; }
@keyframes bodyout { to { opacity: 0; transform: scale(.6) translateY(30px); } }
.grid-2 { align-items: start; }

/* Christmas background on the friend page */
.xmas-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url("../img/christmas-tree.svg") no-repeat center 60% / min(70vh, 90vw) auto; opacity: .08; }
#glitter { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
body.xmas main, body.xmas .footer { position: relative; z-index: 1; }
body.xmas .card { background: rgba(255,255,255,.9); backdrop-filter: blur(2px); }
.xmas-banner { display: inline-block; margin: 0 0 12px; padding: 8px 18px; border-radius: 99px; background: var(--red); color: #fff;
  font-weight: 700; font-size: 1.05rem; box-shadow: 0 4px 14px rgba(179,38,30,.3); animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 4px 14px rgba(179,38,30,.3); } 50% { box-shadow: 0 4px 24px rgba(224,165,38,.7); } }
body.xmas main > *:not(.xmas-bg):not(#glitter) { position: relative; z-index: 1; }
