/* Layout A (compact stack) by default; layout B (map beside the journey) on wide screens. */
:root {
  font-family: system-ui, sans-serif;
  color: #eef0f5;
  background: #24252b;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 6px;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #98b8ff;
  outline-offset: 3px;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 15px 16px;
  border-bottom: 1px solid #41434c;
}
header strong {
  font-size: 23px;
}
header small {
  font-size: 12px;
  color: #9cb7fc;
}
#date {
  font-size: 12px;
  color: #a9adba;
}
#help {
  margin-left: auto;
  background: #3b3e47;
  color: #dfe4ee;
  font-size: 12px;
  padding: 7px 11px;
}
#instructions {
  max-width: 700px;
  margin: 12px auto 0;
  padding: 4px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: #cfd5e0;
}
main {
  max-width: 700px;
  margin: 12px auto;
  display: grid;
  gap: 12px;
  padding: 0 12px;
}
h2 {
  font-size: 15px;
  margin: 0;
}

/* Map clue */
.map-section {
  justify-self: center;
  width: clamp(180px, 30vh, 260px);
}
.map-frame {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #686b75;
}
#map,
#map svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* Metrodle-style target: a soft green disc that tightens onto the station, then fades. */
#target {
  fill: #3fae5a;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: target-pulse 2.4s ease-in-out infinite;
}
@keyframes target-pulse {
  0% {
    transform: scale(1.7);
    opacity: 0;
  }
  45%,
  60% {
    transform: scale(1);
    opacity: 0.55;
  }
  100% {
    transform: scale(0.9);
    opacity: 0;
  }
}
.solved #target {
  animation: none;
  opacity: 0.45;
}
@media (prefers-reduced-motion: reduce) {
  #target {
    animation: none;
    opacity: 0.4;
  }
}
#centres circle {
  fill: none;
  stroke: #d0309a;
  stroke-width: 1;
}
#map.full #target {
  opacity: 0.8;
}
.map-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: #b8bfcc;
  text-align: center;
}
#map-view {
  background: #3b3e47;
  color: #dfe4ee;
  font-size: 11px;
  padding: 5px 9px;
}

/* Journey */
.journey-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: #c1c7d3;
}
#rows {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.guess {
  min-height: 40px;
  background: #3b3e47;
  border-radius: 7px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.guess.empty {
  background: #30323a;
  border: 1px solid #3a3c46;
  color: #6e7381;
  font-size: 12px;
}
.station-title {
  font-size: 15px;
  font-weight: 650;
}
.line-swatches {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 18px;
  border: 1px solid #ffffff70;
  border-radius: 2px;
  background: var(--color);
  color: #10151d;
  font-size: 10px;
  font-weight: 800;
}
.line.miss {
  background: #14161a;
  color: #c2c5cb;
  border-color: #777d89;
}
.distance {
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
}
#status {
  font-size: 12px;
  line-height: 1.5;
  color: #c7ceda;
  margin: 10px 0 0;
}
#share {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  background: #486bc1;
  color: white;
  font-weight: 700;
}
#shuffle {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  background: #30323a;
  color: inherit;
  border: 1px solid #656a79;
  font-weight: 700;
}
#share-text {
  width: 100%;
  min-height: 110px;
  margin-top: 8px;
  background: #30323a;
  color: inherit;
  border: 1px solid #656a79;
  border-radius: 6px;
}

/* Entry: typed query, grouped results, on-screen keyboard */
.entry {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 6px 0 10px;
  background: #24252b;
}
.query-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  padding: 7px 10px;
  background: #30323a;
  border-bottom: 1px solid #656a79;
  border-radius: 6px;
}
#query {
  font-size: 18px;
  letter-spacing: 1px;
}
#query.placeholder {
  color: #9ca6b9;
  font-size: 13px;
  letter-spacing: 0;
}
#clear {
  background: transparent;
  color: #c6cbd6;
  font-size: 12px;
}
#results {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: min(44vh, 350px);
  overflow: auto;
  background: #3b3d46;
  border: 1px solid #6c7281;
  border-radius: 6px;
  box-shadow: 0 -8px 25px #0005;
}
#results:empty {
  display: none;
}
.result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 10px;
  color: white;
  background: transparent;
  border-bottom: 1px solid #515460;
  border-radius: 0;
  font-size: 14px;
}
.result.active,
.result:hover {
  background: #525968;
}
.result .line-swatches {
  margin: 0;
  flex-wrap: nowrap;
}
.group-label {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  color: #10151d;
  background: var(--color);
}
.station-group {
  margin: 0;
  padding: 7px 14px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #c4cee3;
}
#keyboard {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.key-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.key {
  flex: 1;
  min-width: 0;
  max-width: 62px;
  height: 40px;
  background: #486bc1;
  color: white;
  font-weight: 750;
}
.key-row:first-child .key {
  height: 26px;
  font-size: 11px;
  background: #3c527f;
}
.key:disabled,
.key-row:first-child .key:disabled {
  background: #3b3e47;
  color: #777d8b;
  cursor: default;
}
.key.wide {
  flex: 1.5;
  max-width: 85px;
  font-size: 11px;
}
footer {
  max-width: 700px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  color: #8e98aa;
}

@media (min-width: 701px) {
  header,
  #instructions {
    padding-left: 24px;
    padding-right: 24px;
  }
  main {
    max-width: 1140px;
    margin-top: 20px;
    padding: 0 24px;
    grid-template-columns: 1.15fr 1fr;
    gap: 24px;
  }
  .map-section {
    width: 100%;
    grid-row: 1 / 3;
    align-self: start;
    position: sticky;
    top: 20px;
  }
  .journey,
  .entry {
    grid-column: 2;
  }
  .guess {
    min-height: 53px;
    padding: 9px 12px;
  }
  .entry {
    position: relative;
    padding: 0;
  }
  #results {
    position: static;
    max-height: 290px;
    margin: 7px 0;
    border: 0;
    box-shadow: none;
  }
  .key {
    height: 45px;
  }
  .map-caption {
    font-size: 12px;
  }
}

/* ?debug panel (local testing only) */
.debug {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  width: 270px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #f4f1e8;
  color: #1c1f26;
  border: 2px solid #d0309a;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 8px 30px #0008;
}
.debug summary {
  cursor: pointer;
  padding: 7px 10px;
  font-weight: 800;
  color: #a01f76;
}
.debug-body {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}
.debug label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.debug select,
.debug input[type="number"] {
  flex: 1;
  min-width: 0;
  font: inherit;
}
.debug-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.debug button {
  background: #fff;
  color: inherit;
  border: 1px solid #b9b3a3;
  padding: 4px 8px;
  font-size: 12px;
}
.debug button:disabled {
  opacity: 0.4;
}
.debug pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 11px;
  background: #fff;
  padding: 6px;
  border-radius: 4px;
}
.debug p {
  margin: 0;
  color: #7a1c5c;
}
