:root {
  --green: #1f7a4d;
  --red: #c62828;
  --grey: #6b6b6b;
  --ink: #1b1b1b;
  --paper: #fff;
  --line: #ddd;
  --bar: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; height: 100dvh; background: #f4f4f1; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--green); color: #fff;
}
.brand { font-size: 1.1rem; }
.score { font-size: .95rem; }

main { flex: 1; position: relative; min-height: 0; }
.view { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

.gps {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 500; background: rgba(0,0,0,.75); color: #fff; font-size: .8rem;
  padding: 5px 10px; border-radius: 12px; white-space: nowrap;
}
.gps.good { background: rgba(31,122,77,.9); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.seg button { border: 0; border-radius: 0; background: #fff; min-height: 36px; padding: 0 14px; }
.seg button.on { background: var(--green); color: #fff; font-weight: 700; }
.me-row td { font-weight: 700; background: #eef5f0; }
.share-img { display: block; width: 100%; max-height: 60dvh; object-fit: contain; border-radius: 10px; background: #eee; }
.nearby-btn {
  position: absolute; top: 44px; right: 10px; z-index: 500; background: #fff; border: 0; font-weight: 600;
  padding: 0 12px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.nearby { list-style: none; margin: 0; padding: 0; }
.nearby li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.nearby img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #eee; }
.nearby .n-main { min-width: 0; }
.nearby .n-dist { font-weight: 700; }
.nearby .n-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.nearby .n-actions > * { min-height: 36px; padding: 0 10px; font-size: .9rem; }
a.ghost { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; }
select { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.alert-on { background: #eef5f0; border-radius: 10px; padding: 10px; }
.toggle {
  position: absolute; bottom: 12px; left: 10px; z-index: 500; background: #fff;
  padding: 6px 10px; border-radius: 8px; font-size: .85rem; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.view.scroll { overflow-y: auto; padding: 16px; }
.bottom {
  display: grid; grid-template-columns: 1fr 1fr 1.25fr 1fr; gap: 6px;
  padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
button { font: inherit; cursor: pointer; border-radius: 10px; min-height: 44px; }
.bottom button { white-space: nowrap; padding: 0 4px; }
@media (max-width: 360px) { .bottom button { font-size: .9rem; } }
.tab { background: none; border: 1px solid var(--line); }
.tab.active { border-color: var(--green); color: var(--green); font-weight: 600; }
.spot, .primary { background: var(--green); color: #fff; border: 0; font-weight: 600; padding: 0 16px; }
.primary:disabled { background: #9bb8a8; cursor: not-allowed; }
.ghost { background: none; border: 1px solid var(--line); padding: 0 16px; }
.link { background: none; border: 0; color: var(--grey); text-decoration: underline; min-height: 36px; margin-top: 6px; }

dialog {
  width: min(94vw, 440px); max-height: 92dvh; border: 0; border-radius: 16px; padding: 18px;
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin: 0 0 10px; font-size: 1.2rem; }
dialog label { display: block; margin: 10px 0; }
dialog input[type=text], dialog input:not([type]) {
  display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px;
}
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; padding: 8px 10px; }
legend { font-weight: 600; padding: 0 4px; }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.err { color: var(--red); min-height: 1em; margin: 6px 0 0; font-weight: 600; }
.err:empty { display: none; }
.hint { color: var(--grey); margin: 6px 0 0; }
.hint:empty { display: none; }

.photo-slot { position: relative; border: 2px dashed var(--line); border-radius: 12px; padding: 10px; cursor: pointer; }
.photo-slot input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-slot input[type=file]:focus-visible ~ .cam { outline: 2px solid var(--ink); }
.cam { display: block; text-align: center; padding: 12px; border-radius: 10px; background: #eef5f0; color: var(--green); }
.photo-slot span { display: block; font-weight: 600; margin-bottom: 6px; }
.photo-slot img { display: block; width: 100%; max-height: 200px; object-fit: cover; border-radius: 8px; margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { margin: 0; position: relative; }
.chips input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; }
.chips span {
  display: inline-block; padding: 7px 11px; border: 1px solid var(--line); border-radius: 18px; font-size: .9rem;
}
.chips input:checked + span { background: var(--green); color: #fff; border-color: var(--green); }
.chips input:focus-visible + span { outline: 2px solid var(--ink); }
.choice { display: flex; gap: 8px; align-items: flex-start; }
.choice input { margin-top: 4px; }

.pin-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pin-photos figure { margin: 0; }
.pin-photos img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; }
.pin-photos figcaption { font-size: .8rem; color: var(--grey); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .8rem; font-weight: 600; color: #fff; }
.badge.open { background: var(--red); }
.badge.picked { background: var(--green); }
.badge.expired { background: var(--grey); }

/* Map markers: colour AND symbol, so they read in greyscale too. */
.pin { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  color: #fff; font-weight: 800; font-size: 17px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.open { background: var(--red); }
.pin.picked { background: var(--green); }
.pin.expired { background: var(--grey); }
.me { pointer-events: none; width: 16px; height: 16px; border-radius: 50%; background: #1e66d0; border: 3px solid #fff; box-shadow: 0 0 0 2px #1e66d0; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 90vw;
}

.card { background: #fff; border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.big { font-size: 2rem; font-weight: 800; }
.muted { color: var(--grey); font-size: .9rem; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.wide { width: 100%; margin-top: 6px; }
.small { font-size: .85rem; }
.danger { color: var(--red); border-color: var(--red); }
.code { font: 700 1.8rem/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .12em; text-align: center;
  background: #eef5f0; border-radius: 10px; padding: 12px; margin: 8px 0; user-select: all; }
.badges { list-style: none; margin: 0; padding: 0; }
.badge-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.badge-item:last-child { border-bottom: 0; }
.b-icon { font-size: 1.6rem; text-align: center; }
.b-text { display: flex; flex-direction: column; min-width: 0; }
.b-text .muted { font-size: .82rem; }
.b-state { font-size: .85rem; font-weight: 700; white-space: nowrap; }
/* earned vs locked: text ("✓ Earned" vs "3/10") AND look, so it reads without colour */
.badge-item.earned .b-state { color: var(--green); }
.badge-item.locked .b-icon { filter: grayscale(1); opacity: .45; }
.badge-item.locked .b-text b { color: var(--grey); }
.board { width: 100%; border-collapse: collapse; }
.board td, .board th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.board td:last-child, .board th:last-child { text-align: right; }
