:root {
  /* Avalonian night: tinted stone, pale portal light, gold for the destination */
  --abyss: #0f1e23;
  --stone: #172a30;
  --stone-2: #1f363d;
  --line: #2c474e;
  --bone: #e4ece8;
  --mist: #8ba5a9;
  --portal: #79d8c6;
  --portal-dim: #79d8c62e;
  --gold: #e2be6a;
  --bad: #e07a68;
  --bad-dim: #e07a6826;
  --zone-black: #9aa3a6;
  --zone-red: #e0614f;
  --zone-yellow: #e7c552;
  --zone-blue: #5ea3e6;
  --zone-city: #b991e6;

  --display: "Marcellus", "Palatino Linotype", Georgia, serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 15% -120px, #79d8c61a, transparent 70%),
    var(--abyss);
  background-attachment: fixed;
  color: var(--bone);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

.top, main, footer { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { padding-top: 44px; padding-bottom: 6px; }
h1 {
  margin: 0;
  font: 400 40px/1.1 var(--display);
  letter-spacing: .02em;
  color: var(--bone);
}
.sub { margin: 10px 0 0; color: var(--mist); max-width: 60ch; }
h2 { margin: 0; font: 400 22px/1.2 var(--display); letter-spacing: .02em; }

/* Destination sentence */
.setup {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  margin: 28px 0 0; padding: 18px 20px;
  background: var(--stone);
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  border-radius: 14px;
}
.phrase { font-size: 18px; color: var(--mist); }
.target-combo { flex: 1 1 260px; }
.target-combo input { font-size: 18px; padding: 10px 14px; }

input[type=text], input[type=number] {
  width: 100%;
  background: var(--abyss);
  border: 1px solid var(--line);
  color: var(--bone);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
input::placeholder { color: #8ba5a9a6; }
input:focus { border-color: var(--portal); box-shadow: 0 0 0 3px var(--portal-dim); }
input.chosen { border-color: var(--gold); color: var(--gold); }

.stepper { display: flex; }
.stepper input {
  width: 56px; text-align: center; border-radius: 0; font-size: 18px; font-weight: 700;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button {
  width: 40px; background: var(--stone-2); color: var(--bone);
  border: 1px solid var(--line); font: 20px/1 var(--body); cursor: pointer;
}
.stepper button:first-child { border-radius: 8px 0 0 8px; border-right: 0; }
.stepper button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.stepper button:hover { color: var(--portal); }

:focus-visible { outline: 2px solid var(--portal); outline-offset: 2px; }
input:focus-visible { outline: none; }

/* Exits panel */
.exits {
  margin: 16px 0 24px; padding: 20px;
  background: var(--stone);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hint { color: var(--mist); margin: 6px 0 14px; font-size: 15px; }
kbd {
  font: 700 12px/1 var(--body); color: var(--bone);
  background: var(--stone-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 2px 6px;
}

button.ghost {
  background: none; border: 1px solid var(--line); color: var(--mist);
  border-radius: 999px; padding: 5px 14px; cursor: pointer; font: inherit; font-size: 14px;
}
button.ghost:hover { color: var(--bone); border-color: var(--mist); }

/* Autocomplete */
.combo { position: relative; }
.suggest {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 4px; list-style: none;
  background: var(--stone-2); border: 1px solid var(--line); border-radius: 10px;
  max-height: 300px; overflow-y: auto; box-shadow: 0 16px 40px #050d10b3;
  font-size: 16px; color: var(--bone);
}
.suggest li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.suggest li.active { background: #2c474e; }
.suggest mark, .nearby mark { background: none; color: var(--portal); font-weight: 700; }
.suggest .meta, .nearby .meta { margin-left: auto; color: var(--mist); font-size: 13px; white-space: nowrap; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot.black { background: var(--zone-black); }
.dot.red { background: var(--zone-red); }
.dot.yellow { background: var(--zone-yellow); }
.dot.blue { background: var(--zone-blue); }
.dot.city { background: var(--zone-city); }

/* Maps near the destination, shown while adding exits */
.nearby {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--abyss); max-height: 320px; overflow-y: auto;
}
.nearby ul { list-style: none; margin: 0; padding: 4px; }
.nearby li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  box-shadow: inset 3px 0 0 transparent;
}
.nearby li.active { background: var(--stone-2); }
.nearby li.edge { box-shadow: inset 3px 0 0 var(--bad); background: var(--bad-dim); }
.nearby li.edge.active { background: #e07a6840; }
.nearby li.edge .dist { color: var(--bad); }
.nearby li.far { opacity: .55; }
.nearby .dist {
  min-width: 52px; text-align: right; font-size: 14px; font-weight: 700; color: var(--portal);
  font-variant-numeric: tabular-nums;
}
.nearby li.far .dist { color: var(--mist); }
.nearby-head, .nearby-sub {
  position: sticky; top: 0; z-index: 1; background: var(--abyss);
  padding: 9px 14px 8px; font-size: 14px; color: var(--mist);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.nearby-sub { position: static; border-top: 1px solid var(--line); }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sw.edge { width: 10px; height: 10px; border-radius: 2px; background: var(--bad); display: inline-block; }
.nearby-empty { padding: 12px 14px; color: var(--mist); font-size: 15px; }

/* Results */
.summary { margin: 18px 0 8px; color: var(--mist); font-size: 15px; min-height: 1em; }
.summary strong { color: var(--portal); }
.results { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.result { padding: 12px 4px 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
.result::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px;
  background: var(--line);
}
.result.in::before { background: var(--portal); }
.result.out::before { background: var(--bad); }
.result.out .name, .result.none .name { color: #e4ece8b8; }
.result .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result .name { font-weight: 700; font-size: 17px; }
.result .tier { color: var(--mist); font-size: 13px; }

/* Hop track: one pip per map of the allowed range */
.track {
  margin-left: auto; display: inline-flex; align-items: center; gap: 3px;
  width: 160px; flex: none;
}
.track i {
  flex: 1; height: 8px; min-width: 2px; border-radius: 4px;
  background: var(--stone-2); box-shadow: inset 0 0 0 1px var(--line);
}
.in .track i.on { background: var(--portal); box-shadow: 0 0 8px #79d8c666; }
.out .track i.on { background: var(--bad); box-shadow: none; }
.track b { flex: none; width: 26px; color: var(--bad); font-size: 13px; margin-left: 2px; font-variant-numeric: tabular-nums; }

.badge {
  min-width: 64px; text-align: right; font-size: 15px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.track + .badge { margin-left: 0; }
.head > .tier + .badge { margin-left: auto; }
.in .badge { color: var(--portal); }
.out .badge { color: var(--bad); }
.none .badge { color: var(--mist); font-weight: 400; }
.result .remove {
  background: none; border: 0; color: var(--mist); cursor: pointer;
  font-size: 20px; line-height: 1; width: 28px; height: 28px; border-radius: 50%;
}
.result .remove:hover { color: var(--bad); background: var(--bad-dim); }

/* Route as a chain of maps toward the destination */
.path {
  margin-top: 8px; padding-left: 20px; font-size: 14px; color: var(--mist);
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center;
}
.path .step { color: #e4ece8d9; }
.path .arrow {
  width: 14px; height: 2px; border-radius: 1px; background: var(--line); position: relative;
}
.path .arrow::after {
  content: ""; position: absolute; right: -1px; top: -2px;
  border: 3px solid transparent; border-left: 4px solid var(--line); border-right: 0;
}
.path .step.target { color: var(--gold); font-weight: 700; }

.empty { color: var(--mist); padding: 22px 0 10px; border: 0; }

footer { color: var(--mist); font-size: 13px; padding-bottom: 40px; max-width: 720px; }
footer a { color: var(--bone); }

@media (max-width: 560px) {
  .top { padding-top: 26px; }
  h1 { font-size: 32px; }
  .setup, .exits { padding: 16px; }
  .phrase { font-size: 16px; }
  .result .head {
    display: grid; grid-template-columns: 10px 1fr auto 28px; gap: 4px 10px;
  }
  .result .head > * { grid-row: 1; margin-left: 0; }
  .result .head .dot { grid-column: 1; }
  .result .head .name { grid-column: 2; }
  .result .head .badge { grid-column: 3; min-width: 0; }
  .result .head .remove { grid-column: 4; }
  .result .head .tier { grid-row: 2; grid-column: 2 / 5; }
  .result .head .track { grid-row: 3; grid-column: 2 / 4; width: auto; margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
