:root {
  --bg: #0b0420;
  --panel: rgba(18, 8, 44, 0.78);
  --ink: #f6f0ff;
  --muted: #b3a6d9;
  --pink: #ff2e97;
  --cyan: #00e5ff;
  --lime: #b6ff3b;
  --violet: #9d5cff;
  --line: rgba(246, 240, 255, 0.16);
  --display: 'Bungee', system-ui, sans-serif;
  --body: 'Space Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.dragging { cursor: grabbing !important; }
#scene.hovering { cursor: pointer; }

/* ---------- top HUD ---------- */
.hud-top {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  pointer-events: none;
}

.brand h1 {
  position: relative;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 5.5vw, 58px);
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 12px var(--pink), 0 0 32px rgba(255, 46, 151, 0.6), 3px 3px 0 var(--cyan);
}
.brand p {
  margin: 10px 0 0;
  font-weight: 700;
  color: var(--muted);
}
.wp-link {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  font-family: var(--display);
  font-size: 13px;
  text-decoration: none;
  color: var(--bg);
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--pink);
  pointer-events: auto;
  transform: rotate(-2deg);
  transition: transform 0.12s, box-shadow 0.12s;
}
.wp-link:hover { transform: rotate(0) translate(-2px, -2px); box-shadow: 5px 5px 0 var(--pink); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px 18px;
  margin: 0;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(157, 92, 255, 0.25);
  backdrop-filter: blur(8px);
}
.stats div.wide { grid-column: 1 / -1; }
.stats dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.stats dd {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}
.stats div.wide dd { color: var(--pink); text-shadow: 0 0 10px rgba(255, 46, 151, 0.6); }

.hint {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

.view-controls {
  position: fixed;
  left: 16px;
  bottom: 56px;
  display: flex;
  gap: 6px;
}
.view-controls button {
  width: 40px;
  height: 40px;
  font: inherit;
  font-size: 19px;
  line-height: 1;
  color: var(--cyan);
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.45);
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s;
}
.view-controls button:hover { background: rgba(0, 229, 255, 0.15); box-shadow: 0 0 18px rgba(0, 229, 255, 0.5); }
.view-controls button:active { transform: translateY(1px); }

.proto {
  position: fixed;
  right: 16px;
  bottom: 56px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--bg);
  background: var(--violet);
  border-radius: 999px;
  pointer-events: none;
}

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed;
  z-index: 5;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(11, 4, 32, 0.92);
  border: 1px solid var(--pink);
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(255, 46, 151, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- passport card ---------- */
#card {
  position: fixed;
  z-index: 10;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding: 0 0 18px;
  background: rgba(14, 6, 36, 0.92);
  border: 1px solid rgba(255, 46, 151, 0.6);
  border-radius: 18px;
  box-shadow: 0 0 32px rgba(255, 46, 151, 0.35), 6px 6px 0 rgba(0, 229, 255, 0.5);
  backdrop-filter: blur(10px);
  animation: pop 0.25s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-50%) scale(0.92); }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #fff;
}
.card-head button {
  width: 28px;
  height: 28px;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  cursor: pointer;
}

.card-body { position: relative; padding: 16px 18px 0; }
.card-body h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}
.card-body .job {
  margin: 6px 0 14px;
  font-weight: 700;
  color: var(--muted);
}
.card-body dl { margin: 0; }
.card-body dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px dashed var(--line);
}
.card-body dt { color: var(--muted); }
.card-body dd { margin: 0; font-weight: 700; text-align: right; }
.card-body p.line { margin: 0 0 10px; line-height: 1.45; }
.card-body .fine {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stamp {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 4px 10px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.06em;
  border: 2px solid currentColor;
  border-radius: 8px;
  transform: rotate(8deg);
  text-shadow: 0 0 10px currentColor;
  box-shadow: 0 0 10px currentColor inset;
}
.stamp.alive { color: #39ff88; }

/* ---------- news ticker ---------- */
.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42px;
  display: flex;
  align-items: center;
  color: var(--ink);
  background: rgba(11, 4, 32, 0.9);
  border-top: 1px solid rgba(255, 46, 151, 0.5);
  box-shadow: 0 -6px 24px rgba(255, 46, 151, 0.2);
  overflow: hidden;
}
.ticker-label {
  flex: none;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-family: var(--display);
  font-size: 13px;
  color: var(--bg);
  background: var(--pink);
}
.ticker-track { flex: 1; overflow: hidden; }
#ticker-inner {
  display: inline-flex;
  white-space: nowrap;
  animation: ticker 70s linear infinite;
}
#ticker-inner span { padding: 0 32px; font-weight: 500; }
@keyframes ticker { to { transform: translateX(-50%); } }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .hud-top { flex-direction: column; gap: 10px; }
  .stats { grid-template-columns: repeat(3, auto); padding: 8px 12px; }
  .stats dd { font-size: 15px; }
  .hint { display: none; }
  .ticker-label { font-size: 11px; padding: 0 10px; }
  #card {
    top: auto;
    right: 16px;
    left: 16px;
    bottom: 58px;
    width: auto;
    max-height: 55vh;
    transform: none;
  }
  @keyframes pop { from { opacity: 0; transform: translateY(20px); } }
}

@media (prefers-reduced-motion: reduce) {
  #ticker-inner { animation-duration: 240s; }
}

/* ---------- town clock ---------- */
#s-clock { color: var(--ink); text-shadow: none; font-size: 14px; }

/* ---------- billboard shop ---------- */
.shop { margin-top: 10px; }
.shop-meta { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--display);
  font-size: 11px;
  color: var(--bg);
  background: var(--cyan);
  border-radius: 6px;
}
.shop .field { display: grid; gap: 4px; margin-bottom: 10px; }
.shop .field > span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.shop .field small { font-size: 11px; color: var(--muted); }
.shop .field.row { grid-template-columns: auto 70px 1fr; align-items: center; gap: 10px; }
.shop input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.shop input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 229, 255, 0.35); }
.shop .total { text-align: right; color: var(--muted); }
.shop .total strong { color: var(--lime); font-family: var(--display); font-weight: 400; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 28px;
  height: 28px;
  background: var(--c);
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--c);
  cursor: pointer;
}
.swatch[aria-checked="true"] { border-color: #fff; transform: scale(1.12); }
.pay {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-family: var(--display);
  font-size: 14px;
  color: var(--bg);
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--pink);
  cursor: pointer;
}
.pay:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.shop-status { min-height: 1em; margin: 8px 0 0; font-size: 13px; color: var(--cyan); overflow-wrap: anywhere; }

/* ---------- pole builder ---------- */
.builder .slider > span { display: flex; justify-content: space-between; }
.builder .slider output { color: var(--cyan); font-weight: 700; letter-spacing: 0; text-transform: none; }
.builder input[type="range"] { width: 100%; accent-color: var(--pink); padding: 0; background: none; border: 0; }
.builder input[type="file"] { padding: 6px; font-size: 12px; }
.builder .editor {
  display: block;
  max-width: 100%;
  margin: 6px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
  background: repeating-conic-gradient(#1a1233 0% 25%, #120b26 0% 50%) 50% / 16px 16px;
}
.builder .editor:active { cursor: grabbing; }
.price-line { margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.price-line strong { color: var(--lime); font-family: var(--display); font-weight: 400; font-size: 15px; }
.card-body .pay { margin-top: 10px; }
.visit {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--display);
  font-size: 13px;
  color: var(--cyan);
  text-decoration: none;
}
.visit:hover { text-shadow: 0 0 10px var(--cyan); }

/* ---------- wall boards & owner share ---------- */
.wall-offer { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.share {
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  background: rgba(57, 255, 136, 0.1);
  border: 1px solid rgba(57, 255, 136, 0.4);
  border-radius: 8px;
}

.founders { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.founders li { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
.card-body > .pay + .pay { margin-top: 8px; }

/* ---------- plot choice, edit, toggles ---------- */
.choice { display: grid; gap: 8px; }
.pay.alt { background: var(--cyan); }
.edit-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 9px;
  font-family: var(--display);
  font-size: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.edit-btn:hover { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 229, 255, 0.35); }
.toggle { display: flex; gap: 6px; }
.toggle button {
  flex: 1;
  padding: 7px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.toggle button[aria-pressed="true"] { border-color: var(--pink); background: rgba(255, 46, 151, 0.2); }
.builder input[type="range"]:disabled { opacity: 0.45; }
.price-line .discount { color: var(--lime); font-weight: 700; }
.pay.alt2 { background: var(--violet); color: #fff; }

/* ---------- mail and link questions ---------- */
.hud-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hud-buttons .mail-btn { margin-top: 0; }
.mail-btn[hidden] { display: none; } /* only for people who own something */
.reply-form textarea { width: 100%; min-height: 70px; margin: 6px 0; padding: 8px 10px; font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.proposal { margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.proposal p { margin: 4px 0; }
.proposal .choice { grid-template-columns: 1fr 1fr; }
.mail-btn {
  display: block;
  margin-top: 10px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: rgba(18, 5, 46, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.mail-btn.unread { color: #12052e; background: var(--lime); border-color: var(--ink); font-weight: 700; animation: mail-bounce 1.6s ease-in-out infinite; }
@keyframes mail-bounce { 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .mail-btn.unread { animation: none; } }
.ask-link {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 1, 18, 0.6);
}
.ask-link[hidden] { display: none; }
.ask-link .box {
  width: min(420px, 100%);
  padding: 18px;
  color: var(--ink);
  background: #12052e;
  border: 2px solid var(--pink);
  border-radius: 14px;
  box-shadow: 0 0 30px rgba(255, 46, 151, 0.35);
}
.ask-link h2 { margin: 0 0 8px; font-size: 18px; }
.ask-link .url { margin: 0 0 8px; padding: 8px 10px; font-family: monospace; font-size: 13px; word-break: break-all; background: rgba(255, 255, 255, 0.06); border-radius: 8px; }
.ask-link .choice { margin-top: 12px; }
.letter-form textarea {
  width: 100%;
  min-height: 90px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}
.letter-form select { width: 100%; margin: 6px 0; padding: 6px 8px; font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; }
.letter-form select option { color: #12052e; }
.letter-form summary { cursor: pointer; font-weight: 700; margin: 10px 0 6px; }
.letters li .when { color: var(--muted); font-size: 12px; }
.letters li.unread { border-color: var(--lime); }
.letters li p { margin: 4px 0; white-space: pre-wrap; }

/* ---------- Town Hall registry, Café board ---------- */
.card-body h3 { margin: 16px 0 8px; font-size: 14px; letter-spacing: 0.04em; color: var(--cyan); }
.finder { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 6px; }
.finder select { grid-column: 1 / -1; }
.finder input, .finder select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.finder select option { color: #12052e; }
.finder input:focus, .finder select:focus { outline: none; border-color: var(--cyan); }
.finder .pay { width: auto; margin: 0; padding: 8px 14px; }
.link-btn { all: unset; cursor: pointer; display: block; width: 100%; }
.link-btn:hover, .link-btn:focus-visible { color: var(--cyan); }
.move-to { margin-bottom: 12px; }
.share.warn { background: rgba(255, 228, 92, 0.12); border-color: rgba(255, 228, 92, 0.55); }
.share[hidden] { display: none; }
button.visit { padding: 0; background: none; border: 0; cursor: pointer; }
.finder[hidden] { display: none; }
.tg-link { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; opacity: 0.85; }
.tg-link:hover { opacity: 1; text-decoration: underline; }
