:root {
  --bg: #121212;
  --panel: #1b1b1b;
  --line: #2c2c2c;
  --text: #ece8e1;
  --muted: #9a958c;
  --accent: #ff7a1a;
  --twist: #ff2d55;
  --fast: #4ea8ff;
  --ok: #7bd389;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { display: flex; }

#panel {
  width: 380px;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
#map { flex: 1; height: 100%; }

h1 { margin: 0; font-size: 28px; letter-spacing: -0.5px; color: var(--accent); font-style: italic; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 8px; }
.tag { margin: 6px 0 0; color: var(--muted); line-height: 1.4; font-size: 14px; }

form { display: grid; gap: 10px; position: relative; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type="text"], input:not([type]) {
  background: #111;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#swap {
  justify-self: end;
  margin: -6px 4px -6px 0;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  width: 30px;
  height: 26px;
  cursor: pointer;
}
.budget { grid-template-columns: 1fr auto; align-items: center; margin-top: 4px; }
.budget output { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.budget input { grid-column: 1 / -1; accent-color: var(--accent); }

.actions { display: flex; gap: 8px; }
.actions button, .result-actions a, .result-actions button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
#go { background: var(--accent); color: #1a0d00; }
#go:disabled { opacity: 0.5; cursor: wait; }
#stop { background: #333; color: var(--text); flex: 0 0 auto; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }

#status .phase { font-size: 14px; margin-bottom: 6px; }
.bar { height: 4px; background: #2a2a2a; border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #161616; }
.card.best { border-color: var(--accent); }
.card .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .title strong { font-size: 18px; }
.card .extra { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: #1f1f1f; border-radius: 8px; padding: 8px; }
.stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .d { font-size: 11px; color: var(--ok); }
.roads { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.roads b { color: var(--text); font-weight: 500; }
.result-actions { display: flex; gap: 8px; }
.result-actions a { background: var(--accent); color: #1a0d00; }
.result-actions button { background: #2a2a2a; color: var(--text); }
.nofun { color: var(--muted); font-size: 14px; line-height: 1.5; }

#list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
#list li:hover, #list li.sel { border-color: var(--accent); }
#list li.over { opacity: 0.45; }
#list .meta { grid-column: 1 / -1; color: var(--muted); font-variant-numeric: tabular-nums; }

footer { margin-top: auto; font-size: 11px; color: var(--muted); line-height: 1.5; }
footer a { color: var(--muted); }

.legend { background: rgba(20, 20, 20, 0.85); color: var(--text); padding: 8px 10px; border-radius: 8px; font: 12px/1.6 ui-sans-serif, system-ui, sans-serif; }
.legend i { display: inline-block; width: 18px; height: 4px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }

@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; height: 55%; border-right: 0; border-top: 1px solid var(--line); }
  #map { height: 45%; flex: none; }
  .legend { display: none; }
}

.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
.leaflet-container { background: #1a1a1a; }
