:root {
  --paper: #ffffff;
  --ink: #0a0a0a;
  --line: #000000;
  --pencil: #9b9b9b;
  --hair: #e6e6e6;
  --hair-2: #d6d6d6;
  --overlay: rgba(255, 255, 255, 0.85);
  --grid-line: rgba(0, 0, 0, 0.12);
  --sector-line: rgba(0, 0, 0, 0.22);
  --brush-preview-bg: rgba(10, 10, 10, 0.08);
  --accent-bg: var(--ink);
  --accent-fg: var(--paper);

  --font-display: "Archivo Black", "Arial Black", sans-serif;
  --font-body: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", "SF Mono", Consolas, monospace;
}

/* Dark theme: applied automatically from OS preference, or forced either way
   by the toggle button (public/theme.js sets data-theme, which always wins
   over the OS setting via the :not() guard below). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #18181b;
    --ink: #f0f0ee;
    --line: #f0f0ee;
    --pencil: #8f8f95;
    --hair: #2c2c30;
    --hair-2: #3c3c42;
    --overlay: rgba(10, 10, 10, 0.85);
    --grid-line: rgba(255, 255, 255, 0.14);
    --sector-line: rgba(255, 255, 255, 0.26);
    --brush-preview-bg: rgba(240, 240, 238, 0.12);
    --accent-bg: #3a3a40;
    --accent-fg: var(--ink);
  }
}
:root[data-theme="dark"] {
  --paper: #18181b;
  --ink: #f0f0ee;
  --line: #f0f0ee;
  --pencil: #8f8f95;
  --hair: #2c2c30;
  --hair-2: #3c3c42;
  --overlay: rgba(10, 10, 10, 0.85);
  --grid-line: rgba(255, 255, 255, 0.14);
  --sector-line: rgba(255, 255, 255, 0.26);
  --brush-preview-bg: rgba(240, 240, 238, 0.12);
  --accent-bg: #3a3a40;
  --accent-fg: var(--ink);
}

* { box-sizing: border-box; }

/* Mobile browsers flash a gray highlight box on every tap by default; we
   already show our own :focus-visible outline for keyboard users, so this
   default is just noise on a UI that's tapped constantly (placing pixels). */
html { -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  /* Belt-and-suspenders: nothing on this site should ever legitimately need
     horizontal scroll, so this just guards against a stray few px of
     overflow on some narrow device width we didn't test. */
  overflow-x: hidden;
}

h1, h2 { margin: 0; }

::selection { background: var(--ink); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- topbar / wordmark ---------- */

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 400; /* Archivo Black only ships one weight */
  font-size: 26px;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--ink);
  text-transform: uppercase;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .topbar { padding: 16px 16px 14px; gap: 12px; }
  .swatch { width: 28px; height: 28px; }
  .wordmark {
    font-size: 6.2vw;
    /* The vw-scaled size above still doesn't leave enough room for "World
       Wide Whiteboard" on one line on the narrowest phones (~320-375px) —
       rather than chase an exact px/vw ratio that only holds at one width,
       let the two chunks (the plain "World Wide" text and the marked
       "Whiteboard" span) wrap onto their own line instead of overflowing. */
    flex-wrap: wrap;
    white-space: normal;
    row-gap: 0.15em;
  }
}

.wordmark-marked {
  position: relative;
  display: inline-block;
}

.wordmark-underline {
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: -0.32em;
  width: 104%;
  height: 0.28em;
  overflow: visible;
}
.wordmark-underline path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 6;
  stroke-linecap: round;
}

.tagline {
  color: var(--pencil);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; row-gap: 10px; }

/* Day/night switch: a sliding thumb carrying both icons, cross-faded and
   rotated so it reads as one icon "turning into" the other rather than a
   plain swap. Track/icon colors are literal sky colors, not theme
   variables — they represent day vs. night regardless of the site's own
   ink/paper palette, which is exactly the state this control is showing. */
.theme-switch {
  position: relative;
  width: 48px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #cfe8ff;
  transition: background 0.25s ease, border-color 0.15s ease;
}
.theme-switch:hover .theme-switch-track { border-color: var(--ink); }
.theme-switch[aria-checked="true"] .theme-switch-track { background: #141b36; }

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left 0.25s ease;
}
.theme-switch[aria-checked="true"] .theme-switch-thumb { left: 25px; }

.theme-icon {
  position: absolute;
  width: 13px;
  height: 13px;
  transition: opacity 0.2s ease, transform 0.25s ease;
}
.theme-icon-sun { color: #fbbf24; opacity: 1; transform: scale(1) rotate(0deg); }
.theme-icon-moon { color: #1e2a5e; opacity: 0; transform: scale(0.4) rotate(-60deg); }
.theme-switch[aria-checked="true"] .theme-icon-sun { opacity: 0; transform: scale(0.4) rotate(60deg); }
.theme-switch[aria-checked="true"] .theme-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }

.landing-theme-toggle {
  position: absolute;
  top: 24px;
  right: 28px;
}

.auth-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.auth-controls[hidden] { display: none; }
.auth-username {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}
.auth-username::before { content: "@"; color: var(--pencil); }

.wordmark-link {
  text-decoration: none;
  display: inline-flex;
  border-radius: 4px;
}
.wordmark-link:hover { opacity: 0.7; }

/* ---------- landing page ---------- */

.landing-body {
  position: relative;
  min-height: 100vh;
  display: flex;
}

.landing-logo {
  position: absolute;
  top: 24px;
  left: 28px;
}
.landing-logo .wordmark { font-size: 13px; }

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 110px 24px 60px;
}

.hero-tagline {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(32px, 6.4vw, 68px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 780px;
  margin: 0 0 36px;
}

.hero-cta {
  font-size: 16px;
  padding: 14px 30px;
}

.hero-sub {
  margin-top: 18px;
  color: var(--pencil);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* ---------- buttons ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { opacity: 0.75; }
.btn.small { padding: 5px 10px; font-size: 14px; line-height: 1; }
/* .btn's own `display: inline-flex` above beats the browser's default
   [hidden] { display: none } (an author-stylesheet rule always wins over a
   user-agent one, regardless of specificity) — without this, any .btn
   toggled via the `hidden` property/attribute stays visible. Bit this
   project before on other custom-display elements; .btn just hadn't hit it
   until a couple of buttons actually needed to toggle hidden at runtime. */
.btn[hidden] { display: none; }

.btn-accent {
  background: var(--accent-bg);
  color: var(--accent-fg);
  border-color: var(--accent-bg);
}
.btn-accent:hover { background: var(--paper); color: var(--ink); border-color: var(--ink); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--hair-2);
}
.btn-ghost:hover {
  background: transparent;
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* ---------- ad slots ---------- */

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pencil);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--paper);
  border: 1px dashed var(--hair-2);
  border-radius: 4px;
}
.ad-slot[hidden] { display: none; }
.ad-top { height: 90px; margin: 16px 28px 0; }
.ad-side { height: 250px; margin-bottom: 16px; }
.ad-placeholder { height: 160px; margin: 14px 0; }
#ad-countdown { font-size: 20px; letter-spacing: 0.02em; }

/* A purchased banner replaces the dashed-border placeholder with an actual image. */
.ad-slot.ad-slot-filled { border-style: solid; padding: 0; overflow: hidden; }
.ad-slot-filled a { display: block; width: 100%; height: 100%; }
.ad-slot-filled img { display: block; width: 100%; height: 100%; object-fit: cover; }

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

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  padding: 20px 28px 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.canvas-wrap { min-width: 0; }

/* Wraps just the canvas area (not the HUD below it), so the minimap — a
   sibling of #canvas-container, not a child of it — anchors to the bottom
   corner of the canvas itself. A child of #canvas-container would work for
   layout but would scroll away with the panned content, since it's both
   position:relative and the scroll container. */
.canvas-viewport { position: relative; }
.minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 160px;
  height: 90px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  z-index: 15;
}
#minimap-canvas { display: block; width: 100%; height: 100%; }
.minimap-viewport {
  position: absolute;
  border: 1.5px solid var(--ink);
  background: rgba(127, 127, 127, 0.25);
  pointer-events: none;
}
@media (max-width: 900px) {
  .minimap { width: 110px; height: 62px; }
}

/* Tool-select toolbar, opposite corner from the minimap. A flex row so the
   brush-size flyout can sit beside the vertical icon column without needing
   its own popover open/close logic — it just shows/hides with the active
   tool, same as the icon buttons' selected state. */
.toolbar-group {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 15;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
/* On /world, Leaflet's own zoom control already lives in the top-left
   corner (its default position) — push the toolbar below it rather than
   moving the zoom control somewhere non-standard. */
.world-toolbar-group {
  top: 88px;
  z-index: 1000; /* above Leaflet's own panes/controls, same as .world-hud */
}
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.tool-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.tool-btn:hover { background: var(--hair); }
.tool-btn.selected { background: var(--accent-bg); color: var(--accent-fg); }
.tool-btn svg { width: 18px; height: 18px; }

/* Positioned via JS (top/left in px, relative to .toolbar-group — the
   nearest positioned ancestor of both the buttons and this tooltip) rather
   than pure CSS :hover, so it can track whichever button is actually
   hovered instead of being pinned to one fixed spot. */
.tool-tooltip {
  position: absolute;
  width: max-content;
  max-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.tool-tooltip[hidden] { display: none; }
.tool-tooltip-head { display: flex; align-items: center; gap: 6px; }
.tool-tooltip-head strong { font-size: 13px; }
.tool-tooltip kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 2px 5px;
  border: 1px solid var(--hair-2);
  border-radius: 3px;
  background: var(--hair);
  color: var(--pencil);
}
.tool-tooltip span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--pencil);
}

/* Same brush-size buttons as the world map's HUD (.brush-size-toggle,
   .brush-size-btn), just wrapped in its own flyout panel here instead of
   sitting inline in the HUD row. */
.toolbar-brush-sizes {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* Positioned via inline left/top (computed from the click point) rather
   than a fixed corner, since it needs to appear next to whatever pixel was
   inspected — clamped in JS so it never renders outside the viewport. */
.inspect-popover {
  position: absolute;
  /* Must clear /world's HUD/toolbar/minimap (z-index: 1000, matching
     Leaflet's own control layer) as well as /board's (z-index: 15). */
  z-index: 1001;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 12.5px;
}
.inspect-info { line-height: 1.5; }
.inspect-info strong { color: var(--ink); }
.inspect-report-row { display: flex; gap: 6px; margin-top: 8px; }
.inspect-report-row[hidden] { display: none; }
.inspect-report-input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 5px 8px;
  border: 1px solid var(--hair-2);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}
.inspect-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }

#canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 78vh;
  background: var(--paper);
  border-radius: 4px;
  overflow: auto;
  border: 1px solid var(--line);
  cursor: crosshair;
  touch-action: none;
}
#canvas-container.tool-navigate { cursor: grab; }
#canvas-container.tool-navigate:active { cursor: grabbing; }

.canvas-stack {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  position: relative;
}

.board-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}
.board-background[hidden] {
  display: none;
}

/* Repeating-gradient trick: tiles automatically on scroll/pan, no per-frame
   redraw needed, just background-size updated on zoom. */
.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
}
.grid-overlay[hidden] { display: none; }

.heatmap-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
}
.heatmap-canvas[hidden] { display: none; }

/* Same repeating-gradient trick as .grid-overlay, but sized to sectors
   (16 columns) instead of individual pixel cells, and a bolder line —
   this one stays visible across the whole zoom range, including fully
   zoomed out, where individual pixel cells are sub-pixel and would just
   render as mush rather than a usable grid. */
.sector-overlay {
  background-image:
    linear-gradient(to right, var(--sector-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--sector-line) 1px, transparent 1px);
}

.brush-preview {
  position: absolute;
  border: 2px solid var(--ink);
  background: var(--brush-preview-bg);
  pointer-events: none;
  z-index: 8;
}
.brush-preview[hidden] { display: none; }

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--hair);
  padding: 6px;
  border-radius: 4px;
}

.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 3px;
  border: 2px solid var(--hair-2);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink);
}

.recent-colors-wrap { display: flex; align-items: center; gap: 6px; }
.recent-colors-wrap[hidden] { display: none; }
.recent-colors-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pencil);
}
.recent-colors { background: transparent; border-style: dashed; }

.brush-size-toggle { display: flex; gap: 4px; }
.brush-size-toggle[hidden] { display: none; }
.brush-size-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--hair-2);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.brush-size-btn.selected { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--accent-bg); }
.brush-size-btn.selected:hover { background: var(--accent-bg); color: var(--accent-fg); }
.brush-size-btn:hover { border-color: var(--ink); }

/* ---------- custom color wheel ---------- */

.wheel-trigger-wrap { position: relative; }

.wheel-swatch {
  border-radius: 50%;
  border-color: var(--hair-2);
  position: relative;
  background: conic-gradient(from 0deg,
    hsl(0, 100%, 50%) 0deg, hsl(60, 100%, 50%) 60deg, hsl(120, 100%, 50%) 120deg,
    hsl(180, 100%, 50%) 180deg, hsl(240, 100%, 50%) 240deg, hsl(300, 100%, 50%) 300deg,
    hsl(360, 100%, 50%) 360deg);
}
.wheel-swatch::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, white 0%, rgba(255, 255, 255, 0) 75%);
}

.wheel-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 14px;
  width: 200px;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.hue-sat-wheel {
  width: 160px;
  height: 160px;
  margin: 0 auto;
  position: relative;
  border-radius: 50%;
  border: 1px solid var(--hair-2);
  cursor: crosshair;
  touch-action: none;
  background: conic-gradient(from 0deg,
    hsl(0, 100%, 50%) 0deg, hsl(60, 100%, 50%) 60deg, hsl(120, 100%, 50%) 120deg,
    hsl(180, 100%, 50%) 180deg, hsl(240, 100%, 50%) 240deg, hsl(300, 100%, 50%) 300deg,
    hsl(360, 100%, 50%) 360deg);
}
.hue-sat-wheel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, white 0%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

.wheel-cursor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.wheel-slider-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--pencil);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 12px;
}
.wheel-slider-label input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  accent-color: var(--ink);
}

.wheel-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.wheel-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--hair-2);
  flex-shrink: 0;
}
.wheel-hex {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 16px;
  border: 1px solid var(--hair-2);
  border-radius: 4px;
  padding: 5px 6px;
  color: var(--ink);
  background: var(--paper);
  text-transform: uppercase;
}
.wheel-hex:focus {
  border-color: var(--ink);
  outline: none;
}

.hud-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

#coord-readout { font-family: var(--font-mono); }

.goto-form { display: flex; gap: 4px; }
.goto-input {
  width: 92px;
  font-family: var(--font-mono);
  font-size: 16px;
  background: var(--paper);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  padding: 5px 8px;
  border-radius: 4px;
}
.goto-input:focus { border-color: var(--ink); outline: none; }

.status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  padding: 6px 10px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 4px;
  min-width: 160px;
  text-align: center;
}
.status.ready::before { content: "● "; }
.status.cooldown::before { content: "◐ "; }
.status.error::before { content: "✕ "; }

.zoom-controls { display: flex; gap: 4px; }

.sidebar { display: flex; flex-direction: column; }

.panel {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--ink);
}
.muted { color: var(--pencil); font-size: 12.5px; line-height: 1.55; }
.muted a { color: var(--ink); text-decoration-color: var(--hair-2); text-underline-offset: 2px; }
.muted a:hover { text-decoration-color: var(--ink); }
.small-list { margin: 8px 0 0; padding-left: 18px; }
.small-list li { margin-bottom: 6px; }
.small-list strong { color: var(--ink); }

/* ---------- modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Above everything, including /world's HUD/toolbar/minimap (z-index:
     1000, matching Leaflet's own control layer) — a modal should never be
     able to render behind page chrome regardless of what z-index tier that
     chrome needs to beat Leaflet's panes. */
  z-index: 2000;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 24px;
  width: 360px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 18px; text-transform: uppercase; }
.form-row { margin: 14px 0; display: flex; flex-direction: column; gap: 6px; }
.form-row[hidden] { display: none; }
.form-row label { font-size: 12.5px; color: var(--pencil); }
.form-row input[type="text"], .form-row input[type="url"], .form-row input[type="email"], .form-row input[type="password"] {
  background: var(--paper);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 4px;
  font-family: var(--font-body);
  /* iOS Safari auto-zooms the page on focusing any input under 16px —
     16px here isn't a design choice, it's the threshold that avoids that. */
  font-size: 16px;
}
.form-row input[type="text"]:focus, .form-row input[type="url"]:focus, .form-row input[type="email"]:focus, .form-row input[type="password"]:focus {
  border-color: var(--ink);
  outline: none;
}
.form-row input[type="color"] { width: 60px; height: 32px; border: 1px solid var(--hair-2); border-radius: 4px; background: none; cursor: pointer; padding: 2px; }
.price-row { flex-direction: row; align-items: center; justify-content: space-between; }
.price-row strong { font-family: var(--font-mono); font-size: 16px; }
.price-note { margin: -8px 0 0; font-family: var(--font-mono); font-size: 11px; }

.fill-type-toggle { display: flex; gap: 6px; }
.fill-type-btn { flex: 1; justify-content: center; border-color: var(--hair-2); }
.fill-type-btn.selected { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--accent-bg); }
.fill-type-btn.selected:hover { background: var(--accent-bg); color: var(--accent-fg); }

.region-image-preview {
  display: block;
  margin-top: 8px;
  max-width: 100%;
  border: 1px solid var(--hair-2);
  border-radius: 4px;
  image-rendering: pixelated;
}
.region-image-preview[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.error { color: var(--ink); font-family: var(--font-mono); font-size: 12px; margin-top: 10px; padding: 8px; border: 1px dashed var(--ink); border-radius: 4px; }

.leaderboard-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--hair);
}
.leaderboard-rank { font-family: var(--font-mono); color: var(--pencil); width: 1.5em; }
.leaderboard-name { flex: 1; }
.leaderboard-count { font-family: var(--font-mono); color: var(--pencil); }

/* Shared by the leaderboard rows and the Inspect popover's "Placed by" line
   — a username that opens that person's public stats/badges on click. */
.link-username {
  font: inherit;
  font-weight: 500;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.1s ease;
}
.link-username:hover, .link-username:focus-visible { text-decoration-color: currentColor; }

.timelapse-card { width: 480px; }
.timelapse-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  image-rendering: pixelated;
}
.timelapse-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.timelapse-scrub { flex: 1; accent-color: var(--ink); }
.timelapse-progress { font-family: var(--font-mono); font-size: 11px; color: var(--pencil); white-space: nowrap; }

.auth-toggle {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--pencil);
  text-align: center;
}
.auth-toggle a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- suggestions board ---------- */

.suggestions-section {
  max-width: 720px;
  margin: 8px auto 0;
  padding: 28px 28px 8px;
  border-top: 1px solid var(--hair);
}
.suggestions-section h2 {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.suggestions-section > .muted { margin: 6px 0 16px; }

.suggestion-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.suggestion-input {
  flex: 1;
  resize: vertical;
  min-height: 44px;
  background: var(--paper);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  padding: 9px 11px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 13px;
}
.suggestion-input:focus { border-color: var(--ink); outline: none; }

.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0 24px;
}

.suggestion-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--hair);
  border-radius: 4px;
}

.vote-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  width: 32px;
}
.vote-btn {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--hair-2);
  background: var(--paper);
  color: var(--pencil);
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.vote-btn:hover { border-color: var(--ink); color: var(--ink); }
.vote-btn.active-up { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-fg); }
.vote-btn.active-down { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-fg); }
.vote-score {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.suggestion-body { flex: 1; min-width: 0; }
.suggestion-text {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.suggestion-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--pencil);
}

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 32px 28px 40px;
  border-top: 1px solid var(--hair);
  margin-top: 12px;
}
.footer-tip-jar, .footer-link {
  color: var(--pencil);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--hair-2);
}
.footer-tip-jar:hover, .footer-link:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  z-index: 2000; /* clears /world's HUD/toolbar/minimap (z-index: 1000) same as .modal */
}

/* ---------- world map board ---------- */

.world-body {
  height: 100vh; /* fallback for browsers without dvh support */
  height: 100dvh; /* accounts for mobile browser chrome showing/hiding, so the map+HUD don't get cut off under the address bar */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.world-body .topbar { flex-shrink: 0; }

/* .world-map used to be the flex item itself; now .world-map-wrap takes
   that role so #minimap can be an absolutely-positioned sibling anchored to
   this wrap's own box, clear of the topbar above and the floating hud below
   regardless of their exact heights. */
.world-map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
.world-map {
  position: absolute;
  inset: 0;
  background: var(--paper);
}

.world-minimap {
  top: 12px;
  right: 12px;
  bottom: auto;
  width: 170px;
  height: 100px;
  z-index: 1000; /* above Leaflet's own panes/controls, same as .world-hud */
}
@media (max-width: 900px) {
  .world-minimap { width: 120px; height: 74px; }
}

/* Fixed-resolution bitmap, scaled via CSS width/height (set in JS to match
   the real map's current projection) — image-rendering: pixelated keeps
   pixels crisp and blocky like wplace, rather than blurring as they scale. */
.world-pixel-canvas {
  position: absolute;
  image-rendering: pixelated;
}

.world-brush-preview { z-index: 451; }
.world-heatmap-canvas[hidden] { display: none; }

.world-hud {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 1000; /* above Leaflet's own panes/controls */
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 40px);
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.world-hud-left, .world-hud-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* The palette/wheel-picker share styling with /board's in-flow HUD, but on
   /world the HUD floats directly over the map instead of sitting below a
   canvas — shrink it there so it doesn't cover a big chunk of the visible
   map, especially on shorter viewports. */
.world-hud { gap: 10px; padding: 8px 10px; bottom: 14px; }
.world-hud .palette { gap: 4px; padding: 4px; }
.world-hud .swatch { width: 16px; height: 16px; border-width: 1px; }
.world-hud .swatch.selected { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink); }

/* Replaces the always-on status text: only appears during a cooldown, a
   small display-only badge instead of a permanent readout. (It was also the
   "watch an ad to skip it" trigger — disabled for now, see world.js — so
   it's deliberately styled non-interactive rather than clickable.) */
.cooldown-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  padding: 6px 10px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 4px;
  cursor: default;
}
.cooldown-timer::before { content: "◐ "; }
.cooldown-timer[hidden] { display: none; }

/* Leaflet's own controls ship with light-mode-only inline styles; re-theme
   the bits that would otherwise look broken against a dark page. */
.leaflet-control-attribution {
  background: var(--paper) !important;
  color: var(--pencil) !important;
}
.leaflet-control-attribution a { color: var(--ink) !important; }
.leaflet-control-zoom a {
  background: var(--paper) !important;
  color: var(--ink) !important;
  border-color: var(--hair-2) !important;
}
.leaflet-control-zoom a:hover { background: var(--hair) !important; }

/* ---------- admin dashboard ---------- */

.admin-main { max-width: 720px; margin: 0 auto; padding: 24px 28px 60px; }
.admin-gate-row { flex-direction: row; align-items: center; }
.admin-gate-row input { flex: 1; min-width: 0; }
.admin-gate code {
  font-family: var(--font-mono);
  background: var(--hair);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}
.admin-count { color: var(--pencil); font-weight: 400; }
#admin-lock { margin-top: 4px; }

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
}
.admin-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--hair);
  border-radius: 4px;
}
.admin-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-row-title { font-size: 13.5px; }
.admin-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--pencil); }
.admin-row-reason {
  margin-top: 4px;
  font-size: 13px;
  font-style: italic;
  color: var(--pencil);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  text-align: center;
}
.stat-cell strong { font-family: var(--font-mono); font-size: 22px; }
.stat-cell span { font-size: 11.5px; color: var(--pencil); }

/* Earned vs locked is the only state — no progress bars, just dimmed vs
   full-contrast, so a glance at the row shows what's done and what isn't. */
.badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.delete-account-section {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}
.badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--hair);
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--pencil);
  background: transparent;
  opacity: 0.55;
}
.badge-icon { font-size: 13px; line-height: 1; }
.badge.earned {
  opacity: 1;
  border-color: transparent;
  background: var(--accent-bg);
  color: var(--accent-fg);
}

.download-options { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.download-option {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 14px;
  white-space: normal;
  text-align: left;
}
.download-option strong { font-size: 13.5px; }
.download-option span { font-size: 11.5px; color: var(--pencil); }
.download-option:hover span { color: inherit; }
.download-option:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
