:root {
  --bg: #0d1220;
  --ink: #eef1f7;
  --muted: #9aa3b8;
  --accent: #ffd166;
  --glass: rgba(16, 22, 38, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--sans); overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; outline: none; }
.leaflet-tile { image-rendering: auto; }
body.pixelated .leaflet-tile { image-rendering: pixelated; }
.leaflet-control-zoom { display: none; }

.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }

/* loading */
#loading { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg);
  transition: opacity 0.6s ease; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); }
#loading i { display: inline-block; width: 10px; height: 10px; margin-right: 10px; background: var(--accent);
  animation: blink 0.9s steps(2, start) infinite; vertical-align: 1px; }
body.ready #loading { opacity: 0; pointer-events: none; }
@keyframes blink { to { visibility: hidden; } }

/* search */
#top { position: fixed; z-index: 950; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); }
.pill { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px 0 16px; border-radius: 999px; }
.pill .ic { color: var(--muted); flex: none; }
#q { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--ink); font: 500 16px var(--sans); }
#q::placeholder { color: var(--muted); }
#q::-webkit-search-cancel-button { display: none; }
.kbd { font: 600 12px var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.ibtn { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; border: 0;
  background: transparent; color: var(--ink); cursor: pointer; }
.ibtn:hover { background: rgba(255, 255, 255, 0.08); }
.ibtn:focus-visible, #q:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#results { list-style: none; margin: 8px 0 0; padding: 6px; border-radius: 18px; display: none; max-height: 50vh; overflow: auto; }
#results.on { display: block; }
#results li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
#results li[aria-selected="true"], #results li:hover { background: rgba(255, 255, 255, 0.08); }
#results .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; align-self: center; }
#chip { display: none; margin: 8px auto 0; width: max-content; max-width: 100%; padding: 8px 16px; border-radius: 999px;
  font-weight: 600; }
#chip.on { display: block; }

/* pills bottom-left */
#madeby, #writeup { position: fixed; z-index: 940; left: max(16px, env(safe-area-inset-left)); padding: 9px 14px;
  border-radius: 999px; color: var(--ink); font: 500 14px/1 var(--sans); text-decoration: none; }
#madeby { bottom: calc(83px + env(safe-area-inset-bottom)); }
#writeup { bottom: calc(43px + env(safe-area-inset-bottom)); }
#madeby b, #writeup b { color: var(--accent); font-weight: 700; }
#madeby:hover b, #writeup:hover { text-decoration: underline; }
#madeby:empty { display: none; }

#attr { position: fixed; z-index: 930; right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); font-size: 11px;
  color: var(--muted); text-shadow: 0 1px 2px #000; text-align: right; }
#attr a { color: inherit; }

#toast { position: fixed; z-index: 960; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: 0.3s ease; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* map labels */
.area-label { background: none; border: 0; pointer-events: none; }
.area-label span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; color: #fff; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; opacity: var(--o, 1); transition: opacity 0.4s ease;
  text-shadow: 0 0 2px var(--bg), 0 0 6px rgba(13, 18, 32, 0.95), 0 1px 3px rgba(0, 0, 0, 0.9); }
.pin { background: none; border: 0; }
.pin span { position: absolute; left: -9px; top: -26px; width: 18px; height: 18px; background: var(--accent);
  border: 3px solid var(--bg); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }

@media (max-width: 640px) {
  .kbd { display: none; }
  #madeby { bottom: calc(105px + env(safe-area-inset-bottom)); padding: 7px 12px; font-size: 13px; }
  #writeup { bottom: calc(71px + env(safe-area-inset-bottom)); padding: 7px 12px; font-size: 13px; }
  #attr { left: 16px; right: 16px; text-align: left; }
}
