/* 구구땅 — 밝은 보드게임 판. 지도가 주인공, 정보는 그 위에 떠 있는 패널. */

:root {
  --ink: #1d3b42;
  --muted: #5d7277;
  --paper: #fffdf6;
  --paper-2: #f4efe0;
  --line: #e0d9c4;
  --shell-1: #14434f;
  --shell-2: #0a2932;
  --accent: #1c7a68;
  --accent-hover: #146052;
  --accent-soft: #e2f1ea;
  --sea: #b9dde7;
  --sea-2: #9ecddb;
  --land: #f7f1dd;
  --land-line: #b9b09a;
  --admin-line: #8a9382;
  --coast: #1d4d59;
  --gold: #e8a93a;
  --warning: #8f541b;
  --warning-soft: #fff3dc;
  --error: #b2402f;
  --error-soft: #ffeee9;
  --success: #1c7a68;
  --r: 22px;
  --r-sm: 14px;
  --lift: 0 10px 30px rgba(10, 41, 50, .18);
  --press: 110ms ease-out;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: linear-gradient(160deg, var(--shell-1), var(--shell-2));
  color: var(--ink);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overflow: hidden;
}
body.reduce-motion *, body.reduce-motion *::after { animation: none !important; transition: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; left: 12px; top: -80px; z-index: 90;
  background: var(--paper); color: var(--accent); padding: 12px 18px;
  border-radius: var(--r-sm); font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }
:where(a, button, input, select, [tabindex]):focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ── 무대 ─────────────────────────────────────────────── */
.stage { position: relative; height: 100dvh; width: 100%; overflow: hidden; }

/* ── 지도 ─────────────────────────────────────────────── */
.map-viewport {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 10%, #cbe8ef 0%, var(--sea) 45%, var(--sea-2) 100%);
  touch-action: none; overflow: hidden;
}
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.dragging { cursor: grabbing; }

#map .cell { stroke: var(--land-line); stroke-width: .4; vector-effect: non-scaling-stroke; transition: fill 260ms ease-out; }
#map .cell:hover { stroke: var(--coast); stroke-width: 1.6; }
#map .cell.reachable { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 2.5; }
#map .cell.mine { stroke: rgba(255, 255, 255, .75); stroke-width: 1; }
#map #lines-dong { fill: none; stroke: var(--admin-line); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .8; }
#map #lines-sgg { fill: none; stroke: var(--coast); stroke-width: 2.4; vector-effect: non-scaling-stroke; opacity: .75; }
#map #lines-coast { fill: none; stroke: var(--coast); stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
#map #selection-glow { fill: none; stroke: #fff; stroke-width: 7; vector-effect: non-scaling-stroke; pointer-events: none; }
#map #selection { fill: none; stroke: var(--coast); stroke-width: 3.5; vector-effect: non-scaling-stroke; pointer-events: none; }
#map .school-marker { cursor: pointer; }
#map .label { font-weight: 800; fill: var(--ink); paint-order: stroke; stroke: rgba(255, 255, 255, .9); text-anchor: middle; pointer-events: none; }
#map .label.dong { fill: #3e5a4c; }
#map .hidden-layer { display: none; }
#map[data-zoom='far'] .cell { stroke-opacity: .28; }
#map[data-zoom='mid'] .cell { stroke-opacity: .6; }

/* 지도 위 작은 칩들 */
.map-badge, .legend, .map-hint {
  position: absolute; z-index: 3;
  background: rgba(255, 253, 246, .92); border: 1px solid rgba(29, 77, 89, .14);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(10, 41, 50, .1);
}
.map-badge { left: 16px; top: 78px; max-width: min(46ch, 52%); }
.legend { left: 16px; bottom: 16px; display: flex; gap: 14px; align-items: center; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch.neutral { background: var(--land); border: 1px solid var(--land-line); }
.swatch.next { background: var(--land); border: 2px dashed var(--accent); }
.map-hint { left: 50%; transform: translateX(-50%); bottom: 16px; max-width: min(40ch, 60%); text-align: center; }

.compass { position: absolute; right: 16px; top: 78px; z-index: 3; color: var(--coast); opacity: .45; text-align: center; }
.compass svg { width: 15px; height: 19px; display: block; margin: 0 auto; }
.compass span { font-size: 10px; font-weight: 800; }

.map-controls { position: absolute; right: 16px; bottom: 16px; z-index: 4; display: flex; flex-direction: column; gap: 8px; }

/* ── 버튼 ─────────────────────────────────────────────── */
.pad-button {
  min-width: 46px; min-height: 46px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid rgba(29, 77, 89, .16); border-bottom-width: 3px;
  border-radius: var(--r-sm); font-size: 19px; font-weight: 800; cursor: pointer;
  box-shadow: 0 2px 10px rgba(10, 41, 50, .12); transition: transform var(--press), background var(--press);
}
.pad-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pad-button.small { min-width: 38px; min-height: 38px; font-size: 15px; }
.pad-button:hover { background: var(--accent-soft); }
.pad-button:active { transform: translateY(2px); border-bottom-width: 1px; }
.pad-button[aria-pressed='true'] { background: var(--accent); color: #fff; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 22px; border-radius: var(--r-sm);
  border: 1px solid transparent; border-bottom: 4px solid rgba(0, 0, 0, .18);
  font-weight: 800; cursor: pointer; transition: transform var(--press), background var(--press);
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.button.ghost { background: var(--paper-2); border-color: var(--line); border-bottom-color: var(--line); color: var(--ink); }
.button.ghost:hover { background: var(--accent-soft); }
.button.big { min-height: 66px; font-size: 20px; border-radius: 18px; }
.button.wide { width: 100%; }
.button:active { transform: translateY(2px); border-bottom-width: 2px; }
.button[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

/* ── 상단 HUD ─────────────────────────────────────────── */
.hud {
  position: absolute; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-left { flex: 1 1 auto; }

.crest { width: 44px; height: 44px; flex: none; color: var(--gold); filter: drop-shadow(0 2px 6px rgba(10, 41, 50, .35)); }
.crest svg { width: 100%; height: 100%; }

.hud-school { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-school .who {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  background: rgba(255, 253, 246, .94); border-radius: 999px; padding: 6px 14px 6px 7px;
  box-shadow: var(--lift);
}
.hud-school .emblem { width: 32px; height: 32px; flex: none; }
.hud-school .names { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.hud-school .names strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-school .names span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score {
  display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05;
  background: rgba(255, 253, 246, .94); border-radius: 14px; padding: 6px 14px;
  box-shadow: var(--lift); white-space: nowrap;
}
.score b { font-size: 17px; font-variant-numeric: tabular-nums; }
.score small { font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.score.bump { animation: bump 420ms ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }


.connection {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 5px 11px;
  background: rgba(255, 253, 246, .9); color: var(--muted); white-space: nowrap;
}
.connection[data-state='live'] { color: var(--success); }
.connection[data-state='lost'] { color: var(--error); background: var(--error-soft); }

/* ── 패널 ─────────────────────────────────────────────── */
.panels {
  position: absolute; z-index: 8; right: 16px; top: 74px; bottom: 16px; width: 380px;
  display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overscroll-behavior: contain;
  pointer-events: none; scrollbar-width: thin;
}
.panels > * { pointer-events: auto; flex: none; }

.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--lift);
}
.panel-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .09em; color: var(--accent); text-transform: uppercase; }
.panel-title { font-size: 26px; margin: 6px 0 8px; }
.panel-note { font-size: 13px; color: var(--muted); }
.panel-foot { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { font-size: 17px; }
.tag { font-size: 10.5px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }

/* 선택 구역 */
.target .region { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.target .region h2 { font-size: 24px; }
.target .region small { font-size: 12px; color: var(--muted); }
.owner {
  display: flex; align-items: center; gap: 10px; margin: 12px 0;
  background: var(--paper-2); border-radius: var(--r-sm); padding: 9px 12px;
}
.owner .emblem { width: 34px; height: 34px; flex: none; }
.owner .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.owner strong { font-size: 15px; }
.owner span { font-size: 11.5px; color: var(--muted); }

.meter { margin: 12px 0 8px; }
.meter-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.meter-top b { font-size: 13px; }
.meter-top span { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.meter-track { height: 16px; border-radius: 999px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--line); }
.meter-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #2ea98d); border-radius: 999px; transition: width 400ms cubic-bezier(.2, .9, .3, 1); }
.meter-fill.defense { background: linear-gradient(90deg, var(--coast), #46808f); }
.meter-note { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.callout { background: var(--warning-soft); border: 1px solid #f0dcb4; color: var(--warning); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; margin: 10px 0; }
.callout.bad { background: var(--error-soft); border-color: #f3cabf; color: var(--error); }
.callout.good { background: var(--accent-soft); border-color: #bfe3d4; color: var(--success); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chips span { font-size: 11.5px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-variant-numeric: tabular-nums; }

/* 문제 */
.quiz { background: linear-gradient(180deg, #fffdf6, #fbf6e8); }
.quiz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.quiz-target { font-size: 13px; font-weight: 800; }
.quiz-target small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.pips { display: flex; gap: 4px; margin: 12px 0 8px; }
.pips i { flex: 1; height: 8px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); }
.pips i.done { background: var(--accent); border-color: var(--accent); }
.pips i.miss { background: var(--gold); border-color: var(--gold); }
.question {
  font-size: 46px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
  letter-spacing: .01em; margin: 6px 0 12px;
}
#answer {
  width: 100%; min-height: 66px; font-size: 38px; font-weight: 800; text-align: center;
  border: 2px solid var(--line); border-radius: 18px; background: #fff;
  font-variant-numeric: tabular-nums; font-family: inherit;
}
#answer:focus { border-color: var(--accent); outline: none; }
#answer::placeholder { color: #cdc6b2; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 12px; }
.keypad button {
  min-height: 58px; font-size: 25px; font-weight: 800; background: var(--paper);
  border: 1px solid var(--line); border-bottom-width: 4px; border-radius: 16px; cursor: pointer;
  transition: transform var(--press), background var(--press);
}
.keypad button:hover { background: var(--accent-soft); }
.keypad button:active { transform: translateY(2px); border-bottom-width: 2px; }
.keypad button.wordy { font-size: 15px; }
.feedback { margin-top: 12px; font-size: 13.5px; min-height: 1.4em; }
.feedback .verdict { font-size: 19px; font-weight: 800; }
.feedback .verdict.ok { color: var(--success); }
.feedback .verdict.no { color: var(--error); }

/* 순위 */
.rank-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-top: 1px solid var(--line); }
.rank-row:first-child { border-top: 0; }
.rank-row .place { width: 20px; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row .emblem { width: 26px; height: 26px; flex: none; }
.rank-row .name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .area { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-row.mine { background: var(--accent-soft); border-radius: 10px; padding-inline: 8px; }
.rank-row.mine .name { color: var(--accent); }

/* ── 연출 ─────────────────────────────────────────────── */
.fx-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%); font-size: 30px; font-weight: 800;
  color: #fff; text-shadow: 0 2px 10px rgba(10, 41, 50, .5); animation: pop 900ms ease-out forwards;
}
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 25% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
.ring {
  position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border: 4px solid var(--gold); border-radius: 50%; animation: ring 760ms ease-out forwards;
}
@keyframes ring { from { opacity: .9; transform: scale(.3); } to { opacity: 0; transform: scale(5); } }
.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px; max-width: min(90%, 460px);
  background: var(--paper); border: 3px solid var(--gold); border-radius: var(--r);
  padding: 14px 22px; font-size: 19px; font-weight: 800; text-align: left;
  box-shadow: 0 16px 44px rgba(10, 41, 50, .35); animation: banner 640ms cubic-bezier(.2, 1.2, .3, 1);
}
.banner svg { width: 34px; height: 34px; flex: none; }
@keyframes banner { from { opacity: 0; transform: translate(-50%, -20%) scale(.8) rotate(-3deg); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ── 대화상자 · 토스트 ────────────────────────────────── */
dialog {
  border: 1px solid var(--line); border-radius: var(--r); padding: 26px;
  max-width: 460px; width: calc(100% - 28px); color: var(--ink); background: var(--paper);
  box-shadow: 0 24px 60px rgba(10, 41, 50, .4);
}
dialog::backdrop { background: rgba(10, 41, 50, .55); }
dialog h2 { font-size: 23px; margin: 6px 0 8px; }
.dialog-close { position: absolute; right: 14px; top: 14px; }
dialog form { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
dialog label { font-size: 12.5px; font-weight: 800; margin-top: 10px; }
dialog input, dialog select {
  min-height: 50px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #fff; font-size: 16px;
}
dialog input:focus, dialog select:focus { border-color: var(--accent); outline: none; }
dialog .button { margin-top: 14px; }
.error-text { color: var(--error); font-size: 12.5px; min-height: 1.2em; margin-top: 6px; }
.help-list { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; margin: 14px 0; }
.help-list strong { display: block; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-top: 1px solid var(--line); font-weight: 700; }
.setting-row input { width: 24px; height: 24px; accent-color: var(--accent); }
.demo-codes { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.demo-codes label { display: block; font-size: 12.5px; font-weight: 800; margin-bottom: 6px; }
.demo-codes select { width: 100%; }
#data-description { font-size: 12.5px; display: flex; flex-direction: column; gap: 12px; margin-top: 12px; max-height: 58vh; overflow: auto; }
#data-description h3 { font-size: 13.5px; }
#data-description dl { display: grid; grid-template-columns: 76px 1fr; gap: 3px 10px; margin: 6px 0 0; }
#data-description dt { color: var(--muted); }
#data-description dd { margin: 0; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 95;
  background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 700; max-width: calc(100% - 28px); box-shadow: var(--lift);
}
.toast[data-kind='error'] { background: var(--error); }

/* ── 태블릿·휴대폰: 지도 위, 패널 아래 ─────────────────── */
@media (max-width: 1080px), (max-height: 620px) {
  .stage { display: flex; flex-direction: column; }
  .map-viewport { position: relative; inset: auto; flex: 1 1 auto; min-height: 42dvh; }
  .panels {
    position: relative; inset: auto; width: auto; flex: 0 1 auto; max-height: 58dvh;
    padding: 12px; gap: 12px;
  }
  .hud { position: absolute; }
  .map-badge { top: 70px; font-size: 11.5px; }
  .compass { display: none; }
  .map-hint { display: none; }
  .legend { bottom: 12px; left: 12px; font-size: 11.5px; padding: 6px 12px; }
  .map-controls { bottom: 12px; right: 12px; flex-direction: row; }
}

/* 좁은 화면에서는 HUD 를 두 줄로 나눠 잘리지 않게 한다. */
@media (max-width: 960px) {
  .hud { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .hud-left { order: 1; flex: 1 1 100%; }
  .hud-right { order: 2; flex: 1 1 100%; }
  .region-chip { flex: 1 1 auto; max-width: none; }
  .crest { width: 38px; height: 38px; }
  .map-badge { top: 126px; max-width: calc(100% - 32px); }
}

@media (max-width: 720px) {
  .panel-title { font-size: 23px; }
  .question { font-size: 42px; }
  .legend span:nth-child(2) { display: none; }
  .connection { display: none; }
}

@media (max-width: 420px) {
  .map-viewport { min-height: 36dvh; }
  .score small { display: none; }
  .question { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}

/* ── 지역(시·군·구) 전환 ──────────────────────────────── */
.region-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; max-width: 220px;
  padding: 0 14px 0 10px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 253, 246, .94); border: 1px solid rgba(29, 77, 89, .16); border-bottom-width: 3px;
  font-weight: 800; font-size: 13.5px; box-shadow: var(--lift);
  transition: transform var(--press), background var(--press);
}
.region-chip svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.region-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-chip:hover { background: var(--accent-soft); }
.region-chip:active { transform: translateY(2px); border-bottom-width: 1px; }
.region-cell-picker { display: block; margin-top: 12px; font-weight: 800; }
.region-cell-picker select { display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 8px 12px; font: inherit; }

/* 옆 지역에서 넘어온 구역은 살짝 가라앉혀 지금 지역과 구분한다. */
#map .cell.fringe { stroke-dasharray: 2 2; stroke-opacity: .5; }

.wide-dialog { max-width: 760px; }
.atlas-wrap { position: relative; overflow: hidden; margin: 14px 0 10px; background: var(--sea); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; }
#atlas { display: block; width: 100%; height: clamp(220px, 40vh, 420px); }
.atlas-base { stroke: none; pointer-events: none; }
.atlas-region {
  stroke: var(--coast); stroke-width: .7; stroke-opacity: .55; vector-effect: non-scaling-stroke;
  cursor: pointer; transition: fill-opacity 150ms ease-out;
}
.atlas-region:hover, .atlas-region:focus-visible { fill-opacity: 1; stroke-width: 2.2; outline: none; }
.atlas-region.current { stroke: var(--gold); stroke-width: 2.6; }
.atlas-hover {
  position: absolute; left: 12px; bottom: 12px; margin: 0; font-size: 12px; font-weight: 700;
  background: rgba(255, 253, 246, .94); border-radius: 999px; padding: 5px 12px; min-height: 1.2em;
}
#region-search {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #fff; font-size: 15px;
}
#region-search:focus { border-color: var(--accent); outline: none; }
.region-list { max-height: 34vh; overflow-y: auto; margin-top: 12px; }
.region-group { margin-bottom: 14px; }
.region-group h3 { font-size: 12px; color: var(--muted); letter-spacing: .05em; margin-bottom: 6px; }
.region-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.region-pill {
  display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15;
  min-height: 46px; padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--paper-2); border: 1px solid var(--line); border-bottom-width: 3px;
}
.region-pill b { font-size: 13.5px; }
.region-pill small { font-size: 10.5px; color: var(--muted); }
.region-pill:hover { background: var(--accent-soft); }
.region-pill:active { transform: translateY(2px); border-bottom-width: 1px; }
.region-pill.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.region-pill.current small { color: rgba(255, 255, 255, .8); }

@media (max-width: 720px) {
  #atlas { height: 240px; }
}

/* ── 학교 학생 수 ─────────────────────────────────────── */
.students { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin: 10px 0; }
.students-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.students-head b { font-size: 13px; }
.students-head span { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.students-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #fff; border: 1px solid var(--line); margin: 8px 0 7px; }
.students-bar i { display: block; height: 100%; }
.students i.boys { background: #4a8fc7; }
.students i.girls { background: #d1719a; }
.students-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.students-legend span { display: inline-flex; align-items: center; gap: 5px; }
.students-legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.students-legend b { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── 전국 지도: 확대·단계 색·순위 ───────────────────────── */
#atlas { cursor: grab; touch-action: none; }
#atlas.dragging { cursor: grabbing; }
.atlas-base { fill: var(--land); stroke: none; pointer-events: none; }
.atlas-region {
  stroke: var(--coast); stroke-width: .7; stroke-opacity: .5; vector-effect: non-scaling-stroke;
  cursor: pointer; transition: fill 200ms ease-out;
}
.atlas-region[data-step='0'] { fill: var(--land); }
.atlas-region[data-step='1'] { fill: #cfe6d4; }
.atlas-region[data-step='2'] { fill: #9bd0ae; }
.atlas-region[data-step='3'] { fill: #5cb189; }
.atlas-region[data-step='4'] { fill: #1c7a68; }
.atlas-region:hover, .atlas-region:focus-visible { stroke-width: 2.4; stroke-opacity: 1; outline: none; }
.atlas-region.current { stroke: var(--gold); stroke-width: 2.8; stroke-opacity: 1; }
.atlas-region.ours { stroke: #b3401f; stroke-width: 2.2; stroke-opacity: 1; }

.atlas-controls { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.atlas-scale {
  position: absolute; right: 14px; bottom: 14px; z-index: 2;
  display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: var(--muted);
  background: rgba(255, 253, 246, .94); border-radius: 999px; padding: 5px 10px;
}
.atlas-scale i { width: 14px; height: 10px; border-radius: 3px; border: 1px solid rgba(29, 77, 89, .18); }
.atlas-scale i[data-step='0'] { background: var(--land); }
.atlas-scale i[data-step='1'] { background: #cfe6d4; }
.atlas-scale i[data-step='2'] { background: #9bd0ae; }
.atlas-scale i[data-step='3'] { background: #5cb189; }
.atlas-scale i[data-step='4'] { background: #1c7a68; }

.atlas-ranking { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.atlas-ranking h3 { font-size: 14px; }
.atlas-ranking .rank-row { padding: 6px 0; }

/* ── 바다 항로 ────────────────────────────────────────── */
#map #sea-routes {
  fill: none; stroke: var(--coast); stroke-width: 1.6; stroke-dasharray: 5 4;
  stroke-linecap: round; opacity: .75; vector-effect: non-scaling-stroke; pointer-events: none;
}
#map .cell.sea-port { stroke: var(--coast); stroke-width: .9; stroke-dasharray: 1.5 2; }
.sea-note {
  display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--coast);
  background: var(--sea); border-radius: 999px; padding: 2px 10px;
}

/* ── 시즌 ─────────────────────────────────────────────── */
.season-chip {
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 5px 11px; white-space: nowrap;
  background: var(--gold); color: #3b2a06;
}
.season-history { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.season-history h3 { font-size: 14px; }
.season-history .place { width: 30px; }
.season-dot { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(29, 77, 89, .2); }
