:root {
  --night: #0c2419;
  --pine: #14402c;
  --pine-2: #1d6b45;
  --berry: #b3202a;
  --berry-2: #d4343e;
  --gold: #e8b64c;
  --paper: #fffaf0;
  --paper-2: #f5ecd8;
  --ink: #2a2622;
  --muted: #6f6452;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #23573d 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #3a1518 0%, transparent 60%),
    var(--night);
  background-attachment: fixed;
}
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.lights {
  position: fixed; top: 0; left: 0; right: 0; height: 22px; z-index: 2; pointer-events: none;
  background:
    radial-gradient(circle at 10px 14px, #ff5a5f 4px, transparent 5px) 0 0/80px 22px,
    radial-gradient(circle at 30px 16px, #ffd34d 4px, transparent 5px) 0 0/80px 22px,
    radial-gradient(circle at 50px 14px, #5fd38d 4px, transparent 5px) 0 0/80px 22px,
    radial-gradient(circle at 70px 16px, #6db7ff 4px, transparent 5px) 0 0/80px 22px;
  animation: twinkle 2.4s steps(2) infinite;
  filter: drop-shadow(0 0 6px rgba(255,220,120,.6));
}
.lights::before { content: ''; position: absolute; left: 0; right: 0; top: 8px; border-top: 2px solid #233; opacity: .7; }
@keyframes twinkle { 50% { filter: drop-shadow(0 0 2px rgba(255,220,120,.2)) brightness(.75); } }

.top { position: relative; z-index: 3; max-width: 760px; margin: 0 auto; padding: 34px 20px 4px; }
.brand {
  font-family: 'Mountains of Christmas', cursive; font-size: 30px; color: var(--paper);
  text-decoration: none; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.brand-gift { display: inline-block; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-6deg); } }

main { position: relative; z-index: 3; max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.foot { position: relative; z-index: 3; text-align: center; color: rgba(255,250,240,.55); font-size: 13px; padding: 10px 16px 40px; }

.hero { text-align: center; color: var(--paper); padding: 18px 8px 26px; }
.hero h1 {
  font-family: 'Fraunces', serif; font-weight: 900; font-size: clamp(40px, 8vw, 68px);
  line-height: 1; margin: 0 0 12px; letter-spacing: -1px;
}
.hero h1 em { font-family: 'Mountains of Christmas', cursive; font-style: normal; color: var(--gold); font-size: 1.05em; }
.hero p { margin: 0 auto; max-width: 520px; font-size: 18px; color: rgba(255,250,240,.82); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.step { background: rgba(255,250,240,.08); border: 1px solid rgba(255,250,240,.15); color: var(--paper); border-radius: 14px; padding: 12px; font-size: 14px; text-align: center; }
.step b { display: block; font-size: 22px; margin-bottom: 4px; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }

.card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 26px 24px;
  margin: 0 0 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.04);
}
.card.ribbon::before {
  content: ''; position: absolute; top: 0; bottom: 0; right: 42px; width: 16px;
  background: linear-gradient(90deg, var(--berry), var(--berry-2), var(--berry));
  opacity: .12; border-radius: 2px;
}
.card.loading { text-align: center; color: var(--muted); font-style: italic; }
.card h2 { font-family: 'Fraunces', serif; font-weight: 700; font-size: 26px; margin: 0 0 6px; }
.card h3 { font-family: 'Fraunces', serif; font-weight: 700; font-size: 19px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }

label { display: block; font-weight: 800; font-size: 14px; margin: 14px 0 6px; }
label .opt { font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=date], textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid #e3d6b9; background: #fff; color: var(--ink); outline: none; transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--pine-2); }
textarea { resize: vertical; min-height: 92px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-weight: 800; border: 2px solid #e3d6b9; background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.chip.on { background: var(--pine-2); border-color: var(--pine-2); color: #fff; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; margin-top: 18px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--pine-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 800; font-size: 17px; border: 0; cursor: pointer;
  padding: 14px 22px; border-radius: 14px; text-decoration: none;
  background: var(--berry); color: #fff; box-shadow: 0 4px 0 #7d141b; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7d141b; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.green { background: var(--pine-2); box-shadow: 0 4px 0 #0f3d26; }
.btn.ghost { background: transparent; color: var(--pine-2); box-shadow: inset 0 0 0 2px var(--pine-2); }
.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 10px; box-shadow: 0 3px 0 #7d141b; }
.btn.small.ghost { box-shadow: inset 0 0 0 2px var(--pine-2); }
.btn.block { width: 100%; margin-top: 20px; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.error { background: #fde8e8; color: #8a1820; padding: 10px 14px; border-radius: 10px; margin-top: 14px; font-weight: 700; }

.linkbox { display: flex; gap: 8px; align-items: stretch; margin-top: 8px; }
.linkbox input { font-size: 15px; font-family: ui-monospace, monospace; background: var(--paper-2); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0 4px; }
.fact { background: var(--paper-2); border-radius: 12px; padding: 12px 14px; }
.fact small { display: block; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 800; color: var(--muted); }
.fact strong { font-family: 'Fraunces', serif; font-size: 20px; }
.note { background: #fff4d8; border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 8px; margin-top: 14px; white-space: pre-wrap; }

.countdown { display: flex; gap: 8px; justify-content: center; margin: 14px 0 6px; }
.countdown div { background: var(--night); color: var(--paper); border-radius: 12px; padding: 10px 6px; min-width: 66px; text-align: center; }
.countdown b { display: block; font-family: 'Fraunces', serif; font-size: 30px; line-height: 1; }
.countdown span { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .7; }

.names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.names span { background: #e9f3ec; color: #1b4d33; padding: 6px 11px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.big-count { font-family: 'Fraunces', serif; font-size: 56px; font-weight: 900; line-height: 1; color: var(--pine-2); }

/* Present / reveal */
.present-wrap { display: flex; flex-direction: column; align-items: center; padding: 10px 0 0; }
.present { position: relative; width: 170px; height: 170px; margin: 30px auto 10px; cursor: pointer; border: 0; background: none; padding: 0; }
.present .box { position: absolute; left: 10px; right: 10px; bottom: 0; height: 120px; background: var(--berry); border-radius: 8px; box-shadow: inset 0 -12px 0 rgba(0,0,0,.15); }
.present .box::before { content: ''; position: absolute; left: 50%; width: 26px; margin-left: -13px; top: 0; bottom: 0; background: var(--gold); }
.present .lid { position: absolute; left: 0; right: 0; bottom: 112px; height: 34px; background: var(--berry-2); border-radius: 8px; transition: transform .7s cubic-bezier(.3,1.6,.5,1), opacity .7s; z-index: 2; }
.present .lid::before { content: ''; position: absolute; left: 50%; width: 26px; margin-left: -13px; top: 0; bottom: 0; background: var(--gold); }
.present .bow { position: absolute; left: 50%; top: -30px; width: 70px; height: 34px; margin-left: -35px; }
.present .bow::before, .present .bow::after { content: ''; position: absolute; top: 0; width: 34px; height: 30px; border: 8px solid var(--gold); border-radius: 50% 50% 0 50%; }
.present .bow::before { left: 0; transform: rotate(-20deg); }
.present .bow::after { right: 0; transform: scaleX(-1) rotate(-20deg); }
.present.locked { cursor: default; filter: saturate(.6); }
.present.locked .lock { position: absolute; z-index: 3; left: 50%; bottom: 40px; transform: translateX(-50%); font-size: 34px; }
.present:not(.locked):not(.open) { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%,60%,100% { transform: rotate(0); } 70% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } 90% { transform: rotate(-3deg); } }
.present.open .lid { transform: translateY(-120px) rotate(-25deg); opacity: 0; }
.reveal { text-align: center; animation: pop .6s cubic-bezier(.3,1.6,.5,1) both; }
.reveal .label { text-transform: uppercase; letter-spacing: .15em; font-size: 12px; font-weight: 800; color: var(--muted); }
.reveal .who { font-family: 'Fraunces', serif; font-weight: 900; font-size: clamp(38px, 9vw, 58px); color: var(--berry); margin: 6px 0 12px; line-height: 1.05; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.wishlist { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; }
.wishlist li { padding: 10px 14px 10px 38px; background: var(--paper-2); border-radius: 10px; margin-bottom: 6px; position: relative; }
.wishlist li::before { content: '✦'; position: absolute; left: 14px; color: var(--gold); }

/* Leaderboard */
.board { width: 100%; border-collapse: collapse; }
.board td { padding: 9px 6px; border-bottom: 1px dashed #e3d6b9; }
.board td:first-child { width: 40px; font-weight: 900; font-family: 'Fraunces', serif; font-size: 18px; }
.board td:last-child { text-align: right; font-weight: 800; }
.board tr.mine td { color: var(--pine-2); }

/* Game card */
.gamecard { background: linear-gradient(135deg, #14402c, #0c2419); color: var(--paper); }
.gamecard h3 { color: var(--gold); font-size: 24px; }
.gamecard p { color: rgba(255,250,240,.85); }

/* People table */
.people { width: 100%; border-collapse: collapse; font-size: 15px; }
.people th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px; }
.people td { padding: 10px 6px; border-top: 1px solid #efe4cc; vertical-align: middle; }
.people td.e { color: var(--muted); word-break: break-all; }
.people .x { background: none; border: 0; color: var(--berry); font-weight: 800; cursor: pointer; font: inherit; }

/* Modal + game */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,15,10,.86); display: flex; align-items: center; justify-content: center; padding: 10px; }
.modal[hidden] { display: none; }
.modal-inner { position: relative; width: min(480px, 100%); aspect-ratio: 3 / 4; max-height: 92vh; }
#gameCanvas { width: 100%; height: 100%; border-radius: 18px; display: block; touch-action: none; background: #0c2419; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-x { position: absolute; top: -14px; right: -6px; z-index: 3; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--paper); font-weight: 900; cursor: pointer; font-size: 16px; }
.game-hud { position: absolute; top: 12px; left: 14px; right: 40px; display: flex; justify-content: space-between; color: #fff; font-family: 'Fraunces', serif; font-weight: 900; font-size: 22px; z-index: 2; pointer-events: none; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#hudLives { color: #ff6b6b; letter-spacing: 2px; }
.game-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--paper); padding: 30px; border-radius: 18px; background: rgba(12,36,25,.78); }
.game-overlay[hidden] { display: none; }
.game-overlay h2 { font-family: 'Mountains of Christmas', cursive; font-size: 46px; margin: 0 0 6px; color: var(--gold); }
.game-overlay p { margin: 4px 0; }
.game-overlay .legend { display: grid; grid-template-columns: auto auto; gap: 4px 12px; text-align: left; margin: 14px 0 18px; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--night); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 800; z-index: 60; transition: transform .25s; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.show { transform: translateX(-50%) translateY(0); }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 40; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
