* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #bcd6e6;
  font-family: "LXGW WenKai TC", serif;
  color: #3b3226;
}
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#map:active {
  cursor: grabbing;
}
.panel {
  position: fixed;
  background: rgba(250,246,236,0.93);
  border: 1px solid rgba(90,70,40,0.25);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  padding: 10px 12px;
  font-size: 14px;
}
.ctrl {
  top: 16px;
  left: 16px;
  width: 270px;
}
.ctrl .title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 2px;
}
.ctrl .row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}
.ctrl .row > label {
  width: 32px;
  flex: none;
}
.ctrl input[type=number] {
  width: 90px;
  flex: 1;
}
.ctrl input[type=number],
.ctrl select {
  font: inherit;
  padding: 2px 6px;
  border: 1px solid rgba(90,70,40,0.35);
  border-radius: 6px;
  background: #fffdf7;
  color: #3b3226;
}
.ctrl .chk {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  white-space: nowrap;
  cursor: pointer;
}
.ctrl .hint {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 4px;
}
.btn {
  font: inherit;
  border: 1px solid rgba(90,70,40,0.35);
  background: #fffdf7;
  color: #3b3226;
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}
.btn:hover {
  background: #f3e6c8;
}
.info {
  top: 16px;
  right: 16px;
  min-width: 170px;
  pointer-events: none;
}
.info:empty {
  display: none;
}
.info .name {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.info .kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  opacity: 0.8;
}
.sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.25);
  flex: none;
}
.legend {
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 760px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 8px 10px;
}
.legend .item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.legend .item:hover {
  background: rgba(0,0,0,0.06);
}
.legend .item.on {
  border-color: #3b3226;
  background: #fffdf7;
}
.legend .item .n {
  font-size: 11px;
  opacity: 0.55;
}
@media (max-width: 600px) {
  .ctrl {
    top: 8px;
    left: 8px;
    width: 200px;
    padding: 8px 10px;
  }
  .ctrl .title {
    font-size: 18px;
  }
  .info {
    top: auto;
    bottom: 96px;
    right: 8px;
  }
  .legend {
    left: 8px;
    right: 8px;
    bottom: 8px;
    font-size: 12px;
  }
}
.labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.city-label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-weight: 700;
  font-size: 14px;
  color: #3b3226;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255,250,238,0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.city-label.capital {
  font-size: 16px;
  background: rgba(255,236,190,0.92);
}
.ctrl .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ctrl .chip {
  font: inherit;
  font-size: 13px;
  border: 1px solid rgba(90,70,40,0.3);
  background: #fffdf7;
  color: #3b3226;
  border-radius: 999px;
  padding: 1px 9px;
  cursor: pointer;
}
.ctrl .chip.on {
  background: #3b3226;
  color: #fffaf0;
}
.ctrl .chk-wrap .chk + .chk {
  margin-left: 0;
}
.ctrl .row > .chk-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}
.ctrl .row > label.chk {
  width: auto;
  margin-left: 0;
}
.ctrl .row {
  align-items: flex-start;
}
.loading {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(250,246,236,0.93);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  transition: opacity 0.3s;
  pointer-events: none;
}
.loading.done {
  opacity: 0;
}
.link {
  display: inline-block;
  margin: 4px 0 2px;
  color: #7a3b2e;
  font-weight: 700;
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}
