:root {
  --bg: #f3f1eb;
  --panel: #fffdf8;
  --ink: #17201d;
  --muted: #65706b;
  --line: #d5cec0;
  --dark: #263531;
  --green: #2f6f5e;
  --orange: #d68732;
  --red: #bd4b42;
  --blue: #315f91;
  --yellow: #f1ca55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 280px;
  gap: 14px;
  padding: 14px;
}

.toolbar,
.side-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 14px 32px rgba(34, 42, 38, .12);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--green);
  font-size: .78rem;
  font-weight: 850;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

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

.mode-btn,
.actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.mode-btn.active,
.actions button:first-child {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.quiz-box {
  padding: 16px;
  border: 1px solid #e1d4be;
  border-radius: 8px;
  background: #f7efe1;
}

.quiz-box strong {
  display: block;
  min-height: 58px;
  font-size: 1.4rem;
  line-height: 1.25;
}

.feedback {
  min-height: 66px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  line-height: 1.45;
}

.feedback.good {
  border-color: #95bea9;
  background: #eef8f2;
  color: #1f604c;
}

.feedback.bad {
  border-color: #dfa29d;
  background: #fff0ee;
  color: #923333;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score-grid div {
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score-grid strong,
.score-grid span {
  display: block;
}

.score-grid strong {
  font-size: 1.45rem;
  color: var(--blue);
}

.score-grid span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

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

.actions button:first-child {
  grid-column: 1 / -1;
}

.note {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}

.note p {
  margin: 0;
}

.map-panel {
  position: relative;
  min-height: calc(100vh - 28px);
  border: 1px solid #d4dce0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 28px);
  touch-action: none;
  user-select: none;
}

.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .95);
  color: var(--muted);
  font-weight: 850;
}

.loading.hidden {
  display: none;
}

.district {
  fill: #fbfaf7;
  stroke: #8c918f;
  stroke-width: .65;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .12s ease;
}

#map.province-mode .district {
  stroke: transparent;
}

.district:hover {
  fill: #e9f1ed;
}

.district.revealed {
  fill: #f6f1df;
}

.district.wrong {
  fill: rgba(189, 75, 66, .78);
}

.district.correct {
  fill: rgba(47, 111, 94, .78);
}

.district.answer {
  fill: rgba(49, 95, 145, .78);
}

.province-boundary {
  fill: none;
  stroke: #5f6663;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

#map:not(.province-mode) .province-boundary {
  display: none;
}

.map-label {
  pointer-events: none;
  fill: #222;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
  font-size: 10px;
  font-weight: 850;
  text-anchor: middle;
}

.side-panel {
  overflow: auto;
}

#wrongList {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 320px 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .map-panel,
  #map {
    min-height: 620px;
  }
}
