:root {
  --green-900: #0b2f23;
  --green-800: #0e3b2c;
  --green-600: #1f6b4f;
  --green-100: #e3f1ea;
  --red-700: #a40f26;
  --red-600: #c8102e;
  --red-100: #fbe6e9;
  --gold: #d9a521;
  --gold-100: #fbf1d6;
  --cream: #fbf7ef;
  --ink: #1d2320;
  --muted: #66706b;
  --line: #e7e1d4;
  --white: #fff;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(14, 59, 44, .08);
  --nav-h: 68px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--green-600); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .4em; color: var(--green-900); }
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.splash { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 4px solid var(--green-100); border-top-color: var(--red-600);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--green-800); color: var(--white);
  padding: calc(env(safe-area-inset-top) + 10px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-family: var(--display); font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; line-height: 1.1; }
.brand small { display: block; font-family: var(--body); font-weight: 600; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.brand img.logo { height: 34px; }

main.page {
  max-width: 560px; margin: 0 auto;
  padding: 18px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--white); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: center;
}
.bottomnav .inner { display: flex; width: 100%; max-width: 560px; }
.bottomnav a {
  flex: 1; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.bottomnav a .ico { font-size: 1.35rem; line-height: 1; }
.bottomnav a.active { color: var(--red-600); }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px; border: 1px solid rgba(0,0,0,.03);
}
.card.green { background: var(--green-800); color: var(--white); }
.card.green h2, .card.green h3 { color: var(--white); }
.card.red { background: var(--red-600); color: var(--white); }
.card.red h2, .card.red h3 { color: var(--white); }
.card.gold { background: var(--gold-100); border-color: #f0dfae; }
.card.link { display: block; text-decoration: none; color: inherit; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
.card:not(.green):not(.red) .eyebrow { color: var(--red-600); }

/* ---------- Welcome ---------- */
.hero {
  min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, #1b5a43 0%, var(--green-900) 70%);
  color: var(--white);
  display: flex; flex-direction: column; justify-content: center;
  padding: 32px 22px calc(32px + env(safe-area-inset-bottom));
  position: relative; overflow: hidden;
}
.hero .inner { max-width: 460px; margin: 0 auto; width: 100%; position: relative; z-index: 1; }
.hero h1 { color: var(--white); font-size: 2.3rem; }
.hero h1 span { color: var(--gold); display: block; font-size: .5em; font-family: var(--body); font-weight: 700; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 10px; }
.hero p { color: rgba(255,255,255,.85); font-size: 1.05rem; }
.hero .logo { max-width: 220px; margin: 0 auto 18px; }
.snow { position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 20%, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 40% 70%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 85% 60%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 10% 85%, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 55% 45%, #fff 50%, transparent 51%);
  background-size: 300px 300px; animation: snow 18s linear infinite; }
@keyframes snow { to { background-position: 0 300px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

/* ---------- Forms & buttons ---------- */
label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 14px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white);
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px var(--green-100); }
.hero input { border-color: transparent; }
input.pin { letter-spacing: .6em; text-align: center; font-size: 1.5rem; font-weight: 700; }
input.code { letter-spacing: .3em; text-align: center; text-transform: uppercase; font-size: 1.3rem; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 14px; border: 0;
  font: inherit; font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  background: var(--red-600); color: var(--white);
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.green { background: var(--green-600); }
.btn.gold { background: var(--gold); color: var(--green-900); }
.btn.ghost { background: transparent; color: var(--green-800); border: 1.5px solid var(--line); }
.hero .btn.ghost { color: var(--white); border-color: rgba(255,255,255,.35); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .88rem; border-radius: 11px; }
.btn.wa { background: #25d366; color: #073b1d; }
.btn.danger { background: transparent; color: var(--red-700); border: 1.5px solid #f2c4cb; }
.linkbtn { background: none; border: 0; padding: 6px 0; font: inherit; font-weight: 600; color: var(--green-600); text-decoration: underline; cursor: pointer; }

/* ---------- Avatar ---------- */
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  background: var(--green-100); color: var(--green-800);
  display: grid; place-items: center; font-weight: 800; font-family: var(--display); font-size: 1.15rem;
  overflow: hidden; border: 2px solid var(--white); box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 112px; height: 112px; font-size: 2.6rem; border-width: 4px; }
.avatar.sm { width: 36px; height: 36px; font-size: .9rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--green-100); color: var(--green-800); }
.badge.red { background: var(--red-100); color: var(--red-700); }
.badge.gold { background: var(--gold-100); color: #7a5a06; }
.badge.gray { background: #eef0ef; color: var(--muted); }
.team-pill { display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 800; letter-spacing: .08em; }
.team-pill.rojo { background: var(--red-600); color: #fff; }
.team-pill.verde { background: var(--green-600); color: #fff; }

/* ---------- Countdown ---------- */
.countdown { display: flex; gap: 10px; margin-top: 10px; }
.countdown div { flex: 1; text-align: center; background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px 4px; }
.countdown b { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1; }
.countdown span { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }

/* ---------- Tasks ---------- */
.task { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.task:first-of-type { border-top: 0; }
.check {
  flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2px solid #cfd8d3; background: var(--white);
  display: grid; place-items: center; font-weight: 900; color: transparent; cursor: pointer; padding: 0; font-size: 1rem;
}
.check.on { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.check.auto { cursor: default; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 650; }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.task .details { font-size: .86rem; color: var(--muted); margin: 2px 0 0; }
.task .meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task .note { margin-top: 8px; display: flex; gap: 8px; }
.task .note input { padding: 10px 12px; }

/* ---------- Gift / reveal ---------- */
.reveal { text-align: center; padding: 30px 18px; }
.giftbtn {
  width: 160px; height: 160px; margin: 10px auto 18px; border-radius: 28px; border: 0; cursor: pointer;
  font-size: 5.5rem; line-height: 1; background: var(--red-600); box-shadow: 0 14px 34px rgba(200,16,46,.35);
  animation: wobble 2.4s ease-in-out infinite;
}
@keyframes wobble { 0%,100% { transform: rotate(0); } 10% { transform: rotate(-6deg); } 20% { transform: rotate(6deg); } 30% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .giftbtn { animation: none; } }
.pop { animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Wishlist ---------- */
.wish { display: flex; gap: 12px; align-items: flex-start; }
.wish .num {
  flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--gold-100); color: #7a5a06;
  display: grid; place-items: center; font-weight: 800; font-family: var(--display);
}
.wish .body { flex: 1; min-width: 0; }
.wish .title { font-weight: 700; font-size: 1.02rem; }
.wish .details { color: var(--muted); font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; }
.wish .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.wish .price { font-weight: 700; color: var(--green-600); font-size: .9rem; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty .big { font-size: 2.6rem; }
.counter { font-weight: 800; color: var(--green-600); }

/* ---------- People / Teams ---------- */
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .name { font-weight: 650; }
.people .sub { font-size: .8rem; color: var(--muted); }
.teamcol h3 { display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.rojo { background: var(--red-600); } .dot.verde { background: var(--green-600); }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.tabs a { flex: none; padding: 10px 14px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .88rem; }
.tabs a.active { background: var(--green-800); color: #fff; border-color: var(--green-800); }
.admin-item { padding: 12px 0; border-top: 1px solid var(--line); }
.admin-item:first-child { border-top: 0; }
.kv { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.codebox { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; letter-spacing: .25em; font-weight: 800; text-align: center; padding: 14px; background: var(--gold-100); border-radius: 12px; margin: 10px 0; }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 2rem; color: var(--green-800); }
details summary { cursor: pointer; font-weight: 650; padding: 6px 0; }

/* ---------- Secret card ---------- */
.secret { position: relative; cursor: pointer; }
.secret .veil { filter: blur(9px); user-select: none; transition: filter .3s; }
.secret.open .veil { filter: none; }
.secret .tap { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.secret.open .tap { display: none; }

/* ---------- Toast & modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red-700); }

.modal-bg { position: fixed; inset: 0; background: rgba(11,47,35,.55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--cream); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }
