:root {
  --bg-0: #f1f5f9;
  --bg-1: #dbe6f0;
  --bg-2: #c8d6e5;
  --panel: rgba(244, 248, 252, 0.78);
  --panel-border: rgba(89, 106, 126, 0.18);
  --text-0: #0f172a;
  --text-1: #334155;
  --text-2: #64748b;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: "Source Han Sans SC", "HarmonyOS Sans SC", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text-0);
  background:
    radial-gradient(75vw 75vw at 14% 12%, rgba(175, 204, 230, 0.65) 0%, rgba(175, 204, 230, 0) 60%),
    radial-gradient(60vw 60vw at 82% 74%, rgba(153, 188, 214, 0.38) 0%, rgba(153, 188, 214, 0) 70%),
    linear-gradient(150deg, var(--bg-0), var(--bg-1) 44%, var(--bg-2));
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.ambient-layer {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(66, 87, 108, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(66, 87, 108, 0.06) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 40% 36%, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.15) 70%, transparent);
  pointer-events: none;
}

.map-stage {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: min(320px, calc(100vw - 20px));
  z-index: 1;
}

#map {
  width: 100%;
  height: 100%;
}

.top-bar {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.brand {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(89, 106, 126, 0.14);
  background: rgba(244, 248, 252, 0.44);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(3px);
}

.brand-subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-2);
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.control-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(320px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  z-index: 3;
  border-radius: 0;
  border: 1px solid var(--panel-border);
  border-right: none;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.panel-block + .panel-block {
  margin-top: 16px;
}

.panel-block {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(118, 139, 161, 0.17);
}

.label {
  margin: 0 0 8px;
  color: var(--text-2);
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.city-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.candidate-block h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  min-width: 0;
}

.muted {
  margin: 8px 0;
  color: var(--text-1);
}

.count-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  border: 1px solid rgba(100, 116, 139, 0.35);
  background: rgba(241, 245, 249, 0.92);
}

.count-chip.is-visited {
  color: #166534;
  border-color: rgba(34, 197, 94, 0.38);
  background: rgba(220, 252, 231, 0.9);
}

.btn-stack {
  display: grid;
  gap: 10px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  font-family: inherit;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

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

.primary-btn {
  background: linear-gradient(135deg, #0f766e, #0f5e8a);
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.36);
  font-size: 15px;
  font-weight: 600;
}

.accent-btn {
  background: linear-gradient(130deg, #0f8a5f, #0f766e);
  color: #f8fafc;
  box-shadow: 0 8px 20px rgba(15, 138, 95, 0.24);
}

.accent-btn.is-unmark {
  background: linear-gradient(130deg, #d4dbe5, #bcc7d6);
  color: #334155;
  box-shadow: 0 8px 18px rgba(71, 85, 105, 0.16);
}

.ghost-btn {
  background: rgba(248, 250, 252, 0.88);
  color: var(--text-0);
  border: 1px solid rgba(148, 163, 184, 0.32);
}

.quiet-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: rgba(248, 250, 252, 0.84);
  color: var(--text-2);
}

.helper-text {
  margin: 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
}

.toggle-row,
.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: var(--text-1);
}

.range-row {
  margin-top: 12px;
}

input[type="range"] {
  margin-top: 8px;
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-grid article {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.86);
  padding: 10px;
}

.stats-grid article p {
  margin: 0 0 6px;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.02em;
}

.stats-grid article span {
  color: var(--text-2);
  font-size: 12px;
}

.progress-wrap {
  margin-top: 12px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(120deg, #0f766e, #0f5e8a);
  transition: width 220ms ease;
}

.level-tag {
  margin: 0 0 10px;
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.26);
  background: rgba(208, 242, 238, 0.72);
  color: #0f5e59;
  font-size: 13px;
}

.top-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.top-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-1);
}

.top-list li strong {
  color: var(--text-0);
}

.top-list li.empty {
  justify-content: center;
  color: var(--text-2);
}

.top-list li.achievement {
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
}

.top-list li.achievement span {
  color: var(--text-2);
  font-size: 12px;
}

.top-list li.achievement.unlocked {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(220, 245, 241, 0.72);
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  background: transparent;
  border: none;
  padding: 0;
}

.panel-footer-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.panel-footer-actions .ghost-btn,
.panel-footer-actions .quiet-btn {
  width: 100%;
}

.undo-toast {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 4;
  min-width: 260px;
  max-width: calc(100vw - 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 12px;
  border: 1px solid rgba(122, 142, 163, 0.28);
  padding: 12px 14px;
  background: rgba(248, 250, 252, 0.95);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
  transition: opacity 200ms ease, transform 200ms ease;
}

.undo-toast p {
  margin: 0;
  font-size: 14px;
}

.undo-toast button {
  background: #0f766e;
  color: #fff;
  padding: 6px 10px;
  border-radius: 9px;
}

.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}

@media (max-width: 1080px) {
  .map-stage {
    right: min(320px, calc(100vw - 16px));
  }

  .control-panel {
    width: min(320px, calc(100vw - 16px));
    top: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
  }

  .top-bar {
    top: 16px;
    left: 16px;
  }

  .brand h1 {
    font-size: 22px;
  }
}

@media (max-width: 860px) {
  .map-stage {
    right: 0;
  }

  .top-bar {
    top: 14px;
    left: 12px;
    right: 12px;
  }

  .control-panel {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 76px;
    width: auto;
    max-height: 76vh;
    border-radius: 20px;
    padding: 14px;
  }

  .candidate-block h2 {
    font-size: 24px;
  }

  .city-headline {
    align-items: flex-start;
    gap: 8px;
  }

  .panel-footer-actions {
    grid-template-columns: 1fr;
  }

  .stats-grid article p {
    font-size: 20px;
  }
}
