/* Dibs — City Guide materials: warm paper, navy ink, lake teal, serif display.
   Crew colours come from js/core.js and are set as CSS vars at runtime. */
:root {
  --bg: #FBF8F2; --card: #FFFFFF; --group: #F1ECE3; --line: #E4DED3;
  --ink: #13243B; --ink-2: #4A5B70; --ink-3: #6B788B; --accent: #2E7D8A;
  --ok: #3C8C5A; --warn: #C77B1A; --bad: #C0392B;
  --shadow: 0 10px 30px rgba(19, 36, 59, .16), 0 2px 6px rgba(19, 36, 59, .08);
  --radius: 18px; --serif: 'Instrument Serif', Georgia, serif; --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --crew: var(--accent); --crew-ink: #fff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0A111C; --card: #141E2C; --group: #1B2736; --line: #283446; --ink: #F2EEE6; --ink-2: #C2C9D3; --ink-3: #8F9AAA; --accent: #62B6C3; --shadow: 0 10px 30px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#map { position: fixed; inset: 0; background: var(--group); }
.leaflet-container { font: inherit; background: var(--group); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.7); color: #445; }
@media (prefers-color-scheme: dark) { #map, .leaflet-container { background: #0b0d10; } .leaflet-control-attribution { background: rgba(10,17,28,.7); color: #aab; } .leaflet-control-attribution a { color: #8cc; } }

/* ---- top bar ---- */
.top { position: fixed; top: calc(8px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: center; justify-content: space-between; z-index: 1000; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 8px; background: var(--card); padding: 6px 14px 7px; border-radius: 999px; box-shadow: var(--shadow); }
.brand .word { font-family: var(--serif); font-size: 26px; line-height: 1; letter-spacing: -.01em; }
.brand .sub { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.top-actions { display: flex; gap: 8px; }
.round { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; font-size: 18px; }
.round:active { transform: scale(.95); }
.round .badge { position: absolute; top: -3px; right: -3px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; }
.round { position: relative; }

.bounty { position: fixed; top: calc(62px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1000; border: 0; background: var(--ink); color: #FBF8F2; padding: 7px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); display: flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }
.bounty .star { color: #FFD166; }
.bounty b { font-weight: 600; }
.bounty.done { background: var(--ok); }
@media (prefers-color-scheme: dark) { .bounty { background: #F2EEE6; color: #0A111C; } }

.hint { position: fixed; top: calc(102px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1000; background: rgba(19,36,59,.85); color: #fff; padding: 6px 12px; border-radius: 10px; font-size: 12px; }

/* ---- dock ---- */
.dock { position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); z-index: 1000; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 14px 16px 12px; }
.here-eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.here-eyebrow .tag { background: var(--group); color: var(--ink-2); padding: 1px 7px; border-radius: 999px; letter-spacing: .04em; text-transform: none; font-size: 11px; }
.here-name { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; margin: 4px 0 4px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.here-name .lm { font-size: 18px; color: #E0A800; }
.here-status { font-size: 13.5px; color: var(--ink-2); min-height: 18px; }
.here-status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; background: var(--dotc, var(--ink-3)); }
.claim { margin-top: 12px; width: 100%; border: 0; border-radius: 16px; padding: 16px; font-weight: 700; font-size: 17px; letter-spacing: .12em; text-transform: uppercase; background: var(--crew); color: var(--crew-ink); box-shadow: 0 6px 0 rgba(0,0,0,.18); cursor: pointer; transition: transform .08s, box-shadow .08s, background .2s; }
.claim:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.claim:disabled { background: var(--group); color: var(--ink-3); box-shadow: none; cursor: default; }
.claim.quiet { background: var(--group); color: var(--ink); box-shadow: none; }
.claim.busy { opacity: .7; }
.gps { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-3); }
.gps .g { display: flex; align-items: center; gap: 5px; }
.gps .g::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.gps .g.good::before { background: var(--ok); } .gps .g.fuzzy::before { background: var(--warn); } .gps .g.bad::before { background: var(--bad); }
.gps button { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; }

/* ---- sheets ---- */
.sheet { border: 0; padding: 0; margin: 0; width: 100%; max-width: 100%; background: transparent; inset: auto 0 0 0; max-height: 100%; }
.sheet:focus, .sheet:focus-visible { outline: none; }
.sheet::backdrop { background: rgba(10, 17, 28, .45); }
.sheet .panel { background: var(--card); color: var(--ink); border-radius: 24px 24px 0 0; padding: 8px 18px calc(22px + var(--safe-b)); max-height: min(88vh, 760px); overflow: auto; box-shadow: 0 -10px 30px rgba(0,0,0,.2); }
.sheet.small .panel { border-radius: 24px 24px 0 0; }
@media (min-width: 720px) { .sheet { inset: 0; display: grid; place-items: center; } .sheet[open] { display: grid; } .sheet .panel { width: 520px; border-radius: 24px; max-height: 86vh; } }
.grab { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 12px; }
.panel h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0 0 2px; letter-spacing: -.01em; }
.panel h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 8px; font-weight: 600; }
.panel p { margin: 6px 0; line-height: 1.45; color: var(--ink-2); font-size: 14.5px; }
.panel .close { position: absolute; right: 14px; top: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--group); cursor: pointer; font-size: 16px; }
.panel { position: relative; }
.field { margin: 12px 0; }
.field label { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.field input { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); }
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.crews { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.crew-btn { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; text-align: left; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.crew-btn .sw { width: 18px; height: 20px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--c); flex: none; }
.crew-btn b { display: block; font-size: 14px; font-weight: 600; }
.crew-btn small { display: block; font-size: 11px; color: var(--ink-3); line-height: 1.25; }
.crew-btn.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--card)); }
.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--ink); color: var(--bg); width: 100%; cursor: pointer; margin-top: 14px; font-size: 15px; }
.btn.ghost { background: var(--group); color: var(--ink); }
.btn.crew { background: var(--crew); color: var(--crew-ink); }
.btn:disabled { opacity: .5; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 16px; }

.tabs { display: flex; gap: 4px; background: var(--group); border-radius: 12px; padding: 4px; margin: 12px 0; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.list li:last-child { border-bottom: 0; }
.list .rank { width: 26px; color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 13px; }
.list .sw { width: 12px; height: 14px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--c); flex: none; }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .name small { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.list .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.list .sub { font-size: 12px; color: var(--ink-3); }
.list li.me { background: color-mix(in srgb, var(--crew) 10%, transparent); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 10px; }
.list li.tap { cursor: pointer; }
.bar { height: 6px; background: var(--group); border-radius: 6px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--c); }
.feed li { display: block; line-height: 1.4; }
.feed .when { color: var(--ink-3); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--group); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-size: 24px; font-family: var(--serif); font-weight: 400; }
.stat span { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.rules li { margin: 6px 0; font-size: 14px; color: var(--ink-2); }
.rules b { color: var(--ink); }
.meta { font-size: 12px; color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 14px; padding: 12px 0; }

/* ---- map bits ---- */
.lm-icon { font-size: 13px; color: #B88600; text-shadow: 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; text-align: center; line-height: 1; }
.bounty-icon { position: relative; width: 28px; height: 28px; pointer-events: none; }
.bounty-icon::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid #FFB703; animation: ring 1.8s ease-out infinite; }
.bounty-icon::after { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; color: #E08A00; font-size: 18px; text-shadow: 0 0 4px #fff, 0 0 4px #fff; }
@keyframes ring { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
.me-icon { width: 18px; height: 18px; border-radius: 50%; background: #2563EB; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(37,99,235,.35), 0 2px 6px rgba(0,0,0,.3); }
.me-icon.stale { background: #94A3B8; }
.leaflet-bottom.leaflet-right { bottom: 160px; }

/* ---- toast + confetti ---- */
.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(var(--dock-h, 200px) + 24px + var(--safe-b)); z-index: 1200; background: var(--ink); color: #FBF8F2; padding: 12px 18px; border-radius: 16px; font-size: 15px; box-shadow: var(--shadow); max-width: calc(100vw - 40px); text-align: center; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.big { font-family: var(--serif); font-size: 22px; padding: 16px 22px; background: var(--crew); color: var(--crew-ink); }
.toast.big small { display: block; font-family: var(--sans); font-size: 13px; opacity: .9; margin-top: 2px; }
.toast.bad { background: var(--bad); color: #fff; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1100; overflow: hidden; }
#confetti i { position: absolute; width: 10px; height: 14px; top: -20px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .2; } }

/* ---- welcome ---- */
.welcome .hero { font-family: var(--serif); font-size: 34px; line-height: 1.05; margin: 6px 0 8px; letter-spacing: -.01em; }
.welcome .hero em { font-style: italic; color: var(--accent); }
.steps { display: grid; gap: 8px; margin: 12px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--group); border-radius: 14px; padding: 10px 12px; font-size: 14px; color: var(--ink-2); }
.step b { display: block; color: var(--ink); font-size: 15px; }
.step .n { font-family: var(--serif); font-size: 22px; color: var(--accent); line-height: 1; }

@media (min-width: 720px) { .dock { left: 50%; right: auto; transform: translateX(-50%); width: 460px; } }

@media (prefers-reduced-motion: reduce) { .bounty-icon::before { animation: none; } .toast, .claim { transition: none; } #confetti i { display: none; } }
