:root {
  --bg: #111214;
  --surface: #1b1d21;
  --text: #e8e8ea;
  --muted: #9a9ca3;
  --accent: #e5383b;
  --low: #4caf50;
  --mid: #f4a259;
  --high: #e5383b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
}
header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--surface);
}
h1 { margin: 0; letter-spacing: 0.3em; color: var(--accent); font-size: 1.4rem; }
#search-form { display: flex; gap: 0.5rem; flex: 1; max-width: 420px; }
#search-input {
  flex: 1; min-width: 0; padding: 0.5rem 0.75rem; border-radius: 6px;
  border: 1px solid #333; background: var(--bg); color: var(--text);
}
button {
  padding: 0.5rem 1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer;
}
main { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
#map { min-height: 400px; }
#panel { padding: 1rem; overflow-y: auto; background: var(--surface); }
.hint, footer { color: var(--muted); }
footer { padding: 0.5rem 1rem; font-size: 0.8rem; text-align: center; }

.overall { text-align: center; margin-bottom: 1rem; }
.overall .score { font-size: 3.5rem; font-weight: 800; line-height: 1; }
.overall .label { color: var(--muted); }
.place { font-size: 1.1rem; margin: 0 0 1rem; text-align: center; }

.card { background: var(--bg); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.card h3 { margin: 0 0 0.5rem; display: flex; justify-content: space-between; font-size: 1rem; }
.bar { height: 8px; background: #2a2c31; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; }
.card ul { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; }
.card.pending { opacity: 0.6; }


button.secondary { background: transparent; border: 1px solid #333; color: var(--text); }
button.secondary:hover { border-color: var(--accent); }
.rank-controls { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.rank-controls select {
  padding: 0.4rem; border-radius: 6px; border: 1px solid #333;
  background: var(--bg); color: var(--text);
}
.rank-controls select:first-child { flex: 1; min-width: 0; }
.rank-list { margin: 0; padding-left: 2.2rem; }
.rank-list li { padding: 0.35rem 0.25rem; cursor: pointer; border-radius: 4px; color: var(--muted); }
.rank-list li:hover { background: var(--bg); }
.rank-list li > span { display: inline-flex; }
.rank-name { color: var(--text); }
.rank-score { float: right; font-weight: 700; }

.shade-control {
  background: var(--surface); color: var(--text); padding: 0.5rem 0.75rem;
  border-radius: 8px; font-size: 0.85rem; box-shadow: 0 2px 8px #0008; max-width: 240px;
}
.shade-control label { display: flex; flex-direction: column; gap: 0.25rem; }
.shade-control select {
  padding: 0.3rem; border-radius: 6px; border: 1px solid #333; background: var(--bg); color: var(--text);
}
#shade-legend { margin-top: 0.5rem; }
.legend-bands { display: flex; gap: 2px; }
.legend-bands span { flex: 1; height: 10px; }
.legend-bands span:first-child { border-radius: 4px 0 0 4px; }
.legend-bands span:last-child { border-radius: 0 4px 4px 0; }
.legend-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.legend-note { color: var(--muted); font-size: 0.75rem; margin-top: 0.25rem; }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 0; }

.actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.actions .hint { width: 100%; text-align: center; margin: 0; font-size: 0.9rem; }

.compare { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: 0.9rem; table-layout: fixed; }
.compare th, .compare td { padding: 0.35rem 0.4rem; text-align: left; vertical-align: middle; }
.compare thead th { vertical-align: bottom; }
.compare tbody th { font-weight: 500; color: var(--muted); width: 38%; }
.compare td { background: var(--bg); border-radius: 6px; font-weight: 700; }
.compare td.worse { background: color-mix(in srgb, var(--high) 22%, var(--bg)); box-shadow: inset 0 0 0 1px var(--high); }
.compare td .bar { margin-top: 4px; height: 5px; }
.compare tr.total td { font-size: 1.3rem; }
.compare tr.total th { color: var(--text); }
button.link {
  background: none; padding: 0; color: var(--text); text-align: left;
  font: inherit; font-weight: 600; text-decoration: underline dotted;
}
.tag {
  display: inline-block; min-width: 1.4em; margin-right: 0.3em; border-radius: 4px;
  background: var(--accent); color: #fff; text-align: center; font-size: 0.75rem;
}
.verdict { text-align: center; margin: 0.75rem 0 0.25rem; }
.pin-label {
  background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%;
  font: 700 13px/22px system-ui, sans-serif; text-align: center; box-shadow: 0 1px 4px #000a;
}

/* Phones and narrow windows: stack map above results. */
@media (max-width: 800px) {
  body { height: auto; }
  header { padding: 0.5rem 1rem; gap: 0.5rem; }
  h1 { font-size: 1.15rem; }
  #search-form { order: 3; flex-basis: 100%; max-width: none; } /* search gets its own full-width row */
  #rankings-btn { padding: 0.4rem 0.75rem; }
  /* minmax(0, ...) stops wide content (tables, long names) from stretching the page past the screen */
  main { grid-template-columns: minmax(0, 1fr); }
  #map { height: 45vh; min-height: 260px; }
  #panel { overflow: visible; }
  .card ul { overflow-wrap: anywhere; }
  .shade-control { max-width: 160px; padding: 0.35rem 0.5rem; font-size: 0.75rem; }
  .shade-control select { max-width: 100%; }
  .compare { font-size: 0.8rem; }
  .compare tbody th { width: 30%; padding-left: 0; }
  .compare tr.total td { font-size: 1.1rem; }
  .compare thead th { overflow-wrap: anywhere; }
  footer { font-size: 0.7rem; }
}
