/* Saferground: threat controls left, map + inspector centre, survival needs right. Collapses to map first on narrow screens. */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --raise: #f6f8fb;
  --ink: #0e1621;
  --muted: #5c6a7e;
  --line: #e0e6ee;
  --brand: #0d8f89;
  --danger: #e5484d;
  --warn: #c98a0c;
  --shadow: 0 1px 2px rgba(14,22,33,.06), 0 8px 24px rgba(14,22,33,.06);
  --f-display: "Space Grotesk", system-ui, sans-serif;
  --f-body: "Inter", system-ui, sans-serif;
  --f-data: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f15; --surface: #111922; --raise: #17212c; --ink: #e8eef5; --muted: #8794a6; --line: #212d3b;
    --brand: #2ec4b6; --danger: #ff6369; --warn: #f5b942;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); }
.wrap { max-width: 1480px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; margin-bottom: 16px; }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 1.6rem; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }
.top nav { display: flex; gap: 18px; font-size: .9rem; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.top nav a:hover, .top nav a[aria-current] { color: var(--ink); }
.lede { color: var(--muted); max-width: 70ch; margin: -6px 0 16px; }
.app { display: grid; grid-template-columns: 290px minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; min-width: 0; border: 1px solid var(--line); }
h2 { font-family: var(--f-display); font-weight: 600; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.scen { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scen button { font: 600 .85rem var(--f-body); color: var(--ink); background: var(--raise); border: 1px solid var(--line); padding: 9px 10px; text-align: left; cursor: pointer; border-radius: 10px; }
.scen button:hover { border-color: var(--brand); }
.scen button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #04201d; }
.note { margin: 10px 0 0; color: var(--muted); font-size: .82rem; min-height: 2.6em; }
.fr { padding: 8px 0; border-top: 1px solid var(--line); }
.fr:first-of-type { border-top: 0; padding-top: 0; }
.fr.off .fn, .fr.off input[type=range] { opacity: .4; }
.fh { display: flex; align-items: center; gap: 8px; }
.fn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 2px 0; color: var(--ink); font: 500 .9rem var(--f-body); text-align: left; cursor: pointer; }
.fn i { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.fn[aria-pressed="true"] i { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tag { font: 500 .62rem var(--f-data); letter-spacing: .04em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.data { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.tag.calc { color: var(--ink); }
.fh output { font-family: var(--f-data); font-size: .75rem; color: var(--muted); width: 2.6em; text-align: right; }
.sw { position: relative; width: 30px; height: 18px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; background: var(--line); border-radius: 9px; transition: background .15s; }
.sw span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.sw input:checked + span { background: var(--brand); }
.sw input:checked + span::after { transform: translateX(12px); }
.sw input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.fr input[type=range], #wind { width: 100%; accent-color: var(--brand); margin: 4px 0 0; }
.fr small, .hint { display: block; color: var(--muted); font-size: .76rem; }
.chk { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: .88rem; }
.chk input { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
.ico { display: inline-block; width: 9px; height: 9px; flex: none; }
.ico.t { background: var(--danger); border-radius: 50%; }
.ico.r { background: var(--warn); border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface); }
.windrow { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 500; }
.windrow output { font-family: var(--f-data); color: var(--muted); font-size: .8rem; }
.mapcard { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.maphead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; }
.maphead b { font-family: var(--f-display); font-size: 1.05rem; letter-spacing: -.01em; }
.maphead .sub { display: block; color: var(--muted); font-size: .82rem; }
.pill { font: 600 .8rem var(--f-body); background: var(--raise); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.pill:hover { border-color: var(--brand); }
.search { position: relative; padding: 0 16px 12px; }
.search form { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; font: 500 .95rem var(--f-body); padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); color: var(--ink); }
.search button[type=submit] { font: 600 .9rem var(--f-body); padding: 0 16px; border-radius: 12px; border: 0; background: var(--brand); color: #04201d; cursor: pointer; }
.results { position: absolute; left: 16px; right: 16px; top: calc(100% - 6px); z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); list-style: none; margin: 0; padding: 4px; }
.results button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; color: var(--ink); font: inherit; cursor: pointer; }
.results button:hover { background: var(--raise); }
.results .msg { padding: 9px 10px; color: var(--muted); }
#map { height: 620px; width: 100%; background: var(--raise); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; pointer-events: none; }
.mapwrap { position: relative; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; font-size: .78rem; color: var(--muted); }
.bar { width: 150px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2b1c52, #2f5aa8, #1fa3a0, #9be15d, #fff3a3); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.below { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
.score { font-family: var(--f-display); font-weight: 700; font-size: 3rem; line-height: 1; letter-spacing: -.03em; }
.score span { font-size: .8rem; color: var(--muted); letter-spacing: .08em; margin-left: 6px; font-weight: 600; }
.place { font-weight: 600; margin-top: 6px; }
.meta { font-family: var(--f-data); font-size: .72rem; color: var(--muted); margin: 2px 0 8px; }
.sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.sum span { font-size: .76rem; padding: 3px 9px; border-radius: 999px; background: var(--raise); border: 1px solid var(--line); }
.sum .g { color: var(--brand); } .sum .b { color: var(--danger); }
.br { display: grid; grid-template-columns: 112px minmax(0, 1fr) 28px; gap: 8px; align-items: center; font-size: .82rem; margin: 4px 0; }
.br i { display: block; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.br i b { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.br em { font-style: normal; font-family: var(--f-data); font-size: .75rem; text-align: right; }
.br.off { opacity: .4; }
.facts { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: .8rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.facts sup a { font-family: var(--f-data); font-size: .65rem; text-decoration: none; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank button { display: grid; grid-template-columns: 20px minmax(0, 1fr) 34px; gap: 8px; width: 100%; background: none; border: 0; border-radius: 8px; padding: 7px 6px; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.rank button:hover { background: var(--raise); }
.rank .n { font-family: var(--f-data); color: var(--muted); font-size: .75rem; }
.rank .v { font-family: var(--f-data); text-align: right; font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-weight: 500; font-size: .88rem; z-index: 50; }
footer { margin-top: 24px; color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 12px; font: .8rem var(--f-body); box-shadow: var(--shadow); }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-content b { display: block; }
.maplibregl-popup-content span { color: var(--muted); }
.plabel { font: 600 11px var(--f-body); color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.9); transform: translate(8px, 0); white-space: nowrap; pointer-events: none; }
/* about page */
.doc { max-width: 1100px; }
.doc h1 { font-family: var(--f-display); font-size: 2rem; letter-spacing: -.02em; margin: 8px 0 8px; }
.doc h3 { font-family: var(--f-display); font-size: 1.2rem; margin: 28px 0 8px; }
.doc p { max-width: 75ch; }
.method { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.method div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.method b { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.method p { margin: 0; color: var(--muted); font-size: .84rem; }
.refs { padding-left: 22px; margin: 0; font-size: .85rem; }
.refs li { margin-bottom: 8px; color: var(--muted); }
.refs li b { color: var(--ink); font-weight: 500; }
.refs a { word-break: break-word; }
.callout { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 12px; padding: 14px 16px; }
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .main { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .below { grid-template-columns: minmax(0, 1fr); }
  #map { height: 62vh; }
  .brand { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
