:root {
  --bg: #f4f6f8; --card: #fff; --ink: #14212b; --muted: #5d6b76; --line: #dde3e8;
  --head: #0b5a45; --warn-bg: #fff4d6; --warn-ink: #6b4e00;
  --cheap: #11a35b; --mid: #e3a008; --dear: #d6453a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d151b; --card: #16222b; --ink: #e8eef2; --muted: #9aabb7; --line: #26343f; --head: #12876a; --warn-bg: #3a3014; --warn-ink: #f3d98a; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* White in both themes: the wordmark's dark green lettering needs a light background. */
  background: #fff; color: #14212b; border-bottom: 1px solid #dde3e8;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
}
h1 { margin: 0; line-height: 0; }
h1 img { height: 32px; width: auto; }
#fuel {
  font: inherit; font-size: 15px; color: #0b5a45; background: #eef6f2; font-weight: 600;
  border: 1px solid #b9dccb; border-radius: 8px; padding: 6px 8px; min-height: 36px; max-width: 55vw;
}
#fuel option { color: #000; }

#wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #dde3e8; }

#sample, #status {
  position: absolute; z-index: 500; left: 12px; right: 12px; margin: 0;
  padding: 8px 12px; border-radius: 8px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
#sample { top: 10px; background: var(--warn-bg); color: var(--warn-ink); }
#status { top: 10px; background: var(--card); color: var(--ink); }
#sample:not([hidden]) ~ #status { top: 58px; }

#key {
  position: absolute; z-index: 500; left: 10px; bottom: calc(env(safe-area-inset-bottom) + 26px);
  display: flex; align-items: center; gap: 6px; background: var(--card); color: var(--ink);
  padding: 5px 9px; border-radius: 8px; font-size: 12px; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
#key .bar { width: 64px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--cheap), var(--mid), var(--dear)); }

.mapbtns {
  position: absolute; z-index: 500; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 26px);
  display: flex; flex-direction: column; gap: 8px;
}
.mapbtns button {
  width: 44px; height: 44px; border-radius: 22px; border: 0; cursor: pointer;
  background: var(--card); color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.3);
  font-family: inherit; font-weight: 700; font-size: 19px; line-height: 1; display: grid; place-items: center;
}
.mapbtns svg { width: 20px; height: 20px; fill: currentColor; }
#locate.busy svg { animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }

/* Price pins: a rounded label with a point, coloured from cheapest (green) to dearest (red) in view. */
.pin { background: none; border: 0; }
.pin span {
  position: absolute; left: 0; bottom: 0; transform: translate(-50%, -7px);
  padding: 2px 6px; border-radius: 6px; color: #fff; white-space: nowrap;
  font: 700 13px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(0,0,0,.35); border: 1.5px solid #fff;
}
.pin span::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -5px;
  border: 5px solid transparent; border-bottom: 0; border-top-color: inherit;
}
.pin.dot span { padding: 0; width: 13px; height: 13px; border-radius: 50%; transform: translate(-50%, 50%); font-size: 0; }
.pin.dot span::after { display: none; }
.pin.best span { outline: 2px solid var(--cheap); outline-offset: 1px; }
.pin.sel span { transform: translate(-50%, -7px) scale(1.25); outline: 2px solid #000; }
.pin.dot.sel span { transform: translate(-50%, 50%) scale(1.5); }
.me { width: 16px; height: 16px; border-radius: 50%; background: #2b7cff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(43,124,255,.25); }

#card {
  position: absolute; z-index: 600; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 10px);
  max-width: 480px; margin: 0 auto; background: var(--card); color: var(--ink);
  border-radius: 14px; padding: 14px 16px; box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
#card[hidden] { display: none; }
#close { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
#card .top { display: flex; gap: 14px; align-items: center; padding-right: 24px; }
#card .price b { font-size: 30px; font-variant-numeric: tabular-nums; }
#card .price small { display: block; color: var(--muted); font-size: 12px; margin-top: -4px; }
#c-name { font-weight: 700; }
#c-addr, #c-info { color: var(--muted); font-size: 14px; }
#c-info { margin: 8px 0 12px; }
#c-info .stale { color: var(--dear); }
#c-go {
  display: block; text-align: center; background: var(--head); color: #fff; text-decoration: none;
  border-radius: 10px; padding: 11px; font-weight: 600;
}

.leaflet-control-attribution { font-size: 10px; }
