:root {
  --ink: #17312f;
  --muted: #536a67;
  --paper: #fffdf5;
  --teal: #087a73;
  --teal-dark: #075d58;
  --yellow: #f5c542;
  --coral: #e85d3f;
  --blue: #3178b8;
  --green: #2f8f5b;
  --red: #b33a2b;
  --line: #b9cbc5;
  --shadow: 0 14px 40px rgba(23, 49, 47, 0.12);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #dcece6; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(8, 122, 115, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 122, 115, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.site-header {
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid var(--ink);
  background: rgba(255, 253, 245, 0.96);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 700;
}
.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
}
nav { display: flex; gap: 8px; }
.language-control { margin-left: auto; }
.language-control select {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 6px 28px 6px 9px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}
.nav-button, .text-button {
  min-height: 42px;
  border: 0;
  padding: 8px 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
}
.nav-button:hover, .text-button:hover { text-decoration: underline; text-decoration-thickness: 2px; }

main { width: 100%; }
.screen {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(36px, 7vw, 72px) 0 64px;
}
.wide-screen { width: min(1100px, calc(100% - 32px)); }
.narrow-screen { width: min(700px, calc(100% - 32px)); }
.home-intro { max-width: 720px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, p { overflow-wrap: break-word; }
h1 {
  margin: 0;
  max-width: 800px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 6vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: 0;
}
h2 { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0; }
.lead { max-width: 650px; margin: 20px 0 32px; color: var(--muted); font-size: 1.15rem; line-height: 1.65; }

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr)) minmax(220px, 1.6fr);
  gap: 1px;
  margin: 28px 0;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink);
  box-shadow: 7px 7px 0 var(--yellow);
}
.dashboard-strip > div {
  min-height: 88px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: white;
}
.dashboard-strip strong { font-size: 1.4rem; }
.dashboard-strip span { color: var(--muted); font-size: .86rem; font-weight: 700; }
.level-meter { gap: 9px; }
.meter { width: 100%; height: 10px; overflow: hidden; border: 1px solid var(--ink); background: #edf3ef; }
.meter > span { display: block; width: 0; height: 100%; background: var(--teal); transition: width .35s ease; }

.setup-panel, .settings-panel {
  padding: clamp(20px, 4vw, 36px);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}
fieldset { margin: 0 0 28px; padding: 0; border: 0; }
legend { margin-bottom: 10px; font-weight: 800; }
.segmented { display: grid; gap: 8px; }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  min-height: 52px;
  padding: 10px 14px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  transition: border-color .15s ease, background-color .15s ease;
}
.segmented label:hover span { border-color: var(--teal); }
.segmented input:checked + span { border-color: var(--ink); color: white; background: var(--teal); box-shadow: inset 0 0 0 2px white; }
.segmented input:focus-visible + span { outline: 4px solid var(--yellow); outline-offset: 3px; }

.primary-button, .secondary-button, .danger-button {
  min-height: 50px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 11px 20px;
  font-weight: 800;
  box-shadow: 4px 4px 0 var(--ink);
}
.primary-button { color: white; background: var(--teal); }
.primary-button:hover { background: var(--teal-dark); }
.secondary-button { color: var(--ink); background: white; }
.secondary-button:hover { background: #edf6f2; }
.danger-button { color: white; background: var(--red); }
.primary-button:active, .secondary-button:active, .danger-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
button:disabled { cursor: not-allowed; opacity: .55; }

.quiz-topline, .quiz-actions, .action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.round-stats { display: flex; gap: 22px; }
.question-progress { margin: 18px 0; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 18px; font-weight: 700; }
.quiz-panel {
  min-height: 470px;
  padding: clamp(22px, 5vw, 52px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: white;
  box-shadow: 8px 8px 0 var(--blue);
}
.question-kicker { margin: 0 0 10px; color: var(--muted); font-weight: 700; }
.question-title { margin: 0 0 28px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 6vw, 4rem); line-height: 1.05; letter-spacing: 0; }
.prompt-flag { margin-right: 10px; font-family: sans-serif; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice-button {
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 750;
}
.choice-button:hover:not(:disabled) { border-color: var(--teal); background: #edf6f2; }
.choice-button.correct-choice { border-color: var(--green); background: #dff3e8; }
.choice-button.wrong-choice { border-color: var(--red); background: #fbe5e0; text-decoration: line-through; }
.answer-form { display: flex; gap: 10px; }
.answer-form label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.answer-form input, .progress-tools input, .progress-tools select {
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--ink);
  background: white;
}
.answer-form input { min-width: 0; flex: 1; font-size: 1.1rem; }
.hint-text { min-height: 26px; margin: 16px 0 0; color: var(--blue); font-weight: 800; }
.feedback { margin-top: 28px; padding-top: 22px; border-top: 2px dashed var(--line); }
.feedback-title { margin: 0 0 6px; font-size: 1.25rem; font-weight: 900; }
.feedback.correct .feedback-title { color: var(--green); }
.feedback.incorrect .feedback-title { color: var(--red); }
.feedback-answer { margin: 0; color: var(--muted); font-size: 1.05rem; }
.feedback-flag { margin-right: 8px; font-family: sans-serif; font-size: 1.5rem; }
.quiz-actions { margin-top: 24px; justify-content: flex-end; }

.summary-score {
  margin: 28px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: white;
  box-shadow: 7px 7px 0 var(--coral);
}
.summary-score > div { padding: 22px; text-align: center; }
.summary-score > div + div { border-left: 1px solid var(--line); }
.summary-score strong { display: block; font-size: 2rem; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 26px; }
.badge { padding: 10px 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow); font-weight: 800; }
.review-list { margin: 10px 0 30px; padding: 0; list-style: none; }
.review-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.action-row { justify-content: flex-start; flex-wrap: wrap; }

.progress-tools { margin: 28px 0 18px; display: grid; grid-template-columns: auto minmax(180px, 1fr) auto 180px; align-items: center; gap: 10px; font-weight: 800; }
.country-list { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; list-style: none; }
.country-row { min-height: 78px; padding: 14px; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.country-flag { font-family: sans-serif; font-size: 1.8rem; }
.country-name { font-weight: 850; }
.country-capital { color: var(--muted); font-size: .9rem; }
.tier { padding: 5px 8px; border-radius: 4px; color: white; background: var(--muted); font-size: .72rem; font-weight: 850; text-transform: uppercase; }
.tier.learning { background: var(--blue); }
.tier.mastered { background: var(--green); }
.tier.started { color: var(--ink); background: var(--yellow); }
.settings-panel { margin-top: 28px; }

.celebrate { animation: celebrate .5s ease both; }
@keyframes celebrate { 0% { transform: scale(.97); } 60% { transform: scale(1.015); } 100% { transform: scale(1); } }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

@media (max-width: 720px) {
  .site-header { align-items: flex-start; }
  .brand span:last-child { display: none; }
  nav { flex: 1; justify-content: flex-end; gap: 2px; }
  .nav-button { padding-inline: 6px; }
  .language-control { margin-left: 0; }
  .language-control select { width: 68px; padding-right: 18px; }
  .dashboard-strip { grid-template-columns: repeat(3, 1fr); }
  .dashboard-strip .level-meter { grid-column: 1 / -1; }
  .segmented.three { grid-template-columns: 1fr; }
  .segmented.three.compact { grid-template-columns: repeat(3, 1fr); }
  .quiz-panel { min-height: 500px; }
  .choice-grid, .country-list { grid-template-columns: 1fr; }
  .answer-form { flex-direction: column; }
  .summary-score { grid-template-columns: 1fr; }
  .summary-score > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .progress-tools { grid-template-columns: 1fr; }
  .progress-tools label { margin-top: 5px; }
}

@media (max-width: 430px) {
  .site-header { align-items: center; flex-wrap: wrap; }
  .screen { width: min(100% - 22px, 920px); padding-top: 32px; }
  nav { order: 3; flex-basis: 100%; justify-content: space-between; gap: 2px; }
  .dashboard-strip > div { min-height: 76px; padding: 10px; }
  .language-control { order: 2; margin-left: auto; }
  .language-control select { min-width: 108px; }
  .segmented.two { grid-template-columns: 1fr; }
  .quiz-topline { align-items: flex-start; }
  #progress-overview { grid-template-columns: repeat(2, 1fr); }
  .round-stats { gap: 10px; flex-direction: column; text-align: right; }
  .question-progress { grid-template-columns: 1fr; gap: 7px; }
  .quiz-panel { min-height: 510px; box-shadow: 5px 5px 0 var(--blue); }
  .question-title { font-size: 2.25rem; }
  .country-row { grid-template-columns: 38px 1fr; }
  .country-row .tier { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
