.route-setup {
  position: relative;
  padding: 14px;
  border: 2px solid var(--navy, #0a3161);
  color: var(--navy, #0a3161);
  background: linear-gradient(90deg, rgba(232, 212, 180, 0.72), rgba(255, 249, 239, 0.9)), var(--paper, #fff9ef);
}

.route-setup[hidden],
.route-setup [hidden],
.there-yet-controls[hidden] {
  display: none;
}

/* Keep the complete game visible while the existing picker awaits a route. */
.there-yet-layout[data-route-inactive] .there-yet-route-progress-summary,
.there-yet-layout[data-route-inactive] .there-yet-page-turn {
  visibility: hidden;
}

.there-yet-layout[data-route-inactive] .there-yet-map-stage {
  pointer-events: none;
}

.there-yet-layout[data-route-inactive] :is(button, input) {
  cursor: default;
  opacity: 0.65;
}

.there-yet-controls {
  margin-bottom: 0;
}

.route-setup__cities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: start;
  gap: 12px;
}

.route-setup__field {
  position: relative;
  min-width: 0;
}

.route-setup__field:focus-within {
  z-index: 2;
}

.route-setup__field > label {
  display: block;
  margin-bottom: 6px;
  color: var(--red, #bf0d3e);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.route-setup__input-wrap {
  position: relative;
  display: flex;
  min-width: 0;
  border: 2px solid var(--navy, #0a3161);
  background: var(--paper, #fff9ef);
}

.route-setup input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 10px;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-size: 1rem;
}

.route-setup__clear {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 0;
  color: var(--navy, #0a3161);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

.route-setup__options {
  position: absolute;
  z-index: 4;
  top: calc(100% + 2px);
  right: -2px;
  left: -2px;
  max-height: min(20rem, 45vh);
  overflow: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--navy, #0a3161);
  background: var(--paper, #fff9ef);
  box-shadow: 0 8px 16px rgba(10, 49, 97, 0.15);
}

.route-setup__option {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid rgba(10, 49, 97, 0.18);
  color: inherit;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.route-setup__option:last-child {
  border-bottom: 0;
}

.route-setup__option:hover,
.route-setup__option[aria-selected="true"] {
  color: var(--paper, #fff9ef);
  background: var(--navy, #0a3161);
}

.route-setup :is(input, button):focus-visible {
  outline: 3px solid var(--red, #bf0d3e);
  outline-offset: 2px;
}

.route-setup__feedback,
.route-setup__status {
  margin: 5px 0 0;
  min-height: 1.35em;
  font-size: 0.8rem;
  line-height: 1.35;
}

.route-setup__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 0;
  padding-top: calc(0.78rem * 1.5 + 6px);
  scroll-margin-top: 72px;
}

.route-setup__status {
  flex: 1 1 240px;
  margin: 0;
}

.route-setup__launch {
  min-height: 48px;
  margin-top: 0;
}

.route-setup__launch:disabled {
  opacity: 0.55;
  cursor: default;
}

/* The generated chooser extends the existing paper setup; no game layout changes. */
.route-setup:has(.route-choices) {
  padding: 14px;
}

.route-setup__change {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  color: var(--navy, #0a3161);
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.route-gateways {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.route-gateways__context { grid-column: 1 / -1; margin: 0; font-size: .9rem; line-height: 1.5; }
.route-gateway {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 88px;
  padding: 16px; border: 2px solid var(--navy, #0a3161); color: inherit;
  background: var(--paper, #fff9ef); font: inherit; text-align: left; cursor: pointer;
  overflow-wrap: anywhere; line-height: 1.4;
}
.route-gateway:hover { background: #f3e6cf; }
.route-gateway span { font-size: .875rem; }
@media (max-width: 640px) { .route-gateways { grid-template-columns: minmax(0, 1fr); } }

.route-setup[data-busy="true"] .route-setup__status {
  padding: 10px 14px;
  border-left: 3px solid var(--red, #bf0d3e);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.route-setup[data-busy="true"] input {
  opacity: 0.75;
}

.route-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.route-choices[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
  max-width: 38rem;
}

.route-choice {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(10, 49, 97, 0.5);
  border-top: 4px solid var(--navy, #0a3161);
  color: var(--navy, #0a3161);
  background: #fff9ef;
  box-shadow: 3px 4px 0 rgba(10, 49, 97, 0.08);
}

.route-choice__label {
  margin: 0 0 8px;
  color: var(--red, #bf0d3e);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  line-height: 1.4;
}

.route-choice__miles {
  margin: 0;
  line-height: 1.1;
}

.route-choice__miles strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 2.65rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.route-choice__miles span {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.route-choice__extra {
  margin: 8px 0 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.route-choice__roads {
  margin: 10px 0 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(10, 49, 97, 0.22);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.route-choice__states {
  margin: 0 0 12px;
  font-size: 0.875rem;
  letter-spacing: 0.035em;
  line-height: 1.6;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.route-choice__take {
  align-self: flex-start;
  min-height: 48px;
  max-width: 100%;
  margin-top: auto;
  padding: 12px 16px;
  border: 2px solid var(--navy, #0a3161);
  color: #fff9ef;
  background: var(--navy, #0a3161);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.035em;
  cursor: pointer;
}

.route-choice__take:hover {
  border-color: var(--red, #bf0d3e);
  background: var(--red, #bf0d3e);
}

.route-choice__take:disabled {
  opacity: 0.65;
  cursor: wait;
}

.route-choice-diagnostics {
  margin: 16px 0;
  font-size: 0.875rem;
}

.route-choice-diagnostics pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .route-setup__cities {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .route-setup__actions {
    padding-top: 0;
  }

  .route-setup__launch {
    width: 100%;
  }
}

@media (max-width: 580px) {
  .route-choices {
    grid-template-columns: minmax(0, 1fr);
  }

  .route-choice__take {
    align-self: stretch;
    width: 100%;
  }
  .route-setup__cities {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .route-setup__launch {
    width: 100%;
  }
}
