:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #15171c;
  --text: #e8e8ec;
  --muted: #8a8f98;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  width: 100%;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--panel);
}

header h1 { margin: 0; justify-self: start; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-shield { height: 32px; width: auto; border-radius: 4px; display: block; }
.brand-wordmark { height: 20px; width: auto; display: block; }
#status { color: var(--muted); font-size: 13px; justify-self: end; }

.main-nav { display: flex; gap: 20px; align-items: center; justify-self: center; }
.nav-link {
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
  transition: opacity 0.15s ease;
}
.nav-link:hover { opacity: 1; }
.nav-link.active { opacity: 1; font-weight: 600; border-bottom-color: currentColor; }

/* Each nav item takes its color straight from the game's own 16-color palette
   (config.php PALETTE, the exact 2017 r/place hex set — see reddit-place-playbook.md)
   so the header itself reads as part of the canvas, not a generic UI chrome color. */
#nav-canvas     { color: #00D3DD; } /* cyan */
#nav-campaigns  { color: #CF6EE4; } /* purple */
#nav-create     { color: #94E044; } /* light green */
#nav-data       { color: #E59500; } /* orange */
#nav-profile    { color: #FFA7D1; } /* pink */

main { padding: 20px; }

.view { display: none; flex-direction: column; align-items: center; gap: 8px; }
.view.active { display: flex; }

canvas {
  image-rendering: pixelated;
  border: 1px solid #2a2d35;
  cursor: crosshair;
  background: #ffffff;
}

.hint { color: var(--muted); font-size: 13px; margin: 0; }

.zoom-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
}

.zoom-controls button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #2a2d35;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}

#coords { color: var(--muted); font-variant-numeric: tabular-nums; }
#cooldown-msg { color: #ff6b6b; }

.zoom-controls button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.legend {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.legend.visible { display: flex; }
.legend { justify-content: center; margin: 0 auto 10px; }
.legend .bar {
  width: 140px;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, hsl(0 80% 50%), hsl(60 80% 50%), hsl(120 70% 45%));
}
/* Contest heatmap runs the opposite direction to the cooldown bar: pale = untouched,
   red = most fought over (data-visualization-playbook.md). */
.legend .bar.churn {
  background: linear-gradient(90deg, #f5f5f5, hsl(60 90% 50%), hsl(0 90% 45%));
}
/* Economic view uses a money-green ramp, deliberately unlike the churn heat ramp so
   the two overlays are never confused at a glance. */
.legend .bar.economic {
  background: linear-gradient(90deg, #f8f8fa, hsl(150 45% 70%), hsl(150 80% 22%));
}
/* Persistence glow is the inverse of churn: dark = just changed hands, bright gold =
   held longest. */
.legend .bar.glow {
  background: linear-gradient(90deg, hsl(45 85% 12%), hsl(45 85% 40%), hsl(45 85% 67%));
}

/* Live Map Collaboration view switcher (community-collaboration.md #5) */
.view-mode-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 10px;
  flex-wrap: wrap;
}
.view-mode-btn {
  background: var(--panel, #1a1c22);
  color: var(--muted);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.view-mode-btn:hover { color: #fff; }
.view-mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

#palette {
  display: none;
  position: sticky;
  bottom: 0;
  width: 100%;
  padding: 12px;
  justify-content: center;
  gap: 8px;
  background: var(--panel);
}
#palette.visible { display: flex; }

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.selected {
  border-color: var(--accent);
  transform: scale(1.1);
}

/* --- Background-tick master switch pill (added 2026-08-18) -------------------
   Sits in the header's right-hand grid column. Deliberately loud when paused:
   a silently-paused world looks identical to a broken one, and forgetting it's off
   is the main failure mode of having the switch at all. */
.header-right { display: flex; align-items: center; gap: 12px; justify-self: end; }

.ticks-pill {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid currentColor;
  background: transparent;
  transition: opacity 0.15s ease;
}
.ticks-pill:hover:not(:disabled) { opacity: 0.75; }
.ticks-pill:disabled { cursor: default; opacity: 0.5; }
/* Green = the world is live; amber = deliberately halted, not broken. Both from the
   game's own 16-color palette (config.php PALETTE) like the rest of the nav. */
.ticks-pill.is-running { color: #02BE01; }
.ticks-pill.is-paused  { color: #E59500; }

/* --- Wallet pill (added 2026-08-19) ------------------------------------------
   Injected by wallet.js into .header-right, so it lands on all eight pages
   without touching their markup. Shares the sim pill's shape on purpose: same
   row, same affordance, one visual language for "session state".

   The colour split carries real meaning and should not be flattened. Cyan =
   signature-verified, this address is provably yours. Grey = an UNSIGNED
   prototype name that anyone could type, which must not look like an account.
   Grey rather than amber because unsigned is the old normal here, not a
   warning state. */
.wallet-pill {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid currentColor;
  background: transparent;
  transition: opacity 0.15s ease;
  font-variant-numeric: tabular-nums;
}
.wallet-pill:hover:not(:disabled) { opacity: 0.75; }
.wallet-pill:disabled { cursor: default; opacity: 0.5; }
.wallet-pill.is-signed   { color: #00D3DD; }
.wallet-pill.is-unsigned { color: #888888; }

/* --- Ad Canvas (added 2026-08-18) -------------------------------------------
   Page chrome above the main canvas: fixed in the page flow, its own display
   scale, and deliberately never part of the canvas pan/zoom surface. */
#ad-canvas-mount { display: flex; flex-direction: column; align-items: center;
  padding: 14px 12px 6px 12px; }
.adc-wrap { display: flex; flex-direction: column; align-items: center; }
.adc-link { display: block; line-height: 0; border: 1px solid var(--line, #2a2a2e);
  border-radius: 3px; overflow: hidden; }
.adc-canvas { display: block; image-rendering: pixelated; }
.adc-empty {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--muted, #888); border-radius: 3px;
  color: var(--muted, #888); font-size: 12px; letter-spacing: .04em;
  text-decoration: none; background: rgba(255,255,255,.02);
}
.adc-empty:hover { color: #fff; border-color: #fff; }

.adc-caption { display: flex; justify-content: space-between; align-items: center;
  gap: 18px; margin-top: 6px; font-size: 11px; white-space: nowrap; }
.adc-advertise { color: var(--muted, #888); text-decoration: none; }
.adc-advertise:hover { color: #fff; text-decoration: underline; }
.adc-right { display: flex; align-items: center; gap: 10px; }
/* Destination host shown so a click is informed, not blind — with no approval
   step this is the main thing standing between a clean logo and a phishing page. */
.adc-host { color: var(--muted, #888); font-family: ui-monospace, monospace; opacity: .8; }
.adc-report { color: var(--muted, #888); text-decoration: none; opacity: .75; }
.adc-report:hover { color: #E59500; opacity: 1; text-decoration: underline; }

.adc-report-panel { margin-top: 10px; padding: 12px 14px; max-width: 380px;
  background: var(--panel, #141418); border: 1px solid var(--line, #2a2a2e);
  border-radius: 4px; font-size: 12px; }
.adc-report-panel strong { display: block; margin-bottom: 6px; }
.adc-dest { color: var(--muted, #888); margin: 0 0 8px 0; }
.adc-dest code { font-size: 11px; }
.adc-report-panel select, .adc-report-panel input {
  width: 100%; margin-bottom: 7px; padding: 5px 6px; font: inherit;
  background: #0d0d10; color: inherit; border: 1px solid var(--line, #2a2a2e);
  border-radius: 3px;
}
.adc-actions { display: flex; gap: 8px; }
.adc-actions button { font: inherit; font-size: 12px; padding: 5px 11px; cursor: pointer;
  border-radius: 3px; border: 1px solid currentColor; background: transparent; color: #E59500; }
.adc-actions button.ghost { color: var(--muted, #888); }
.adc-msg { margin: 7px 0 0 0; color: var(--muted, #888); }

@media (max-width: 640px) {
  /* 3x would overflow a 375px viewport; the API also reports scale_mobile. */
  .adc-canvas, .adc-empty { max-width: 100%; height: auto; }
  .adc-caption { flex-direction: column; align-items: flex-start; gap: 4px; }
}
#nav-advertise  { color: #E5D900; } /* yellow — Ad Canvas is commerce, not gameplay */

/* --- Blueprint drafts bar (added 2026-08-19) ------------------------------- */
.draft-bar { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--line, #2a2a2e);
  border-radius: 4px; background: rgba(255,255,255,.02); }
.draft-pick { flex: 1; min-width: 200px; margin: 0; }
.draft-bar select { width: 100%; }
.draft-bar .ghost-btn { white-space: nowrap; }
