:root {
  --red: #c41e3a;
  --red-deep: #8e0f1f;
  --red-dark: #5d0a15;
  --cream: #fffaf0;
  --paper: #fdf6e3;
  --ink: #2b1d16;
  --ink-soft: #6b564b;
  --gold: #e9b949;
  --green: #1f6f4a;
  --line: rgba(196, 30, 58, 0.16);
  --shadow: 0 18px 40px rgba(40, 0, 8, 0.45);
}

* { box-sizing: border-box; }

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

body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: #fff;
  background:
    radial-gradient(1200px 600px at 50% -10%, #e2364d 0%, transparent 60%),
    linear-gradient(180deg, var(--red) 0%, var(--red-deep) 55%, var(--red-dark) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

.top, main, .foot { position: relative; z-index: 1; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  max-width: 880px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand span { font-family: 'Mountains of Christmas', serif; font-size: clamp(1.5rem, 5vw, 2rem); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
#account { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
#account .who { opacity: .85; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px 16px 40px; }
.foot { text-align: center; font-size: .8rem; opacity: .7; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }

h1, h2 { font-family: 'Mountains of Christmas', serif; margin: 0 0 8px; line-height: 1.1; }
h1 { font-size: clamp(2rem, 8vw, 3rem); text-align: center; text-shadow: 0 3px 0 rgba(0,0,0,.2); }
h2 { font-size: 1.6rem; }
.lead { text-align: center; margin: 0 auto 22px; max-width: 30em; opacity: .92; font-size: 1.05rem; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 800; border: 0; border-radius: 999px; cursor: pointer;
  padding: 13px 26px; min-height: 48px; color: var(--red-deep); background: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.22); transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn.primary { background: var(--red); color: #fff; }
.btn.gold { background: var(--gold); color: #4a2f00; }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); min-height: 40px; padding: 8px 16px; }
.btn.block { width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- cards & paper ---------- */
.card {
  background: var(--cream); color: var(--ink); border-radius: 22px; padding: 22px;
  box-shadow: var(--shadow); border: 4px solid #fff;
}
.card + .card, .card + .paper, .paper + .card { margin-top: 22px; }

.paper {
  position: relative; background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 30px 24px 34px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent 0 2.05rem, var(--line) 2.05rem calc(2.05rem + 1px));
  background-position: 0 1.5rem;
  border-top: 10px solid transparent;
  border-image: repeating-linear-gradient(135deg, var(--red) 0 14px, #fff 14px 28px) 10;
}
.hand { font-family: 'Caveat', cursive; font-size: 1.7rem; line-height: 2.05rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 800; font-size: .9rem; margin: 14px 0 6px; color: var(--ink-soft); }
input[type=text], input[type=email], input[type=password], input[type=number] {
  font: inherit; width: 100%; padding: 12px 14px; border-radius: 12px; min-height: 48px;
  border: 2px solid #e6d9c3; background: #fff; color: var(--ink);
}
input:focus { border-color: var(--red); outline: none; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.row > .narrow { flex: 0 0 96px; }
.error { color: #b00020; font-weight: 800; min-height: 1.3em; margin: 12px 0 0; }
.hint { color: var(--ink-soft); font-size: .88rem; margin: 10px 0 0; }

.tabs { display: flex; background: #f1e6d2; border-radius: 999px; padding: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; font: inherit; font-weight: 800; border: 0; background: none; padding: 10px; border-radius: 999px; cursor: pointer; color: var(--ink-soft); min-height: 44px; }
.tabs button[aria-selected=true] { background: var(--red); color: #fff; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: .85rem; margin: 18px 0 14px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: #e6d9c3; }
.sso { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.apple-btn { font: inherit; font-weight: 600; background: #000; color: #fff; border: 0; border-radius: 999px; min-height: 44px; padding: 0 22px; cursor: pointer; display: flex; align-items: center; gap: 8px; }

.paper textarea {
  width: 100%; min-height: calc(2.05rem * 8); border: 0; background: transparent; resize: vertical;
  color: var(--ink); padding: 0; outline: none; display: block;
}
.paper .dear { margin: 0; color: var(--red-deep); font-weight: 700; }
.paper .sign { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.paper .sign input { font: inherit; border: 0; border-bottom: 2px dashed var(--red); border-radius: 0; background: transparent; padding: 0 4px; min-height: 0; height: 2.05rem; }
.paper .sign .name { flex: 1 1 140px; min-width: 0; }
.paper .sign .age { flex: 0 0 60px; width: 60px; }
.send-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.count { font-family: 'Nunito', sans-serif; font-size: .85rem; color: var(--ink-soft); }

/* ---------- mailbox ---------- */
.mail { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.mail a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; min-height: 60px;
  background: #fff; color: var(--ink); text-decoration: none; border: 2px solid #f1e6d2;
}
.mail a:hover { border-color: var(--red); }
.mail .meta { flex: 1; min-width: 0; }
.mail .meta b { display: block; }
.mail .meta small { color: var(--ink-soft); }
.chip { font-size: .78rem; font-weight: 800; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.chip.wait { background: #fdeccf; color: #8a5a00; }
.chip.new { background: var(--red); color: #fff; }
.chip.read { background: #e3f1e9; color: var(--green); }
.env-ico { flex: 0 0 34px; }

/* ---------- waiting ---------- */
.journey { text-align: center; }
.sleigh-track { position: relative; height: 12px; border-radius: 999px; background: #f1e6d2; margin: 34px 6px 14px; }
.sleigh-fill { height: 100%; border-radius: 999px; background: repeating-linear-gradient(135deg, var(--red) 0 12px, #fff 12px 24px); width: 0; transition: width 1s linear; box-shadow: inset 0 0 0 2px var(--red); }
.sleigh-env { position: absolute; top: -26px; left: 0; width: 44px; margin-left: -22px; transition: left 1s linear; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.stage { font-family: 'Mountains of Christmas', serif; font-size: 1.5rem; color: var(--red-deep); margin: 18px 0 4px; min-height: 2em; }
.eta { color: var(--ink-soft); margin: 0; }

/* ---------- envelope ---------- */
.envelope-wrap { display: grid; place-items: center; gap: 18px; text-align: center; padding: 10px 0 4px; }
.envelope { width: min(320px, 80vw); cursor: pointer; background: none; border: 0; padding: 0; animation: wiggle 2.4s ease-in-out infinite; filter: drop-shadow(0 16px 20px rgba(40,0,8,.5)); }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-3deg); } 80% { transform: rotate(3deg); } 90% { transform: rotate(-2deg); } }
.envelope.opening { animation: open .6s ease-in forwards; }
@keyframes open { to { transform: scale(1.25) translateY(-20px); opacity: 0; } }

/* ---------- Santa's reply ---------- */
.reply { min-height: 320px; padding-bottom: 70px; animation: unfold .5s ease-out; }
@keyframes unfold { from { transform: scaleY(.2); opacity: 0; transform-origin: top; } }
.reply .text { white-space: pre-wrap; margin: 0; }
.reply .w { display: inline-block; white-space: pre; }
.reply .c { opacity: 0; transition: opacity .18s ease-out; }
.reply .c.on { opacity: 1; }
.pen { position: absolute; top: 0; left: 0; width: 0; height: 0; pointer-events: none; transition: transform .09s linear; z-index: 2; }
.pen svg { position: absolute; left: -3px; bottom: -2px; width: 70px; height: 70px; filter: drop-shadow(3px 6px 4px rgba(0,0,0,.3)); transform-origin: 0 100%; }
.pen.writing svg { animation: scribble .22s ease-in-out infinite alternate; }
@keyframes scribble { from { transform: rotate(-5deg) translateY(0); } to { transform: rotate(4deg) translateY(-3px); } }
.pen.done { transition: transform .6s ease, opacity .6s .3s; opacity: 0; }
.spark { position: absolute; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; z-index: 3;
  background: radial-gradient(circle, #fff 0 25%, var(--gold) 45%, transparent 70%);
  animation: spark .7s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.mine { margin-top: 22px; }
.mine summary { cursor: pointer; font-weight: 800; color: var(--ink-soft); }
.mine p { white-space: pre-wrap; margin: 10px 0 0; }
.back { display: inline-block; color: #fff; margin: 0 0 14px; font-weight: 800; text-decoration: none; padding: 8px 0; }

@media (max-width: 480px) {
  .card { padding: 18px; }
  .paper { padding: 26px 16px 30px; }
  .hand { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .envelope, .sleigh-env, .pen.writing svg { animation: none; }
  #snow { display: none; }
}

/* ---------- December Pass + video ---------- */
.video-opt { display: flex; align-items: center; gap: 12px; margin: 18px 0 0; padding: 12px 14px; border-radius: 14px; background: #fff; border: 2px solid var(--gold); cursor: pointer; font-family: 'Nunito', sans-serif; color: var(--ink); }
.video-opt input { width: 24px; height: 24px; accent-color: var(--red); flex: 0 0 auto; }
.video-opt b, .video-opt small { display: block; }
.video-opt small { color: var(--ink-soft); font-weight: 600; }
.pass { margin-top: 22px; border-color: var(--gold); text-align: center; }
.pass p { margin: 6px auto 16px; max-width: 32em; color: var(--ink-soft); }
.notice { background: #fff; color: var(--ink); border-left: 6px solid var(--gold); border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; font-weight: 600; }
.film { margin: 0 0 22px; border-radius: 18px; overflow: hidden; border: 4px solid #fff; box-shadow: var(--shadow); background: #000; }
.film video { display: block; width: 100%; max-height: 70vh; }

.packs { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.pack { font: inherit; cursor: pointer; min-width: 120px; min-height: 76px; padding: 12px 18px; border-radius: 16px; border: 0; background: var(--gold); color: #4a2f00; box-shadow: 0 4px 0 rgba(0,0,0,.22); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pack b { font-size: 1.1rem; }
.pack span { font-weight: 800; font-size: 1.25rem; }
.pack:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.22); }
.pack:disabled { opacity: .6; cursor: default; }
.remove { display: block; margin: 26px auto 0; background: none; border: 0; color: #fff; opacity: .75; font: inherit; font-size: .88rem; text-decoration: underline; cursor: pointer; min-height: 44px; padding: 8px 12px; }
.remove:hover { opacity: 1; }

/* ---------- account ---------- */
.acct { text-decoration: none; display: inline-flex; align-items: center; }
.card form .btn { margin-top: 12px; }
.card .error.ok { color: var(--green); }
textarea.plain { font: inherit; width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid #e6d9c3; background: #fff; color: var(--ink); resize: vertical; }
textarea.plain:focus { border-color: var(--red); outline: none; }
.receipt table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.receipt th, .receipt td { text-align: left; padding: 10px 4px; border-bottom: 1px solid #e6d9c3; vertical-align: top; }
.receipt th { color: var(--ink-soft); font-weight: 600; width: 40%; }
@media print {
  body { background: #fff; color: #000; }
  #snow, .top, .foot, .noprint { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; }
}
