:root {
  --bg: #0b0c0e;
  --panel: #14161a;
  --panel-2: #1b1e24;
  --line: #2c313a;
  --text: #e8e4dc;
  --muted: #8b909a;
  --brass: #c9a227;
  --killed: #8a2f2f;
  --go: #3f7d4e;
  --ag: #c5c7c9;
  --cu: #c67b3a;
  --u: #a3e635;
  --v: #22d3ee;
  --pb: #94a3b8;
  --zn: #7dd3fc;
  --mn: #c084fc;
  --au: #fbbf24;
  --w: #f97316;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--brass); }
.mast {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: .7rem 1rem .55rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #16181d, #0f1114);
}
.mast h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #f3ead2;
  font-weight: 650;
}
.tag { margin: .15rem 0 0; color: var(--muted); font-size: .78rem; }
.tag span { color: var(--brass); }
.rule { margin: 0; max-width: 22rem; font-size: .7rem; color: var(--muted); text-align: right; }
.filters { padding: .45rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .3rem; }
.chip-row:last-child { margin-bottom: 0; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .22rem .55rem;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: var(--brass); }
.chip.on { background: #2a2414; border-color: var(--brass); color: var(--brass); }
.chip.metal-ag.on { color: var(--ag); border-color: var(--ag); }
.chip.metal-cu.on { color: var(--cu); border-color: var(--cu); }
.chip.metal-u.on { color: var(--u); border-color: var(--u); }
.chip.metal-v.on { color: var(--v); border-color: var(--v); }
.chip.metal-pb.on { color: var(--pb); border-color: var(--pb); }
.chip.metal-zn.on { color: var(--zn); border-color: var(--zn); }
.chip.metal-mn.on { color: var(--mn); border-color: var(--mn); }
.chip.metal-au.on { color: var(--au); border-color: var(--au); }
.chip.metal-w.on { color: var(--w); border-color: var(--w); }
.desk {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr minmax(18rem, 26rem);
  min-height: 0;
}
.rank, .packet {
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.packet { border-right: 0; border-left: 1px solid var(--line); padding: .85rem; }
.rank-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .7rem .85rem .4rem;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.rank-head h2 { margin: 0; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--brass); }
.muted { color: var(--muted); font-size: .75rem; }
#rank-list { list-style: none; margin: 0; padding: 0 .4rem .8rem; }
#rank-list li {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  gap: .4rem;
  padding: .45rem .45rem;
  border-radius: .45rem;
  cursor: pointer;
  border: 1px solid transparent;
}
#rank-list li:hover { background: var(--panel-2); }
#rank-list li.on { border-color: var(--brass); background: #1f1c12; }
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: .9rem;
  color: #f3ead2;
}
.tname { font-size: .82rem; }
.tmeta { display: block; color: var(--muted); font-size: .68rem; margin-top: .1rem; }
.badge {
  font-size: .62rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .12rem .35rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  height: fit-content;
}
.badge.killed { border-color: var(--killed); color: #e7a1a1; }
.badge.cal { border-color: var(--brass); color: var(--brass); }
.badge.usgs { border-color: #3f7d4e; color: #8fd19a; }
.walk-card {
  margin: .5rem 0 .75rem;
  padding: .7rem .75rem .6rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #1b1e24;
}
.walk-dist {
  margin: 0 0 .45rem;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: .01em;
  color: #f3ead2;
}
.walk-dist span {
  color: var(--brass);
  font-size: .95rem;
  letter-spacing: .08em;
}
a.go {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: .55rem;
  background: #3d3418;
  border: 1px solid var(--brass);
  color: #f3ead2;
  text-decoration: none;
  font-size: .84rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  touch-action: manipulation;
}
.tmeta .away { color: var(--brass); }
.walk-links { font-size: .78rem; color: var(--muted); }
.walk-links a { color: var(--brass); }
button.linkish {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: var(--brass);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.packet code { font-size: .72rem; color: #c9a227; }
.rule a { color: var(--brass); text-decoration: underline; text-underline-offset: 2px; }
.map-wrap { position: relative; min-height: 18rem; }
#map { position: absolute; inset: 0; background: #0e1210; }
.legend {
  position: absolute;
  z-index: 500;
  left: .6rem;
  bottom: .6rem;
  background: rgba(20,22,26,.92);
  border: 1px solid var(--line);
  border-radius: .45rem;
  padding: .4rem .55rem;
  font-size: .68rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .6rem;
  max-width: 70%;
}
.legend i {
  display: inline-block;
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  margin-right: .25rem;
  vertical-align: -1px;
}
.legend .meridian-swatch {
  width: .85rem;
  height: 0;
  border-radius: 0;
  border-top: 2px solid #c9a227;
  background: transparent;
  vertical-align: 2px;
}
.grid-label, .meridian-label {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  font: 650 10px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: .04em;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  color: #c9a227;
}
.grid-label { color: #9aa0aa; font-weight: 500; }
.packet h3 { margin: 0 0 .2rem; font-size: 1.02rem; color: #f3ead2; }
.packet h4 {
  margin: .9rem 0 .25rem;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brass);
}
.packet p { margin: .25rem 0; font-size: .82rem; line-height: 1.45; }
.packet ul { margin: .2rem 0 .4rem 1.1rem; padding: 0; font-size: .8rem; }
.packet li { margin: .15rem 0; }
.clip {
  border: 1px solid #3d3424;
  background: #16140f;
  padding: .55rem .65rem;
  border-radius: .4rem;
  margin: .4rem 0 .55rem;
}
.clip h5 {
  margin: 0 0 .2rem;
  font-size: .82rem;
  color: #e8d5a3;
  font-weight: 650;
}
.clip blockquote {
  margin: .35rem 0;
  padding: .35rem .5rem;
  border-left: 2px solid #8a7040;
  color: #d7c9a6;
  font-size: .78rem;
  line-height: 1.45;
}
.warn {
  border: 1px solid #5c3a12;
  background: #24180c;
  color: #e6c48a;
  padding: .55rem .65rem;
  border-radius: .4rem;
  font-size: .78rem;
}
.killed-banner {
  border: 1px solid var(--killed);
  background: #2a1212;
  color: #f0c0c0;
  padding: .5rem .65rem;
  border-radius: .4rem;
  font-size: .78rem;
}
.bars { display: grid; gap: .25rem; margin: .4rem 0 .6rem; }
.bar-row { display: grid; grid-template-columns: 4.2rem 1fr 2.4rem; gap: .35rem; align-items: center; font-size: .72rem; }
.bar { height: .45rem; background: #2a2e35; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; }
.note-form { display: grid; gap: .35rem; margin-top: .4rem; }
.note-form textarea, .note-form input, .note-form button {
  font: inherit;
  background: #0b0c0e;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: .35rem;
  padding: .4rem .5rem;
}
.note-form button { background: #3d3418; border-color: var(--brass); color: #f3ead2; cursor: pointer; }
.log-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.notes li { font-size: .75rem; color: var(--muted); }
.field-tools {
  position: absolute;
  z-index: 500;
  top: .65rem;
  right: .65rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.locate-btn {
  position: static;
  min-width: 44px;
  min-height: 44px;
  padding: 0 .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 22, 26, .92);
  color: var(--brass);
  font: inherit;
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  touch-action: manipulation;
  cursor: pointer;
}
.locate-btn.on { background: #2a2414; border-color: var(--brass); color: #f3ead2; }
.pro-banner {
  margin: 0;
  padding: .45rem 1rem;
  background: #1a160c;
  border-bottom: 1px solid var(--line);
  color: #f3ead2;
  font-size: .78rem;
}
.pro-banner button { margin-left: .4rem; }
.pro-sheet {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  padding: 1rem;
}
.pro-sheet.open { display: flex; }
.pro-card {
  width: min(28rem, 100%);
  background: #14161a;
  color: var(--text);
  border: 1px solid var(--brass);
  border-radius: .8rem;
  padding: 1rem 1rem 1.1rem;
}
.pro-card h2 { margin: .2rem 0 .4rem; color: #f3ead2; font-size: 1.25rem; }
.pro-card .kicker { margin: 0; color: var(--brass); letter-spacing: .08em; text-transform: uppercase; font-size: .72rem; }
.pro-offers { display: grid; gap: .45rem; margin: .7rem 0; }
.pro-offer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .15rem .6rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
}
.pro-offer.best { border-color: var(--brass); }
.pro-offer span { color: var(--brass); font-weight: 650; }
.pro-offer em { grid-column: 1 / -1; color: var(--muted); font-style: normal; font-size: .78rem; }
.pro-actions { display: flex; gap: .5rem; margin-top: .8rem; }
.pro-actions button {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--brass);
  background: #2a2414;
  color: #f3ead2;
  padding: .45rem .8rem;
  cursor: pointer;
}
@media (max-width: 980px) {
  .pro-sheet { align-items: flex-end; padding: .6rem; }
}
.phone-dock { display: none; }

@media (max-width: 980px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  body { min-height: 0; }
  .mast {
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
    padding: .4rem .75rem .35rem;
    padding-top: max(.4rem, env(safe-area-inset-top));
  }
  .mast h1 { font-size: .98rem; letter-spacing: .06em; }
  .tag { display: none; }
  .rule { text-align: left; max-width: none; font-size: .65rem; }
  .filters { padding: .35rem .45rem .15rem; }
  .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    gap: .4rem;
    margin-bottom: .35rem;
    padding-bottom: .15rem;
    scrollbar-width: none;
  }
  .chip-row::-webkit-scrollbar { display: none; }
  #play-chips, #belt-chips, #base-chips, #overlay-chips { display: none; }
  body.show-filters #play-chips,
  body.show-filters #belt-chips,
  body.show-filters #base-chips,
  body.show-filters #overlay-chips { display: flex; }
  body.show-filters .filters { max-height: 34dvh; overflow: auto; }
  .chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: .45rem .8rem;
    font-size: .78rem;
    touch-action: manipulation;
  }
  .desk {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "map" "sheet";
  }
  .map-wrap {
    grid-area: map;
    min-height: 10rem;
    height: 100%;
    position: relative;
  }
  .rank, .packet {
    grid-area: sheet;
    display: none;
    max-height: 20rem;
    border: 0;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }
  body.sheet-list .legend,
  body.sheet-packet .legend { display: none; }
  body.sheet-list .rank,
  body.sheet-packet .packet { display: block; }
  #rank-list li {
    min-height: 52px;
    align-items: center;
    touch-action: manipulation;
  }
  .legend {
    left: .4rem;
    right: .4rem;
    bottom: .35rem;
    max-width: none;
    max-height: 2.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .field-tools { right: auto; left: .5rem; top: .5rem; }
  .leaflet-control-zoom { margin-top: .4rem !important; margin-right: .4rem !important; }
  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 22px !important;
  }
  .leaflet-control-attribution {
    font-size: 9px;
    max-width: 42vw;
    max-height: 2rem;
    overflow: hidden;
  }
  .legend { bottom: 1.7rem; }
  .phone-dock {
    display: block;
    background: #101216;
    border-top: 1px solid var(--line);
    padding: .35rem .5rem calc(.4rem + env(safe-area-inset-bottom));
  }
  .phone-peek {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: baseline;
    gap: .6rem;
    min-height: 44px;
    margin-bottom: .3rem;
    padding: .35rem .7rem;
    border-radius: .6rem;
    border: 1px solid var(--line);
    background: #1b1e24;
    color: #f3ead2;
    font: inherit;
    text-align: left;
    touch-action: manipulation;
  }
  .phone-peek strong {
    font-size: .86rem;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .phone-peek span { color: var(--brass); font-size: .75rem; flex: 0 0 auto; }
  .phone-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
  .phone-tabs button {
    appearance: none;
    min-height: 44px;
    border-radius: .55rem;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    font-size: .75rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    touch-action: manipulation;
  }
  .phone-tabs button.on {
    background: #2a2414;
    border-color: var(--brass);
    color: var(--brass);
  }
}
