:root {
  --bg: #121418;
  --panel: #1a1d24;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --danger: #c44;
  --ok: #3d9;
  --line: #2a3140;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #1a2030 0%, var(--bg) 55%);
  color: var(--text);
}

header {
  padding: 1.25rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

header h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.75rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.info-btn {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  padding: 0;
  font-weight: 800;
  line-height: 1;
}

header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 380px;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.map-wrap {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  min-height: 420px;
  position: relative;
}

.map-wrap.map-explore {
  cursor: grab;
  touch-action: none;
}

.map-wrap.map-explore:active {
  cursor: grabbing;
}

.map-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

label {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

input[type="search"],
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0e1016;
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.autocomplete-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1016;
}

.autocomplete-list li {
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid #222833;
}

.station-option-name {
  font-weight: 600;
}

.station-option-lines {
  margin-left: 0.45rem;
}

.autocomplete-list li:last-child {
  border-bottom: none;
}

.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] {
  background: #222a3a;
}

.autocomplete-list li.guessed {
  text-decoration: line-through;
  opacity: 0.55;
  cursor: default;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.mode-row {
  margin-top: 0.45rem;
}

.mode-row button {
  flex: 1;
}

button.mode-active {
  background: linear-gradient(180deg, #3d5a9e, #2c4175);
  border-color: #4a6ab8;
}

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2a3348, #1e2433);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
}

button.primary {
  background: linear-gradient(180deg, #3d5a9e, #2c4175);
  border-color: #4a6ab8;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guess-log {
  list-style: none;
  margin: 0;
  padding: 0;
}

.guess-log li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #2a3140;
  font-size: 0.9rem;
}

.guess-log li:last-child {
  border-bottom: none;
}

.stats-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: grid;
  gap: 0.2rem;
}

.stats-histogram {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.3rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 18px 1fr 28px;
  align-items: center;
  gap: 0.45rem;
}

.stats-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
}

.stats-track {
  height: 0.62rem;
  border-radius: 999px;
  background: #0e1016;
  border: 1px solid #2a3140;
  overflow: hidden;
}

.stats-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, #4f85ff, #73a1ff);
}

.stats-value {
  color: var(--text);
  font-size: 0.78rem;
  text-align: right;
}

.guess-name {
  font-weight: 600;
}

.guess-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-right: 0.2rem;
  vertical-align: middle;
}

.status-bar {
  font-size: 0.85rem;
  color: var(--muted);
}

.status-bar strong {
  color: var(--text);
}

.win {
  color: var(--ok);
  font-weight: 600;
}

.lose {
  color: var(--danger);
}

.line-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.station-list-scroll {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.station-list-scroll div {
  padding: 0.2rem 0;
  border-bottom: 1px solid #222833;
}

.station-list-scroll div:last-child {
  border-bottom: none;
}

.station-list-scroll .guessed {
  text-decoration: line-through;
  opacity: 0.55;
}

footer {
  padding: 1rem 1.5rem 2rem;
  max-width: 1280px;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Map overlay: Metrodle-style target pulse + guessed station labels */
#map-wrap svg .mtd-target-ring {
  fill: rgba(58, 143, 255, 0.12);
  stroke: #3a8fff;
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: mtd-target-pulse 1.85s ease-in-out infinite;
}

#map-wrap svg .mtd-target-dot {
  fill: #ffffff;
  stroke: #1e3a6e;
  stroke-width: 1.5;
}

@keyframes mtd-target-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.88);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

#map-wrap svg .guess-station-label {
  font-size: 11px;
  font-weight: 600;
  fill: #141820;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3px;
  paint-order: stroke fill;
  pointer-events: none;
}

#map-wrap svg .answer-station-label {
  font-size: 12px;
  font-weight: 700;
  fill: var(--ok);
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 3px;
  paint-order: stroke fill;
  pointer-events: none;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  margin-right: 0.25rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #0b1020;
  background: var(--pill, #888888);
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.route-pill.route-pill-acorn {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: none;
}

.route-pill.route-pill-acorn img {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  object-fit: contain;
}

.win-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  padding: 1.25rem;
}

.win-modal.open {
  display: flex;
}

.win-modal-card {
  max-width: 520px;
  width: min(520px, 100%);
  background: linear-gradient(180deg, #1f2636, #151a24);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 1.1rem;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.win-modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.win-modal-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
