:root {
  --bg: #0b1220;
  --bg-soft: #111c2e;
  --line: #1e2d44;
  --text: #e6edf7;
  --text-dim: #8ba0bd;
  --accent: #f87171;
  --ok: #16a34a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

html {
  /* 猜测列表从空到有会让页面出现滚动条，不占位就会导致地图宽度跳变、点击坐标偏 */
  scrollbar-gutter: stable;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #16273f 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
  flex: none;
}

.mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.brand h1 {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.02em;
}

.meta {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.stage {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.prompt {
  padding: 16px 18px 10px;
  text-align: center;
}

.ask {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.answer-slot {
  margin: 4px 0 2px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-height: 40px;
  color: var(--text);
}

.answer-slot.revealed { color: #7dd3fc; }

.hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 19px;
}

.map-wrap {
  position: relative;
  background: #0a1526;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

#map {
  display: block;
  width: 100%;
  height: auto;
  /* 未缩放时让页面能正常纵向滚动；放大后由 JS 切成 none 接管拖拽 */
  touch-action: pan-y;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  background: #0a1526;
}

.map-loading[hidden] { display: none; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  justify-content: center;
  padding: 9px 14px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.legend[hidden] { display: none; }

.lg { display: inline-flex; align-items: center; gap: 5px; }

.lg i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.link-btn {
  margin-left: auto;
  padding: 2px 9px;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--text);
  background: #1b2b42;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.link-btn:hover { background: #24374f; }
.link-btn[hidden] { display: none; }

.panel {
  margin-top: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row[hidden] { display: none; }

.combo {
  position: relative;
  flex: 1;
  min-width: 0;
}

#guess {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--text);
  background: #0a1526;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font-family: inherit;
}

#guess:focus { border-color: #3b6ea8; }

#guess::placeholder { color: #5b7294; }

.suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #142135;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.suggest[hidden] { display: none; }

.suggest li {
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}

.suggest li:hover, .suggest li[aria-selected="true"] {
  background: #1d2f49;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  color: #0b1220;
  background: var(--accent);
  cursor: pointer;
  flex: none;
  transition: filter 0.15s, opacity 0.15s;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:hover { background: #16233a; }

.result-row {
  display: flex;
  gap: 8px;
}

.result-row[hidden] { display: none; }

.error {
  margin: 10px 0 0;
  font-size: 13px;
  color: #fca5a5;
}

.error[hidden] { display: none; }

.guesses {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guesses:empty { display: none; }

.guesses li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #0a1526;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.guesses .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.guesses .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guesses .km {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
}

.guesses li.correct {
  border-color: rgba(22, 163, 74, 0.5);
  background: rgba(22, 163, 74, 0.12);
}

.guesses li.correct .km { color: #86efac; }

.countdown {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.howto {
  margin-top: 26px;
  color: var(--text-dim);
  font-size: 14px;
}

.howto h2 {
  font-size: 14px;
  color: var(--text);
  margin: 22px 0 8px;
  font-weight: 650;
}

.howto ul { margin: 0; padding-left: 20px; }
.howto li { margin-bottom: 5px; }
.howto b { color: var(--text); }
.howto p { margin: 0; }

.foot {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 34px;
  font-size: 12px;
  color: #5b7294;
}

@media (max-width: 560px) {
  .answer-slot { font-size: 23px; }
  .brand h1 { font-size: 16px; }
  .meta { font-size: 11.5px; }
  .btn { padding: 11px 16px; }
  .legend { gap: 3px 10px; font-size: 11px; }
}