:root {
  --night: #0a1430;
  --night-2: #1b2d5c;
  --pine: #24508a;
  --pine-soft: #e8eef8;
  --red: #b3202a;
  --red-deep: #8c1820;
  --gold: #d9a441;
  --gold-soft: #f6e7c4;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --ink: #2b2420;
  --muted: #7a6d63;
  --line: #eadfcd;
  --ok: #2f7d55;
  --radius: 22px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .12);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --script: 'Dancing Script', 'Be Vietnam Pro', cursive;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(217, 164, 65, .22), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(90, 60, 140, .28), transparent 60%),
    linear-gradient(180deg, var(--night-2), var(--night) 60%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.wrap {
  position: relative; z-index: 1;
  max-width: 520px; margin: 0 auto;
  padding: 28px 16px 48px;
}
.wrap.wide { max-width: 1100px; }

/* ---------- Header ---------- */
.hero { text-align: center; color: var(--cream); margin-bottom: 22px; }
.hero .star { width: 54px; height: 54px; filter: drop-shadow(0 0 14px rgba(246, 210, 120, .75)); animation: twinkle 3.2s ease-in-out infinite; }
.hero h1 {
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(2.3rem, 10vw, 3.2rem);
  line-height: 1.05;
  margin: 6px 0 8px;
  color: var(--gold-soft);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25), 0 0 24px rgba(217, 164, 65, .35);
}
.hero p { margin: 0 auto; max-width: 30ch; opacity: .85; font-size: .98rem; line-height: 1.5; }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.08) rotate(6deg); opacity: .85; } }

/* hang đá + Lời Chúa */
.nativity { display: block; width: min(300px, 88%); height: auto; margin: 0 auto -4px; filter: drop-shadow(0 0 18px rgba(255, 220, 140, .25)); }
.nativity .nv-star, .nativity .nv-glow { transform-origin: 160px 30px; animation: twinkle 3.6s ease-in-out infinite; }
.nativity .nv-beam { animation: beam 3.6s ease-in-out infinite; }
@keyframes beam { 0%, 100% { opacity: 1; } 50% { opacity: .65; } }
.verse { margin: 14px auto 0 !important; max-width: 34ch !important; font-style: italic; font-size: .9rem !important; line-height: 1.55; color: var(--gold-soft); opacity: .9 !important; }
.verse span { display: block; font-style: normal; font-size: .78rem; letter-spacing: .12em; margin-top: 4px; opacity: .8; }
/* garland */
.garland { display: flex; justify-content: center; gap: 14px; margin: 14px 0 0; }
.garland span { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: blink 2.4s infinite; }
.garland span:nth-child(3n+1) { background: #e8484f; box-shadow: 0 0 10px #e8484f; animation-delay: .4s; }
.garland span:nth-child(3n+2) { background: #5fd08f; box-shadow: 0 0 10px #5fd08f; animation-delay: .8s; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Card ---------- */
.card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px 22px;
  overflow: hidden;
}
.card::before { /* ribbon on top */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px;
  background: linear-gradient(90deg, var(--gold), #f3d488 50%, var(--gold));
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 4px 0 4px; font-size: 1.25rem; color: var(--red-deep); }
.card .lead { margin: 0 0 18px; color: var(--muted); font-size: .94rem; line-height: 1.5; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; margin-bottom: 7px; color: var(--pine); }
.field label .ico { font-size: 1.05rem; }
.field label small { font-weight: 400; color: var(--muted); }
input, textarea, select {
  width: 100%;
  font: inherit; font-size: 16px; /* chống zoom trên iOS */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(217, 164, 65, .2); }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(180deg, #c92a35, var(--red-deep));
  border-radius: 16px;
  padding: 15px 18px;
  box-shadow: 0 10px 20px -10px rgba(140, 24, 32, .9), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .12s, filter .2s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { filter: grayscale(.5) opacity(.6); cursor: not-allowed; }
.btn.green { background: linear-gradient(180deg, #3566a8, var(--pine)); box-shadow: 0 10px 20px -10px rgba(20, 45, 90, .9), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.ghost { background: transparent; color: var(--pine); border: 1.5px solid var(--line); box-shadow: none; }
.btn.gold { background: linear-gradient(180deg, #e7b858, #b9862a); color: #3b2706; }
.btn.small { width: auto; font-size: .9rem; padding: 9px 14px; border-radius: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.msg { border-radius: 14px; padding: 12px 14px; font-size: .93rem; line-height: 1.45; margin-bottom: 14px; }
.msg.err { background: #fdecec; color: #8c1820; border: 1px solid #f5c6c6; }
.msg.info { background: var(--pine-soft); color: var(--pine); border: 1px solid #cdd9ee; }
.hidden { display: none !important; }

/* ---------- Code ticket ---------- */
.ticket {
  text-align: center;
  background: linear-gradient(180deg, #fff8e8, var(--gold-soft));
  border: 2px dashed var(--gold);
  border-radius: 18px;
  padding: 18px 12px;
  margin: 14px 0 16px;
}
.ticket .lbl { font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; color: #8a6420; }
.ticket .code { font-size: 2.4rem; font-weight: 800; letter-spacing: .18em; color: var(--red-deep); margin: 4px 0; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.links { text-align: center; margin-top: 18px; color: var(--cream); opacity: .85; font-size: .9rem; }
.links a { color: var(--gold-soft); }

/* ---------- Gift box (draw page) ---------- */
.stage { display: grid; place-items: center; padding: 8px 0 4px; }
.giftbox { position: relative; width: 190px; height: 190px; cursor: pointer; border: 0; background: none; padding: 0; }
.giftbox .box, .giftbox .lid {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #d0313b, var(--red-deep));
  border-radius: 12px;
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, .18), 0 18px 30px -14px rgba(0, 0, 0, .6);
}
.giftbox .box { bottom: 0; width: 150px; height: 112px; }
.giftbox .lid { bottom: 106px; width: 170px; height: 38px; transition: transform .7s cubic-bezier(.2, 1.6, .4, 1), opacity .5s; z-index: 2; }
.giftbox .box::after, .giftbox .lid::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 24px; transform: translateX(-50%); background: linear-gradient(90deg, #e7b858, #c8952f); }
.giftbox .bow { position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%); width: 104px; height: 40px; z-index: 3; transition: transform .7s cubic-bezier(.2, 1.6, .4, 1), opacity .5s; }
.giftbox .bow::before, .giftbox .bow::after { content: ''; position: absolute; bottom: 0; width: 48px; height: 32px; border: 9px solid #e0ad4c; border-radius: 50%; }
.giftbox .bow::before { left: 2px; transform: rotate(-24deg); transform-origin: right bottom; }
.giftbox .bow::after { right: 2px; transform: rotate(24deg); transform-origin: left bottom; }
.giftbox.idle { animation: bob 2.6s ease-in-out infinite; }
.giftbox.shake { animation: shake .5s ease-in-out infinite; }
.giftbox.open .lid { transform: translate(-50%, -70px) rotate(-18deg); opacity: 0; }
.giftbox.open .bow { transform: translate(-50%, -90px) rotate(20deg); opacity: 0; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

.shuffle { min-height: 2.2em; margin: 16px 0 6px; text-align: center; font-weight: 700; color: var(--pine); font-size: 1.1rem; }

.reveal {
  text-align: center;
  animation: pop .7s cubic-bezier(.2, 1.4, .4, 1) both;
}
.reveal .tag { display: inline-block; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #8a6420; background: var(--gold-soft); border-radius: 999px; padding: 5px 12px; }
.reveal .gift { font-family: var(--script); font-size: clamp(2rem, 9vw, 2.6rem); line-height: 1.15; color: var(--red-deep); margin: 12px 0 8px; word-break: break-word; }
.reveal .note { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left; white-space: pre-wrap; line-height: 1.55; color: var(--ink); }
.reveal .note::before { content: '💌 Lời nhắn'; display: block; font-weight: 700; color: var(--pine); font-size: .85rem; margin-bottom: 6px; }
.secret { margin-top: 14px; font-size: .88rem; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(.7) translateY(20px); } to { opacity: 1; transform: none; } }

.who { margin-top: 14px; padding: 14px; border-radius: 16px; background: var(--pine-soft); color: var(--pine); font-weight: 700; text-align: center; animation: pop .6s both; }

.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 5; pointer-events: none; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Admin ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: rgba(255, 250, 240, .08); border: 1px solid rgba(255, 250, 240, .14); color: var(--cream); border-radius: 18px; padding: 14px 12px; }
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.stat .t { font-size: .82rem; opacity: .8; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch b { display: block; }
.switch small { color: var(--muted); }
.toggle { position: relative; flex: none; width: 52px; height: 30px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: #d8cfc2; transition: .2s; cursor: pointer; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: .2s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(22px); }

.search { margin-bottom: 12px; }
.plist { display: grid; gap: 10px; }
.pitem { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: #fff; }
.pitem .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pitem .nm { font-weight: 700; }
.pitem .nm small { color: var(--muted); font-weight: 500; }
.pitem .gf { margin: 6px 0 4px; color: var(--red-deep); font-weight: 600; }
.pitem .nt { font-size: .88rem; color: var(--muted); white-space: pre-wrap; }
.pitem .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .78rem; padding: 4px 9px; border-radius: 999px; background: var(--pine-soft); color: var(--pine); font-weight: 600; }
.chip.code { background: var(--gold-soft); color: #7a5410; letter-spacing: .08em; font-family: ui-monospace, Menlo, monospace; }
.chip.no { background: #f3ece3; color: var(--muted); }
.chip.to { background: #fbe6e7; color: var(--red-deep); }
.iconbtn { border: 0; background: #f4eee5; border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; }
pre.script { background: #16203a; color: #dde6f7; border-radius: 14px; padding: 14px; overflow: auto; font-size: .78rem; line-height: 1.5; max-height: 300px; }
ol.steps { padding-left: 20px; line-height: 1.7; font-size: .92rem; }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .grid2 { grid-template-columns: 380px 1fr; align-items: start; }
  .grid2 .card + .card { margin-top: 0; }
  .side .card + .card { margin-top: 16px; }
}

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 20, 15, .6); backdrop-filter: blur(2px); }
dialog .card { box-shadow: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: .92rem; z-index: 50; box-shadow: var(--shadow); animation: pop .3s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.card a:not(.btn) { color: var(--pine); font-weight: 600; text-underline-offset: 3px; }

.budget { background: linear-gradient(180deg, #fff8e8, var(--gold-soft)); border: 1px solid #ecd29a; color: #6b4a10; border-radius: 14px; padding: 11px 14px; margin-bottom: 16px; font-size: .95rem; line-height: 1.5; text-align: center; }
.budget small { color: #8a6a2a; }
.stats { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.chip.given { border: 0; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600; }
.chip.given.yes { background: #e3f3ea; color: #23704a; }
.qrs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.qrs figure { margin: 0; text-align: center; font-size: .82rem; color: var(--muted); }
.qrs img { width: 100%; max-width: 160px; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.btnstack { display: grid; gap: 10px; }
.archives { margin: 12px 0 0; padding: 0; list-style: none; font-size: .9rem; }
.archives li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

.wh { font-size: 1rem; color: var(--pine); margin: 20px 0 10px; }
.wish { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; white-space: pre-wrap; line-height: 1.55; }
.wish .wd { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); margin-bottom: 4px; text-transform: capitalize; white-space: normal; }
.wish .wd .iconbtn { width: 30px; height: 30px; font-size: .85rem; }
.wish.recv { background: linear-gradient(180deg, #fffdf6, #fff6e0); border-color: #ecd29a; }
.wish .wf { margin-top: 8px; text-align: right; font-weight: 700; color: var(--red-deep); white-space: normal; }

/* Nhiều lớp */
.classpill { display: inline-block; margin: 0 0 12px; padding: 5px 12px; border-radius: 999px; background: var(--pine-soft); color: var(--pine); font-weight: 700; font-size: .88rem; cursor: default; }
#classPill { cursor: pointer; }
#classPill::after { content: ' · đổi'; font-weight: 500; opacity: .7; }
.classbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 0 0 16px; }
.classbar select { font: inherit; font-weight: 700; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--gold); background: #fffaf0; color: var(--night); max-width: 100%; }
.classbar .cbwho { color: var(--cream, #f6e7c4); font-size: .92rem; }
.citem { border: 1px solid #ece3d3; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; background: #fffdf8; }
.citem .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.citem .nm { font-weight: 700; }
.citem .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.citem.cur { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217,164,65,.25); }

/* Món quà em mong muốn (trang bốc thăm) */
.mygift { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0 0 16px; padding: 12px 14px; border-radius: 16px; background: var(--pine-soft); border: 1px dashed var(--pine); text-align: center; }
.mygift .mg-label { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pine); }
.mygift .mg-gift { font-size: 1.15rem; font-weight: 700; color: var(--ink); word-break: break-word; }
