:root {
  color-scheme: dark;
  --map-land: color-mix(in srgb, var(--ground) 65%, var(--ground-raised));
  --map-coast: color-mix(in srgb, var(--ground) 62%, var(--ink-muted));
  --brand-mark: url("./brand/layover-mark-night.svg");
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
}

[data-theme="day"] {
  color-scheme: light;
  --map-land: color-mix(in srgb, var(--ground) 84%, var(--ink-muted));
  --map-coast: color-mix(in srgb, var(--ground) 58%, var(--ink-muted));
  --brand-mark: url("./brand/layover-mark-day.svg");
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .48; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ink-muted); outline-offset: 3px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: var(--stroke-control); stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.wrap { width: min(1200px, calc(100% - 80px)); margin-inline: auto; }

.intro { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block: var(--space-3); }
.intro-brand { width: clamp(208px, 29vw, 344px); }
.brand-lockup { margin: 0; line-height: 0; }
.brand-lockup img { display: block; width: 100%; height: auto; }
.brand-lockup .lockup-day, [data-theme="day"] .brand-lockup .lockup-night { display: none; }
[data-theme="day"] .brand-lockup .lockup-day { display: block; }
.brand-tagline { margin: 0 0 0 35%; color: var(--ink-muted); font-size: clamp(9px, 1vw, 12px); font-weight: 600; line-height: 1.35; letter-spacing: .25em; text-transform: uppercase; }
.intro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.help-button, .day-notice button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 7px 12px; border: 1px solid var(--ink-muted); border-radius: var(--radius-none); background: transparent; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.help-button:hover:enabled, .day-notice button:hover:enabled { background: var(--ground-raised); }
.eyebrow, .map-status, .endpoint-label { color: var(--ink-muted); font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: var(--space-2); }

.day-notice { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); padding: 10px var(--space-3); border-block: 1px solid var(--hairline); background: var(--ground-raised); color: var(--ink); font-size: 13px; }

.game { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(350px, 1fr); align-items: start; gap: var(--space-3); }
.map-card, .ticket { border: 1px solid var(--hairline); border-radius: var(--radius-m); background: var(--ground-raised); }
.map-card { grid-area: 1 / 1; overflow: hidden; }
.map-heading, .map-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px var(--space-3); }
.map-heading { border-bottom: 1px solid var(--hairline); }
.map-heading > div { display: flex; align-items: center; gap: var(--space-2); }
.map-heading .icon { color: var(--ink); }
.map-heading h2 { margin: 0; font-size: 15px; font-weight: 700; }
.map-status { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.map-status i { display: inline-block; width: 6px; height: 6px; flex: none; border-radius: var(--radius-pill); background: var(--ink-muted); }
.chart { background: var(--ground); }
.map-land { fill: var(--map-land); stroke: var(--map-coast); }
.map-grid { stroke: var(--hairline); }
.map-viewport { position: relative; }
#route-map { display: block; width: 100%; height: auto; aspect-ratio: 900 / 375; touch-action: pan-y; }
#route-map:focus-visible { outline-offset: -3px; }
#route-map[data-zoomed="true"] { cursor: grab; touch-action: none; }
#route-map.is-dragging { cursor: grabbing; }
.map-tools { position: absolute; top: 8px; right: 8px; display: grid; gap: 4px; }
.map-tools button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--ink-muted); border-radius: var(--radius-none); background: var(--ground-raised); color: var(--ink); }
.map-tools button:hover:enabled { background: var(--ground); }
.zoom-level { position: absolute; bottom: 8px; right: 8px; padding: 4px 7px; border: 1px solid var(--hairline); background: var(--ground-raised); color: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; pointer-events: none; }
.oceans { fill: var(--ink-muted); font-size: 8px; font-weight: 600; letter-spacing: 2px; }
.map-footer { justify-content: flex-end; min-height: 36px; padding-block: 8px; border-top: 1px solid var(--hairline); color: var(--ink-muted); }
#network-count { font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }

.ticket { grid-area: 1 / 2; padding: var(--space-3); }
.ticket-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: 12px; }
.ticket-top .icon { width: 15px; height: 15px; }
.ticket h2 { margin: 5px 0 0; font-size: 22px; line-height: 1.15; }
.icon-button, .remove-stop { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid var(--ink-muted); border-radius: var(--radius-none); background: transparent; }
.icon-button:hover:enabled, .remove-stop:hover:enabled { background: var(--ground); }
.round-meta { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); margin: 0 0 12px; font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.round-meta > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 10px; }
.difficulty { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border: 1px solid var(--ink-muted); border-radius: var(--radius-pill); color: var(--ink); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
#route-form { margin-top: var(--space-3); }
.builder-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--space-1) var(--space-2); align-items: baseline; margin-bottom: var(--space-2); }
.builder-heading h3 { margin: 0; font-size: 14px; font-weight: 700; }
.builder-counts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); color: var(--ink-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.builder-counts span:empty { display: none; }
#solution-count { padding-inline-start: var(--space-2); border-inline-start: 1px solid var(--hairline); }
.route-chain {
  --route-rail: 17px;
  --route-dot: 10px;
  padding-block: var(--space-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  background: var(--ground);
}
.route-chain .endpoint, .stop-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: 52px;
  padding: var(--space-1) var(--space-2) var(--space-1) 34px;
}
.route-chain .endpoint::before, .stop-slot::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--route-rail);
  width: 1px;
  background: var(--ink-muted);
  content: "";
}
.route-chain .endpoint::after, .stop-slot::after {
  position: absolute;
  top: 50%;
  inset-inline-start: calc(var(--route-rail) - var(--route-dot) / 2 + .5px);
  width: var(--route-dot);
  height: var(--route-dot);
  border: 1px solid var(--ink-muted);
  border-radius: var(--radius-pill);
  background: var(--ground);
  transform: translateY(-50%);
  content: "";
}
.route-chain .departure::before { inset-block-start: 50%; }
.route-chain .arrival::before { inset-block-end: 50%; }
.route-chain .departure::after { border-color: var(--horizon); background: var(--horizon); }
.route-chain .arrival::after, .stop-slot:has(.stop-place)::after { border-color: var(--ink); background: var(--ink); }
.endpoint-code { display: grid; gap: 2px; min-width: 44px; }
.endpoint-label { font-size: 10px; }
.endpoint-code strong { font-size: 21px; line-height: 1; font-weight: 800; }
.endpoint-place { min-width: 0; overflow-wrap: anywhere; }
.city, .airport-name { display: block; }
.city { font-size: 14px; font-weight: 700; line-height: 1.2; }
.airport-name { margin-top: 3px; color: var(--ink-muted); font-size: 12px; line-height: 1.3; }
#stops { margin: 0; padding: 0; list-style: none; }
.slot-search {
  width: 100%;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  border: 1px dashed var(--ink-muted);
  background: var(--ground);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: start;
}
.slot-search:hover:enabled { border-style: solid; background: var(--ground-raised); }
.stop-slot > .search-wrap { flex: 1; min-width: 0; }
.stop { display: flex; flex: 1; align-items: center; gap: var(--space-2); min-width: 0; }
.stop > strong, .match-code { font-size: 13px; font-weight: 800; letter-spacing: .06em; }
.stop-place { flex: 1; min-width: 0; padding-block: 4px; overflow-wrap: anywhere; }
.stop-city, .stop-airport { display: block; }
.stop-city { font-size: 13px; font-weight: 700; }
.stop-airport { margin-top: 2px; color: var(--ink-muted); font-size: 12px; line-height: 1.3; }
.remove-stop { border: 0; }
.remove-stop:hover:enabled { background: var(--ground-raised); }
.remove-stop .icon { width: 15px; height: 15px; }
.search-wrap { position: relative; }
.search-field { display: flex; align-items: center; gap: var(--space-2); padding-left: 10px; min-height: 46px; border: 1px solid var(--ink-muted); background: var(--ground); color: var(--ink); }
.search-field:focus-within { outline: 2px solid var(--ink-muted); outline-offset: 2px; }
.search-field input { outline: none; min-width: 0; min-height: 44px; flex: 1; border: 0; color: var(--ink); background: transparent; font-size: 14px; }
.search-field input::placeholder { color: var(--ink-muted); opacity: 1; }
#add-stop { width: 44px; height: 44px; padding: 0; border: 0; border-inline-start: 1px solid var(--ink-muted); background: transparent; }
#add-stop:hover:enabled { background: var(--ground-raised); }
#matches { z-index: 2; position: absolute; inset: calc(100% + 6px) 0 auto; margin: 0; padding: 4px; max-height: 230px; overflow: auto; list-style: none; border: 1px solid var(--ink-muted); background: var(--ground-raised); }
.match { display: flex; gap: var(--space-2); align-items: center; min-height: 44px; padding: 6px 8px; cursor: pointer; }
.match:hover, .match[aria-selected="true"] { background: var(--ground); outline: 1px solid var(--ink-muted); outline-offset: -1px; }
.match-code { padding: 4px 5px; border: 1px solid var(--hairline); }
.place-match .match-code, .place-stop > strong { flex: none; color: var(--ink-muted); font-size: 10px; }
.match span:last-child { min-width: 0; }
.match strong, .match small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match strong { font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
.place-match strong { white-space: normal; overflow-wrap: anywhere; }
.match small, .no-match { font-size: 12px; color: var(--ink-muted); }
.no-match { padding: 9px; }
.input-message { margin: 8px 0 0; font-size: 13px; color: var(--ink); }
.text-button { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; border: 0; background: transparent; padding: 4px 0; font-size: 13px; font-weight: 700; color: var(--ink-muted); }
.text-button:hover:enabled { text-decoration: underline; text-underline-offset: 3px; }
.text-button .icon { width: 16px; height: 16px; }
.editing-note { margin: var(--space-2) 0; color: var(--ink-muted); font-size: 12px; }
.submit-actions { display: flex; gap: var(--space-2); }
#check-route { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: var(--space-2); border: 0; border-bottom: var(--stroke-horizon) solid var(--horizon); padding-top: var(--stroke-horizon); border-radius: var(--radius-none); background: var(--ink); color: var(--ground); font-size: 15px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
#check-route:hover:enabled { opacity: .9; }
#check-route .icon { width: 18px; height: 18px; }
#route-hint { flex: none; white-space: nowrap; }
#route-hint:hover:enabled { background: var(--ground); }
#give-up { margin-top: var(--space-1); }

.attempt-history { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--hairline); }
.attempt-history h3 { margin: 0; font-size: 13px; }
#attempts { margin: var(--space-1) 0 0; padding-inline-start: 22px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
#attempts li { padding: var(--space-1) 0; }
#attempts li::marker { color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.result { margin-top: 12px; padding: 12px; border: 1px solid var(--hairline); border-radius: var(--radius-m); background: var(--ground); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.result.error { border-inline-start: var(--stroke-control) solid var(--horizon); }
.result h3 { margin: 0 0 4px; font-size: 16px; }
.result p { margin: 3px 0 0; }
.result ul { margin: 5px 0 0; padding-left: 18px; }
.compass-clue {
  margin-top: var(--space-2);
  padding: var(--space-2) 10px;
  border: 1px solid var(--hairline);
  border-inline-start: var(--stroke-horizon) solid var(--ink-muted);
  background: var(--ground);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#hint-feedback { display: grid; grid-template-columns: minmax(70px, auto) minmax(0, 1fr); align-items: center; gap: var(--space-1) var(--space-2); }
.clue-heading { grid-column: 1 / -1; margin: 0; color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.clue-reading {
  --clue-accent: var(--ink-muted);
  justify-self: start;
  margin: 0;
  padding: 2px var(--space-2);
  border: 1px solid var(--clue-accent);
  background: color-mix(in srgb, var(--clue-accent) 14%, var(--ground));
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}
.clue-reading[data-temperature="hot"] { --clue-accent: var(--horizon); }
.clue-reading[data-temperature="warm"] { --clue-accent: color-mix(in srgb, var(--horizon) 68%, var(--ink)); }
.clue-reading[data-temperature="cool"] { --clue-accent: color-mix(in srgb, var(--ink-muted) 62%, var(--ink)); }
.clue-reading[data-temperature="ice-cold"] { --clue-accent: color-mix(in srgb, var(--sky) 55%, var(--blue)); }
.clue-direction { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; }
.clue-dial {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink-muted);
  border-radius: var(--radius-pill);
  color: var(--ink-muted);
  font-weight: 800;
  vertical-align: middle;
}
.clue-dial > span { position: absolute; top: 2px; font-size: 9px; line-height: 1; }
.clue-dial svg { display: block; width: 22px; height: 22px; transform-origin: center; }
.clue-copy { margin: 0; }
.clue-heading + .clue-copy { grid-column: 1 / -1; }
.clue-trend { display: block; color: var(--ink-muted); font-size: 11px; font-weight: 600; }
#route-hint-content { margin: var(--space-2) 0 0; padding: var(--space-2) 10px; border: 1px solid var(--hairline); background: var(--ground); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.itinerary-review { margin-top: 12px; border: 1px solid var(--hairline); background: var(--ground); }
.itinerary-review summary { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: var(--space-2) 12px; list-style: none; cursor: pointer; font-size: 13px; font-weight: 700; }
.itinerary-review summary::-webkit-details-marker { display: none; }
.itinerary-review summary::before { content: ""; width: 7px; height: 7px; flex: none; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); }
.itinerary-review[open] summary::before { transform: rotate(45deg); }
.itinerary-review summary:hover { background: var(--ground-raised); }
#itinerary-status { margin-inline-start: auto; color: var(--ink-muted); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; text-align: right; }
.itinerary-body { padding: 0 12px 12px; }
#legs { display: grid; list-style: none; margin: 0; padding: 0; }
.itinerary-leg { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: 10px 0; border-top: 1px solid var(--hairline); }
.leg-mark { display: grid; flex: none; place-items: center; width: 24px; height: 24px; border: 1px solid var(--ink-muted); border-radius: var(--radius-pill); color: var(--ink-muted); font-size: 15px; }
.confirmed .leg-mark { color: var(--ground); background: var(--ink); border-color: var(--ink); }
.missing .leg-mark { color: var(--ink); border-color: var(--horizon); }
.place-leg .leg-mark { border-style: dashed; }
.leg-details { display: flex; flex: 1; min-width: 130px; flex-direction: column; gap: 3px; }
.leg-details strong { font-size: 13px; font-weight: 700; }
.leg-details > span, .leg-km, .network-note { color: var(--ink-muted); font-size: 12px; }
.leg-details .leg-cities { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.leg-km { font-variant-numeric: tabular-nums; }
.leg-source { color: var(--ink-muted); font-size: 12px; text-underline-offset: 3px; }
.network-note { margin: var(--space-1) 0 0; line-height: 1.5; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--space-2); margin-top: 4px; }
.copy-status { font-size: 12px; color: var(--ink-muted); line-height: 1.5; margin: 8px 0 0; }
#copy-output { width: 100%; height: 110px; resize: vertical; margin-top: 10px; padding: 10px; font-size: 13px; line-height: 1.5; color: var(--ink); border: 1px solid var(--ink-muted); background: var(--ground); }

.footer { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; margin: var(--space-3) 0 var(--space-4); color: var(--ink-muted); font-size: 12px; }
.footer p { margin: 0; }
.footer a { color: var(--ink-muted); text-underline-offset: 3px; font-weight: 700; }
.footer .icon { width: 14px; height: 14px; }
dialog { width: min(470px, calc(100% - 30px)); max-height: calc(100% - 40px); padding: 20px; color: var(--ink); background: var(--ground-raised); border: 1px solid var(--hairline); border-radius: var(--radius-m); font-size: 14px; line-height: 1.5; }
dialog::backdrop { background: color-mix(in srgb, var(--navy) 76%, transparent); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.give-up-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
#confirm-give-up { background: var(--ink); color: var(--ground); }
#confirm-give-up:hover:enabled { opacity: .9; }
dialog ol { padding-left: 22px; }
dialog li + li { margin-top: 7px; }
.snapshot-note { margin-bottom: 0; font-size: 12px; line-height: 1.5; color: var(--ink-muted); }
.data-credits { margin-top: 10px; font-size: 12px; color: var(--ink-muted); }
.data-credits summary { color: var(--ink); cursor: pointer; }
.data-credits a { color: inherit; text-underline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 1020px) {
  .wrap { width: calc(100% - 48px); }
  .game { grid-template-columns: minmax(0, 1.45fr) minmax(318px, 1fr); }
}
@media (max-width: 710px) {
  .wrap { width: calc(100% - 32px); }
  .intro { flex-direction: column; align-items: flex-start; gap: 12px; }
  .intro-actions { gap: 6px; }
  .intro-actions .help-button { padding-inline: 9px; font-size: 11px; }
  .game { display: flex; flex-direction: column; }
  .map-card, .ticket { width: 100%; }
  .map-tools { grid-auto-flow: column; }
  .day-notice { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 370px) {
  .wrap { width: calc(100% - 24px); }
  .ticket { padding: 12px; }
}
@media (max-width: 319px) { .brand-tagline { display: none; } }
