:root {
  color-scheme: dark;
  --pine: #123524;
  --pine-deep: #10281c;
  --holly: #c0392b;
  --gold: #f0c14a;
  --cream: #fff6e4;
  --cocoa: #3a221c;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background-color: var(--pine-deep);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(240, 193, 74, 0.16), transparent 32%),
    radial-gradient(circle at 100% 8%, rgba(192, 57, 43, 0.32), transparent 36%);
  color: var(--cream);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  line-height: 1.35;
}

body.is-nice {
  background-color: #0e2c3a;
  background-image:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.2), transparent 42%),
    radial-gradient(circle at 8% 12%, rgba(240, 193, 74, 0.18), transparent 28%);
}

body.is-naughty {
  background-color: var(--cocoa);
  background-image:
    radial-gradient(circle at 50% 12%, rgba(240, 193, 74, 0.2), transparent 42%),
    radial-gradient(circle at 90% 0%, rgba(192, 57, 43, 0.28), transparent 34%);
}

button, input { font: inherit; }

#fx {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.snow,
.confetti {
  position: absolute;
  top: -12%;
  animation-name: drift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.snow {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff;
}

.snow.flake {
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
  color: #fff;
  font-size: 16px;
}

.confetti { border-radius: 2px; }

@keyframes drift {
  0% { transform: translate3d(0, -8vh, 0) rotate(0deg); }
  100% { transform: translate3d(16px, 110vh, 0) rotate(320deg); }
}

#corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 4;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
}

#corner::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(240, 193, 74, 0.55);
}

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

main {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 12px 16px 4px;
}

.top {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px 10px;
  align-items: center;
}

#logo {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#logo img { display: block; width: 72px; height: 72px; border-radius: 50%; }

h1, h2, .sub { font-family: Georgia, "Iowan Old Style", Palatino, serif; }

h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sub { margin: 2px 0 0; font-size: 1rem; }

#mute {
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-size: 0.85rem;
  font-weight: 800;
}

#scan-screen, #result-screen { margin-top: 12px; }

#status {
  min-height: 2.7em;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(240, 193, 74, 0.12);
  text-align: center;
  font-size: 1.12rem;
  font-weight: 800;
}

.meter {
  height: 16px;
  margin: 0 0 14px;
  overflow: hidden;
  border: 2px solid rgba(240, 193, 74, 0.75);
  border-radius: 999px;
  background: rgba(255, 246, 228, 0.12);
}

.meter > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--holly), var(--gold));
}

.pad-wrap { display: flex; justify-content: center; }

#pad {
  position: relative;
  width: min(70vw, 270px);
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 6px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #2f9a5a 0%, #14613a 55%, #0d3a24 100%);
  box-shadow:
    0 0 0 8px rgba(240, 193, 74, 0.18),
    0 0 36px rgba(192, 57, 43, 0.45);
  color: #fff4cc;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#pad svg { width: 68%; height: 78%; margin-top: 12%; }

#pad.is-scanning {
  box-shadow:
    0 0 0 10px rgba(240, 193, 74, 0.5),
    0 0 48px rgba(255, 220, 120, 0.75);
}

#pad.is-scanning::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px solid rgba(240, 193, 74, 0.8);
  border-radius: 50%;
  animation: pulse 1.1s ease-out infinite;
}

@keyframes pulse {
  from { transform: scale(0.96); opacity: 0.85; }
  to { transform: scale(1.12); opacity: 0; }
}

.scanline {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, #fff6c8, #fff, #fff6c8, transparent);
  box-shadow: 0 0 16px var(--gold);
  opacity: 0;
  top: 18%;
}

#pad.is-scanning .scanline {
  opacity: 1;
  animation: sweep 1.05s linear infinite;
}

@keyframes sweep {
  from { top: 14%; }
  to { top: 80%; }
}

.hint {
  margin: 12px 0 0;
  color: rgba(255, 246, 228, 0.84);
  text-align: center;
  font-size: 0.98rem;
}

#scan-screen { position: relative; }

#scan-screen.is-live #status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#scan-screen.is-live #pad { width: min(48vw, 190px); }

.scan-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 10px;
  overflow: hidden;
  border-radius: 14px;
  background: #10281c;
}

.scan-hero > img,
.scan-hero > .art-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#terminal {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  margin: 0;
  overflow: hidden;
  border: 2px solid #1f8f4a;
  border-radius: 12px;
  background: rgba(4, 18, 8, 0.9);
  color: #b6ffc8;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  box-shadow: 0 0 18px rgba(57, 245, 122, 0.18);
}

.term-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #071a0e;
  border-bottom: 1px solid #1f8f4a;
}

.term-title {
  color: #39f57a;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.term-screen {
  position: relative;
  height: 86px;
}

#rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#terminal-log {
  position: relative;
  z-index: 1;
  height: 100%;
  margin: 0;
  padding: 8px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.3;
  color: #c8ffd4;
  text-shadow: 0 0 6px rgba(80, 255, 140, 0.45);
  white-space: pre-wrap;
}

.log-line { min-height: 1.35em; }

#result-screen { text-align: center; }

#sleigh { width: 210px; height: 66px; pointer-events: none; }
#sleigh svg { width: 210px; height: 66px; display: block; }
#sleigh.go {
  position: fixed;
  top: 18%;
  left: 0;
  z-index: 6;
  animation: flyby 2.6s linear both;
}
#sleigh.parked { position: relative; margin: 0 auto 6px; }
#sleigh .deer { transform-origin: 40px 40px; animation: gallop 0.35s ease-in-out infinite; }
#sleigh .deer-b { animation-delay: -0.17s; }

@keyframes gallop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes flyby {
  from { transform: translateX(-240px); }
  to { transform: translateX(110vw); }
}

.toy-list {
  margin: 12px 0 4px;
  text-align: left;
}

.toy-list h3 {
  margin: 0 0 8px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  color: #8a5a12;
}

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

.toy-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  opacity: 0;
  transform: translateY(8px);
  animation: toy-in 0.4s ease forwards;
  animation-delay: calc(var(--i) * 0.55s);
}

.toy-list .check {
  grid-row: span 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  transform: scale(0);
  animation: check-pop 0.35s cubic-bezier(.2, 1.4, .4, 1) forwards;
  animation-delay: calc(var(--i) * 0.55s + 0.25s);
}

.toy-list.is-approved .check { background: #14613a; color: var(--cream); }
.toy-list.is-hold .check { background: #8a5a12; color: var(--cream); }

.toy-list .toy-name {
  font-weight: 700;
  color: var(--cocoa);
}

.toy-list .toy-status {
  grid-column: 2;
  font-size: 12px;
  line-height: 1.25;
}

.toy-list.is-approved .toy-status { color: #14613a; }
.toy-list.is-hold .toy-status { color: #8a4b32; }

@keyframes toy-in {
  to { opacity: 1; transform: none; }
}

@keyframes check-pop {
  to { transform: scale(1); }
}

.workshop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.elf {
  position: absolute;
  width: 86px;
  height: 96px;
}

.elf svg { width: 86px; height: 96px; display: block; }
.elf-hammer { left: -8px; top: 27%; }
.elf-wrap { right: -6px; top: 34%; }
.hammer-arm { transform-origin: 48px 50px; animation: hammer 0.72s ease-in-out infinite; }
.elf-wrap .wrap-arms { transform-origin: 43px 54px; animation: wrap-hands 1.1s ease-in-out infinite; }
.elf-wrap .gift { transform-origin: 43px 71px; animation: gift-bob 1.1s ease-in-out infinite; }

@keyframes hammer {
  0%, 100% { transform: rotate(-32deg); }
  50% { transform: rotate(16deg); }
}

@keyframes wrap-hands {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.86); }
}

@keyframes gift-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-3px) rotate(2deg); }
}

.conveyor {
  position: absolute;
  left: 0;
  right: 0;
  top: 41%;
  height: 42px;
}

.belt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 22px;
  overflow: hidden;
  background: repeating-linear-gradient(90deg, #2a241c 0 14px, #3d3428 14px 28px);
  border-top: 3px solid #6b3a22;
}

.belt-edge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 8px;
  background: #1a140f;
}

.box {
  position: absolute;
  bottom: 2px;
  width: 28px;
  height: 18px;
  border-radius: 2px;
  animation: carry 9s linear infinite;
}

.box-a { background: #c0392b; animation-delay: 0s; }
.box-b { background: #14613a; animation-delay: -3s; }
.box-c { background: #f0c14a; animation-delay: -6s; }
.box::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(255, 246, 228, 0.85);
}

@keyframes carry {
  from { transform: translateX(-40px); }
  to { transform: translateX(100vw); }
}

#santa-peek {
  position: absolute;
  top: 16%;
  right: 0;
  width: 104px;
  height: 122px;
  opacity: 0;
  transform: translateX(72%);
}

#santa-peek svg { width: 104px; height: 122px; display: block; }
body.is-scanning #santa-peek { animation: santa-peek 2.8s ease-in-out infinite; }
.peek-list { transform-origin: 88px 108px; animation: list-check 1.4s ease-in-out infinite; }

@keyframes santa-peek {
  0%, 100% { opacity: 0; transform: translateX(78%); }
  18%, 78% { opacity: 1; transform: translateX(8%); }
}

@keyframes list-check {
  0%, 100% { transform: rotate(8deg); }
  50% { transform: rotate(-6deg); }
}

body.page-hidden .workshop *,
body.page-hidden #sleigh .deer {
  animation-play-state: paused !important;
}

.certificate {
  position: relative;
  margin: 4px 0 0;
  padding: 18px 14px 14px;
  border: 8px solid #14613a;
  border-radius: 16px;
  outline: 3px solid var(--gold);
  outline-offset: -12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 193, 74, 0.28), transparent 42%),
    #fff8ea;
  color: #123524;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.dept {
  margin: 0 0 6px;
  color: #14613a;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.santa-frame {
  display: grid;
  width: 100%;
  aspect-ratio: 900 / 506;
  margin: 0 0 6px;
  overflow: hidden;
  border-radius: 12px;
  background: #1a3a28;
}

.santa-frame > * { grid-area: 1 / 1; }

.santa-frame img,
.santa-frame svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.seal-wrap {
  position: relative;
  width: min(52vw, 190px);
  aspect-ratio: 640 / 554;
  margin: 2px auto 10px;
}

.seal, #seal-fallback {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(240, 193, 74, 0.9));
}

.seal-wrap.is-stamping::after {
  content: "";
  position: absolute;
  inset: 10% 18% 22%;
  border-radius: 50%;
  pointer-events: none;
  animation: seal-glow 1.3s ease-out;
}

@keyframes seal-glow {
  0% { box-shadow: 0 0 0 0 rgba(240, 193, 74, 0); }
  45% { box-shadow: 0 0 22px 8px rgba(240, 193, 74, 0.8); }
  100% { box-shadow: 0 0 12px 3px rgba(240, 193, 74, 0.45); }
}

.seal-wrap.is-stamping .seal,
.seal-wrap.is-stamping #seal-fallback {
  animation: stamp-slam 0.55s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

@keyframes stamp-slam {
  0% { transform: scale(1.75) rotate(-16deg); opacity: 0; }
  68% { transform: scale(0.92) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-7deg); opacity: 1; }
}

.naughty-stamp {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  display: grid;
  place-items: center;
}

.naughty-stamp span {
  padding: 4px 8px;
  border: 3px solid #c0392b;
  border-radius: 6px;
  background: rgba(255, 248, 234, 0.9);
  color: #c0392b;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: rotate(-10deg);
}

.seal-wrap.is-stamping .naughty-stamp span {
  animation: stamp-slam 0.6s 0.08s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}

#result-title {
  margin: 4px 0 0;
  color: #123524;
  font-size: clamp(1.35rem, 5.6vw, 1.8rem);
  line-height: 1.15;
}

#result-title.is-long { font-size: clamp(1.15rem, 4.6vw, 1.45rem); }

#result-name {
  margin: 6px 0 0;
  color: #8e1e18;
  font-size: 1.45rem;
  font-weight: 800;
}

.still-time {
  margin: 8px 0 0;
  color: #8e2f3a;
  font-weight: 800;
}

.cert-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 0;
  text-align: left;
  font-size: 0.78rem;
}

.cert-meta div { min-width: 0; }
.cert-meta dt { font-weight: 800; color: #14613a; }
.cert-meta dd {
  margin: 0;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  overflow-wrap: anywhere;
}

.signature {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.sign-block { min-width: 120px; margin: 0 auto; text-align: center; }
.sign-script {
  display: block;
  color: #1a2744;
  font-family: "Segoe Script", "Snell Roundhand", "Apple Chancery", cursive;
  font-size: 1.45rem;
  line-height: 1;
}
.sign-rule { display: block; height: 1px; margin: 2px 8px 0; background: #123524; }
.sign-caption {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.big, #kidding, #done {
  width: 100%;
  min-height: 60px;
  border-radius: 999px;
  font-size: 1.25rem;
  font-weight: 800;
}

.big {
  border: 3px solid var(--gold);
  background: var(--holly);
  color: #fff8ea;
}

#kidding {
  border: 3px solid var(--gold);
  background: var(--gold);
  color: var(--cocoa);
}

.credit {
  width: min(440px, 100%);
  margin: 8px auto 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 0.85rem;
}

.credit a { color: var(--gold); }

#parents {
  width: min(360px, calc(100vw - 28px));
  max-height: min(92vh, 820px);
  padding: 18px 16px 16px;
  overflow: auto;
  border: 4px solid var(--gold);
  border-radius: 24px;
  background: var(--cream);
  color: var(--pine);
}

#parents::backdrop { background: rgba(8, 20, 14, 0.72); }

#parents h2 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  line-height: 1.1;
}

.parents-note { margin: 0 0 12px; font-size: 0.95rem; }

.modes {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.modes legend {
  margin-bottom: 8px;
  font-weight: 800;
}

.modes label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid #1c6b42;
  border-radius: 14px;
  background: #fff;
  font-weight: 800;
}

.modes label:has(input:checked) {
  border-color: var(--gold);
  background: #14613a;
  color: var(--cream);
}

.modes input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--holly);
}

.santas-list {
  margin: 0 0 14px;
  padding: 10px 10px 2px;
  border: 2px solid rgba(212, 160, 23, 0.7);
  border-radius: 12px;
}

.santas-list legend {
  padding: 0 6px;
  color: #8a5a12;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.toy-label {
  margin: 2px 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: #5c3b08;
}

.name-field,
.toy-field { display: grid; gap: 6px; margin-bottom: 10px; font-weight: 800; }

#kid-name,
.toy-field input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid #1c6b42;
  border-radius: 12px;
  background: #fff;
  color: var(--pine);
  font-size: 16px;
}

#done {
  border: 3px solid #1c6b42;
  background: #14613a;
  color: var(--cream);
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  #pad.is-scanning::after,
  .scanline,
  .snow,
  .confetti,
  #sleigh.go,
  #sleigh .deer,
  .seal-wrap.is-stamping .seal,
  .seal-wrap.is-stamping #seal-fallback,
  .seal-wrap.is-stamping::after,
  .seal-wrap.is-stamping .naughty-stamp span,
  .workshop *,
  .toy-list li,
  .toy-list .check { animation: none !important; }

  #pad.is-scanning .scanline { top: 46%; opacity: 1; }

  .snow, .confetti { top: 18%; }

  #sleigh.go { position: relative; top: auto; left: auto; margin: 0 auto 6px; }

  .toy-list li,
  .toy-list .check { opacity: 1; transform: none; }

  body.is-scanning #santa-peek { opacity: 1; transform: translateX(8%); }
}
