:root {
  color-scheme: dark;
  --ink: #f7fbf8;
  --muted: #a8bdb3;
  --soft: rgba(247, 251, 248, 0.72);
  --panel: rgba(9, 23, 18, 0.78);
  --panel-strong: rgba(12, 33, 26, 0.92);
  --line: rgba(238, 255, 246, 0.16);
  --accent: #48e0a4;
  --accent-strong: #26c281;
  --amber: #ffbf47;
  --cyan: #5fd4ff;
  --rose: #ff6b81;
  --blue: #5578ff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  --radius: 8px;
  --radius-sm: 6px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(8, 33, 27, 0.98), rgba(21, 20, 18, 0.98) 52%, rgba(23, 32, 43, 0.98)),
    #0b1713;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  width: 100vw;
  height: 100vh;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
  background: #07110d;
}

.map {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(45deg, rgba(72, 224, 164, 0.06), transparent),
    #07110d;
}

.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  background:
    radial-gradient(circle at 42% 45%, transparent 0, transparent 42%, rgba(4, 10, 8, 0.18) 72%, rgba(4, 10, 8, 0.55) 100%),
    linear-gradient(90deg, rgba(3, 10, 8, 0.3), transparent 28%, transparent 68%, rgba(3, 10, 8, 0.44));
}

.scanline {
  position: absolute;
  inset: 0;
  z-index: 401;
  pointer-events: none;
  opacity: 0.2;
  background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 100% 5px;
  mix-blend-mode: overlay;
}

.map-badge,
.zoom-stack {
  position: absolute;
  z-index: 450;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(4, 14, 10, 0.64);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.map-badge {
  left: 24px;
  top: 24px;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--soft);
}

.map-badge svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.text-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.zoom-stack {
  left: 24px;
  bottom: 24px;
  gap: 8px;
  min-height: 52px;
  padding: 9px;
  border-radius: 999px;
}

.zoom-step {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.06);
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.zoom-step.is-active {
  color: #06140f;
  border-color: rgba(72, 224, 164, 0.82);
  background: var(--accent);
  transform: translateY(-2px);
}

.zoom-step.is-past {
  color: var(--accent);
  border-color: rgba(72, 224, 164, 0.32);
  background: rgba(72, 224, 164, 0.1);
}

.console {
  position: relative;
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  padding: 28px;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(11, 28, 23, 0.95), rgba(11, 17, 20, 0.94)),
    var(--panel-strong);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 850;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  font-size: 30px;
  line-height: 1.15;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.icon-button:hover,
.secondary-button:hover,
.text-button:hover {
  border-color: rgba(72, 224, 164, 0.5);
  background: rgba(72, 224, 164, 0.12);
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.text-button:active {
  transform: translateY(1px);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.1;
}

.guess-form {
  position: relative;
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.guess-form label {
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

.input-wrap {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.input-wrap:focus-within {
  border-color: rgba(72, 224, 164, 0.78);
  box-shadow: 0 0 0 4px rgba(72, 224, 164, 0.1);
}

.input-wrap svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-right: 10px;
  color: var(--accent);
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.suggestions {
  position: absolute;
  top: 82px;
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 228px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(8, 24, 19, 0.98);
  box-shadow: var(--shadow);
}

.suggestions.is-open {
  display: block;
}

.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  text-align: left;
}

.suggestion:last-child {
  border-bottom: 0;
}

.suggestion:hover,
.suggestion.is-highlighted {
  background: rgba(72, 224, 164, 0.12);
}

.suggestion small {
  color: var(--muted);
}

.guess-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  color: #06140f;
  background: var(--accent);
}

.primary-button:hover {
  background: #7af0bf;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
}

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

.feedback {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 76px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid rgba(72, 224, 164, 0.24);
  border-radius: var(--radius);
  background: rgba(72, 224, 164, 0.08);
}

.feedback-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  color: var(--accent);
  background: rgba(72, 224, 164, 0.14);
}

.feedback-icon svg {
  width: 23px;
  height: 23px;
}

.feedback p {
  margin: 0 0 4px;
  font-weight: 850;
}

.feedback span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.history-section {
  display: flex;
  flex: 1 1 auto;
  min-height: 210px;
  flex-direction: column;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 800;
}

.history {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
}

.history-empty,
.history-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.history-empty {
  display: grid;
  min-height: 148px;
  place-items: center;
  padding: 18px;
  color: rgba(255, 255, 255, 0.42);
  text-align: center;
}

.history-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 10px;
}

.try-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #06140f;
  background: var(--amber);
  font-weight: 900;
}

.try-index.is-correct {
  background: var(--accent);
}

.try-index.is-final {
  color: var(--ink);
  background: var(--rose);
}

.history-name {
  display: block;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.direction-arrow {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: 0 3px;
  border: 1px solid rgba(72, 224, 164, 0.42);
  border-radius: 999px;
  color: #06140f;
  background: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  transform: rotate(var(--bearing));
  transform-origin: center;
  vertical-align: -4px;
}

.feedback .direction-arrow {
  display: inline-grid;
  width: 20px;
  height: 20px;
  color: #06140f;
  font-size: 13px;
}

.temperature {
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 999px;
  color: #07110d;
  background: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.temperature.cold {
  background: #83a7ff;
}

.temperature.warm {
  background: #ffd166;
}

.temperature.hot {
  background: #ff8a5b;
}

.temperature.hit {
  background: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 20px;
}

.city-picker-dialog {
  width: min(1040px, calc(100vw - 18px));
  height: min(820px, calc(100vh - 18px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow);
}

.city-picker-dialog::backdrop {
  background: rgba(1, 6, 4, 0.62);
  backdrop-filter: blur(8px);
}

.city-picker-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  padding: 12px;
  background:
    linear-gradient(145deg, rgba(12, 35, 28, 0.98), rgba(13, 21, 24, 0.98)),
    var(--panel-strong);
}

.city-picker-header,
.picker-head-actions,
.picker-toolbar {
  display: flex;
  align-items: center;
}

.city-picker-header {
  justify-content: space-between;
  gap: 18px;
}

.picker-head-actions {
  gap: 10px;
}

.picker-count {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(72, 224, 164, 0.1);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.picker-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  margin: 12px 0;
}

.compact-input {
  height: 42px;
}

.city-board {
  display: grid;
  grid-template-columns: repeat(36, minmax(20px, 1fr));
  gap: 2px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  padding: 2px 2px 4px 0;
}

.city-board.is-filtered {
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
}

.province-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
}

.region-gap {
  min-width: 0;
}

.province-column-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 32px;
  padding: 0 2px;
  border: 1px solid rgba(72, 224, 164, 0.2);
  border-radius: 4px;
  color: var(--accent);
  background: rgba(72, 224, 164, 0.1);
}

.province-column.is-empty .province-column-head {
  color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.035);
}

.province-column.is-special .province-column-head {
  border-color: transparent;
  background: transparent;
}

.province-column.is-special .province-column-head strong,
.province-column.is-special .province-column-head span {
  display: none;
}

.province-column-head strong {
  overflow: hidden;
  width: 100%;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.province-column-head span {
  display: grid;
  place-items: center;
  min-width: 13px;
  height: 13px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  font-size: 8px;
  font-weight: 800;
}

.province-column-cities {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
}

.city-chip {
  min-width: 0;
  width: 100%;
  min-height: 24px;
  padding: 0 1px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.075);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-chip:hover {
  border-color: rgba(72, 224, 164, 0.58);
  color: #06140f;
  background: var(--accent);
}

.city-chip.is-used {
  color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.035);
}

.compact-empty {
  min-height: 180px;
}

.leaflet-control-attribution {
  max-width: min(70vw, 760px);
  color: rgba(255, 255, 255, 0.62);
  background: rgba(0, 0, 0, 0.35);
}

.leaflet-container {
  touch-action: none;
  background: #07110d;
  font-family: inherit;
}

.leaflet-control-container {
  position: relative;
  z-index: 390;
}

.target-boundary-path {
  filter: drop-shadow(0 0 5px rgba(72, 224, 164, 0.88));
}

.wrong-boundary-path {
  filter: drop-shadow(0 0 4px rgba(231, 200, 116, 0.58));
}

.answer-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(72, 224, 164, 0.22);
}

.wrong-boundary-label {
  pointer-events: none;
}

.wrong-boundary-label span {
  display: inline-flex;
  transform: translate(-50%, -50%);
  max-width: 132px;
  padding: 3px 8px;
  border: 1px solid rgba(216, 185, 106, 0.62);
  border-radius: 999px;
  color: #ffe39c;
  background: rgba(19, 16, 9, 0.72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
}

.result-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow);
}

.result-dialog::backdrop {
  background: rgba(1, 6, 4, 0.68);
  backdrop-filter: blur(8px);
}

.result-shell {
  position: relative;
  padding: 28px;
  background:
    linear-gradient(145deg, rgba(17, 42, 34, 0.98), rgba(16, 22, 27, 0.98)),
    var(--panel-strong);
}

.close-dialog {
  position: absolute;
  top: 16px;
  right: 16px;
}

.result-shell h2 {
  margin: 0 44px 12px 0;
}

.result-shell p {
  color: var(--muted);
  line-height: 1.6;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  .shell {
    display: flex;
    min-height: 100vh;
    height: auto;
    flex-direction: column;
  }

  .map-stage {
    min-height: 58vh;
  }

  .console {
    width: 100%;
    height: auto;
    min-height: 42vh;
    padding: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-left: 0;
  }

  .zoom-stack {
    left: 16px;
    bottom: 16px;
  }

  .map-badge {
    left: 16px;
    top: 16px;
  }

  .city-board.is-filtered {
    grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  }

  .city-board:not(.is-filtered) {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .city-board:not(.is-filtered) .region-gap {
    display: none;
  }

  .city-board:not(.is-filtered) .province-column {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: start;
    gap: 4px;
  }

  .city-board:not(.is-filtered) .province-column-head {
    min-height: 24px;
    padding: 0 3px;
    flex-direction: row;
  }

  .city-board:not(.is-filtered) .province-column-head strong {
    font-size: 12px;
  }

  .city-board:not(.is-filtered) .province-column-head span {
    display: none;
  }

  .city-board:not(.is-filtered) .province-column-cities {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
  }

  .city-board:not(.is-filtered) .city-chip {
    flex: 0 0 24px;
    width: 24px;
    min-height: 24px;
  }
}

@media (max-width: 560px) {
  .map-stage {
    min-height: 48vh;
  }

  h1 {
    font-size: 28px;
  }

  .status-grid,
  .actions,
  .guess-actions,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .city-picker-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .city-picker-shell {
    padding: 14px;
  }

  .picker-toolbar {
    grid-template-columns: 1fr;
  }

  .history-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .temperature {
    grid-column: 2;
    justify-self: start;
  }
}
