/* 밤에 내려다본 지도. 태어난 곳에만 불이 켜진다.
   이 페이지는 그 한 장면에 걸었으므로 라이트 테마를 두지 않는다. */
:root {
  --ink: #e8ecf5;
  --dim: #8590a8;
  --faint: #767f97;   /* 배경 4.92:1 · 패널 4.63:1 — 작은 글자도 읽힌다 */
  --ground: #080b14;
  --panel: #0e1322;
  --line: #1c2438;
  --land: #18203a;
  --land-edge: #232d4a;
  --glow: #ffc978;
  --glow-soft: #6a5330;
  --step: clamp(14px, 1.6vw, 18px);
  --title: clamp(20px, 2.6vw, 26px);
  --big: clamp(26px, 3.4vw, 38px);
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--step)/1.55 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}

::selection { background: var(--glow); color: #17120a; }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; border-radius: 3px; }

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) clamp(14px, 3vw, 28px) 28px;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vw, 22px);
  min-height: 100dvh;
}

/* 머리 */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 {
  font-size: var(--title);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.year { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 0.85em; }

select {
  appearance: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 30px 7px 11px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
                    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: right 14px center, right 9px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:hover { border-color: var(--faint); }

/* 무대 */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 34px);
  align-items: start;
  flex: 1;
}

.mapwrap { position: relative; }
#map { width: 100%; height: auto; display: block; max-height: 74dvh; }
#map path {
  fill: var(--land);
  stroke: var(--land-edge);
  stroke-width: 0.7;
  stroke-linejoin: round;
}
/* 켜진 곳. 흐릿한 후광이 아니라 실제로 빛나 보이게 두 겹으로 쌓는다. */
#map path.lit {
  fill: var(--glow);
  stroke: var(--glow);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 7px rgba(255, 201, 120, 0.75))
          drop-shadow(0 0 22px rgba(255, 201, 120, 0.32));
}
/* 소속 위계. 태어난 구가 가장 밝고, 같은 시·같은 도로 갈수록 옅어진다.
   "경기도 › 수원시 › 팔달구"라는 계층이 지도에서도 읽히게 하는 장치다. */
#map path.si {
  fill: #4a3a22;
  stroke: #6b5330;
  stroke-width: 1;
}
#map path.sido {
  fill: #262a3c;
  stroke: #333a52;
}
@media (prefers-reduced-motion: no-preference) {
  #map path { transition: fill 160ms ease-out, stroke 160ms ease-out; }
}

.legend {
  position: absolute; left: 2px; bottom: 2px;
  display: flex; align-items: center; gap: 7px;
  color: var(--faint); font-size: 0.76em;
}
.legend b { color: var(--faint); font-weight: 400; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 8px rgba(255, 201, 120, 0.8);
}
.dot.si { background: #6b5330; box-shadow: none; }
.dot.sido { background: #333a52; box-shadow: none; }
.legend { --faint: #6b748c; }

/* 오른쪽 판 */
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; color: var(--faint);
  font: inherit; font-size: 0.88em;
  padding: 7px 13px; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--glow); }
.tabs button:hover { color: var(--dim); }

.empty, .hint { color: var(--faint); font-size: 0.9em; padding: 26px 0; }
.empty b { color: var(--dim); font-weight: 600; }

/* 행정구역 계층 — 들여쓰기로 단계를 보인다 */
.where { list-style: none; padding: 0; }
.where li {
  color: var(--dim);
  font-size: 0.92em;
  line-height: 1.4;
}
.where li::before { content: "└ "; color: var(--faint); }
.where li:first-child::before { content: ""; }
.where li:last-child {
  color: var(--ink);
  font-size: var(--big);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 3px;
}
.where li:nth-child(2) { padding-left: 0; }
.where li:nth-child(3) { padding-left: 13px; }
.where li:nth-child(4) { padding-left: 26px; }

.born { color: var(--dim); margin-top: 10px; font-variant-numeric: tabular-nums; }

.stats { margin-top: 20px; display: flex; flex-direction: column; }
.stats > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.stats dt { color: var(--faint); font-size: 0.86em; }
.stats dd {
  font-variant-numeric: tabular-nums;
  font-size: 1.02em;
  letter-spacing: -0.01em;
}
.stats dd.none { color: var(--faint); }

/* 이력 */
.hist { list-style: none; padding: 0; max-height: 46dvh; overflow-y: auto; }
.hist li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
}
.hist .place { color: var(--ink); }
.hist .meta { color: var(--faint); white-space: nowrap; }
.hist li.hit .place { color: var(--glow); }

/* 조작부 */
.controls {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.goal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.goal label { color: var(--faint); font-size: 0.86em; }
.odds { color: var(--dim); font-size: 0.83em; font-variant-numeric: tabular-nums; }

.run { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.count { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 0.9em; min-width: 6.5em; }
.count span { color: var(--ink); font-size: 1.15em; font-weight: 600; }

.bar { flex: 1; min-width: 90px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--glow-soft); }
.bar i.on { background: var(--glow); }

.btn {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 18px; font: inherit; font-size: 0.9em; cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--glow); color: #1a1204; border-color: var(--glow); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: 0.4; cursor: default; }

.hist::-webkit-scrollbar { width: 9px; }
.hist::-webkit-scrollbar-track { background: transparent; }
.hist::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
.hist::-webkit-scrollbar-thumb:hover { background: #2a3450; }
.hist { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* 데이터가 800KB라 첫 화면에서 기다리는 시간이 보인다 */
.loading { color: var(--faint); font-size: 0.9em; padding: 26px 0; }
.loading b { color: var(--dim); font-weight: 400; }

.src { color: var(--faint); font-size: 0.74em; line-height: 1.5; }
.src a { color: var(--faint); }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; }
  #map { max-height: 46dvh; }
  .legend { position: static; margin-top: 6px; }
}
