/* ==========================================================================
   Jack's Inventions
   One stylesheet for the whole site. Change colors and sizes in :root.
   ========================================================================== */

:root {
  --bg: #0d0b22;
  --panel: #1b1747;
  --panel-2: #241f5c;
  --ink: #f4f1ff;
  --muted: #b3aedf;
  --yellow: #ffd23f;
  --aqua: #3de8c8;
  --pink: #ff4f9a;
  --blue: #4d7cff;
  --shadow: #05040f;

  /* Colors that used to be written straight into rules. At night they are exactly what they were. */
  --on-accent: #1a1033;   /* text that sits on a yellow or aqua button */
  --panel-deep: #120f33;  /* the quiz panel */
  --code-bg: #070618;     /* code blocks */
  --scan: rgba(0, 0, 0, 0.13); /* the faint CRT lines */
  --good: #58d26b;        /* "correct" text */
  --bright: #ffffff;      /* the big quiz score */
  --sky-0: #0d0b22; --sky-1: #0d0b22; --sky-2: #0d0b22; --sky-3: #0d0b22; --sky-4: #0d0b22; /* the daytime sky, top to horizon */

  --px: 4px; /* the size of one "pixel" in borders and shadows */
  --nav-h: 3.5rem;
  --gutter: 1.25rem; /* page side margin */
  --img-max: 30rem; /* biggest width for images inside posts and covers. Lower it to make them smaller */
  --buddy-w: 96px; /* 4 screen pixels per sprite pixel, the same as the ridge */
  --ridge-room: 13rem; /* how much height the mountains get above the footer text */

  --font-pixel: "Press Start 2P", ui-monospace, "Courier New", monospace;
  --font-body: "Pixelify Sans", ui-monospace, "Courier New", monospace;
  --font-display: var(--font-pixel); /* logo and page titles */

  /* Text size dials. The font themes in static/themes/ change these. 1 = the original size. */
  --ui-scale: 1;               /* menu, buttons, labels, small headings */
  --display-scale: var(--ui-scale); /* logo and page titles */
  --body-scale: 1;             /* paragraphs */
}

@media (max-width: 559px) {
  :root { --buddy-w: 72px; --ridge-room: 9rem; }
}
@media (max-width: 520px) {
  :root { --gutter: 0.85rem; }
}

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

html {
  scroll-padding-top: calc(var(--nav-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg) url("/static/images/stars.svg") top left / 480px 480px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(1.2rem * var(--body-scale));
  line-height: 1.6;
  font-variant-ligatures: none; /* stops Pixelify Sans from turning "fi" into a lookalike of "A" */
  font-feature-settings: "liga" 0, "clig" 0;
}

/* The living sky (static/js/sky.js draws it behind everything). Until it loads, or if it is off,
   the plain star tile in the body rule above is what you see. */
#sky {
  position: fixed;
  left: 0;
  top: 0;
  z-index: -1;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
html.has-sky body { background-image: none; }

/* Faint CRT scanlines over everything. Delete this rule to remove them. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    var(--scan) 2px,
    var(--scan) 3px
  );
}

main { flex: 1; padding-bottom: 4rem; }

img { max-width: 100%; height: auto; }

a { color: var(--aqua); text-underline-offset: 0.2em; text-decoration-thickness: 3px; }
a:hover { color: var(--yellow); }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 400;
  padding: 0.8rem 1rem;
  background: var(--yellow);
  color: var(--on-accent);
  font-family: var(--font-pixel);
  font-size: calc(0.7rem * var(--ui-scale));
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(60rem, 100% - 2 * var(--gutter)); margin-inline: auto; }

/* --------------------------------------------------------------------------
   Pixel building blocks
   -------------------------------------------------------------------------- */

/* A panel with notched, stair-step corners. */
.pixel-box {
  --ring: var(--ink);
  background: var(--panel);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ring),
    0 var(--px) 0 0 var(--ring),
    calc(var(--px) * -1) 0 0 0 var(--ring),
    var(--px) 0 0 0 var(--ring);
}

.button,
.px-btn {
  --cut: 4px;
  display: inline-block;
  padding: 0.95em 1.2em;
  border: 0;
  background: var(--yellow);
  color: var(--on-accent);
  font-family: var(--font-pixel);
  font-size: calc(0.7rem * var(--ui-scale));
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    inset calc(var(--cut) * -1) calc(var(--cut) * -1) 0 0 rgba(0, 0, 0, 0.3),
    inset var(--cut) var(--cut) 0 0 rgba(255, 255, 255, 0.4);
  clip-path: polygon(
    0 var(--cut), var(--cut) var(--cut), var(--cut) 0,
    calc(100% - var(--cut)) 0, calc(100% - var(--cut)) var(--cut), 100% var(--cut),
    100% calc(100% - var(--cut)), calc(100% - var(--cut)) calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%, var(--cut) calc(100% - var(--cut)),
    0 calc(100% - var(--cut))
  );
}
.button:hover,
.px-btn:hover { background: var(--aqua); color: var(--on-accent); }
.button:active,
.px-btn:active {
  box-shadow:
    inset var(--cut) var(--cut) 0 0 rgba(0, 0, 0, 0.3),
    inset calc(var(--cut) * -1) calc(var(--cut) * -1) 0 0 rgba(255, 255, 255, 0.25);
  padding-top: calc(0.95em + 2px);
  padding-bottom: calc(0.95em - 2px);
}
.px-btn-small { padding: 0.75em 0.8em; font-size: calc(0.6rem * var(--ui-scale)); min-width: 2.6rem; }
.px-btn-ghost { background: var(--panel-2); color: var(--ink); }
.px-btn[aria-pressed="false"] { background: var(--panel-2); color: var(--muted); }

h1, h2, h3, h4 { font-family: var(--font-pixel); font-weight: 400; line-height: 1.45; margin: 0 0 1rem; }
h1 { font-family: var(--font-display); font-size: calc(clamp(1.15rem, 4.6vw, 2rem) * var(--display-scale)); color: var(--yellow); text-shadow: 3px 3px 0 var(--shadow); }
h2 { font-size: calc(clamp(0.9rem, 2.6vw, 1.15rem) * var(--ui-scale)); }
h3 { font-size: calc(0.9rem * var(--ui-scale)); color: var(--aqua); }

.lede { max-width: 38rem; color: var(--muted); font-size: calc(1.3rem * var(--body-scale)); }
.empty { color: var(--muted); }

/* --------------------------------------------------------------------------
   Header and nav
   -------------------------------------------------------------------------- */

.site-nav {
  /* Both sizes scale smoothly with the screen width. Change the three numbers in each
     clamp() to make them bigger or smaller: clamp(smallest, grows-with-screen, largest) */
  --logo-fs: clamp(8px, 0.6vw + 5.5px, 13px);
  --menu-fs: clamp(8px, 0.45vw + 5.8px, 11px);
  --logo-img-h: clamp(26px, 2.2vw + 12px, 42px); /* height of your own logo image */

  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel);
  border-bottom: var(--px) solid var(--ink);
  box-shadow: 0 var(--px) 0 0 var(--shadow);
}

/* One row at every size: logo on the left, menu on the right. */
.nav-inner {
  width: min(60rem, 100% - 2 * var(--gutter));
  min-height: var(--nav-h);
  margin-inline: auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.5rem, 2vw, 1.5rem);
  padding-block: 0.5rem;
}

.logo {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.7em;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: calc(var(--logo-fs) * var(--display-scale));
  line-height: 1.35;
}
/* Your own logo image (static/images/logo.png). It shrinks to fit if the menu needs the room. */
.logo:has(.logo-img) { flex: 0 1 auto; min-width: 0; }
.logo picture { display: flex; min-width: 0; }
.logo-img {
  display: block;
  height: var(--logo-img-h);
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.nav-inner > nav { flex: none; }

.logo-head { display: inline-flex; }
.logo-head svg { display: block; width: 28px; height: auto; } /* 2x: stays crisp */
.logo:hover .logo-head svg { animation: head-bob 0.5s steps(2) infinite; }
@keyframes head-bob { 50% { transform: translateY(-3px); } }
.logo-a, .logo-b { text-shadow: 0.18em 0.18em 0 var(--shadow); }
.logo-a { color: var(--yellow); }
.logo-b { color: var(--aqua); }
.logo:hover .logo-a, .logo:hover .logo-b { color: var(--pink); }

.nav-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: calc(var(--menu-fs) * var(--ui-scale));
}
.nav-list a {
  display: block;
  padding: 1em 0.45em;
  font-family: var(--font-pixel);
  font-size: 1em;
  line-height: 1;
  color: var(--ink);
  background: var(--panel-2);
  text-decoration: none;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
}
.nav-list a:hover { background: var(--blue); color: #fff; }
.nav-list a[aria-current="page"] { background: var(--yellow); color: var(--on-accent); }

/* Phones: the name stacks on two lines so everything fits on one row. */
@media (max-width: 639px) {
  .logo-text { display: flex; flex-direction: column; }
}
@media (max-width: 389px) {
  .logo-head svg { width: 14px; } /* 1x */
  .nav-list { gap: 0.3em; }
  .nav-list a { padding: 1em 0.32em; }
}
@media (max-width: 349px) {
  :root { --gutter: 0.6rem; }
  .logo-head { display: none; }
}
@media (max-width: 329px) {
  .nav-list { gap: 0.2em; }
  .nav-list a { padding: 1em 0.2em; }
}

@media (min-width: 640px) {
  .nav-list a { padding: 0.85em 0.95em; }
}

/* --------------------------------------------------------------------------
   Home: globe
   -------------------------------------------------------------------------- */

.home-top { padding-top: 2.5rem; }
.home-hero h1 { margin-bottom: 1.2rem; }
.globe-section { padding-top: 1.5rem; }

@media (min-width: 62rem) {
  .home-top {
    display: grid;
    grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
    gap: 3rem;
    align-items: center;
    min-height: calc(100svh - var(--nav-h));
    padding-block: 2rem;
  }
  .home-top .globe-section { padding-top: 0; }
  .home-top h1 { font-size: calc(1.2rem * var(--display-scale)); }
  .home-top .globe-stage { width: min(100%, 40rem, 80svh); margin-inline: 0 auto; }
}

.globe-stage {
  --ring: var(--aqua);
  position: relative;
  width: min(100%, 44rem, 78svh);
  aspect-ratio: 1;
  margin-inline: auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #070618;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.globe-stage.is-dragging { cursor: grabbing; }

#globe-frame { position: relative; }
#globe-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#globe-pins { position: absolute; inset: 0; pointer-events: none; }

.globe-hud {
  position: absolute;
  left: 0.8rem;
  top: 0.8rem;
  font-family: var(--font-pixel);
  font-size: calc(0.5rem * var(--ui-scale));
  line-height: 1.6;
  color: var(--aqua);
  text-shadow: 2px 2px 0 #000;
  white-space: pre;
  padding: 0.5rem 0.6rem;
  background: rgba(7, 6, 24, 0.8);
  pointer-events: none;
}

.globe-ui {
  position: absolute;
  right: 0.8rem;
  top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.globe-note { margin: 1.4rem auto 0; max-width: 40rem; text-align: center; color: var(--muted); }
code { padding: 0.1em 0.4em; background: var(--panel-2); color: var(--yellow); font-size: 0.9em; }

/* Pins */
.pin {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 38px;
  margin: -38px 0 0 -14px; /* the pin's tip sits exactly on the map point */
  padding: 0;
  border: 0;
  background: none;
  color: var(--pink);
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
}
.pin[hidden] { display: none; }
.pin::before { content: ""; position: absolute; inset: -8px -10px -2px; } /* bigger tap target */
.pin-icon { position: absolute; left: 0; top: 0; display: block; animation: pin-bob 0.9s steps(2) infinite; }
.pin-icon svg { display: block; }
.pin.is-selected { color: var(--yellow); z-index: 3; }
.pin:hover, .pin:focus-visible { color: var(--aqua); z-index: 4; }
.pin:focus-visible { outline: none; }
.pin-label {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: none;
  white-space: nowrap;
  padding: 0.5em 0.7em;
  background: #000;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: calc(0.5rem * var(--ui-scale));
  line-height: 1;
}
.pin:hover .pin-label, .pin:focus-visible .pin-label, .pin.is-selected .pin-label { display: block; }

@keyframes pin-bob { 50% { transform: translateY(-4px); } }

/* RPG-style text box */
.globe-card {
  --ring: var(--yellow);
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.9rem;
  padding: 1rem 1.1rem 1.1rem;
  background: #120f33;
  z-index: 5;
  cursor: default;
}
.globe-card[hidden] { display: none; }
.card-title { margin: 0 0 0.5rem; font-size: calc(0.8rem * var(--ui-scale)); color: var(--yellow); }
.card-meta { margin: 0 0 0.5rem; font-family: var(--font-pixel); font-size: calc(0.5rem * var(--ui-scale)); color: var(--aqua); line-height: 1.6; }
.card-text { margin: 0 0 0.9rem; font-size: calc(1.05rem * var(--body-scale)); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-text:empty { display: none; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

@media (max-width: 520px) {
  .globe-card { padding: 0.8rem; }
  .card-text { font-size: calc(0.95rem * var(--body-scale)); -webkit-line-clamp: 2; }
  .card-actions .button, .card-actions .px-btn { font-size: calc(0.55rem * var(--ui-scale)); padding: 0.8em 0.9em; }
}

/* --------------------------------------------------------------------------
   Cards and lists
   -------------------------------------------------------------------------- */

.latest { padding-top: 3rem; }
.section-title { margin-bottom: 1.6rem; color: var(--yellow); }

.list-page { padding-top: 2.5rem; }

.entries { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: 1.6rem; }

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1.2rem;
  padding: 1.4rem 1.4rem 1.5rem;
}
.entry[hidden] { display: none; }
.entry:hover { --ring: var(--yellow); }

.entry-side { display: flex; flex-direction: column; gap: 0.8rem; }
.entry-cover { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 3px solid var(--panel-2); }
.entry-date { padding-top: 0.2rem; font-family: var(--font-pixel); font-size: calc(0.55rem * var(--ui-scale)); line-height: 1.6; color: var(--aqua); }
.entry-title { margin: 0; font-size: calc(clamp(0.85rem, 2.4vw, 1.05rem) * var(--ui-scale)); line-height: 1.5; }
.entry-title a { color: var(--ink); text-decoration: none; }
.entry-title a::after { content: ""; position: absolute; inset: 0; } /* makes the whole card clickable */
.entry:hover .entry-title a { color: var(--yellow); }
.entry:has(a:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 6px; }
.entry-place { margin: 0.6rem 0 0; color: var(--pink); }
.entry-summary { margin: 0.7rem 0 0; color: var(--muted); max-width: 38rem; }

.entry-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.entry-tags li {
  padding: 0.25em 0.7em;
  background: var(--panel-2);
  color: var(--aqua);
  font-size: calc(0.95rem * var(--body-scale));
  box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.3);
}

.more { margin-top: 2rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2rem; }
.chip {
  padding: 0.7em 0.9em;
  border: 0;
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: calc(0.55rem * var(--ui-scale));
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
}
.chip:hover { background: var(--blue); }
.chip.is-active { background: var(--yellow); color: var(--on-accent); }

@media (max-width: 40rem) {
  .entry { grid-template-columns: 1fr; gap: 0.6rem; }
  .entry-cover { width: min(100%, 12rem); }
}

/* --------------------------------------------------------------------------
   Posts and About (long-form text)
   -------------------------------------------------------------------------- */

.prose-wrap { width: min(46rem, 100% - 2 * var(--gutter)); padding-top: 2.5rem; }
.back { margin: 0 0 1.5rem; font-family: var(--font-pixel); font-size: calc(0.6rem * var(--ui-scale)); }
.post-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 0 0 1.5rem; font-family: var(--font-pixel); font-size: calc(0.55rem * var(--ui-scale)); line-height: 1.7; color: var(--aqua); }
.post-place { color: var(--pink); }
.post-coords { color: var(--muted); }
.post-tags { margin-top: 2.5rem; }

.prose { font-size: calc(1.25rem * var(--body-scale)); line-height: 1.7; margin-top: 1.5rem; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: 2.6rem; color: var(--yellow); }
.prose h3 { margin-top: 2rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.3rem; }
.prose li::marker { color: var(--pink); }
.prose img {
  display: block;
  width: auto;
  max-width: min(100%, var(--img-max));
  height: auto;
  margin: 1.8rem auto;
  border: var(--px) solid var(--ink);
  background: var(--panel);
}

.post-cover {
  display: block;
  width: min(100%, var(--img-max));
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin: 0 0 1.6rem;
  border: var(--px) solid var(--ink);
  background: var(--panel);
}
.prose blockquote {
  margin: 1.8rem 0;
  padding: 0.6rem 1.2rem;
  border-left: calc(var(--px) * 2) solid var(--yellow);
  background: var(--panel);
  color: var(--muted);
}
.prose hr { border: 0; border-top: var(--px) dashed var(--panel-2); margin: 2.5rem 0; }
.prose pre {
  overflow-x: auto;
  padding: 1rem 1.2rem;
  background: var(--code-bg);
  border: var(--px) solid var(--panel-2);
  font-size: calc(1rem * var(--body-scale));
  line-height: 1.5;
}
.prose pre code { padding: 0; background: none; color: var(--ink); }
/* Collapsed sections: <details><summary>Title</summary> ... </details> */
.prose details {
  margin: 1.6rem 0;
  background: var(--panel);
  border: 3px solid var(--panel-2);
}
.prose summary {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-pixel);
  font-size: calc(0.7rem * var(--ui-scale));
  line-height: 1.5;
  color: var(--aqua);
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::before { content: "\25B6"; flex: none; color: var(--yellow); font-size: 0.85em; }
.prose details[open] > summary::before { content: "\25BC"; }
.prose details[open] > summary { border-bottom: 3px solid var(--panel-2); }
.prose summary:hover { color: var(--yellow); background: var(--panel-2); }
.prose summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }
.prose details > :not(summary) { margin-left: 1.1rem; margin-right: 1.1rem; }
.prose details > summary + * { margin-top: 1.1rem; }
.prose details > :last-child { margin-bottom: 1.1rem; }

.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: calc(1.05rem * var(--body-scale)); }
.prose th, .prose td { padding: 0.5rem 0.8rem; border: 3px solid var(--panel-2); text-align: left; }
.prose th { background: var(--panel); color: var(--yellow); font-family: var(--font-pixel); font-size: calc(0.6rem * var(--ui-scale)); }

.gameover { text-align: left; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer-toggles { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.site-footer { position: relative; margin-top: 2rem; background: var(--panel); border-top: var(--px) solid var(--ink); }

/* The ridgeline footer. ridge.js draws the mountains and adds .has-ridge. Stars show through above the ridge. */
#ridge { position: absolute; right: 0; bottom: 0; z-index: 0; pointer-events: none; image-rendering: pixelated; image-rendering: crisp-edges; }
.site-footer.has-ridge { background: none; border-top: 0; padding-top: var(--ridge-room); }
.footer-inner { position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.5rem; }
.footer-inner p { margin: 0; color: var(--muted); font-size: calc(1.05rem * var(--body-scale)); }

/* --------------------------------------------------------------------------
   Buddy (the little character) and easter eggs
   -------------------------------------------------------------------------- */

#buddy {
  position: absolute; /* inside the footer; ridge.js and site.js set left and bottom so he stands on the ledge */
  left: 0;
  bottom: 0;
  z-index: 3;
  width: var(--buddy-w);
  aspect-ratio: 24 / 28;
  pointer-events: none;
  will-change: transform;
}
#buddy[hidden] { display: none; }

.buddy-sprite {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
}
.buddy-sprite::after { /* ground shadow */
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -3px;
  height: 4px;
  background: rgba(0, 0, 0, 0.45);
}
.buddy-flip { width: 100%; height: 100%; }
.buddy-flip svg,
.buddy-flip img { display: none; width: 100%; height: 100%; image-rendering: pixelated; }
.buddy-flip img { display: block; }
#buddy[data-pose="idle"] .px-idle,
#buddy[data-pose="walk-a"] .px-walk-a,
#buddy[data-pose="walk-b"] .px-walk-b,
#buddy[data-pose="point"] .px-point { display: block; }
#buddy[data-pose="walk-b"] .buddy-sprite { transform: translateY(-4px); }
#buddy[data-pose="idle"] .buddy-sprite { animation: buddy-breathe 1.8s steps(1) infinite; }
@keyframes buddy-breathe { 50% { transform: translateY(-4px); } }
#buddy.jump .buddy-sprite { animation: buddy-jump 0.45s steps(6); }
@keyframes buddy-jump { 40% { transform: translateY(-28px); } 100% { transform: translateY(0); } }

.buddy-bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: max-content;
  max-width: min(15rem, 68vw);
  padding: 0.85rem 0.95rem;
  background: #fff;
  color: #1a1033;
  font-family: var(--font-pixel);
  font-size: calc(0.55rem * var(--ui-scale));
  line-height: 1.8;
  box-shadow:
    0 -4px 0 0 #1a1033, 0 4px 0 0 #1a1033, -4px 0 0 0 #1a1033, 4px 0 0 0 #1a1033;
}
.buddy-bubble[hidden] { display: none; }
.buddy-bubble::after { /* tail */
  content: "";
  position: absolute;
  left: 18px;
  bottom: -8px;
  width: 8px;
  height: 8px;
  background: #fff;
  box-shadow: 4px 0 0 0 #1a1033, -4px 0 0 0 #1a1033, 0 4px 0 0 #1a1033;
}
#buddy.buddy--right .buddy-bubble { left: auto; right: 0; }
#buddy.buddy--right .buddy-bubble::after { left: auto; right: 18px; }
/* Konami confetti */
.confetti {
  position: fixed;
  top: -20px;
  z-index: 250;
  width: 10px;
  height: 10px;
  pointer-events: none;
  animation: confetti-fall 2.6s steps(14) forwards;
}
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(180deg); } }

/* --------------------------------------------------------------------------
   About page and 404: the character, bigger
   -------------------------------------------------------------------------- */

.about { padding-top: 2.5rem; display: grid; gap: 2.5rem; }
.player-card { --ring: var(--yellow); width: 14rem; padding: 1.4rem 1rem 1.2rem; text-align: center; justify-self: center; }
.player-sprite svg, .gameover-sprite svg { display: block; margin-inline: auto; image-rendering: pixelated; }
.player-sprite svg { animation: idle-bob 1.2s steps(1) infinite; }
@keyframes idle-bob { 50% { transform: translateY(-4px); } }
.player-name { margin: 1rem 0 0.4rem; font-family: var(--font-pixel); font-size: calc(0.9rem * var(--ui-scale)); color: var(--yellow); }
.player-class { margin: 0; font-family: var(--font-pixel); font-size: calc(0.5rem * var(--ui-scale)); color: var(--aqua); }
.about-text h1 { margin-bottom: 0; }
.about-text .prose { margin-top: 1.2rem; }

@media (min-width: 52rem) {
  .about { grid-template-columns: 14rem minmax(0, 1fr); gap: 3.5rem; align-items: start; }
  .player-card { position: sticky; top: calc(var(--nav-h) + 1.5rem); }
}

.gameover-sprite { margin-bottom: 1.5rem; }

/* --------------------------------------------------------------------------
   World Quest (the quiz easter egg) plays out on the home page globe
   -------------------------------------------------------------------------- */

.quiz-panel[hidden] { display: none; }
.quiz-panel { --ring: var(--yellow); background: var(--panel-deep); padding: 1.2rem 1.2rem 1.3rem; margin-top: 1.6rem; }

/* While the quiz runs: the intro text makes room for the questions, and anything that gives answers away is hidden */
.quiz-mode .home-hero,
.quiz-mode .globe-hud,
.quiz-mode .globe-note,
.quiz-mode .latest { display: none; }
.quiz-on .pin { display: none !important; }
.quiz-mode .globe-stage { width: min(100%, 44rem, 54svh); }

@media (max-width: 61.99rem) {
  .quiz-mode .home-top { padding-top: 0.5rem; }
  .quiz-mode .globe-section { padding-top: 0; }
  .quiz-mode .globe-stage { width: min(100%, 44rem, 40svh); }
  .quiz-panel { margin-top: 0.9rem; padding: 1rem; }
}

@media (min-width: 62rem) {
  .quiz-mode .home-top { grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); gap: 2.5rem; align-items: start; padding-top: 1.5rem; }
  .quiz-panel { grid-column: 1; grid-row: 1; margin-top: 0; }
  .quiz-mode .home-top .globe-stage { width: min(100%, 40rem, 80svh); }
}

.qz-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin-bottom: 0.9rem; }
.qz-title { margin: 0; font-size: calc(0.85rem * var(--ui-scale)); color: var(--yellow); }
.qz-meta { order: 3; flex-basis: 100%; font-family: var(--font-pixel); font-size: calc(0.45rem * var(--ui-scale)); line-height: 1.7; color: var(--aqua); white-space: pre-wrap; }
.qz-quit { margin-left: auto; }
.px-btn[hidden], .button[hidden] { display: none; }

.qz-bar { display: flex; gap: 3px; margin-bottom: 1rem; }
.qz-pip { flex: 1; height: 8px; background: var(--panel-2); }
.qz-pip.is-now { background: var(--yellow); }
.qz-pip.is-right { background: #58d26b; }
.qz-pip.is-wrong { background: var(--pink); }

.qz-kind { display: flex; gap: 0.5rem; margin: 0 0 0.7rem; }
.qz-tag { padding: 0.35em 0.6em; background: var(--panel-2); color: var(--aqua); font-family: var(--font-pixel); font-size: calc(0.45rem * var(--ui-scale)); line-height: 1; }
.qz-tier-1 { color: var(--good); }
.qz-tier-2 { color: var(--yellow); }
.qz-tier-3 { color: var(--pink); }

.qz-q { margin: 0 0 1rem; font-size: calc(1.35rem * var(--body-scale)); line-height: 1.3; }
.qz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem; }

.qz-option {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  width: 100%;
  padding: 0.75rem 0.8rem;
  border: 0;
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(1.1rem * var(--body-scale));
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
}
.qz-option:hover:not(:disabled) { background: var(--blue); }
.qz-option:disabled { cursor: default; }
.qz-key { flex: none; font-family: var(--font-pixel); font-size: calc(0.5rem * var(--ui-scale)); color: var(--yellow); }
.qz-option.is-right { background: #1f8a45; color: #fff; }
.qz-option.is-wrong { background: #b3245f; color: #fff; }
.qz-option.is-dim { opacity: 0.4; }

.qz-feedback { min-height: 3rem; margin: 1rem 0 0; font-size: calc(1.05rem * var(--body-scale)); line-height: 1.4; color: var(--muted); }
.qz-good { color: var(--good); font-weight: 600; }
.qz-bad { color: var(--pink); font-weight: 600; }
.qz-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.9rem; }
.qz-loading { margin: 0; color: var(--muted); }

.qz-score { margin: 0.3rem 0 0.4rem; font-family: var(--font-pixel); font-size: calc(1.8rem * var(--ui-scale)); color: var(--bright); line-height: 1.2; }
.qz-rank { margin: 0 0 0.5rem; font-family: var(--font-pixel); font-size: calc(0.8rem * var(--ui-scale)); }
.qz-verdict { margin: 0 0 0.4rem; font-size: calc(1.15rem * var(--body-scale)); }
.qz-stats { margin: 0 0 0.9rem; font-family: var(--font-pixel); font-size: calc(0.45rem * var(--ui-scale)); line-height: 1.8; color: var(--aqua); }
.qz-share { flex: 0 0 10.5rem; width: 10.5rem; max-width: 100%; margin: 0; }
.qz-share-status { margin: 0.5rem 0 0; min-height: 1.4rem; color: var(--muted); font-size: calc(1rem * var(--body-scale)); }
.qz-card { display: block; width: 100%; image-rendering: pixelated; border: var(--px) solid var(--ink); background: #0d0b22; }
.qz-endrow { display: flex; flex-wrap: wrap; gap: 1rem 1.2rem; align-items: flex-start; margin-top: 0.4rem; }
.qz-endcol { flex: 1 1 10rem; min-width: 10rem; display: flex; flex-direction: column; gap: 1rem; }
.qz-share-buttons { display: flex; flex-direction: column; gap: 0.6rem; align-items: stretch; }
.qz-share-buttons .px-btn { text-align: center; }
.qz-share-buttons .qz-share-status { margin: 0; font-size: calc(0.95rem * var(--body-scale)); line-height: 1.3; }
.qz-actions-end { flex-direction: column; margin-top: 0; }
.qz-actions-end .px-btn { text-align: center; }

.qz-notice {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 400;
  width: min(92vw, 30rem);
  padding: 0.9rem 1.1rem;
  background: #fff;
  color: #1a1033;
  border: var(--px) solid #1a1033;
  font-size: calc(1.05rem * var(--body-scale));
  line-height: 1.4;
}

/* The target ring the quiz drops on the globe for "which city is this?" questions */
.target { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 2; }
.target[hidden] { display: none; }
.target::before { content: ""; position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; border: 4px solid #1a1033; outline: 4px solid var(--yellow); outline-offset: -8px; } /* a steady ring */
.target-dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; background: #fff; box-shadow: 0 0 0 4px #1a1033; }
.target-ring { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border: 4px solid var(--yellow); animation: target-pulse 1.3s steps(5) infinite; }
.target-ring2 { animation-delay: 0.65s; }
@keyframes target-pulse { 0% { transform: scale(0.35); opacity: 1; } 100% { transform: scale(1.7); opacity: 0; } }
.target-label {
  position: absolute;
  left: 0;
  bottom: 26px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0.5em 0.7em;
  background: #000;
  color: var(--yellow);
  font-family: var(--font-pixel);
  font-size: calc(0.5rem * var(--ui-scale));
  line-height: 1;
}
.target-label[hidden] { display: none; }

/* ==========================================================================
   Daytime: warm, with four seasons.
   theme.js sets data-theme="day" only when it is daytime AND the visitor has not asked for a dark theme.
   Everything above is the night site and is not touched by any of this.
   ========================================================================== */

html[data-theme="day"] {
  --bg: #fff1d6; --panel: #fff8ea; --panel-2: #ffe8c2; --ink: #3b2415; --muted: #66452f;
  --yellow: #a94a0a; --aqua: #085369; --pink: #b8235a; --blue: #2d5fd3; --shadow: #f0c58a;
  --on-accent: #fff8ea; --panel-deep: #fff6e0; --code-bg: #fff0d2; --scan: rgba(150, 90, 30, 0.05);
  --good: #1d7a3b; --bright: #3b2415;
}
/* The colors of each season. --yellow is the site's main accent. --sky-0 is the top of the sky and --sky-4 the horizon. */
html[data-theme="day"][data-season="spring"] {
  --bg: #fff0e6; --panel: #fff8f2; --panel-2: #ffe6dc; --muted: #704c33; --yellow: #b03a4d; --aqua: #255f43; --pink: #a8286e; --blue: #3a67c4; --shadow: #f3c2b8;
  --sky-0: #9bd0ea; --sky-1: #bfdde8; --sky-2: #efe0d4; --sky-3: #f9d3c6; --sky-4: #fbc9bd;
}
html[data-theme="day"][data-season="summer"] {
  --bg: #fff3d0; --panel: #fff9ea; --panel-2: #ffe9b8; --muted: #66452f; --yellow: #a94a0a; --aqua: #085369; --pink: #b8235a; --blue: #2d5fd3; --shadow: #f0c58a;
  --sky-0: #82c5ef; --sky-1: #a9d6ee; --sky-2: #f4e3ac; --sky-3: #ffd98a; --sky-4: #ffcf74;
}
html[data-theme="day"][data-season="autumn"] {
  --bg: #ffe9cf; --panel: #fff6e8; --panel-2: #fbdcb4; --muted: #543926; --yellow: #8f3c0c; --aqua: #394315; --pink: #a93b2f; --blue: #3b5fa0; --shadow: #ebb98a;
  --sky-0: #a4c5dc; --sky-1: #d3ccc2; --sky-2: #f0c89c; --sky-3: #ebb07c; --sky-4: #e39a62;
}
html[data-theme="day"][data-season="winter"] {
  --bg: #f7efe6; --panel: #fffaf2; --panel-2: #efe6dc; --muted: #765036; --yellow: #9b3030; --aqua: #1c5e7a; --pink: #a62d62; --blue: #3a5fa8; --shadow: #e3d3c0;
  --sky-0: #b7d2e6; --sky-1: #d3e0ea; --sky-2: #ebe6e4; --sky-3: #f1e5db; --sky-4: #f5e2d0;
}

/* The sky behind everything. sky.js paints it; this is what you see before it loads, or with the sky switched off. */
html[data-theme="day"] {
  background: var(--sky-4) linear-gradient(to bottom, var(--sky-0), var(--sky-1) 25%, var(--sky-2) 50%, var(--sky-3) 75%, var(--sky-4)) fixed;
}
html[data-theme="day"] body { background: none; } /* so the sky canvas, which sits just above the page background, shows through */

/* The globe keeps its night colors, so it looks exactly the same by day. */
html[data-theme="day"] .globe-stage {
  --bg: #0d0b22; --panel: #1b1747; --panel-2: #241f5c; --ink: #f4f1ff; --muted: #b3aedf;
  --yellow: #ffd23f; --aqua: #3de8c8; --pink: #ff4f9a; --blue: #4d7cff; --shadow: #05040f;
  --on-accent: #1a1033; --panel-deep: #120f33; --code-bg: #070618; --scan: rgba(0, 0, 0, 0.13);
  --good: #58d26b; --bright: #ffffff;
}

/* Daytime has no CRT lines of its own. The globe keeps its night ones, laid on exactly where they fall at night. */
html[data-theme="day"] body::after { display: none; }
html[data-theme="day"] .globe-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.13) 2px, rgba(0, 0, 0, 0.13) 3px) fixed;
}

/* Small adjustments so the pixel bevels and shadows look right on light colors */
html[data-theme="day"] .nav-list a,
html[data-theme="day"] .chip,
html[data-theme="day"] .qz-option { box-shadow: inset -3px -3px 0 rgba(90, 50, 10, 0.2), inset 3px 3px 0 rgba(255, 255, 255, 0.6); }
html[data-theme="day"] .qz-option:hover:not(:disabled),
html[data-theme="day"] .chip:hover { color: #fff; }
html[data-theme="day"] .entry-tags li { box-shadow: inset 0 -3px 0 0 rgba(90, 50, 10, 0.12); }
html[data-theme="day"] .footer-inner p { color: var(--ink); }
html[data-theme="day"] .buddy-sprite::after { background: rgba(80, 40, 10, 0.28); }

/* --------------------------------------------------------------------------
   Respect "reduce motion"
   -------------------------------------------------------------------------- */

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