:root {
  --pine-900: #0b2016;
  --pine-800: #0f2a1d;
  --pine-700: #163a29;
  --pine-600: #1f4a35;
  --cranberry: #a3202f;
  --cranberry-dark: #7a1522;
  --gold: #d4a64a;
  --gold-light: #f0d48a;
  --cream: #f7f0e1;
  --paper: #fffaf0;
  --ink: #2a1d14;
  --muted: #6b5a49;
  --line: #e6d6b6;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --script: 'Pinyon Script', 'Snell Roundhand', 'Apple Chancery', cursive;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 16px/1.5 var(--body);
  color: var(--cream);
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(240, 212, 138, 0.16), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(163, 32, 47, 0.18), transparent 70%),
    var(--pine-800);
  background-attachment: fixed;
  overflow-x: hidden;
}

body.has-devbar { padding-bottom: 120px; }

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

/* ---------- ambient: snow + lights ---------- */

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

.lights {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.lights svg { display: block; }
.lights .wire { fill: none; stroke: #0a1a12; stroke-width: 2; }
.lights .cap { fill: #3b3b33; }
.lights .bulb {
  animation: twinkle 3.2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center top;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px currentColor); }
  50% { opacity: 0.55; filter: drop-shadow(0 0 1px currentColor); }
}

/* ---------- layout ---------- */

.page {
  position: relative;
  z-index: 2;
  max-width: 820px;
  margin: 0 auto;
  padding: 76px max(16px, env(safe-area-inset-left)) 48px;
}

.masthead { text-align: center; margin-bottom: 28px; }

.masthead__name {
  margin: 0;
  font-family: var(--script);
  font-size: clamp(56px, 13vw, 88px);
  line-height: 1;
  color: var(--gold-light);
  text-shadow: 0 2px 24px rgba(240, 212, 138, 0.25);
}

.masthead__title {
  margin: 6px 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(15px, 3.4vw, 19px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--cream);
}

.ornament { color: var(--gold); font-size: 0.8em; letter-spacing: 0; vertical-align: 0.1em; }

.masthead__sub {
  margin: 10px 0 0;
  font-family: var(--display);
  font-style: italic;
  color: rgba(247, 240, 225, 0.62);
}

/* ---------- the card on stage ---------- */

.stage { display: flex; justify-content: center; margin-bottom: 56px; min-height: 200px; }

.card {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 32px;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border-radius: 22px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 166, 74, 0.35);
}

.card::before {
  content: '';
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(212, 166, 74, 0.45);
  border-radius: 15px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cranberry);
}

.card__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  text-wrap: balance;
}

.card__hint { margin: 8px 0 0; color: var(--muted); }

/* ---------- wrapped present ---------- */

.present {
  position: relative;
  width: 170px;
  height: 158px;
  margin: 18px auto 22px;
  animation: wobble 5s ease-in-out 1.5s infinite;
}

.present__box {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 104px;
  border-radius: 6px;
  background: linear-gradient(160deg, #be2b3b, var(--cranberry) 55%, var(--cranberry-dark));
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.18);
}

.present__box::before,
.present__lid::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 24px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #b88a33, var(--gold-light) 45%, var(--gold) 70%, #b88a33);
}

.present__box::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 25% 30%, rgba(255, 255, 255, 0.14) 0 3px, transparent 4px) 0 0 / 26px 26px;
}

.present__lid {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 34px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(170deg, #c93445, var(--cranberry));
  box-shadow: 0 6px 10px -4px rgba(0, 0, 0, 0.35);
  z-index: 2;
  transition: transform 0.7s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.6s ease 0.2s;
}

.present__bow { position: absolute; left: 50%; top: -30px; width: 0; height: 0; }

.present__bow::before,
.present__bow::after {
  content: '';
  position: absolute;
  top: 0;
  width: 42px;
  height: 30px;
  border: 8px solid var(--gold);
  border-radius: 50% 50% 8px 50%;
}

.present__bow::before { right: 4px; transform: rotate(-18deg); }
.present__bow::after { left: 4px; transform: rotate(18deg) scaleX(-1); }

.present__knot {
  position: absolute;
  left: 50%;
  top: -12px;
  width: 20px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 6px;
  background: var(--gold-light);
  box-shadow: inset 0 -3px 0 #b88a33;
  z-index: 1;
}

.present__tag {
  position: absolute;
  right: -6px;
  bottom: 18px;
  padding: 4px 9px 4px 12px;
  font: 600 14px var(--display);
  color: var(--cranberry-dark);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 4px 10px 10px 4px;
  transform: rotate(8deg);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 3;
}

.present--small { transform: scale(0.72); margin: -8px auto 0; animation: none; }

@keyframes wobble {
  0%, 88%, 100% { transform: rotate(0); }
  91% { transform: rotate(-3deg); }
  94% { transform: rotate(3deg); }
  97% { transform: rotate(-1.5deg); }
}

.is-opening .present { animation: none; }
.is-opening .present__lid { transform: translateY(-90px) rotate(-22deg); opacity: 0; }
.is-opening .present__box { animation: squash 0.5s ease; }

@keyframes squash {
  40% { transform: scale(1.06, 0.92); }
  100% { transform: scale(1); }
}

/* ---------- code entry ---------- */

.code { margin-top: 22px; }

.code__digits { display: flex; justify-content: center; gap: 10px; }

.code__digit {
  width: 56px;
  height: 68px;
  padding: 0;
  font: 600 32px var(--display);
  text-align: center;
  color: var(--cranberry-dark);
  caret-color: var(--cranberry);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.code__digit:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(212, 166, 74, 0.25); }
.code__digit:disabled { opacity: 0.5; }

.code__digits.is-wrong { animation: shake 0.42s; }
.code__digits.is-wrong .code__digit { border-color: var(--cranberry); }

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  min-width: 180px;
  padding: 13px 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cream);
  background: var(--cranberry);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(163, 32, 47, 0.8);
  transition: background 0.15s, transform 0.15s;
}

.btn:hover { background: var(--cranberry-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.code__msg { min-height: 1.5em; margin: 12px 0 0; font-size: 14px; color: var(--cranberry); }

/* ---------- revealed gift ---------- */

.reveal__photo {
  margin: 14px 0 20px;
  overflow: hidden;
  border-radius: 14px;
  aspect-ratio: 1;
  background: var(--cream);
  box-shadow: 0 0 0 1px var(--line), 0 14px 30px -14px rgba(0, 0, 0, 0.4);
}

.reveal__photo img { width: 100%; height: 100%; object-fit: cover; }

.reveal__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 6vw, 32px);
  line-height: 1.15;
}

.reveal__note {
  margin: 10px 0 0;
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
}

.reveal__next {
  margin: 22px 0 0;
  padding-top: 18px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px dashed var(--line);
}

.is-entering { animation: enter 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2); }

@keyframes enter {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.sparkle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 50;
}

/* ---------- countdown / finale ---------- */

.countdown { display: flex; justify-content: center; gap: 10px; margin: 18px 0 6px; }

.countdown div {
  min-width: 70px;
  padding: 12px 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.countdown span {
  display: block;
  font: 600 34px/1 var(--display);
  color: var(--cranberry-dark);
  font-variant-numeric: tabular-nums;
}

.countdown small {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.finale__star { font-size: 46px; line-height: 1; color: var(--gold); margin: 6px 0 10px; }

/* ---------- December calendar ---------- */

.month__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212, 166, 74, 0.3);
}

.month__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 5vw, 34px);
  color: var(--cream);
}

.month__progress { margin: 0; font-size: 14px; color: var(--gold-light); }

.month__weekdays,
.month__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.month__weekdays {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(240, 212, 138, 0.7);
}

.month__weekdays b { font-weight: inherit; }
.month__weekdays i { display: none; font-style: normal; }

.month__grid { margin: 0; padding: 0; list-style: none; }

.cell { aspect-ratio: 1; border-radius: 12px; }

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: none;
  text-align: center;
}

button.day { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
button.day:hover { transform: translateY(-3px); }
button.day:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }

.day__num { font: 600 clamp(15px, 2.8vw, 24px)/1 var(--display); }

.day__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.day__icon { width: 14px; height: 14px; opacity: 0.6; }

/* not yet */
.day--locked {
  color: rgba(247, 240, 225, 0.42);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(247, 240, 225, 0.1);
}

/* ready to open */
.day--available {
  color: var(--cranberry-dark);
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(240, 212, 138, 0.35);
}

.day--today { animation: glow 2.4s ease-in-out infinite; }

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(240, 212, 138, 0.3); }
  50% { box-shadow: 0 0 0 2px var(--gold-light), 0 0 30px rgba(240, 212, 138, 0.7); }
}

/* opened: photo thumbnail */
.day--opened { background: var(--pine-600); box-shadow: 0 0 0 1px rgba(212, 166, 74, 0.5); }

.day--opened img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.day--opened .day__num {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 24px;
  padding: 4px 5px 3px;
  font-size: 13px;
  color: var(--cranberry-dark);
  background: var(--paper);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.day__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.68));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.day--today.day--opened { animation: none; box-shadow: 0 0 0 2px var(--gold-light), 0 0 22px rgba(240, 212, 138, 0.45); }

/* Christmas Day */
.day--christmas.day--locked {
  color: var(--gold-light);
  background: linear-gradient(160deg, rgba(190, 43, 59, 0.55), rgba(122, 21, 34, 0.55));
  box-shadow: inset 0 0 0 1px rgba(240, 212, 138, 0.45);
}

.day__star { font-size: 14px; line-height: 1; color: var(--gold-light); }

/* Dec 26–31 */
.cell--after { display: flex; align-items: center; justify-content: center; }
.cell--after .day__num { color: rgba(247, 240, 225, 0.16); font-size: clamp(13px, 2.4vw, 18px); }

.month__meta { display: flex; align-items: center; gap: 12px; }

.month__lock {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-light);
  background: none;
  border: 1px solid rgba(240, 212, 138, 0.4);
  border-radius: 999px;
  cursor: pointer;
}

.month__lock:hover { background: rgba(240, 212, 138, 0.1); }

/* past-gifts passcode */
.calendar-gate { display: flex; justify-content: center; padding-top: 8px; }

.gate__icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 2px auto 16px;
  color: var(--gold-light);
  background: linear-gradient(160deg, #be2b3b, var(--cranberry-dark));
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(212, 166, 74, 0.35);
}

.gate__icon svg { width: 26px; height: 26px; }

/* ---------- modal ---------- */

.modal {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  overflow: visible;
}

.modal::backdrop { background: rgba(5, 15, 10, 0.72); backdrop-filter: blur(4px); }

.modal .card { max-width: none; }

.modal__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 5;
  width: 34px;
  height: 34px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.modal__close:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }

/* ---------- demo toolbar ---------- */

.devbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 10px 14px;
  font-size: 13px;
  color: #e9e6df;
  background: rgba(17, 17, 17, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.devbar__tag {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #111;
  background: var(--gold-light);
  border-radius: 6px;
}

.devbar select,
.devbar button {
  padding: 5px 9px;
  font-size: 13px;
  color: #fff;
  background: #2b2b2b;
  border: 1px solid #444;
  border-radius: 8px;
  cursor: pointer;
}

.devbar button:hover { background: #3a3a3a; }
.devbar strong { font: 600 15px var(--display); letter-spacing: 0.12em; color: var(--gold-light); }

.devbar__codes {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 4px 16px;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid #333;
  font-variant-numeric: tabular-nums;
}

.devbar__codes span { white-space: nowrap; color: #aaa; }
.devbar__codes b { color: #fff; font-weight: 600; }

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .page { padding-top: 64px; }
  .card { padding: 30px 20px 24px; }
  .code__digit { width: 52px; height: 62px; font-size: 28px; }
  .month__weekdays, .month__grid { gap: 5px; }
  .month__weekdays b { display: none; }
  .month__weekdays i { display: inline; }
  .cell { border-radius: 8px; }
  .day__label, .day__name, .day__icon { display: none; }
  .day--opened .day__num { top: 3px; left: 3px; min-width: 18px; padding: 3px 4px 2px; font-size: 10px; }
  .countdown div { min-width: 60px; }
  .countdown span { font-size: 28px; }
  .devbar { font-size: 12px; }
  .devbar__codes { grid-template-columns: repeat(3, auto); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
