/* ============ tokens ============ */
:root {
  --pix: 'Press Start 2P', ui-monospace, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --c-country: #3b82f6; --c-state: #22c55e; --c-city: #facc15; --c-landmark: #ff8a3d;
  --radius: 0px;
  --panel-w: min(420px, 38vw);
}
html[data-theme="midnight"] {
  --space: #050b18; --bg: #0e1c33; --bg-2: #142a4a; --bg-3: #1c375e; --ink: #e9f0fb; --ink-2: #9db0cc; --ink-3: #8fa3c4;
  --line: #2a4670; --edge: #06101f; --accent: #ffd447; --accent-ink: #1e1830; --glass: rgba(14, 28, 51, 0.88);
}
html[data-theme="atlas"] {
  --space: #1d1610; --bg: #f3ecdc; --bg-2: #e9e0cb; --bg-3: #dccfb2; --ink: #2f261d; --ink-2: #6b5c49; --ink-3: #655744;
  --line: #c9b994; --edge: #4a3b2a; --accent: #b4442e; --accent-ink: #fff7e8; --glass: rgba(243, 236, 220, 0.93);
}
html[data-theme="arcade"] {
  --space: #07021a; --bg: #1a0c3b; --bg-2: #24124f; --bg-3: #321a6b; --ink: #f6edff; --ink-2: #c3a9ff; --ink-3: #a995ec;
  --line: #4a2e99; --edge: #05010f; --accent: #00f5d4; --accent-ink: #12052e; --glass: rgba(26, 12, 59, 0.9);
}
html[data-theme="daylight"] {
  --space: #0d2238; --bg: #ffffff; --bg-2: #f1f5f9; --bg-3: #e2e8f0; --ink: #1d2433; --ink-2: #536076; --ink-3: #566377;
  --line: #d3dbe6; --edge: #1d2433; --accent: #2563eb; --accent-ink: #ffffff; --glass: rgba(255, 255, 255, 0.93);
}

/* ============ base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--space); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img { image-rendering: auto; }
canvas { image-rendering: pixelated; }

#map { position: fixed; inset: 0; z-index: 1; background: transparent; }
#stars { position: fixed; inset: 0; z-index: 0; background: var(--space); }
#stars::before, #stars::after { content: ''; position: absolute; inset: 0; background-image: var(--starfield); background-size: 320px 320px; opacity: .9; }
#stars::after { background-size: 520px 520px; opacity: .5; animation: twinkle 5s steps(2) infinite; }
@keyframes twinkle { 50% { opacity: .15; } }
.maplibregl-canvas { outline: none; }

/* pixel frame used by cards & buttons: notched corners */
.pix-frame {
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 6px 6px 0 0 rgba(0,0,0,.25);
}

/* ============ top bar ============ */
.topbar {
  position: fixed; z-index: 10; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; gap: 14px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; }
.brand, .search input, .top-actions .seg, .icon-btn, .account-btn, .ribbon, .legend, .map-ctrls button, .panel, .sheet-card, .toast, .hover-tip, .search-results {
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 6px 6px 0 0 rgba(0,0,0,.28);
}
.brand h1 { font-family: var(--pix); font-size: 11px; line-height: 1.5; margin: 0; letter-spacing: .5px; color: var(--ink); }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; letter-spacing: .4px; }
#brand-plane { width: 42px; height: 33px; animation: bob 2.4s steps(4) infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }

.search { position: relative; flex: 1; max-width: 520px; margin: 0 auto; }
.search input { width: 100%; height: 46px; border: 0; padding: 0 14px 0 42px; outline: none; font-size: 15px; }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { box-shadow: 0 -3px 0 0 var(--accent), 0 3px 0 0 var(--accent), -3px 0 0 0 var(--accent), 3px 0 0 0 var(--accent), 6px 6px 0 0 rgba(0,0,0,.28); }
.search-ico { position: absolute; z-index: 2; left: 14px; top: 15px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search-results { position: absolute; top: 56px; left: 0; right: 0; max-height: min(60vh, 520px); overflow-y: auto; padding: 6px 0; }
.sr-group { font-family: var(--pix); font-size: 8px; color: var(--ink-3); padding: 10px 14px 6px; letter-spacing: 1px; }
.sr-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px; }
.sr-item:hover, .sr-item.active { background: var(--bg-3); }
.sr-item .sr-sub { color: var(--ink-3); font-size: 12px; margin-left: auto; white-space: nowrap; }
.sr-item canvas { width: 27px; height: 27px; flex: none; }
.sr-item .flag { width: 22px; height: 16px; object-fit: cover; flex: none; }
.sr-item .dot { width: 10px; height: 10px; flex: none; background: var(--ink-3); }
.sr-item .dot.on { background: var(--c-city); }
.sr-empty { padding: 14px; color: var(--ink-3); font-size: 14px; }

.top-actions { display: flex; gap: 12px; align-items: center; }
.seg { display: flex; padding: 3px; }
.seg button { border: 0; background: none; padding: 8px 10px; font-family: var(--pix); font-size: 9px; white-space: nowrap; color: var(--ink-2); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.icon-btn { width: 44px; height: 44px; border: 0; font-size: 18px; display: grid; place-items: center; }
.account-btn { height: 44px; border: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 6px; font-family: var(--pix); font-size: 9px; }
.acct-avatar { width: 32px; height: 32px; display: grid; place-items: center; background: var(--bg-3); font-family: var(--pix); font-size: 11px; overflow: hidden; flex: none; }
.acct-avatar img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.sync-dot { width: 8px; height: 8px; background: var(--ink-3); display: inline-block; }
.sync-dot.synced { background: #3ddc84; } .sync-dot.saving, .sync-dot.connecting { background: var(--c-state); } .sync-dot.error { background: var(--c-city); }

/* quick add */
.quick-btn { height: 44px; border: 0; padding: 0 14px; font-family: var(--pix); font-size: 9px; display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 6px 6px 0 0 rgba(0,0,0,.28); }
.quick-btn span { font-family: var(--sans); font-size: 18px; font-weight: 700; }
.quick-card { width: min(640px, 100%); }
.quick-card textarea { width: 100%; margin: 12px 0 4px; border: 0; background: var(--bg-2); padding: 12px; font-size: 15px; line-height: 1.5; outline: none; resize: vertical; box-shadow: inset 0 0 0 2px var(--line); }
.quick-card textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); }
#quick-results { margin-top: 14px; display: grid; gap: 6px; }
.qr { display: grid; grid-template-columns: 22px minmax(70px, 140px) 1fr 26px; gap: 10px; align-items: center; background: var(--bg-2); padding: 8px 10px; font-size: 14px; }
.qr .st { font-size: 15px; text-align: center; }
.qr .q { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr select { width: 100%; min-width: 0; border: 0; padding: 7px 8px; background: var(--bg-3); font-size: 13px; color: var(--ink); }
.qr .nf { color: var(--ink-3); font-size: 13px; }
.qr .skip { border: 0; background: none; color: var(--ink-3); font-size: 15px; }
.qr.off { opacity: .45; }
.quick-foot { position: sticky; bottom: -22px; background: var(--glass); padding: 12px 0 4px; margin-top: 12px; }
.map-ctrls button.off { opacity: .45; filter: grayscale(1); }

/* icons */
.ico { width: 20px; height: 20px; flex: none; display: block; }
.map-ctrls button .ico { width: 21px; height: 21px; }
.icon-btn .ico { width: 21px; height: 21px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; }
.seg button .ico { width: 15px; height: 15px; }
.quick-btn .ico, .fab .ico { width: 17px; height: 17px; stroke-width: 3; }
.map-ctrls button.off { opacity: .4; filter: none; }
#toggle-wish:not(.off) { color: #f0abfc; }

/* tabs: icon over a readable label, on every screen size */
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 0 8px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 600; letter-spacing: 0; color: var(--ink-3); }
.tabs i { display: block; } .tabs .ico { width: 19px; height: 19px; }
.tabs button.active { background: none; box-shadow: inset 0 -3px 0 var(--accent); color: var(--ink); }
.tabs button:hover { color: var(--ink-2); }

/* wishlist */
.sw.hatch { background: repeating-linear-gradient(135deg, var(--wish) 0 2px, transparent 2px 6px), color-mix(in srgb, var(--wish) 18%, transparent); box-shadow: inset 0 0 0 1px var(--wish); }
.pix-btn.wish-btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 10px; color: #f0abfc; background: transparent;
  background-image: repeating-linear-gradient(135deg, rgba(232,121,249,.16) 0 3px, transparent 3px 9px); }
.pix-btn.wish-btn.on { color: #1e1830; background: #e879f9; }
.pop-btns .pix-btn.star { flex: 0 0 44px; font-size: 18px; font-family: var(--sans); color: #f0abfc; }
.pop-btns .pix-btn.star.on { background: #e879f9; color: #1e1830; }
.lb-mode, .qmode { display: flex; width: 100%; padding: 3px; background: var(--bg-2); }
.lb-mode button, .qmode button { flex: 1; font-size: 9px; padding: 10px 6px; }
.qmode { margin: 12px 0 0; }
.qmode button[data-qm="wish"].active, .lb-mode button[data-lbm="wish"].active { background: #e879f9; color: #1e1830; }
.wl { display: flex; align-items: center; gap: 8px; background: var(--bg-2); padding: 6px 6px 6px 8px; margin-bottom: 6px;
  background-image: repeating-linear-gradient(135deg, rgba(232,121,249,.08) 0 3px, transparent 3px 10px); }
.wl.done { opacity: .6; background-image: none; }
.wl-go { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 4px 0; color: var(--ink); }
.wl-go .flag { width: 30px; height: 22px; object-fit: cover; flex: none; } .wl-go canvas { flex: none; }
.wl-go span { min-width: 0; display: flex; flex-direction: column; } .wl-go b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-go small { color: var(--ink-3); font-size: 12px; }
.wl-done { font-size: 12px; color: #4ade80; white-space: nowrap; }
.wl-x { border: 0; background: none; color: var(--ink-3); width: 36px; height: 36px; font-size: 15px; flex: none; }

/* friends */
.tabs button { position: relative; }
.tabs button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  background: #f43f5e; color: #fff; font: 700 10px/16px var(--sans); text-align: center; }
.avatar { width: 44px; height: 44px; display: grid; place-items: center; font: 700 18px var(--pix); color: #fff; flex: none; box-shadow: 3px 3px 0 rgba(0,0,0,.3); }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; box-shadow: none; }
.me-card { display: flex; align-items: center; gap: 12px; background: var(--bg-2); padding: 12px; }
.me-card b { font-size: 17px; } .me-card > div:nth-child(2) { flex: 1; min-width: 0; }
.add-row { display: flex; align-items: center; gap: 8px; }
.add-row .at { font: 700 18px var(--sans); color: var(--ink-3); }
.add-row .filter-input { flex: 1; min-width: 0; }
.add-row .pix-btn { white-space: nowrap; }
.f-msg { min-height: 1.2em; margin: 8px 0 10px; } .f-msg.bad { color: #f87171; }
.req { display: flex; align-items: center; gap: 10px; background: var(--bg-2); padding: 8px 10px; margin-bottom: 6px; }
.req b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board { display: grid; gap: 6px; }
.lb { display: grid; grid-template-columns: 34px 28px 1fr auto; grid-template-rows: auto 6px; align-items: center; gap: 4px 10px; border: 0; background: var(--bg-2); padding: 9px 10px 8px; text-align: left; color: var(--ink); }
.lb:hover:not(:disabled) { background: var(--bg-3); } .lb:disabled { cursor: default; opacity: 1; }
.lb.me { box-shadow: inset 3px 0 0 var(--accent); }
.lb .rk { font-size: 18px; text-align: center; font-family: var(--pix); font-size: 11px; } .lb .rk:not(:empty) { font-size: 17px; }
.lb .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lb .nm small { color: var(--ink-3); font-weight: 400; }
.lb .val { font-family: var(--pix); font-size: 12px; }
.lb .bar { grid-column: 3 / 5; height: 6px; background: var(--bg-3); } .lb .bar i { display: block; height: 100%; background: var(--c-country); }
.vs-head { display: flex; justify-content: space-around; align-items: center; margin: 14px 0 4px; text-align: center; }
.vs-head > div { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; } .vs-head b { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.vs-head > .vs { flex-direction: row; align-items: baseline; gap: 0; font: 20px var(--pix); } .vs small { margin: 0 6px; color: var(--ink-3); }
.h2h { display: grid; gap: 10px; margin: 16px 0; }
.h2h-row { display: grid; grid-template-columns: 52px 1fr 52px; grid-template-rows: auto auto; align-items: center; gap: 2px 8px; }
.h2h-row b { font: 12px var(--pix); color: var(--ink-2); } .h2h-row b:last-of-type { text-align: right; } .h2h-row b.win { color: var(--ink); }
.h2h-row b.win::after { content: ' ★'; color: var(--accent); }
.h2h-row span { grid-column: 1 / 4; grid-row: 2; text-align: center; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.h2h-bar { display: flex; height: 12px; background: var(--bg-3); } .h2h-bar i { display: block; height: 100%; } .h2h-bar .a { background: var(--c-country); } .h2h-bar .b { background: #f43f5e; }
.flag-wall { display: flex; flex-wrap: wrap; gap: 6px; } .flag-wall .flag { width: 30px; height: 22px; object-fit: cover; box-shadow: 0 0 0 2px var(--edge); }
.compare-bar { position: fixed; z-index: 12; top: 76px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 14px; font-size: 13px; white-space: nowrap;
  background: var(--glass); box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 5px 5px 0 rgba(0,0,0,.3); }
.compare-bar[hidden] { display: none; }
.compare-bar span { display: flex; align-items: center; gap: 6px; } .compare-bar button { border: 0; background: var(--bg-3); width: 32px; height: 32px; font-size: 15px; }
.sw { width: 12px; height: 12px; display: inline-block; } .sw.both { background: #a855f7; } .sw.you { background: var(--c-country); } .sw.them { background: #f43f5e; }

/* ============ ribbon ============ */
.ribbon { position: fixed; z-index: 9; top: 88px; left: 12px; display: flex; gap: 2px; padding: 6px; }
.rb { display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 4px 6px; }
.rb b { font-family: var(--pix); font-size: 13px; }
.rb span { font-size: 10px; letter-spacing: .6px; color: var(--ink-3); text-transform: uppercase; margin-top: 5px; }
.rb i { width: 100%; height: 3px; margin-top: 5px; }

/* ============ legend ============ */
.ribbon:empty, .legend:empty { display: none; }
.legend { position: fixed; z-index: 9; left: 12px; bottom: 34px; padding: 10px 12px; font-size: 12px; display: grid; gap: 6px; }
.legend .lg { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 14px; height: 14px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.legend .lg-title { font-family: var(--pix); font-size: 8px; color: var(--ink-3); letter-spacing: 1px; margin-bottom: 2px; }

/* ============ map controls ============ */
.map-ctrls { position: fixed; z-index: 9; right: calc(var(--panel-w) + 36px); bottom: 34px; display: flex; flex-direction: column; gap: 10px; }
.map-ctrls button { width: 42px; height: 42px; border: 0; font-size: 18px; font-family: var(--pix); display: grid; place-items: center; }
.map-ctrls button:active, .pix-btn:active { transform: translate(2px, 2px); }
.maplibregl-ctrl-bottom-left { left: 190px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ============ hover tip ============ */
.hover-tip { position: fixed; z-index: 12; pointer-events: none; padding: 6px 10px; font-size: 13px; white-space: nowrap; transform: translate(14px, 14px); }
.hover-tip small { color: var(--ink-3); margin-left: 6px; }

/* ============ panel ============ */
.panel { position: fixed; z-index: 10; top: 76px; right: 15px; bottom: 15px; width: var(--panel-w); display: flex; flex-direction: column; }
.panel-grip { display: none; }
.tabs { display: flex; border-bottom: 3px solid var(--edge); }
.tabs button { flex: 1; min-width: 0; border: 0; background: none; white-space: nowrap; }
.panel-body { flex: 1; overflow-y: auto; padding: 18px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

.p-title { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.p-title h2 { font-family: var(--sans); font-size: 24px; line-height: 1.15; font-weight: 700; margin: 0; }
.p-title .flag { width: 40px; height: 30px; object-fit: cover; box-shadow: 0 0 0 3px var(--edge); flex: none; }
.p-title canvas { width: 54px; height: 54px; flex: none; }
.crumbs { font-size: 13px; color: var(--ink-3); margin: 2px 0 14px; }
.crumbs a { color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin: 10px 0 16px; }
.kv b { color: var(--ink); font-weight: 600; }
.p-sec { margin-top: 22px; }
.p-sec h3, .sheet-card h3 { font-family: var(--pix); font-size: 9px; letter-spacing: 1px; color: var(--ink-3); margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.p-sec h3 span { font-family: var(--sans); font-size: 12px; letter-spacing: 0; color: var(--ink-2); }
.panel a, .sheet-card a { color: var(--accent); }
.muted { color: var(--ink-3); font-size: 13px; line-height: 1.5; }
.blurb { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin: 8px 0 14px; }

/* pixel buttons */
.pix-btn {
  border: 0; font-family: var(--pix); font-size: 10px; padding: 12px 16px; background: var(--bg-3); color: var(--ink);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset -3px -3px 0 rgba(0,0,0,.18), inset 3px 3px 0 rgba(255,255,255,.12);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; letter-spacing: .5px; text-decoration: none;
}
.pix-btn.small { font-size: 8px; padding: 9px 11px; }
.pix-btn.ghost { background: transparent; }
.pix-btn.danger { color: var(--c-city); }
.pix-btn.primary { background: var(--accent); color: var(--accent-ink); }
.pix-btn.been { width: 100%; padding: 15px; font-size: 11px; }
.pix-btn.been.on { background: var(--btn-on, var(--c-country)); color: #111; }
.pix-btn.been .box { width: 14px; height: 14px; box-shadow: inset 0 0 0 3px currentColor; display: inline-grid; place-items: center; font-size: 10px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.field { display: grid; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.field input, .field textarea, .filter-input {
  border: 0; background: var(--bg-2); padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
  box-shadow: inset 0 0 0 2px var(--line);
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field textarea:focus, .filter-input:focus { box-shadow: inset 0 0 0 2px var(--accent); }

/* lists with checkboxes */
.ck-list { display: grid; gap: 2px; }
.ck { display: flex; align-items: center; gap: 10px; padding: 7px 8px; cursor: pointer; font-size: 14px; user-select: none; }
.ck:hover { background: var(--bg-2); }
.ck .bx { width: 16px; height: 16px; flex: none; box-shadow: inset 0 0 0 2px var(--ink-3); display: grid; place-items: center; }
.ck.on .bx { background: var(--ck, var(--c-city)); box-shadow: inset 0 0 0 2px rgba(0,0,0,.35); }
.ck.on .bx::after { content: ''; width: 6px; height: 6px; background: #111; }
.ck .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck .sub { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.ck .go { border: 0; background: none; color: var(--ink-3); padding: 0 4px; font-size: 14px; }
.ck .go:hover { color: var(--ink); }
.ck .cap { font-size: 10px; color: var(--accent); }
.more-btn { margin-top: 8px; }

/* progress bar */
.bar { height: 12px; background: var(--bg-2); box-shadow: inset 0 0 0 2px var(--line); position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 2px auto 2px 2px; background: var(--fill, var(--c-country));
  background-image: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,.18) 6px 8px); }

/* landmark chips + collection. Not ticked: the real sprite, dimmed. Ticked: full colour and a landmark-coloured frame. */
.lm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lm-chip-w { display: inline-flex; align-items: stretch; background: var(--bg-2); }
.lm-chip { display: flex; align-items: center; gap: 8px; border: 0; background: var(--bg-2); padding: 4px 10px 4px 4px; font-size: 13px; text-align: left; color: inherit; }
.lm-chip-w .lm-chip { background: transparent; color: var(--ink-2); }
.lm-chip canvas { width: 36px; height: 36px; }
.lm-chip.on { box-shadow: inset 0 0 0 2px var(--c-landmark); }
.lm-chip-w .lm-chip.on { color: var(--ink); background: color-mix(in srgb, var(--c-landmark) 16%, transparent); }
.chip-loc, .dex-loc, .ck .loc { border: 0; background: none; color: var(--ink-3); display: grid; place-items: center; cursor: pointer; padding: 0; }
.chip-loc { width: 32px; flex: none; }
.ck .loc { min-width: 30px; align-self: stretch; }
.chip-loc .ico, .dex-loc .ico, .ck .loc .ico { width: 16px; height: 16px; }
.chip-loc:hover, .dex-loc:hover, .ck .loc:hover { color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { border: 0; padding: 6px 9px; font-size: 12px; background: var(--bg-2); color: var(--ink-2); }
.chip.active { background: var(--accent); color: var(--accent-ink); }
.tap-hint { margin: -6px 0 10px; }
.tap-hint .ico { display: inline-block; width: 13px; height: 13px; vertical-align: -2px; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.dex-item { position: relative; display: flex; }
.dex-card { flex: 1; border: 0; background: var(--bg-2); color: var(--ink-2); padding: 8px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; line-height: 1.25; text-align: center; position: relative; min-height: 112px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.dex-card canvas { width: 54px; height: 54px; }
.dex-card.on { color: var(--ink); background: color-mix(in srgb, var(--c-landmark) 14%, var(--bg-2)); box-shadow: inset 0 0 0 2px var(--c-landmark); }
.dex-card.on::after { content: '★'; position: absolute; top: 4px; left: 7px; color: var(--c-landmark); font-size: 13px; }
.dex-card:hover { background: var(--bg-3); }
.dex-card.on:hover { background: color-mix(in srgb, var(--c-landmark) 22%, var(--bg-2)); }
.dex-loc { position: absolute; top: 0; right: 0; width: 32px; height: 32px; }
.dex-no { font-family: var(--pix); font-size: 7px; color: var(--ink-3); }
/* dimmed until ticked: in every landmark list */
.dex-card:not(.on) canvas, .lm-chip-w .lm-chip:not(.on) canvas, .lm-ck:not(.on) canvas { filter: grayscale(.75) brightness(.62) contrast(.9); opacity: .85; }
/* the moment it is ticked: a pixel pop and a ring in the landmark colour */
.just canvas { animation: lm-pop .45s steps(5) both; }
.dex-card.just::before, .lm-chip.just::before { content: ''; position: absolute; inset: 0; box-shadow: 0 0 0 0 var(--c-landmark); animation: lm-ring .5s steps(5) both; pointer-events: none; }
.lm-chip { position: relative; }
.unjust canvas { animation: lm-drop .25s steps(3) both; }
@keyframes lm-pop { 0% { transform: scale(.8); filter: brightness(1.8); } 40% { transform: scale(1.28) rotate(-4deg); } 70% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes lm-ring { 0% { box-shadow: 0 0 0 0 var(--c-landmark); opacity: 1; } 100% { box-shadow: 0 0 0 9px var(--c-landmark); opacity: 0; } }
@keyframes lm-drop { 0% { transform: scale(1); } 50% { transform: scale(.88); } 100% { transform: scale(1); } }
.lm-ck.just .bx { animation: lm-pop .35s steps(4) both; }
.toast .t-undo { pointer-events: auto; margin-left: 10px; border: 0; background: var(--bg-3); color: var(--ink); font: inherit; font-weight: 700; padding: 6px 10px; cursor: pointer; }
.toast:not(.show) .t-undo { pointer-events: none; }
.sg-c.open .chev { transform: rotate(90deg); }
.sg-body:not(:empty) { padding: 0 2px 10px; }
.sg-go { width: 100%; margin-top: 8px; }

/* logbook list */
.cont-h { font-family: var(--pix); font-size: 9px; letter-spacing: 1px; color: var(--ink-3); margin: 18px 0 8px; display: flex; justify-content: space-between; }
.lb-country { background: var(--bg-2); margin-bottom: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; }
.lb-row .flag { width: 26px; height: 19px; object-fit: cover; flex: none; }
.lb-row .nm { flex: 1; font-weight: 600; }
.lb-row .cnt { font-size: 12px; color: var(--ink-3); }
.lb-row .chev { color: var(--ink-3); transition: transform .15s; }
.lb-country.open .chev { transform: rotate(90deg); }
.lb-inner { display: none; padding: 0 10px 10px 46px; }
.lb-country.open .lb-inner { display: block; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; margin: 3px 4px 0 0; font-size: 12px; background: var(--bg-3); cursor: pointer; border: 0; }
.tag i { width: 8px; height: 8px; flex: none; }
.tag.st i { background: var(--c-state); } .tag.ci i { background: var(--c-city); } .tag.lm i { background: var(--c-landmark); }
.empty { text-align: center; padding: 24px 10px; color: var(--ink-3); }
.empty canvas { width: 84px; height: 66px; margin-bottom: 12px; }
.empty p { line-height: 1.6; font-size: 14px; }

/* passport */
.passport { background: var(--pp-bg, #f4ecd8); color: #3b2f22; padding: 18px 14px 22px; position: relative;
  background-image: radial-gradient(rgba(120,90,50,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 6px 6px, 100% 100%; box-shadow: 0 0 0 3px #3b2f22; min-height: 300px; }
.passport-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--pix); font-size: 8px; letter-spacing: 1px; color: #7a6142; border-bottom: 2px dashed #b9a17c; padding-bottom: 10px; margin-bottom: 8px; }
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px 4px; }
.stamp { display: grid; place-items: center; padding: 4px; cursor: pointer; }
.stamp svg { width: 100%; max-width: 124px; height: auto; mix-blend-mode: multiply; }
.stamp:hover svg { transform: scale(1.06) rotate(0deg) !important; }
.passport .empty { color: #7a6142; }
.pp-cover { background: #23345c; color: #e9d48a; text-align: center; padding: 26px 16px; box-shadow: 0 0 0 3px #111a30; margin-bottom: 16px; }
.pp-cover .t { font-family: var(--pix); font-size: 11px; letter-spacing: 2px; margin-top: 10px; }
.pp-cover .s { font-size: 12px; opacity: .8; margin-top: 8px; letter-spacing: 2px; text-transform: uppercase; }

/* stats */
.big-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.bs { background: var(--bg-2); padding: 14px; }
.bs b { font-family: var(--pix); font-size: 20px; display: block; }
.bs span { font-size: 12px; color: var(--ink-3); display: block; margin-top: 8px; }
.bs.wide { grid-column: span 2; }
.rank { display: flex; align-items: center; gap: 14px; background: var(--bg-2); padding: 14px; margin-bottom: 14px; }
.rank canvas { width: 60px; height: 60px; }
.rank .t { font-family: var(--pix); font-size: 12px; line-height: 1.6; }
.rank .s { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.cont-row { display: grid; grid-template-columns: 112px 1fr 64px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.cont-row .n { text-align: right; color: var(--ink-3); font-size: 12px; }

/* popups */
.pix-popup .maplibregl-popup-content { background: var(--glass); color: var(--ink); border-radius: 0; padding: 14px 14px 12px; backdrop-filter: blur(8px);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 6px 6px 0 0 rgba(0,0,0,.3); min-width: 260px; font-family: var(--sans); }
.pix-popup .maplibregl-popup-tip { display: none; }
.pix-popup .maplibregl-popup-close-button { color: var(--ink-3); font-size: 18px; padding: 2px 8px; }
.pop-h { display: flex; gap: 10px; align-items: center; padding-right: 18px; }
.pop-h .flag { width: 30px; height: 22px; object-fit: cover; flex: none; }
.pop-h canvas { width: 45px; height: 45px; flex: none; }
.pop-h b { font-size: 16px; line-height: 1.2; display: block; }
.pop-h small { font-size: 12px; color: var(--ink-3); display: block; margin-top: 2px; }
.pop-btns { display: flex; gap: 8px; margin-top: 12px; }
.pop-btns .pix-btn { flex: 1; padding: 10px 8px; font-size: 8px; }

/* markers */
.pix-marker { cursor: pointer; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.35)); }
.pix-marker canvas { display: block; width: 42px; }
.pix-you canvas { width: 30px; animation: pulse 1.2s steps(3) infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }

/* sheets & toast */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.sheet[hidden] { display: none; }
.sheet-card { width: min(520px, 100%); max-height: 88vh; overflow-y: auto; padding: 20px 22px 22px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { font-family: var(--pix); font-size: 12px; margin: 0; letter-spacing: 1px; }
.x { border: 0; background: none; font-size: 18px; color: var(--ink-3); }
.sheet-card h3 { margin-top: 22px; }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.theme-card { border: 0; padding: 0 0 8px; background: var(--bg-2); font-family: var(--pix); font-size: 7px; display: grid; gap: 8px; }
.theme-card .pv { height: 54px; position: relative; overflow: hidden; }
.theme-card .pv i { position: absolute; }
.theme-card.active { box-shadow: 0 0 0 3px var(--accent); }
.color-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-row { display: flex; align-items: center; gap: 10px; background: var(--bg-2); padding: 8px 10px; font-size: 14px; }
.color-row input[type=color] { width: 34px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.about { margin: 0 0 10px; }
.setup-steps { font-size: 14px; line-height: 1.6; color: var(--ink-2); padding-left: 20px; }
.setup-steps code, .muted code { background: var(--bg-2); padding: 1px 5px; font-size: 12px; }
.acct-head { display: flex; gap: 14px; align-items: center; }
.acct-head .acct-avatar { width: 56px; height: 56px; font-size: 18px; }
.gbtn { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #1f1f1f; border: 0; padding: 12px 16px; font-weight: 600; font-size: 15px; box-shadow: 0 0 0 3px var(--edge), 5px 5px 0 rgba(0,0,0,.25); }
.gbtn svg { width: 20px; height: 20px; }

.toast { position: fixed; z-index: 40; left: 50%; bottom: 40px; transform: translate(-50%, 30px); opacity: 0; padding: 12px 18px; font-size: 14px; pointer-events: none; transition: all .25s steps(4); max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--accent); }

/* boot */
.boot { position: fixed; inset: 0; z-index: 5; background: #0a1426; display: grid; place-items: center; transition: opacity .5s; color: #e9f0fb; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.boot-inner canvas { width: 84px; animation: bob 1.2s steps(3) infinite; }
.boot-title { font-family: var(--pix); font-size: 14px; margin: 18px 0; letter-spacing: 1px; }
.boot-bar { width: 220px; height: 16px; margin: 0 auto; box-shadow: 0 0 0 3px #e9f0fb; padding: 3px; }
.boot-bar span { display: block; height: 100%; width: 5%; background: #3b82f6; transition: width .3s steps(5); }
.boot-msg { font-size: 12px; margin-top: 14px; opacity: .7; }

/* keyboard focus */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.search input:focus-visible, .field input:focus-visible, .field textarea:focus-visible, .filter-input:focus-visible, .quick-card textarea:focus-visible { outline: none; }

/* ============ responsive ============ */
/* landmark checklists (city panel, country panel, the cities & sights dialog) */
.lm-ck canvas { width: 26px; height: 26px; flex: none; margin: -4px 0; image-rendering: pixelated; }
.lm-ck .sub { color: var(--c-landmark); font-size: 11px; }
.small-note { margin: -4px 0 8px; font-size: 12px; }
.lm-group { margin-top: 10px; }
.lm-group-h { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 8px; font-size: 13px; color: var(--ink-2); box-shadow: inset 0 -2px 0 var(--line); }
.lm-group-h a { cursor: pointer; font-weight: 600; text-decoration: none; }
.lm-group-h span:last-child { font-family: var(--pix); font-size: 8px; color: var(--ink-3); }
.trip-open { width: 100%; margin-top: 14px; }
.trip-card { width: min(520px, 100%); display: flex; flex-direction: column; overflow: hidden; height: min(640px, 88vh); }
.trip-card .sheet-head h2 { display: flex; align-items: center; gap: 10px; }
.trip-card .sheet-head .flag { width: 24px; height: 18px; }
.trip-sub { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.trip-picked { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; max-height: 72px; overflow-y: auto; }
.trip-picked:empty { display: none; }
.trip-list { flex: 1; align-content: start; min-height: 120px; overflow-y: auto; margin-top: 8px; padding-right: 2px; }
.trip-list .ck.locked { opacity: .6; cursor: default; }
.trip-list .ck:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.trip-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding-top: 12px; margin-top: 8px; box-shadow: 0 -2px 0 var(--line); }
.trip-foot .trip-gap { flex: 1; }
.trip-foot [hidden] { display: none; }
.trip-foot .pix-btn { white-space: nowrap; }
.sg-list { display: grid; gap: 2px; }
.sg-row { width: 100%; border: 0; text-align: left; background: transparent; color: inherit; font: inherit; }
.sg-row:hover { background: var(--bg-2); }

@media (max-width: 1100px) {
  .brand-sub { display: none; }
  #proj-toggle button { font-size: 0; padding: 8px 9px; gap: 0; }
  .ribbon .rb:nth-child(n+5) { display: none; }
}
.phone-only { display: none !important; }
.tabs i { font-style: normal; }
html { -webkit-text-size-adjust: 100%; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

/* ===== phones & small tablets: Apple-Maps-style layout =====
   one-row top bar · full-bleed map · draggable bottom sheet (peek / half / full) */
@media (max-width: 820px) {
  :root { --panel-w: 100vw; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
          --peek-h: 132px; --sheet-h: calc(var(--peek-h) + var(--safe-b)); }
  .map-ctrls .phone-only { display: grid !important; } .fab.phone-only, .sheet-peek.phone-only { display: flex !important; }
  .top-actions .seg, #theme-btn, #quick-btn { display: none; }
  .ribbon, .legend, .hover-tip, #zoom-in, #zoom-out, #go-home, .maplibregl-ctrl-bottom-left { display: none !important; }

  /* top bar: logo · search · account */
  .topbar { top: calc(8px + var(--safe-t)); left: 10px; right: 10px; gap: 8px; flex-wrap: nowrap; align-items: center; }
  .brand { padding: 0; width: 46px; height: 46px; justify-content: center; flex: none; }
  .brand > div { display: none; }
  #brand-plane { width: 32px; height: 25px; }
  .search { flex: 1; min-width: 0; max-width: none; margin: 0; }
  .search input { height: 46px; font-size: 16px; padding-right: 10px; }
  .search-results { position: fixed; top: calc(66px + var(--safe-t)); left: 10px; right: 10px; max-height: calc(100dvh - 90px - var(--safe-t) - var(--sheet-h)); }
  .top-actions { gap: 0; }
  .account-btn { width: 46px; height: 46px; padding: 0; justify-content: center; }
  .account-btn #acct-label { display: none; }
  .acct-avatar { width: 34px; height: 34px; }

  /* right-hand control column, floats just above the sheet */
  .map-ctrls { right: 10px; bottom: calc(var(--sheet-h) + 14px); gap: 8px; transition: bottom .25s ease, opacity .2s; }
  .map-ctrls button { width: 46px; height: 46px; font-size: 19px; }
  .fab { position: fixed; z-index: 9; left: 10px; bottom: calc(var(--sheet-h) + 14px); height: 46px; padding: 0 16px; border: 0;
         font-family: var(--pix); font-size: 9px; display: flex; align-items: center; gap: 8px; background: var(--accent); color: var(--accent-ink);
         box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), 5px 5px 0 0 rgba(0,0,0,.3);
         transition: bottom .25s ease, opacity .2s; }
  .fab span { font-family: var(--sans); font-size: 20px; font-weight: 700; }
  body.sheet-full .map-ctrls, body.sheet-full .fab { opacity: 0; pointer-events: none; }
  body.sheet-half #proj-btn, body.sheet-half #reset-view { display: none !important; }

  /* bottom sheet */
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: calc(var(--peek-h) + var(--safe-b));
           transition: height .28s cubic-bezier(.2,.8,.2,1); padding-bottom: var(--safe-b); z-index: 11;
           box-shadow: 0 -3px 0 0 var(--edge), 0 -10px 30px rgba(0,0,0,.35); }
  .panel.half { height: 56dvh; }
  .panel.full { height: calc(100dvh - 70px - var(--safe-t)); }
  .panel.dragging { transition: none; }
  .panel-head { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
  .panel-grip { display: block; border: 0; background: none; height: 22px; width: 100%; padding: 0; }
  .panel-grip span { display: block; width: 44px; height: 5px; background: var(--ink-3); margin: 8px auto 0; border-radius: 3px; }
  .sheet-peek { display: flex; justify-content: space-around; padding: 2px 10px 8px; font-size: 12px; color: var(--ink-2); }
  .sheet-peek .pk { display: flex; flex-direction: column; align-items: center; min-width: 0; }
  .sheet-peek b { font-family: var(--pix); font-size: 12px; color: var(--ink); }
  .sheet-peek span { font-size: 10px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }
  .sheet-peek i { width: 20px; height: 3px; margin-top: 4px; }
  .tabs { border-bottom: 2px solid var(--edge); }
  .tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 6px; min-height: 52px;
                 font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0; }
  .panel-body { padding: 14px 14px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .panel:not(.half):not(.full) .panel-body { overflow: hidden; }

  /* comfortable reading + no iOS zoom-on-focus (inputs must be ≥16px) */
  .p-title h2 { font-size: 22px; }
  .blurb { font-size: 15px; }
  .filter-input, .field input, .field textarea, .quick-card textarea, .qr select, select { font-size: 16px; }
  .ck { padding: 11px 8px; font-size: 15px; min-height: 46px; }
  .ck .go { min-width: 44px; min-height: 44px; margin: -8px -8px -8px 0; font-size: 20px; }
  .more-btn { min-height: 44px; width: 100%; }
  .panel-grip { height: 28px !important; }
  .lm-chip { padding: 6px 10px 6px 6px; }
  .pix-btn.small { font-size: 9px; padding: 12px 12px; }
  .row-btns .pix-btn { flex: 1 1 auto; }

  /* dialogs become bottom sheets */
  .sheet { padding: 0; align-items: end; }
  .sheet-card { width: 100%; max-height: calc(100dvh - 40px - var(--safe-t)); padding: 18px 16px calc(18px + var(--safe-b)); }
  .quick-card { width: 100%; }
  .trip-card { width: 100%; height: calc(100dvh - 40px - var(--safe-t)); }
  .trip-foot { gap: 6px; }
  .trip-foot .pix-btn { padding: 14px 10px; font-size: 9px; }
  .lm-ck canvas { width: 30px; height: 30px; }
  .qr { grid-template-columns: 22px 1fr 36px; row-gap: 6px; } .qr .q { grid-column: 2; } .qr select, .qr .nf { grid-column: 1 / 4; }
  .qr .st { grid-row: 1; } .qr .skip { grid-column: 3; grid-row: 1; font-size: 18px; min-width: 40px; min-height: 40px; }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .color-rows { grid-template-columns: 1fr; }
  .dex { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .dex-loc { width: 40px; height: 40px; }
  .chip-loc { width: 40px; }
  .cont-row { grid-template-columns: 96px 1fr 52px; }
  .toast { bottom: calc(var(--sheet-h) + 76px); }
  body.sheet-full .toast { bottom: calc(18px + var(--safe-b)); }
  .compare-bar { top: calc(66px + var(--safe-t)); max-width: calc(100vw - 20px); gap: 10px; font-size: 12px; }
  .tabs button { font-size: 10px; }
  .tabs button[data-badge]:not([data-badge=""])::after { top: 2px; right: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
