:root {
  --ink: #241d33;
  --ink2: #4a4063;
  --mute: #6d6683;
  --paper: #fffaf0;
  --cream: #fdf6e3;
  --line: #e6dcc4;
  --yellow: #f3cc4f;
  --red: #e0524a;
  --green: #62a548;
  --blue: #4b72c8;
  --sea: #2c5491;
  --t3: #f0c040;
  --t2: #8f63c9;
  --t1: #4b72c8;
  --t0: #aaa6b6;
  --r: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --pixel: "Pixelify Sans", ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--sea);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2, h3 { font-family: var(--pixel); margin: 0; }
h3 { font-size: 18px; margin: 18px 0 8px; }
small, .mute { color: var(--mute); }
a { color: var(--blue); }

#map { position: fixed; inset: 0; background: var(--sea); }
.leaflet-container { background: var(--sea); font: inherit; outline: none; }
.leaflet-tile, .pip-marker, .px { image-rendering: crisp-edges; image-rendering: pixelated; }

/* ---------------------------------------------------------------- top bar */
#top {
  position: fixed; z-index: 1000;
  top: calc(8px + var(--safe-t)); left: 8px; right: 8px;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
#top > * { pointer-events: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 4px 12px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  font: 600 15px var(--pixel); white-space: nowrap;
}
.chip img { width: 28px; height: 35px; margin: -6px -2px -4px -6px; image-rendering: pixelated; }
#brand span { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
#phase { flex: 1; justify-content: center; min-width: 0; max-width: 460px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; }
#phase.hide { background: #e9f6df; }
#phase.seek { background: #fff1c2; }
#phase.market { background: #f2e9ff; }
#meChip { padding: 4px 10px; }
#meChip img { margin: -6px -4px -4px -4px; }

#banner {
  position: fixed; z-index: 990;
  top: calc(62px + var(--safe-t)); left: 8px; right: 8px;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: 0 3px 0 var(--ink); padding: 8px 40px 8px 12px; font-weight: 600;
}
#banner button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 18px; min-width: 32px; min-height: 32px; }

/* ------------------------------------------------------------- HUD + tabs */
#hud {
  position: fixed; z-index: 999;
  left: 8px; right: 8px; bottom: calc(82px + var(--safe-b));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
#hud > * { pointer-events: auto; }
.panel {
  background: var(--cream); border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: 0 4px 0 var(--ink); padding: 10px 12px;
}
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat b { font: 700 22px var(--pixel); }
.stat small { font-size: 12px; }
#pop .taunt { font: 600 15px var(--pixel); background: #fff7d6; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 10px; margin: 8px 0; }
.hunted { display: block; width: 100%; margin-top: 8px; padding: 6px 10px; border: 2px dashed var(--ink2); border-radius: 10px; background: #fff7d6; font: 600 13px var(--pixel); text-align: left; color: var(--ink); }
.hint {
  align-self: center; background: rgba(36, 29, 51, .86); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
}

#tabs {
  position: fixed; z-index: 1000;
  left: 8px; right: 8px; bottom: calc(8px + var(--safe-b));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--ink); border-radius: 18px; padding: 5px;
}
#tabs button {
  min-height: 54px; border: 0; border-radius: 13px; background: transparent; color: #d8d5e0;
  font: 600 13px var(--pixel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  position: relative;
}
#tabs button span { font-size: 19px; line-height: 1; }
#tabs button.on { background: var(--yellow); color: var(--ink); }
#tabs button .dot { position: absolute; top: 6px; right: 18%; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); }

/* ------------------------------------------------------------------ buttons */
.btn {
  appearance: none; border: 3px solid var(--ink); border-radius: 12px;
  background: var(--yellow); color: var(--ink); box-shadow: 0 4px 0 var(--ink);
  font: 700 17px var(--pixel); padding: 8px 14px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.white { background: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.small { min-height: 40px; font-size: 15px; padding: 4px 10px; }
.btn.block { width: 100%; }
.linkbtn { border: 0; background: none; color: var(--blue); text-decoration: underline; padding: 8px 0; font-weight: 600; }

/* ------------------------------------------------------------------- sheet */
#scrim { position: fixed; inset: 0; z-index: 1050; background: rgba(36, 29, 51, .38); opacity: 0; pointer-events: none; transition: opacity .2s; }
#scrim.on { opacity: 1; pointer-events: auto; }
#sheet {
  position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0;
  max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--paper); border-top: 3px solid var(--ink); border-radius: 22px 22px 0 0;
  transform: translateY(105%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b);
}
#sheet.open { transform: none; }
#sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #cfc8dc; margin: 8px auto 4px; flex: none; }
#sheet .head { display: flex; align-items: center; justify-content: space-between; padding: 2px 12px 8px 16px; flex: none; }
#sheet .head h2 { font-size: 22px; }
#sheet .close { border: 0; background: none; font-size: 20px; min-width: 44px; min-height: 44px; }
#sheet .body { overflow-y: auto; padding: 0 16px 20px; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) {
  #sheet { left: auto; right: 16px; bottom: 16px; width: 420px; border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); transform: translateY(120%); }
  #hud { left: auto; right: 16px; width: 420px; }
  #tabs { left: auto; right: 16px; width: 420px; }
}

.seg { display: grid; grid-auto-flow: column; gap: 4px; background: #efe6d2; border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.seg button { border: 0; border-radius: 9px; min-height: 40px; background: transparent; font: 600 14px var(--pixel); }
.seg button.on { background: #fff; box-shadow: 0 2px 0 var(--ink); }

.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: #fff; border: 2px solid var(--line); border-radius: 12px; min-height: 52px; }
.item.me { border-color: var(--ink); background: #fff7d6; }
.item .pos { width: 30px; font: 700 16px var(--pixel); text-align: center; color: var(--mute); }
.item img { width: 32px; height: 40px; image-rendering: pixelated; flex: none; }
.item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .num { font: 700 18px var(--pixel); text-align: right; }

.award { display: flex; align-items: center; gap: 10px; padding: 10px; }
.award-emoji { font-size: 28px; width: 34px; text-align: center; }
.award img { width: 32px; height: 40px; image-rendering: pixelated; }
.flagbig { font-size: 28px; width: 34px; text-align: center; }
.select { width: 100%; font: 16px system-ui, sans-serif; padding: 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); }
.seg button { padding: 0 2px; }
.tier { display: inline-block; padding: 1px 7px; border-radius: 999px; font: 600 12px var(--pixel); border: 2px solid var(--ink); }
.tier.t3 { background: var(--t3); }
.tier.t2 { background: var(--t2); color: #fff; }
.tier.t1 { background: var(--t1); color: #fff; }
.tier.t0 { background: #eceaf1; }

.card { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px; box-shadow: 0 4px 0 var(--ink); }
.listing { display: grid; grid-template-columns: 40px 1fr; gap: 4px 10px; align-items: start; }
.listing.featured { background: #fff7d6; }
.listing img { width: 40px; height: 50px; image-rendering: pixelated; grid-row: span 2; }
.listing .pname { font: 700 18px var(--pixel); }
.listing .pitch { color: var(--ink2); }
.listing .foot { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.report { border: 0; background: none; color: var(--mute); font-size: 13px; min-height: 40px; }

label.field { display: block; margin: 10px 0; font-weight: 600; }
label.field span { display: block; margin-bottom: 4px; }
input[type=text], input[type=url], textarea {
  width: 100%; font: 16px system-ui, sans-serif; padding: 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 3px solid var(--yellow); outline-offset: 1px; }
.prefix { display: flex; align-items: center; border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding-left: 12px; font-weight: 700; }
.prefix input { border: 0; padding-left: 4px; }
.err { color: var(--red); font-weight: 600; min-height: 1.4em; }

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.swatches button { aspect-ratio: 1; border-radius: 10px; border: 3px solid transparent; min-height: 34px; }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 2px solid var(--ink); border-radius: 999px; background: #fff; padding: 6px 12px; min-height: 40px; font: 600 14px var(--pixel); }
.chips button.on { background: var(--yellow); }
.preview { display: flex; align-items: flex-end; justify-content: center; height: 170px; background: linear-gradient(#bfe0f5, #bfe0f5 60%, #86c35b 60%); border: 3px solid var(--ink); border-radius: 16px; }
.preview img { width: 128px; height: 160px; image-rendering: pixelated; margin-bottom: -2px; }

.code { font: 700 26px ui-monospace, Menlo, monospace; letter-spacing: 2px; text-align: center; padding: 14px; background: #fff; border: 3px dashed var(--ink); border-radius: 12px; user-select: all; }
pre.share { white-space: pre-wrap; font: 15px/1.45 system-ui, sans-serif; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 10px; }
.steps { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; }
.step .ico { font-size: 30px; text-align: center; }
.spot { display: flex; gap: 6px; justify-content: center; align-items: flex-end; background: #86c35b; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 4px 2px; }
.spot figure { margin: 0; text-align: center; font: 600 11px var(--pixel); }
.spot img { width: 48px; height: 60px; image-rendering: pixelated; display: block; }
.spot figure.real figcaption { background: var(--yellow); border: 2px solid var(--ink); border-radius: 6px; }

.hide-preview { width: 96px; height: 96px; border: 3px solid var(--ink); border-radius: 10px; flex: none; background: var(--sea); }
.meter { height: 12px; background: #eceaf1; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.meter i { display: block; height: 100%; background: var(--green); transition: width .2s; }
.meter.bad i { background: var(--red); }

/* ---------------------------------------------------------- pop + toast */
#pop {
  position: fixed; z-index: 1200; left: 50%; top: 44%;
  width: min(330px, calc(100vw - 32px)); transform: translate(-50%, -50%) scale(.85);
  opacity: 0; pointer-events: none; transition: .18s ease-out; text-align: center;
}
#pop.on { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
#pop .card { padding: 16px; }
#pop .big { font: 700 28px var(--pixel); margin: 2px 0; }
#pop img.hero { width: 128px; height: 160px; image-rendering: pixelated; margin: -24px auto -8px; display: block; }
#toast {
  position: fixed; z-index: 1300; left: 50%; top: calc(64px + var(--safe-t));
  transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; transition: .2s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------- map bits */
.found-badge { background: var(--green); color: #fff; border: 2px solid var(--ink); border-radius: 50%; font: 700 12px/16px system-ui; text-align: center; box-shadow: 0 2px 0 var(--ink); }
.tag-anchor { width: 0 !important; height: 0 !important; overflow: visible; }
.tag-anchor > span { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); white-space: nowrap; }
.you-tag, .reveal-tag {
  background: var(--cream); border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px;
  font: 600 12px/18px var(--pixel); text-align: center; cursor: pointer;
}
.you-tag { background: var(--yellow); }
.reveal-tag.t3 { background: var(--t3); }
.reveal-tag.t2 { background: var(--t2); color: #fff; }
.reveal-tag.t1 { background: var(--t1); color: #fff; }
.reveal-tag.house { background: #fff1c2; }
.reveal-tag.prank { background: #ffd6e4; }
.shake { animation: shake .45s ease-in-out; }
@keyframes shake { 20% { transform: translateX(-8px) rotate(-2deg); } 40% { transform: translateX(8px) rotate(2deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.map-label { font: 700 13px var(--pixel); color: #fff; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); pointer-events: none; }
.map-label.small { font-size: 11px; color: #fff1c2; }
.miss-ring { width: 100%; height: 100%; border: 3px solid var(--red); border-radius: 50%; animation: ring .55s ease-out forwards; }
@keyframes ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.placing { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 3px 0 rgba(36, 29, 51, .5)); animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { margin-top: -4px; } }

.confetti { position: fixed; z-index: 1250; width: 9px; height: 9px; pointer-events: none; animation: fly 1s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(540deg); opacity: 0; } }

.noscript { position: fixed; inset: 40% 16px auto; background: #fff; padding: 16px; border-radius: 12px; text-align: center; }

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