:root {
  --bg: #ffffff;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --line: rgba(0, 0, 0, 0.12);
  --accent: #2f6b3a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1e1f1d; --fg: #f1f0ea; --muted: #a8a79f; --line: rgba(255, 255, 255, 0.14); --accent: #7fc48a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#map { position: fixed; inset: 0; }
.hidden { display: none !important; }

#crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #111; box-shadow: 0 0 0 1px #fff; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }

#topbar { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 10px; display: flex; gap: 6px; }
.chip { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 18px;
  padding: 8px 13px; font: inherit; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
.chip.on { background: var(--accent); color: #fff; border-color: transparent; }

.maplibregl-ctrl-top-right { top: env(safe-area-inset-top); }
/* keep scale bar + attribution visible above the land card */
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: calc(env(safe-area-inset-bottom) + 136px); }
@media (min-width: 700px) { .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 0; } }

#card { position: fixed; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 12px);
  max-width: 460px; margin: 0 auto; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.swatch { width: 30px; height: 30px; border-radius: 7px; flex: none; border: 1px solid var(--line); background: transparent; }
.lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.val { font-size: 18px; font-weight: 700; }
.val small { font-weight: 500; color: var(--muted); font-size: 13px; }

.panel { position: fixed; top: calc(env(safe-area-inset-top) + 58px); left: 10px; width: min(320px, calc(100vw - 20px));
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; max-height: 60vh; overflow: auto; }
.panel h3 { margin: 4px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.panel label { display: block; padding: 6px 0; }
.panel small, .note { color: var(--muted); }
.note { font-size: 12px; margin: 10px 0 0; }
.panel input[type=range], .panel progress { width: 100%; }
.legend-item { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.legend-item .swatch { width: 22px; height: 22px; border-radius: 5px; }
.btns { display: flex; gap: 8px; margin-top: 10px; }
.btns button { font: inherit; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer; }
.btns button.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
#offline-status { font-size: 14px; margin: 6px 0; }

.maplibregl-popup-content { color: #1d1d1b; font: 14px/1.35 -apple-system, sans-serif; }

/* ---- Pins ---- */
#btn-pin { margin-left: auto; flex: none; background: #c0392b; color: #fff; border: 0; border-radius: 20px;
  padding: 9px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.row .txt { min-width: 0; }
body.sheet-open #card { display: none; }
#pin-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-width: 520px; margin: 0 auto;
  background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.25);
  padding: 14px 14px calc(env(safe-area-inset-bottom) + 14px); max-height: 75vh; overflow: auto; }
#pin-label { width: 100%; font: inherit; font-size: 19px; font-weight: 700; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--fg); }
#pin-notes { width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 10px; margin-top: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--fg); resize: vertical; }
#pin-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 2px 0; }
.swatch.sm { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
#pin-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-top: 10px; }
.thumb { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: center / cover no-repeat;
  cursor: pointer; padding: 0; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24px;
  color: var(--muted); background: transparent; border-style: dashed; }
.thumb.add span { font-size: 12px; }
.btns button.danger { color: #c0392b; }
.btnlike { font: inherit; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
#photo-viewer { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.92); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); }
#photo-viewer img { max-width: 100%; max-height: calc(100% - 70px); object-fit: contain; border-radius: 6px; }
#photo-viewer .btns button { color: #fff; border-color: rgba(255,255,255,.3); }
#photo-viewer .btns button.danger { color: #ff8a80; }
#pin-list { display: flex; flex-direction: column; gap: 2px; }
.pin-row { display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 8px 2px; font: inherit; color: var(--fg); cursor: pointer; }
.pin-row-txt { display: flex; flex-direction: column; }
.pin-row-txt small { color: var(--muted); }
.panel h3 small { text-transform: none; letter-spacing: 0; }
.mine-dot { display: inline-block; width: 11px; height: 11px; transform: rotate(45deg); border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25); margin: 0 6px 0 2px; }
.mine-pop { margin-bottom: 6px; }
.mine-pop > div { margin-top: 3px; }
.mine-pop small { color: #6b6b66; }

/* ---- Mining claims ---- */
.claim-icon { display: flex; align-items: center; justify-content: center; font-size: 17px; background: transparent; }
#row-claims.has-claims .claim-icon { background: #e67e22; color: #fff; border-color: transparent; }
#row-claims.has-claims .val { color: #e67e22; }
.val.sm { font-size: 15px; }
.claims-pop { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(0,0,0,.12); }
.claims-pop ul { margin: 4px 0 0; padding-left: 16px; max-height: 150px; overflow: auto; }
.claims-pop li { margin: 2px 0; }
.claims-pop small { color: #6b6b66; }
.pin-claims { flex-basis: 100%; }
.pin-claims.has { color: #e67e22; font-weight: 600; }
#pin-list h4 { margin: 10px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
