/* US States trainer (/states). Builds on styles.css (buttons, hand map, flag zoom). */
body.us-page {
  height: 100dvh;
  overflow: hidden;
}

/* styles.css greys out every button in dark mode; keep the main actions blue. */
body.us-page.dark-mode button.primary { background: #2563eb; color: #fff; }

.us-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  min-height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
body.dark-mode .us-header { background: #1f2937; border-bottom-color: #374151; }
.us-header h1 { margin: 0; font-size: 18px; white-space: nowrap; }
.us-back {
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.us-back:hover { text-decoration: underline; }
body.dark-mode .us-back { color: #93c5fd; }
.us-header-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
}
.us-header-stats[hidden] { display: none; }
body.dark-mode .us-header-stats { color: #d1d5db; }
.us-header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.us-header-actions [hidden] { display: none; }

.us-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.us-panel {
  width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #e5e7eb;
}
body.dark-mode .us-panel { background: #1f2937; border-right-color: #374151; }
.us-view { padding: 18px 20px 28px; }
.us-view[hidden] { display: none; }
.us-map-panel {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}
.us-map-panel #map { position: absolute; inset: 0; }
.us-map-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.us-map-hint[hidden] { display: none; }

/* ── Setup ── */
.us-setup h2 { margin: 0 0 6px; font-size: 22px; }
.us-lead { margin: 0 0 16px; color: #4b5563; font-size: 14px; line-height: 1.45; }
body.dark-mode .us-lead, body.dark-mode .us-hint { color: #9ca3af; }
.us-hint { color: #6b7280; font-size: 12px; line-height: 1.4; }
.us-field { border: 0; margin: 0 0 14px; padding: 0; }
.us-field[hidden] { display: none; }
.us-field legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
}
.us-task-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.us-task {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 10px 10px 34px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  background: #f9fafb;
  transition: border-color 0.15s, background 0.15s;
}
.us-task input { position: absolute; left: 10px; top: 11px; margin: 0; accent-color: #2563eb; }
.us-task strong { font-size: 13px; }
.us-task span { font-size: 11.5px; color: #6b7280; line-height: 1.3; }
.us-task:has(input:checked) { border-color: #2563eb; background: #eff6ff; }
body.dark-mode .us-task { background: #111827; border-color: #374151; }
body.dark-mode .us-task span { color: #9ca3af; }
body.dark-mode .us-task:has(input:checked) { border-color: #60a5fa; background: #1e3a5f; }

.us-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.us-chip { position: relative; cursor: pointer; }
.us-chip input { position: absolute; opacity: 0; pointer-events: none; }
.us-chip span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  transition: all 0.15s;
}
.us-chip input:checked + span { background: #2563eb; border-color: #2563eb; color: #fff; }
.us-chip input:focus-visible + span { outline: 2px solid #93c5fd; outline-offset: 2px; }
body.dark-mode .us-chip span { background: #111827; border-color: #4b5563; color: #d1d5db; }
body.dark-mode .us-chip input:checked + span { background: #3b82f6; border-color: #3b82f6; color: #fff; }

.us-options { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 16px; }
.us-options .checkbox { font-size: 13px; }
.us-start { width: 100%; padding: 12px; font-size: 15px; }
.us-start:disabled { opacity: 0.5; cursor: not-allowed; }
.us-error { color: #dc2626; font-size: 13px; margin: 8px 0 0; }
.us-error[hidden] { display: none; }

.us-mastery { margin-top: 22px; padding-top: 16px; border-top: 1px solid #e5e7eb; }
body.dark-mode .us-mastery { border-top-color: #374151; }
.us-mastery h3 { margin: 0 0 10px; font-size: 14px; }
.us-mastery-row { display: grid; grid-template-columns: 70px 1fr 54px; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.us-mastery-bar { height: 10px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.us-mastery-bar div { height: 100%; background: #22c55e; border-radius: 999px; transition: width 0.3s; }
body.dark-mode .us-mastery-bar { background: #374151; }
.us-mastery-count { text-align: right; font-variant-numeric: tabular-nums; color: #6b7280; }
.us-mastery .us-hint { margin: 8px 0 10px; }

.us-explore {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 10px;
  border-radius: 10px;
  background: #f3f4f6;
}
.us-explore[hidden] { display: none; }
body.dark-mode .us-explore { background: #111827; }
.us-explore img { width: 96px; border-radius: 4px; border: 1px solid #e5e7eb; cursor: zoom-in; }
.us-explore div { display: flex; flex-direction: column; gap: 2px; }
.us-explore-hint { margin: 10px 0 0; }
.us-explore-plate { width: 96px; margin-left: auto; border-radius: 4px; cursor: zoom-in; }
.us-explore-plate[hidden] { display: none; }
.us-plates-note { margin: 8px 0 0; }
.us-plates-note[hidden] { display: none; }
.us-credits { margin-top: 14px; font-size: 12px; color: #6b7280; }
.us-credits summary { cursor: pointer; font-weight: 600; }
.us-credits ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.5; }
.us-credits a { color: inherit; }
body.dark-mode .us-credits { color: #9ca3af; }

/* ── Question ── */
.us-progress-track { height: 4px; border-radius: 999px; background: #e5e7eb; overflow: hidden; margin-bottom: 14px; }
.us-progress-fill { height: 100%; width: 0; background: #2563eb; transition: width 0.3s; }
body.dark-mode .us-progress-track { background: #374151; }
.us-task-prompt { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.03em; }
.us-clue { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 14px; }
.us-clue-flag {
  max-width: 100%;
  max-height: 210px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  background: #f9fafb;
  cursor: zoom-in;
}
.us-clue-plate {
  max-width: 100%;
  max-height: 170px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  cursor: zoom-in;
}
.us-plates-blurred .us-clue-plate { filter: blur(6px); cursor: default; }
.us-plates-blurred .us-choices-plate img { filter: blur(4.5px); }
.us-options .checkbox[hidden] { display: none; }
.us-clue-flag[hidden], .us-clue-plate[hidden], .us-clue-name[hidden], .us-clue-map[hidden] { display: none; }
.us-clue-name { margin: 0; font-size: 26px; font-weight: 800; text-align: center; }
.us-clue-map {
  margin: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: #4f86c6;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.us-choices { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
.us-choices[hidden] { display: none; }
.us-choices-flag, .us-choices-plate { grid-template-columns: 1fr 1fr; }
.us-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  text-align: left;
  background: #fff;
  border: 1px solid #d1d5db;
  font-size: 15px;
}
.us-choices-flag .us-choice, .us-choices-plate .us-choice { flex-direction: column; align-items: stretch; padding: 6px; gap: 4px; }
.us-choices-flag .us-choice img, .us-choices-plate .us-choice img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: #f3f4f6; border-radius: 4px; }
.us-choice-key {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  flex-shrink: 0;
}
.us-choices-flag .us-choice-key, .us-choices-plate .us-choice-key { width: 100%; height: 18px; background: none; }
.us-choice:not(:disabled):hover { border-color: #2563eb; background: #eff6ff; }
.us-choice:disabled { cursor: default; opacity: 0.6; }
.us-choice.is-correct { opacity: 1; border-color: #16a34a; background: #dcfce7; box-shadow: 0 0 0 2px #16a34a inset; }
.us-choice.is-wrong { opacity: 1; border-color: #dc2626; background: #fee2e2; box-shadow: 0 0 0 2px #dc2626 inset; }
body.dark-mode .us-choice { background: #111827; border-color: #4b5563; }
body.dark-mode .us-choice-key { background: #374151; color: #d1d5db; }
body.dark-mode .us-choice:not(:disabled):hover { background: #1e3a5f; border-color: #60a5fa; }
body.dark-mode .us-choice.is-correct { background: #14532d; }
body.dark-mode .us-choice.is-wrong { background: #7f1d1d; }

.us-type-form { display: flex; gap: 8px; margin-bottom: 10px; }
.us-type-form[hidden] { display: none; }
.us-type-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}
body.dark-mode .us-type-form input { background: #111827; border-color: #4b5563; color: #f9fafb; }

.us-question-actions { display: flex; justify-content: center; }
.us-question-actions [hidden] { display: none; }

.us-feedback {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}
.us-feedback[hidden] { display: none; }
.us-feedback[data-result="correct"] { border-color: #86efac; background: #f0fdf4; }
.us-feedback[data-result="wrong"] { border-color: #fca5a5; background: #fef2f2; }
body.dark-mode .us-feedback { background: #111827; border-color: #374151; }
body.dark-mode .us-feedback[data-result="correct"] { border-color: #166534; background: #052e16; }
body.dark-mode .us-feedback[data-result="wrong"] { border-color: #991b1b; background: #2a0b0b; }
.us-feedback-title { margin: 0 0 10px; font-size: 17px; font-weight: 800; }
/* Last answer kept under the next question: quieter, no continue button. */
.us-feedback[data-previous] { opacity: 0.85; }
.us-feedback[data-previous] .us-feedback-title { font-size: 13px; margin-bottom: 8px; }
.us-continue[hidden] { display: none; }
.us-feedback[data-result="correct"] .us-feedback-title { color: #15803d; }
.us-feedback[data-result="wrong"] .us-feedback-title { color: #b91c1c; }
body.dark-mode .us-feedback[data-result="correct"] .us-feedback-title { color: #4ade80; }
body.dark-mode .us-feedback[data-result="wrong"] .us-feedback-title { color: #f87171; }
.us-feedback-answer { display: flex; align-items: center; gap: 12px; }
.us-feedback-answer img { width: 104px; border-radius: 4px; border: 1px solid #e5e7eb; cursor: zoom-in; }
.us-feedback-answer div { display: flex; flex-direction: column; gap: 2px; }
.us-feedback-answer strong { font-size: 18px; }
.us-feedback-plate { width: 104px; margin-left: auto; border-radius: 4px; cursor: zoom-in; }
.us-feedback-plate[hidden] { display: none; }
.us-feedback-other { margin: 10px 0 0; font-size: 13px; line-height: 1.4; }
.us-feedback-other[hidden] { display: none; }
.us-continue { width: 100%; margin-top: 12px; padding: 11px; }

/* ── Recap ── */
.us-recap h2 { margin: 0 0 4px; font-size: 22px; }
.us-recap-list { list-style: none; margin: 14px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.us-recap-list li {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f9fafb;
  cursor: pointer;
}
body.dark-mode .us-recap-list li { background: #111827; }
.us-recap-list img { grid-row: span 2; width: 44px; border-radius: 3px; border: 1px solid #e5e7eb; }
.us-recap-list span { font-weight: 600; font-size: 14px; }
.us-recap-list small { grid-column: 2; color: #6b7280; font-size: 11.5px; }
.us-recap-list b { grid-row: 1 / span 2; grid-column: 3; font-size: 18px; }
.us-recap-list li.is-correct b { color: #16a34a; }
.us-recap-list li.is-wrong b { color: #dc2626; }
.us-recap-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.us-recap-actions [hidden] { display: none; }

/* ── Phones: panel on top, map below ── */
@media (max-width: 760px) {
  body.us-page { height: auto; min-height: 100dvh; overflow: auto; }
  .us-header { flex-wrap: wrap; gap: 6px 12px; padding: 6px 12px; position: sticky; top: 0; z-index: 20; }
  .us-header h1 { font-size: 16px; }
  .us-header-stats { font-size: 12px; gap: 10px; }
  /* During a round the header is one line: back, title, stats, end round. */
  body:has(.us-main[data-view="question"]) .us-header { flex-wrap: nowrap; }
  body:has(.us-main[data-view="question"]) .us-header h1,
  body:has(.us-main[data-view="question"]) .us-header .lang-switch { display: none; }
  .us-main { flex-direction: column; }
  .us-panel { width: auto; border-right: 0; border-bottom: 1px solid #e5e7eb; overflow: visible; }
  .us-map-panel { min-height: 62dvh; }
  .us-task { padding: 8px 8px 8px 30px; }
  .us-task input { left: 8px; top: 9px; }
  .us-task strong { font-size: 12.5px; }
  .us-task span { font-size: 11px; }
  .us-view { padding: 14px 14px 18px; }
  .us-setup h2 { font-size: 19px; }
  .us-lead { margin-bottom: 12px; font-size: 13px; }
  /* Keep the start button reachable while scrolling the options. */
  .us-start {
    position: sticky;
    bottom: 10px;
    z-index: 5;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
  }
  .play-legal-links { display: none; }

  /* Question: everything on one screen, the map takes what the card leaves. */
  body.us-page:has(.us-main[data-view="question"]) { height: 100dvh; overflow: hidden; }
  .us-main[data-view="question"] { flex: 1 1 auto; min-height: 0; }
  .us-main[data-view="question"] .us-panel { flex-shrink: 0; max-height: 58dvh; overflow-y: auto; }
  .us-main[data-view="question"] .us-map-panel { min-height: 0; flex: 1 1 auto; }
  .us-question .us-clue { flex-direction: row; justify-content: center; gap: 12px; margin-bottom: 10px; }
  .us-clue-flag { max-height: 84px; max-width: 46%; }
  .us-clue-plate { max-height: 96px; max-width: 70%; }
  .us-clue-name { font-size: 20px; }
  .us-task-prompt { margin-bottom: 8px; font-size: 11.5px; }
  .us-progress-track { margin-bottom: 10px; }
  .us-choices:not(.us-choices-flag) { grid-template-columns: 1fr 1fr; }
  .us-choice { font-size: 14px; min-height: 40px; padding: 6px 8px; }
  .us-choices-flag .us-choice img, .us-choices-plate .us-choice img { aspect-ratio: 2 / 1; }
  .us-feedback-plate { width: 72px; }
  .us-feedback { margin-top: 8px; padding: 10px; }
  .us-feedback-answer img { width: 72px; }
  .us-feedback-answer strong { font-size: 16px; }
  .us-map-hint { bottom: 10px; font-size: 12px; }
}
