/* ==========================================================================
   Santa's North Pole - base styles (mobile first)
   Theme: [data-theme="day"] (lights OFF) / [data-theme="night"] (lights ON)
   Content panels are 8-bit pixel boxes; only the dial-up loader is Win95.
   ========================================================================== */

:root {
  --lights-h: 56px;
  --px: 4px; /* one "pixel" of the 8-bit frames */
  --font: "Comic Sans MS", "Comic Sans", "Chalkboard SE", "Comic Neue", "Marker Felt", cursive;
  --mono: "Courier New", Courier, "Lucida Console", monospace;

  /* Fixed palettes (self-contained widgets) */
  --led: #ff3b3b;
  --led-bg: #140000;
  --crt: #39ff14;
  --crt-bg: #001400;
  --gold: #ffde00;

  /* Win95 chrome: dial-up loader only */
  --panel: #c0c0c0;
  --bevel-light: #ffffff;
  --bevel-mid: #dfdfdf;
  --bevel-shade: #808080;
  --bevel-dark: #404040;
  --title-a: #000080;
  --title-b: #0b5aa0;

  /* Day / lights OFF (default) */
  --sky: #bfe3ff;
  --sky-tile: url("../assets/backgrounds/stars-day.svg");
  --on-sky: #0b0b3b;
  --focus: #000000;
  --focus-halo: #ffde00;
  --new: #b00000;
  --snow: #ffffff;
  --snow-shadow: 0 0 1px #2a4f9a, 0 0 3px #3a64b0;
  --wire: #2b3a2b;

  --box-bg: #fffdf4;
  --box-fg: #10123a;
  --box-frame: #10123a;
  --box-title: #b00000;
  --box-link: #0000ee;
  --box-visited: #551a8b;
  --inset-bg: #ffffff;
  --inset-fg: #10123a;
  --inset-line: #8a8fb0;
  --muted: #3d4266;
  --ok: #074716;
  --err: #8c0000;
  --done: #2f5a2f;
  --btn-bg: #ffde00;
  --btn-bg-hover: #fff07a;
  --btn-fg: #000000;
  --btn-frame: #000000;
  --btn-depth: #9a7a00;
  color-scheme: light;
}

/* Night / lights ON. Repeated for "no stored choice + dark device" so the
   page is right even before (or without) JavaScript. */
:root[data-theme="night"] {
  --sky: #0b0b3b;
  --sky-tile: url("../assets/backgrounds/stars-night.svg");
  --on-sky: #ffffff;
  --focus: #ffde00;
  --focus-halo: #000000;
  --new: #ff8a8a;
  --snow-shadow: none;
  --wire: #0f1a0f;

  --box-bg: #12154a;
  --box-fg: #ffffff;
  --box-frame: #ffffff;
  --box-title: #ffde00;
  --box-link: #9fdcff;
  --box-visited: #e3b3ff;
  --inset-bg: #070825;
  --inset-fg: #f0f0ff;
  --inset-line: #7a80c0;
  --muted: #c8ccf0;
  --ok: #8fe08f;
  --err: #ff9a9a;
  --done: #8fe08f;
  --btn-frame: #ffffff;
  --btn-depth: #6b5500;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --sky: #0b0b3b;
    --sky-tile: url("../assets/backgrounds/stars-night.svg");
    --on-sky: #ffffff;
    --focus: #ffde00;
    --focus-halo: #000000;
    --new: #ff8a8a;
    --snow-shadow: none;
    --wire: #0f1a0f;
    --box-bg: #12154a;
    --box-fg: #ffffff;
    --box-frame: #ffffff;
    --box-title: #ffde00;
    --box-link: #9fdcff;
    --box-visited: #e3b3ff;
    --inset-bg: #070825;
    --inset-fg: #f0f0ff;
    --inset-line: #7a80c0;
    --muted: #c8ccf0;
    --ok: #8fe08f;
    --err: #ff9a9a;
    --done: #8fe08f;
    --btn-frame: #ffffff;
    --btn-depth: #6b5500;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--lights-h) + env(safe-area-inset-top) + 8px); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--on-sky);
  background-color: var(--sky);
  background-image: var(--sky-tile);
  background-repeat: repeat;
  background-size: 96px 96px;
  padding-top: calc(var(--lights-h) + env(safe-area-inset-top));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; }

a { color: var(--box-link); }
a:visited { color: var(--box-visited); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--focus-halo);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  background: var(--gold);
  color: #000;
  padding: 8px 12px;
  border: 3px solid #000;
  font-weight: bold;
}
.skip-link:focus { top: calc(var(--lights-h) + env(safe-area-inset-top) + 8px); }

.container {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
.layout > * { min-width: 0; }

.small-print { font-size: 0.85rem; }

/* ---------- 8-bit pixel helpers ---------- */

/* A one-pixel frame with notched (stepped) corners, drawn with box-shadow so
   it never affects layout. Set --frame and --px on the element. */
.pixel-frame,
.pixel-box,
.btn8,
.switch-track,
.switch-knob,
.mini-box,
.toast {
  --frame: var(--box-frame);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--frame),
    0 var(--px) 0 0 var(--frame),
    calc(var(--px) * -1) 0 0 0 var(--frame),
    var(--px) 0 0 0 var(--frame);
}

/* ---------- Pixel boxes (content panels) ---------- */

.pixel-box {
  background: var(--box-bg);
  color: var(--box-fg);
  margin: var(--px);
  /* second, offset shadow = chunky drop shadow */
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--frame),
    0 var(--px) 0 0 var(--frame),
    calc(var(--px) * -1) 0 0 0 var(--frame),
    var(--px) 0 0 0 var(--frame),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 0 rgba(0, 0, 0, 0.35);
}

/* Christmas trim: a snow ledge along the top edge and a sprig of holly on the
   top-left corner of every box (pixel SVGs exported from sprites.js). */
.pixel-box { position: relative; }
.pixel-box::before,
.pixel-box::after {
  content: "";
  position: absolute;
  pointer-events: none;
  image-rendering: pixelated;
}
.pixel-box::before {
  left: calc(var(--px) * -1);
  right: calc(var(--px) * -1);
  top: -14px;
  height: 18px;
  background: url("../assets/snowcap.svg") repeat-x left top / 48px 18px;
}
.pixel-box::after {
  left: -10px;
  top: -18px;
  width: 45px;
  height: 30px;
  background: url("../assets/holly.svg") no-repeat center / contain;
}
.box-title {
  padding: 18px 16px 0 44px;
}
.box-title h2 {
  margin: 0;
  padding-bottom: 10px;
  font-size: 1.2rem;
  color: var(--box-title);
  letter-spacing: 0.5px;
  background: repeating-linear-gradient(90deg, var(--box-frame) 0 var(--px), transparent var(--px) calc(var(--px) * 2))
    left bottom / 100% var(--px) no-repeat;
}

.box-body { padding: 14px 16px 16px; }
.box-body > :first-child { margin-top: 0; }
.box-body > :last-child { margin-bottom: 0; }

/* Small framed boxes (header controls, web ring, toast) */
.mini-box {
  background: var(--box-bg);
  color: var(--box-fg);
  margin: var(--px);
}

/* ---------- Buttons ---------- */

.btn8 {
  --frame: var(--btn-frame);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: var(--px) var(--px) calc(var(--px) * 2);
  padding: 6px 16px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 0;
  border-bottom: var(--px) solid var(--btn-depth);
  font-weight: bold;
  cursor: pointer;
  text-align: center;
}
.btn8:active:not(:disabled) {
  transform: translateY(var(--px));
  border-bottom-width: 0;
  margin-bottom: calc(var(--px) * 3);
}
.btn8:disabled { opacity: 0.6; cursor: wait; }
.btn-exit {
  --btn-bg: #b00000;
  --btn-bg-hover: #d01818;
  --btn-fg: #ffffff;
  --btn-depth: #5a0000;
}

/* Text fields: solid pixel border */
.field8 {
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) solid var(--box-frame);
  border-radius: 0;
}
textarea.field8 { resize: vertical; min-height: 88px; }
.field8[aria-invalid="true"] { border-color: var(--err); border-style: dashed; }

.rainbow-hr {
  height: 8px;
  border: 0;
  margin: 16px 0;
  background: linear-gradient(90deg,
    #e40303 0 14.28%, #ff8c00 14.28% 28.57%, #ffed00 28.57% 42.85%, #008026 42.85% 57.14%,
    #24408e 57.14% 71.42%, #732982 71.42% 85.71%, #e40303 85.71% 100%);
}

/* ---------- Christmas lights ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  height: calc(var(--lights-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 env(safe-area-inset-left);
  background: linear-gradient(var(--sky) 70%, transparent);
  pointer-events: none;
}
.lights {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
}
.lights-wire {
  position: absolute;
  left: 0; right: 0;
  top: 6px;
  height: 3px;
  background: var(--wire);
}
.topbar-switch {
  pointer-events: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 0 4px 0 8px;
  font-size: 0.9rem;
}
.topbar-switch .switch8 { min-height: 40px; gap: 6px; padding: 0 2px; }
.topbar-switch .switch-track { width: 52px; height: 26px; }
.topbar-switch .switch-knob { width: 18px; height: 18px; }
.topbar-switch .switch8[aria-checked="true"] .switch-knob { left: 30px; }
.topbar-switch .switch-text { min-width: 2.2em; font-size: 1rem; }
.bulb {
  position: relative;
  margin-top: 6px;
  width: 12px;
  height: 22px;
}
.bulb::before { /* socket */
  content: "";
  position: absolute;
  left: 2px; top: 0;
  width: 8px; height: 6px;
  background: #2f3b2f;
  border: 1px solid #000;
}
.bulb::after { /* glass */
  content: "";
  position: absolute;
  left: 0; top: 6px;
  width: 12px; height: 16px;
  border: 2px solid #000;
  border-radius: 45% 45% 50% 50%;
  background: var(--bulb);
  opacity: 0.5;
  filter: saturate(0.5);
}
.bulb.c1 { --bulb: #ff2b2b; }
.bulb.c2 { --bulb: #2bff5a; }
.bulb.c3 { --bulb: #2b8bff; }
.bulb.c4 { --bulb: #ffd92b; }
.bulb.c5 { --bulb: #ff5bf0; }

:root[data-theme="night"] .bulb::after {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 8px 3px var(--bulb), 0 0 16px 4px var(--bulb);
  animation: bulb-blink 1.6s steps(1, end) infinite;
}
:root[data-theme="night"] .bulb:nth-child(even)::after { animation-delay: 0.8s; }
:root[data-theme="night"] .lights.flicker .bulb::after { animation: bulb-flicker 0.9s steps(1, end) 1; }

@keyframes bulb-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; box-shadow: none; }
}
@keyframes bulb-flicker {
  0% { opacity: 0.2; } 15% { opacity: 1; } 30% { opacity: 0.1; } 45% { opacity: 1; }
  60% { opacity: 0.3; } 75% { opacity: 1; } 100% { opacity: 1; }
}

/* ---------- Snow, trail, sky layer ---------- */

.snow, .sky-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.snow { z-index: 45; } /* in front of the boxes, under the lights (50); never catches clicks */
.sky-layer { z-index: 60; }

.flake {
  position: absolute;
  top: -2em;
  color: var(--snow);
  text-shadow: var(--snow-shadow);
  font-family: var(--mono);
  font-weight: bold;
  animation: fall var(--dur, 12s) linear var(--delay, 0s) infinite;
  will-change: transform;
}
@keyframes fall {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(var(--drift, 20px), calc(100vh + 3em), 0); }
}

.trail-star {
  position: fixed;
  z-index: 65;
  pointer-events: none;
  font-size: 18px;
  line-height: 1;
  text-shadow: 1px 1px 0 #000;
  transform: translate(-50%, -50%);
  animation: trail 0.7s ease-out forwards;
}
@keyframes trail {
  to { opacity: 0; transform: translate(-50%, 20px) scale(0.4); }
}

/* ---------- Header ---------- */

.site-header { text-align: center; padding: 20px 12px 12px; }

.construction {
  margin: 0 0 8px;
  padding: 4px;
  background: repeating-linear-gradient(45deg, #ffd800 0 12px, #000 12px 24px);
}
.construction-inner {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 8px;
  padding: 3px 10px;
  font-size: 0.9rem;
  background: #ffd800;
  color: #000;
  font-weight: bold;
}
.construction-sub { font-weight: normal; font-size: 0.85rem; }

.rainbow {
  margin: 8px 0 12px;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  letter-spacing: 1px;
}
.rainbow-letters {
  display: inline-block;
  animation: rainbow-shift 3s linear infinite;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.rainbow-letters span:nth-child(7n + 1) { color: #ff3030; }
.rainbow-letters span:nth-child(7n + 2) { color: #ff9a1a; }
.rainbow-letters span:nth-child(7n + 3) { color: #ffe81a; }
.rainbow-letters span:nth-child(7n + 4) { color: #3dff3d; }
.rainbow-letters span:nth-child(7n + 5) { color: #31e5ff; }
.rainbow-letters span:nth-child(7n + 6) { color: #8fa8ff; }
.rainbow-letters span:nth-child(7n + 7) { color: #ff7aff; }
@keyframes rainbow-shift {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

.ticker {
  --frame: var(--box-frame);
  min-width: 0;
  overflow: hidden;
  margin: var(--px);
  background: #000;
  color: #ffff3b;
  font-family: var(--mono);
  font-weight: bold;
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--frame), 0 var(--px) 0 0 var(--frame),
    calc(var(--px) * -1) 0 0 0 var(--frame), var(--px) 0 0 0 var(--frame);
}
.ticker-track {
  margin: 0;
  padding: 6px 0;
  white-space: nowrap;
}
.ticker-track span {
  display: inline-block;
  padding-left: 100%;
  animation: ticker 32s linear infinite;
}
.ticker:hover .ticker-track span,
.ticker:focus-within .ticker-track span { animation-play-state: paused; }
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.blink-new {
  color: var(--new);
  font-weight: bold;
  animation: blink 1s steps(1, end) infinite;
}
.pixel-box .blink-new { color: var(--err); }
@keyframes blink {
  50% { visibility: hidden; }
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 8px;
}

.santa-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.santa-btn {
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
}
.speech {
  --frame: #000;
  order: -1;
  position: relative;
  max-width: min(260px, 70vw);
  margin: var(--px) var(--px) 16px;
  padding: 8px 12px;
  background: #fff;
  color: #000;
  font-weight: bold;
  box-shadow: 0 calc(var(--px) * -1) 0 0 #000, 0 var(--px) 0 0 #000,
    calc(var(--px) * -1) 0 0 0 #000, var(--px) 0 0 0 #000;
}
.speech:empty { visibility: hidden; padding: 0; box-shadow: none; margin: 0; }
.speech::after { /* pixel tail */
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--px) * -4);
  width: calc(var(--px) * 3);
  height: calc(var(--px) * 3);
  background:
    linear-gradient(#000, #000) 0 0 / var(--px) 100% no-repeat,
    linear-gradient(#000, #000) 100% 0 / var(--px) calc(var(--px) * 2) no-repeat,
    linear-gradient(#000, #000) var(--px) 100% / var(--px) var(--px) no-repeat,
    linear-gradient(#fff, #fff) var(--px) 0 / var(--px) calc(var(--px) * 2) no-repeat;
  transform: translateX(-50%);
}
.speech:empty::after { display: none; }
.santa-hint { margin: 4px 0 0; font-weight: bold; }

.switch-label { font-weight: bold; }

/* Chunky pixel toggle switch */
.switch8 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 6px;
  background: none;
  border: 0;
  cursor: pointer;
  font-weight: bold;
}
.switch-track {
  position: relative;
  width: 68px;
  height: 32px;
  margin: var(--px);
  background: #3a3a4a;
}
.switch-knob {
  --frame: #000;
  position: absolute;
  top: var(--px);
  left: var(--px);
  width: 24px;
  height: 24px;
  background: #e8e8e8;
  border-bottom: var(--px) solid #8a8a8a;
  transition: left 0.12s steps(3, end);
}
.switch8[aria-checked="true"] .switch-track { background: var(--gold); }
.switch8[aria-checked="true"] .switch-knob { left: 40px; }
.switch-text { min-width: 2.6em; font-family: var(--mono); font-size: 1.1rem; }

.led-counter {
  font-family: var(--mono);
  font-weight: bold;
  font-size: 1.2rem;
  letter-spacing: 2px;
  padding: 2px 6px;
  background: var(--led-bg);
  color: var(--led);
  border: var(--px) solid #000;
}
.counter-note { font-size: 0.8rem; flex-basis: 100%; }
.counter-note:empty { display: none; }

/* ---------- Countdown ---------- */

.led-panel {
  background: var(--led-bg);
  border: var(--px) solid #000;
  padding: 12px 6px;
  text-align: center;
}
.led-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
}
.led-cell { display: flex; flex-direction: column; align-items: center; }
.led, .led-sep {
  font-family: var(--mono);
  font-weight: bold;
  color: var(--led);
  text-shadow: 0 0 6px rgba(255, 40, 40, 0.8);
  font-size: clamp(1.7rem, 9vw, 2.6rem);
  line-height: 1;
}
.led-unit { margin-top: 4px; font-size: 0.75rem; color: #ffb3b3; letter-spacing: 1px; }
.merry { margin: 0; }

/* ---------- Tracker ---------- */

.tracker-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 0;
}
.source-tag {
  font-size: 0.85rem;
  padding: 2px 8px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
}
#tracker[data-demo="on"] .source-tag { background: var(--gold); font-weight: bold; }

.tracker-buttons { margin-bottom: 12px; }
.tracker-panel { margin-bottom: 16px; }

/* CRT radar (before takeoff) */
#radar-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: var(--crt-bg);
  color: var(--crt);
  border: var(--px) solid #000;
  font-family: var(--mono);
}

.radar {
  position: relative;
  width: min(240px, 70vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--crt);
  background:
    linear-gradient(transparent calc(50% - 1px), rgba(57, 255, 20, 0.5) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(57, 255, 20, 0.5) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    repeating-radial-gradient(circle, transparent 0 18%, rgba(57, 255, 20, 0.45) 18% calc(18% + 2px)),
    #002200;
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.35);
}
.radar-sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, rgba(57, 255, 20, 0.55), rgba(57, 255, 20, 0) 70deg, transparent 360deg);
  animation: sweep 4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.radar-blip {
  position: absolute;
  left: 58%;
  top: 24%;
  line-height: 0;
  filter: drop-shadow(0 0 4px var(--crt));
  animation: blink 1.2s steps(1, end) infinite;
}
.radar-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, 0.35) 2px 4px);
}
.crt-text { text-align: center; text-shadow: 0 0 6px rgba(57, 255, 20, 0.7); }
.crt-text p { margin: 4px 0; }
.crt-big { font-size: 1.4rem; font-weight: bold; letter-spacing: 2px; margin: 4px 0; }
.crt-led { font-weight: bold; }
.crt-small { font-size: 0.85rem; }

/* Live map */
.map-frame {
  background: #000;
  border: var(--px) solid #000;
  line-height: 0;
}
.world-map { display: block; width: 100%; height: auto; }
.map-sea { fill: #0a2a6a; }
.map-land rect { fill: #2f9a3e; stroke: #1a5a22; stroke-width: 0.5; }
.map-grid line { stroke: rgba(255, 255, 255, 0.22); stroke-width: 0.5; }
.map-route { fill: none; stroke: #ffde00; stroke-width: 1.2; stroke-dasharray: 4 3; }
.map-cities rect { fill: #fff; stroke: #000; stroke-width: 0.6; }
.map-link { stroke: #ff5050; stroke-width: 1.4; stroke-dasharray: 1 2.5; stroke-linecap: round; }

.tracker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.tracker-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--inset-bg);
  color: var(--inset-fg);
  font-size: 0.95rem;
  border: var(--px) solid var(--box-frame);
}
.tracker-table th, .tracker-table td {
  border: 2px solid var(--inset-line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.tracker-table th { width: 40%; }
.route-box h3 { margin: 0 0 6px; font-size: 1rem; }
.route {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) solid var(--box-frame);
  font-family: var(--mono);
  font-size: 0.9rem;
  columns: 2;
}
.route li { break-inside: avoid; }
.route-delivered { color: var(--done); }
.route-next-stop { font-weight: bold; background: var(--gold); color: #000; }

.complete {
  text-align: center;
  padding: 16px;
  background: var(--crt-bg);
  color: var(--crt);
  font-family: var(--mono);
  border: var(--px) solid #000;
}
.complete .btn8 { font-family: var(--font); }

/* Find me */
.findme {
  margin: 0;
  border: var(--px) dashed var(--box-frame);
  padding: 8px 12px 12px;
}
.findme legend { font-weight: bold; padding: 0 6px; color: var(--box-title); }
.findme-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.findme-row .field8 { width: auto; flex: 1 1 160px; }
.findme-status:empty { display: none; }
.findme-result {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 8px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: 2px solid var(--inset-line);
}
.findme-result div { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.findme-result dt { font-weight: bold; }
.findme-result dt::after { content: ":"; }
.findme-result dd { margin: 0; }

/* ---------- Navigation & list ---------- */

.navbar-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  padding: 18px 12px 10px 44px;
}
.navbar-title {
  margin: 0;
  font-size: 1rem;
  color: var(--box-title);
  white-space: nowrap;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 4px;
}
a.btn8, a.btn8:visited { color: var(--btn-fg); text-decoration: none; }
.btn8 .blink-new, .pixel-box .btn8 .blink-new { color: #8c0000; }
.nav-list .btn8 { min-height: 40px; padding: 4px 12px; gap: 6px; font-size: 0.95rem; }

.list-form label { display: block; font-weight: bold; margin-bottom: 4px; }
.list-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.list-row .field8 { flex: 1 1 160px; width: auto; margin-top: var(--px); }
.list-result {
  min-height: 1.5em;
  font-size: 1.15rem;
  font-weight: bold;
}
.list-result[data-verdict="nice"] { color: var(--ok); }
.list-result[data-verdict="naughty"] { color: var(--err); }
.verdict-face { font-family: var(--mono); font-size: 1.6rem; margin-right: 8px; }

/* ---------- Recipes ---------- */

.recipes { display: grid; gap: 16px; }
.recipe-card {
  --frame: #000;
  margin: var(--px);
  background-color: #fffdf0;
  background-image:
    linear-gradient(90deg, transparent 28px, #e88 28px 30px, transparent 30px),
    repeating-linear-gradient(transparent 0 23px, #a9c4ec 23px 24px);
  color: #10123a;
  box-shadow: 0 calc(var(--px) * -1) 0 0 #000, 0 var(--px) 0 0 #000,
    calc(var(--px) * -1) 0 0 0 #000, var(--px) 0 0 0 #000;
  padding: 8px 12px 8px 40px;
  line-height: 24px;
}
.recipe-card summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 1.1rem;
  color: #8a0000;
  list-style: none;
  min-height: 32px;
}
.recipe-card summary::-webkit-details-marker { display: none; }
.recipe-card summary::before { content: "[+] "; font-family: var(--mono); color: #000; }
.recipe-card[open] summary::before { content: "[-] "; }
.recipe-card h3 { font-size: 0.95rem; margin: 8px 0 2px; text-decoration: underline; }
.recipe-card ul, .recipe-card ol { margin: 0; padding-left: 20px; }
.recipe-meta { font-size: 0.85rem; margin: 2px 0; font-style: italic; }

/* ---------- Guestbook ---------- */

.gb-offline {
  margin-top: 0;
  padding: 8px;
  background: var(--gold);
  color: #000;
  border: var(--px) solid #000;
  font-weight: bold;
}
.gb-form { display: grid; gap: 10px; }
.gb-signed {
  margin: 0;
  padding: 10px 12px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) dashed var(--box-frame);
  font-weight: bold;
}
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: end; }
.field-row label { font-weight: bold; }
.field-row .field8 { grid-column: 1 / -1; }
.char-count { grid-column: 2; grid-row: 1; font-family: var(--mono); font-size: 0.8rem; }
.req { font-weight: normal; font-size: 0.85rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.gb-form .btn8 { justify-self: start; }
.gb-status { font-weight: bold; }
.gb-status:empty { display: none; }
.gb-status[data-kind="error"] { color: var(--err); }
.gb-status[data-kind="ok"] { color: var(--ok); }
.gb-feed-title { font-size: 1rem; margin: 0 0 8px; }
.gb-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) solid var(--box-frame);
}
.gb-entry {
  padding: 8px;
  border-bottom: 2px dashed var(--inset-line);
  overflow-wrap: anywhere;
}
.gb-entry:last-child { border-bottom: 0; }
.gb-place, .gb-time { color: var(--muted); }
.gb-time { display: block; font-size: 0.75rem; }

/* ---------- Footer: one panel, two columns, badge strip ---------- */

.site-footer {
  margin: 32px var(--px) var(--px);
  padding: 24px 16px 16px;
  text-align: center;
}
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.footer-col {
  min-width: 0;
  padding: 12px;
  border: var(--px) dashed var(--box-frame);
}
.footer-col p { margin: 0; }
.footer-side {
  display: grid;
  align-content: center;
  gap: 16px;
}
.counter-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-weight: bold;
}
.webring { display: grid; gap: 8px; }
.webring-btns { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }
.webring-btns .btn8 { min-height: 40px; padding: 4px 8px; font-size: 0.85rem; }
.webring-msg:empty { display: none; }

/* 90s "88x31" web badges, drawn with CSS + text */
.badges {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 12px;
  padding: 16px 0 0;
  background: repeating-linear-gradient(90deg, var(--box-frame) 0 var(--px), transparent var(--px) calc(var(--px) * 2))
    left top / 100% var(--px) no-repeat;
}
.badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 108px;
  height: 40px;
  border: 2px solid #000;
  box-shadow: inset 2px 2px rgba(255, 255, 255, 0.45), inset -2px -2px rgba(0, 0, 0, 0.35);
  font-family: var(--mono);
  font-weight: bold;
  font-size: 0.85rem;
  line-height: 1.1;
  text-decoration: none;
}
.badge small { font-size: 0.65rem; font-weight: normal; }
.badge-netscape { background: #0b2a8a; color: #fff; }
.badge-netscape small { color: #ffde00; }
.badge-notepad { background: #fff; color: #000; }
.badge-y2k { background: #0f6a20; color: #fff; }
a.badge-top, a.badge-top:visited { background: var(--gold); color: #000; }
.copyright { margin: 0; font-size: 0.8rem; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--box-bg);
  color: var(--box-fg);
  font-family: var(--mono);
  font-weight: bold;
  white-space: nowrap;
}

/* ---------- Advent calendar ---------- */

.advent-note { margin-top: 0; font-weight: bold; }
.advent-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 8px var(--px) 16px;
}
.door {
  --frame: #000;
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  margin: var(--px);
  padding: 0;
  border: 0;
  color: #fff;
  font-family: var(--mono);
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 calc(var(--px) * -1) 0 0 #000, 0 var(--px) 0 0 #000,
    calc(var(--px) * -1) 0 0 0 #000, var(--px) 0 0 0 #000;
}
.door-red { background: #b00000; }
.door-green { background: #0f6a20; }
.door::after { /* little gold knob = "this door can open" */
  content: "";
  position: absolute;
  right: 5px;
  top: 50%;
  width: 4px;
  height: 4px;
  background: var(--gold);
}
.door-locked {
  color: #e8e8e8;
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.35) 0 4px, transparent 4px 8px);
  cursor: not-allowed;
}
.door-locked::after { display: none; }
.door-opened {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--inset-bg);
  color: var(--inset-fg);
}
.door-opened::after { display: none; }
.door-num { font-size: 0.7rem; }
.door-icon { font-size: 1rem; color: var(--box-title); }
.advent-reveal:empty { display: none; }
.advent-reveal {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) dashed var(--box-frame);
  text-align: center;
}
.advent-reveal p { margin: 4px 0; }
.advent-reveal-title { font-weight: bold; color: var(--box-title); }
.advent-art { display: inline-block; line-height: 0; margin: 4px 0; }
.advent-art .sprite { width: auto; max-height: 72px; }

/* ---------- Decorate the tree ---------- */

.deco-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 6px 8px 10px;
  border: var(--px) dashed var(--box-frame);
}
.deco-tools legend { font-weight: bold; padding: 0 6px; color: var(--box-title); }
.deco-tools label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 10px;
  background: var(--inset-bg);
  color: var(--inset-fg);
  border: var(--px) solid var(--inset-line);
  cursor: pointer;
  font-size: 0.9rem;
}
.deco-tools input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.deco-tools label:has(input:checked) {
  background: var(--gold);
  color: #000;
  border-color: #000;
  font-weight: bold;
  text-decoration: underline;
}
.deco-tools label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--focus-halo);
}
.tool-icon { display: inline-flex; line-height: 0; }
.tool-icon svg { width: 16px; height: auto; }
.tool-icon-text { line-height: 1; font-family: var(--mono); font-weight: bold; }
.deco-stage {
  max-width: 300px;
  margin: 8px auto;
  padding: 8px;
  background: var(--inset-bg);
  border: var(--px) solid var(--box-frame);
  cursor: crosshair;
}
.deco-tree { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.deco-cursor { stroke: #ffde00; stroke-width: 1; stroke-dasharray: 2 1; visibility: hidden; }
.deco-stage:focus-visible .deco-cursor { visibility: visible; }
:root[data-theme="night"] .deco-star { animation: blink 1.4s steps(1, end) infinite; }
.deco-count { text-align: center; font-weight: bold; margin: 4px 0 8px; }
#deco-clear { display: flex; margin: 0 auto 4px; }

/* ---------- Jukebox ---------- */

.player {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
}
.player p { margin: 0; }
.player-title { font-weight: bold; color: var(--box-title); }
.player-display {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 10px;
  background: #000;
  color: #39ff14;
  font-family: var(--mono);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq span { width: 3px; height: 3px; background: #39ff14; }
.is-playing:not(.no-eq) .eq span { animation: eq 0.6s steps(4, end) infinite alternate; }
.eq span:nth-child(2) { animation-delay: -0.2s !important; }
.eq span:nth-child(3) { animation-delay: -0.4s !important; }
.eq span:nth-child(4) { animation-delay: -0.1s !important; }
.eq span:nth-child(5) { animation-delay: -0.3s !important; }
@keyframes eq { from { height: 3px; } to { height: 14px; } }
#player-track { white-space: nowrap; }
#player-track::before { content: "\266A  "; }
#player-track::after { content: "  \266A"; }
@media (max-width: 420px) {
  #player-track::before, #player-track::after { content: none; }
  .footer-col { padding: 10px 8px; }
  .player-display { padding: 6px 8px; font-size: 0.8rem; }
}
.player-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.player-controls .btn8 { min-width: 56px; font-family: var(--mono); }
.player-volume-row { display: flex; align-items: center; gap: 8px; }
.player-volume { font-weight: bold; font-size: 0.9rem; }
#player-volume { width: min(160px, 50vw); accent-color: var(--gold); min-height: 24px; }
.player-note { font-size: 0.8rem; }

/* ---------- 404: Elf Not Found ---------- */

.nf-main { max-width: 640px; margin: 24px auto 0; }
.nf-box { padding: 28px 20px 20px; text-align: center; }
.nf-box .rainbow { margin-top: 0; }
.nf-lead { font-size: 1.15rem; font-weight: bold; }
.nf-stage {
  position: relative;
  max-width: 420px;
  margin: 8px auto 16px;
  padding: 24px 8px 8px;
  background: var(--inset-bg);
  border: var(--px) solid var(--box-frame);
}
.nf-scene { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.nf-lcd { font-family: var(--mono); font-size: 2.6px; font-weight: bold; fill: #39ff14; }

/* idle: Elf Jingle bobs, hands take turns pressing, the 3 working keys flash */
.nf-elf, .nf-hand { transform-box: fill-box; }
.nf-elf { animation: nf-bob 0.8s steps(1, end) infinite; }
.nf-hand-l { animation: nf-press 0.8s steps(1, end) infinite; }
.nf-hand-r { animation: nf-press 0.8s steps(1, end) -0.4s infinite; }
.nf-working { animation: nf-key 1.2s steps(1, end) infinite; }
.nf-key-A { animation-delay: -0.8s; }
.nf-key-B { animation-delay: -0.4s; }
@keyframes nf-bob { 50% { transform: translateY(-1px); } }
@keyframes nf-press { 50% { transform: translateY(1px); } }
@keyframes nf-key { 0%, 30% { fill: #ffde00; } 31%, 100% { fill: #ffffff; } }

/* during the solo, JavaScript drives the keys and hands instead */
.nf-stage.solo .nf-working,
.nf-stage.solo .nf-hand,
.nf-stage.solo .nf-elf { animation: none; }
.nf-stage.solo .nf-working.lit { fill: #ffde00; }
.nf-stage.solo .nf-tape.lit { fill: #ff4040; }
.nf-stage[data-hand="l"] .nf-hand-l,
.nf-stage[data-hand="r"] .nf-hand-r { transform: translateY(1px); }

.nf-notes span {
  position: absolute;
  bottom: 55%;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--box-title);
  opacity: 0;
  animation: nf-note 2.4s linear infinite;
}
.nf-notes span:nth-child(1) { left: 22%; }
.nf-notes span:nth-child(2) { left: 34%; animation-delay: 0.6s; }
.nf-notes span:nth-child(3) { left: 46%; animation-delay: 1.2s; }
.nf-notes span:nth-child(4) { left: 28%; animation-delay: 1.8s; }
.nf-stage.solo .nf-notes span { animation-duration: 1.2s; }
@keyframes nf-note {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(10px, -60px); }
}
.nf-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; margin: 12px 0 4px; }
.nf-status { min-height: 1.5em; font-weight: bold; color: var(--box-title); }

/* ---------- Simulated date banner (localhost testing only) ---------- */

.sim-banner {
  position: fixed;
  z-index: 75;
  left: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  max-width: calc(100% - 16px);
  margin: 0;
  padding: 4px 8px;
  background: #ff00ff;
  color: #000;
  border: 3px solid #000;
  font-family: var(--mono);
  font-weight: bold;
  font-size: 0.8rem;
  pointer-events: none;
}

/* ---------- Dial-up loader (the one Win95 window) ---------- */

.win95 {
  background: var(--panel);
  color: #000;
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  box-shadow: inset 1px 1px var(--bevel-mid), inset -1px -1px var(--bevel-shade);
  padding: 3px;
  --focus: #000;
  --focus-halo: #ffde00;
}
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff;
  padding: 4px 8px;
  font-weight: bold;
}
.titlebar-btns { font-family: var(--mono); font-size: 0.85rem; letter-spacing: 2px; }
.win95-body { padding: 12px; }
.btn95 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 14px;
  background: var(--panel);
  color: #000;
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  box-shadow: inset 1px 1px var(--bevel-mid), inset -1px -1px var(--bevel-shade);
  cursor: pointer;
}
.btn95:active {
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
  box-shadow: inset 1px 1px var(--bevel-shade);
}

.dialup {
  width: min(92vw, 440px);
  padding: 3px;
  margin: auto;
}
.dialup::backdrop { background: #008080; }
.dialup-modem { font-family: var(--mono); text-align: center; overflow-wrap: anywhere; }
.progress {
  height: 26px;
  padding: 2px;
  background: #fff;
  border: 2px solid;
  border-color: var(--bevel-shade) var(--bevel-light) var(--bevel-light) var(--bevel-shade);
}
.progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--title-a) 0 12px, transparent 12px 15px);
}
.dialup-status { min-height: 3em; font-weight: bold; }
.dialup-hint { font-size: 0.85rem; }

/* ---------- Reduced motion: stop every animation ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .snow, .trail-star, .sky-layer { display: none !important; }
  .ticker-track { white-space: normal; }
  .ticker-track span { padding-left: 8px; }
}
