:root {
  color-scheme: light;
  --ink: #20262d;
  --muted: #68717b;
  --soft-muted: #8b949d;
  --line: #d7dde3;
  --line-dark: #c2cbd4;
  --paper: #ffffff;
  --page: #f4f6f8;
  --blue: #24579d;
  --blue-dark: #19447f;
  --blue-soft: #eaf1fa;
  --green: #2d7950;
  --green-soft: #edf7f0;
  --red: #b54c42;
  --red-soft: #fff1ef;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  height: 58px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1120px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand, .text-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
}

.brand { font-weight: 700; letter-spacing: -0.01em; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.text-button { color: var(--blue); font-size: 14px; font-weight: 700; }
.text-button:hover { color: var(--blue-dark); text-decoration: underline; }
.danger-text { color: var(--red); font-weight: 600; }

.app-shell { max-width: 1120px; margin: 0 auto; padding: 42px 24px 72px; }
.site-footer { max-width: 1120px; margin: 0 auto; padding: 0 24px 18px; color: var(--soft-muted); font-size: 11px; }
.view[hidden] { display: none; }
.page-heading, .quiz-topbar, .results-heading { margin-bottom: 26px; }
.page-heading { display: flex; gap: 36px; align-items: end; justify-content: space-between; }
.page-heading > div:first-child { max-width: 680px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--soft-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.1; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 19px; line-height: 1.2; }
.lede { max-width: 620px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.data-note { flex: 0 0 auto; color: var(--muted); font-size: 13px; }

.builder-grid, .quiz-layout, .results-grid { display: grid; gap: 20px; }
.builder-grid { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr); align-items: start; }
.quiz-layout { grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }
.results-grid { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.builder-panel, .setup-panel, .quiz-side-panel, .results-score-panel, .mistakes-panel { padding: 24px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.count-badge, .mode-label { padding: 4px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }

.field-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 14px; font-weight: 700; }
.text-input { width: 100%; min-height: 42px; border: 1px solid var(--line-dark); border-radius: 3px; background: var(--paper); color: var(--ink); padding: 9px 11px; outline: none; }
.text-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(36, 87, 157, 0.12); }
input[type="search"] { appearance: none; }
.builder-panel > .field-label:not(:first-of-type) { margin-top: 20px; }
.field-help, .fine-print { color: var(--muted); font-size: 13px; }
.field-help { margin: 8px 0 22px; }
.fine-print { margin: 15px 0 0; }

.search-wrap { position: relative; }
.search-results { position: absolute; z-index: 4; top: calc(100% + 4px); left: 0; right: 0; border: 1px solid var(--line-dark); border-radius: 3px; background: var(--paper); box-shadow: 0 4px 12px rgba(30, 40, 50, 0.11); overflow: hidden; }
.search-result { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf0f2; background: transparent; color: var(--ink); text-align: left; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result.active { background: var(--blue-soft); }
.place-icon { flex: 0 0 24px; font-size: 19px; text-align: center; }
.result-copy { min-width: 0; display: grid; gap: 1px; }
.result-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-copy span { color: var(--muted); font-size: 12px; }

.list-section-heading { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 9px; color: var(--muted); font-size: 14px; font-weight: 700; }
.selected-places { min-height: 88px; border-top: 1px solid var(--line); }
.empty-state { margin: 18px 0; color: var(--soft-muted); font-size: 14px; }
.place-row { display: grid; grid-template-columns: 27px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid #edf0f2; }
.place-row:last-child { border-bottom: 0; }
.row-icon { font-size: 18px; text-align: center; }
.row-copy { min-width: 0; display: grid; gap: 1px; }
.row-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-copy span { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 3px; }
.icon-button { width: 27px; height: 27px; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--muted); }
.icon-button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.icon-button:disabled { opacity: 0.35; cursor: default; }

.setting-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 15px 0; border-top: 1px solid var(--line); }
.setting-row strong, .setting-row span { display: block; }
.setting-row strong { font-size: 15px; }
.setting-row > div span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.setting-row-stacked { display: block; }
.setting-row-stacked .field-label { margin-bottom: 8px; }
.share-box { margin-top: 20px; padding: 14px; border: 1px solid #cbd8e7; border-radius: 3px; background: var(--blue-soft); }
.share-box strong, .share-box span { display: block; }
.share-box span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.share-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-top: 12px; }
.copy-status { min-height: 18px; margin: 6px 0 0; color: var(--green); font-size: 12px; }
.panel-actions { display: flex; gap: 9px; margin-top: 24px; }
.panel-actions .button { flex: 1; }
.button { min-height: 42px; padding: 9px 15px; border: 1px solid var(--blue); border-radius: 3px; background: var(--blue); color: white; font-weight: 700; }
.button:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button:disabled { cursor: default; opacity: 0.45; }
.button-secondary { border-color: var(--line-dark); background: var(--paper); color: var(--blue); }
.button-secondary:hover { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.button-small { min-height: 34px; padding: 6px 12px; font-size: 14px; }

.quiz-topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.quiz-topbar h1 { margin-bottom: 0; }
.quiz-stats { display: flex; gap: 22px; }
.quiz-stats div { min-width: 62px; }
.quiz-stats span, .quiz-stats strong { display: block; }
.quiz-stats span { color: var(--muted); font-size: 12px; }
.quiz-stats strong { margin-top: 3px; font-size: 18px; }
.map-panel { overflow: hidden; }
.map-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 17px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.map-toolbar-actions, .map-zoom-controls { display: flex; align-items: center; gap: 5px; }
.map-toolbar-actions { gap: 17px; }
.map-zoom-controls .icon-button { width: 30px; height: 30px; }
.map-zoom-controls .zoom-reset { width: 42px; font-size: 11px; }
.map-wrap { position: relative; min-height: 400px; background: #f7fbfd; }
#world-map { display: block; width: 100%; height: auto; touch-action: none; }
#world-map.is-pannable { cursor: grab; }
#world-map.is-dragging { cursor: grabbing; }
#world-map.is-pannable .country { cursor: grab; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.map-loading[hidden], .next-button[hidden] { display: none; }
#world-map.is-ready + .map-loading { display: none; }
.country { fill: #dfe5e8; stroke: #ffffff; stroke-width: 0.65px; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill 100ms ease; }
.country:hover { fill: #cbd9e6; }
.country.is-correct { fill: #76b991; }
.country.is-wrong { fill: #d9877d; }
.country.is-reveal { fill: #b8cee3; }
.water-region { fill: transparent; stroke: transparent; pointer-events: none; }
.water-region.active-target { pointer-events: all; cursor: pointer; }
.water-region.is-correct, .water-region.is-wrong { fill: transparent; stroke: transparent; }
.water-label { display: none; }
.feedback { margin: 0 17px; padding: 11px 13px; border-radius: 3px; font-size: 14px; }
.feedback.correct { background: var(--green-soft); color: var(--green); }
.feedback.incorrect { background: var(--red-soft); color: var(--red); }
.next-button { display: block; margin: 12px 17px 17px auto; }
.quiz-side-panel { min-height: 188px; }
.quiz-side-panel h2 { margin-bottom: 5px; }
.side-summary { margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.quiz-remaining { display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.remaining-place { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.remaining-place.current { color: var(--ink); font-weight: 700; }
.remaining-place.correct { color: var(--green); }
.remaining-place.mistake { color: var(--red); }

.results-score-panel { display: grid; align-content: start; gap: 7px; }
.results-score-label, .results-time { color: var(--muted); }
.results-score { font-size: 52px; line-height: 1; letter-spacing: -0.06em; }
.results-time { font-size: 14px; }
.mistakes-list { border-top: 1px solid var(--line); }
.mistake-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 13px 0; border-bottom: 1px solid #edf0f2; }
.mistake-row:last-child { border-bottom: 0; }
.mistake-row strong, .mistake-row span { display: block; }
.mistake-row span { margin-top: 2px; color: var(--muted); font-size: 13px; }
.all-correct { padding: 18px 0; color: var(--green); }
.toast { position: fixed; right: 20px; bottom: 20px; padding: 10px 13px; border: 1px solid var(--line-dark); border-radius: 3px; background: var(--paper); box-shadow: 0 4px 16px rgba(30, 40, 50, 0.14); color: var(--ink); font-size: 14px; }

@media (max-width: 760px) {
  .site-header { height: auto; }
  .header-inner { min-height: 58px; padding: 0 16px; }
  .header-actions { gap: 12px; }
  .app-shell { padding: 28px 16px 52px; }
  .site-footer { padding: 0 16px 14px; }
  .page-heading, .quiz-topbar { display: block; }
  .data-note { margin-top: 16px; }
  .builder-grid, .quiz-layout, .results-grid { grid-template-columns: 1fr; }
  .quiz-stats { margin-top: 18px; justify-content: space-between; }
  .quiz-stats div { min-width: 0; }
  .map-wrap { min-height: 0; }
  .quiz-side-panel { order: -1; }
}

@media (max-width: 440px) {
  .brand { font-size: 14px; }
  .header-actions .text-button { display: none; }
  .builder-panel, .setup-panel, .quiz-side-panel, .results-score-panel, .mistakes-panel { padding: 18px; }
  .panel-actions { flex-direction: column; }
  .share-actions { grid-template-columns: 1fr; }
  .map-toolbar { align-items: start; }
  .map-toolbar-actions { align-items: start; gap: 10px; }
}
