:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e5ea;
  --text: #1a1d24;
  --text-dim: #6b7280;
  --accent: #2563eb;
  --good: #1a8f5e;
  --good-bg: #eafaf2;
  --bad: #c2410c;
  --bad-bg: #fdf1ea;
  --found: #eab308;
  --water: #dfe7f0;
  --land: #64748b;
  --land-hover: #475569;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over elements whose own class
   (e.g. .btn's display:inline-block) would otherwise override the browser's
   default [hidden]{display:none} - that's what let the "Revoir mes erreurs"
   button stay visible despite el.hidden being correctly set to true. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ---------- Home ---------- */

.site-header {
  text-align: center;
  margin-bottom: 40px;
}

.site-header h1 {
  font-size: 2.2rem;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--text-dim);
  margin: 0;
}

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

.mode-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.mode-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mode-section-head h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}


.capital-toggle {
  position: relative;
  display: inline-flex;
  margin-top: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  font-weight: 600;
}

.capital-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.capital-toggle-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background: var(--accent);
  border-radius: 999px;
  transition: transform 0.18s ease;
}

.capital-toggle input:checked ~ .capital-toggle-thumb {
  transform: translateX(100%);
}

.capital-toggle-option {
  position: relative;
  z-index: 1;
  min-width: 62px;
  text-align: center;
  padding: 5px 8px;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.capital-toggle input:not(:checked) ~ .capital-toggle-option--pays,
.capital-toggle input:checked ~ .capital-toggle-option--capitale {
  color: white;
}

.mode-play-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.mode-options {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.mode-options-placeholder {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.option-label {
  font-size: 0.92rem;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.option-row--disabled {
  opacity: 0.45;
}

.minutes-input {
  width: 64px;
  padding: 6px 10px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.minutes-input:disabled {
  cursor: not-allowed;
}

.site-footer {
  text-align: center;
  color: var(--text-dim);
  margin-top: 48px;
  font-size: 0.85rem;
}

/* ---------- Game ---------- */

.page--game {
  max-width: 1200px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.back-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--text);
}

.score-board {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  font-size: 0.95rem;
  color: var(--text-dim);
}

.score-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-board strong {
  color: var(--text);
}

.prompt-bar {
  text-align: center;
  margin-bottom: 16px;
}

.prompt-label {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prompt-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 8px;
}

.target-flag {
  height: 3rem;
  width: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

#target-country,
#target-capital {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--accent);
}

.feedback {
  min-height: 24px;
  font-weight: 500;
  font-size: 0.98rem;
}

.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.summary {
  text-align: center;
  max-width: 440px;
  margin: 80px auto 0;
  padding: 40px 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.summary h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
  font-weight: 600;
}

.summary p {
  color: var(--text-dim);
  margin: 0 0 24px;
  line-height: 1.5;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary--wide {
  max-width: 900px;
  text-align: left;
}

.summary--wide h2,
.summary--wide p {
  text-align: center;
}

.results-table {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 0 0 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.results-col {
  min-width: 140px;
}

.results-col h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.results-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.results-col li {
  font-size: 0.88rem;
}

.results-col li.is-found {
  color: var(--good);
}

.results-col li.is-missing {
  color: var(--bad);
}

.map-wrap {
  position: relative;
  background: var(--water);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

#map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1120 / 500;
  cursor: grab;
  touch-action: none;
}

#map:active {
  cursor: grabbing;
}

.country {
  fill: var(--land);
  stroke: var(--water);
  stroke-width: 0.15;
  fill-rule: evenodd;
  transition: fill 0.12s ease;
}

.country:hover {
  fill: var(--land-hover);
}

/* Countries outside the current game's scope (another continent, or not in the
   "review mistakes" list): darker, inert, no hover/click. */
.country.is-inactive {
  fill: #3a4457 !important;
  pointer-events: none;
  transition: none;
}

.country-marker.is-inactive {
  display: none;
}

.country.is-correct {
  fill: var(--good) !important;
}

.country.is-wrong {
  fill: var(--bad) !important;
}

@keyframes hint-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.country.is-target {
  fill: var(--bad) !important;
  animation: hint-blink 1s ease-in-out infinite;
}

.country.is-target:hover {
  fill: var(--land-hover) !important;
}

.country.is-correct {
  animation: none;
}

.country.is-found {
  fill: var(--found) !important;
}

/* "Trouver le nom du pays" mode: the country to identify, blinking blue
   (distinct from the red "you failed 3 times" hint used elsewhere). */
.country.is-quiz-target {
  fill: var(--accent) !important;
  animation: hint-blink 1s ease-in-out infinite;
}

.country-marker {
  fill: rgba(37, 99, 235, 0.1);
  stroke: rgba(37, 99, 235, 0.55);
  stroke-width: 0.4;
  stroke-dasharray: 1 0.8;
  pointer-events: all;
}

.country-marker:hover {
  fill: rgba(37, 99, 235, 0.22);
}

.country-marker.is-correct {
  fill: rgba(26, 143, 94, 0.3) !important;
  stroke: var(--good) !important;
}

.country-marker.is-wrong {
  fill: rgba(194, 65, 12, 0.3) !important;
  stroke: var(--bad) !important;
}

.country-marker.is-target {
  fill: rgba(194, 65, 12, 0.35) !important;
  stroke: var(--bad) !important;
  animation: hint-blink 1s ease-in-out infinite;
}

.country-marker.is-correct {
  animation: none;
}

.country-marker.is-found {
  fill: rgba(234, 179, 8, 0.3) !important;
  stroke: var(--found) !important;
}

.country-marker.is-quiz-target {
  fill: rgba(37, 99, 235, 0.35) !important;
  stroke: var(--accent) !important;
  animation: hint-blink 1s ease-in-out infinite;
}

.country-marker.is-target:hover {
  fill: rgba(37, 99, 235, 0.22) !important;
  stroke: rgba(37, 99, 235, 0.55) !important;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

.zoom-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.zoom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.zoom-btn--reset {
  width: auto;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 500;
}

.answer-form {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.answer-input {
  width: 100%;
  max-width: 320px;
  padding: 11px 16px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.answer-input:focus {
  outline: none;
  border-color: var(--accent);
}

.answer-input:disabled {
  opacity: 0.6;
}

.below-map-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.below-map-controls-label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  opacity: 0.9;
}

.btn--disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: default;
}

.btn--small {
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: 7px;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn--ghost:disabled {
  opacity: 0.35;
}

@media (max-width: 600px) {
  #target-country, #target-capital { font-size: 1.4rem; }
  .target-flag { height: 1.8rem; }
  .score-board { flex-direction: column; gap: 4px; align-items: flex-end; }
}
