:root {
  color-scheme: light;
  --paper: #f8f4ea;
  --ink: #201e1a;
  --accent: #1d644d;
  --rule: color-mix(in srgb, var(--ink) 26%, var(--paper));
  --display: Georgia, "Times New Roman", serif;
  --body: "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.4 var(--body);
}
.shell { width: min(100% - 2rem, 36rem); margin-inline: auto; }
.mast {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding-block: 1.25rem .4rem;
  border-bottom: 1px solid var(--ink);
}
.brand {
  margin: 0;
  font: 700 clamp(2.5rem, 8vw, 3.75rem)/1 var(--display);
  letter-spacing: -.055em;
}
.mast-actions, .controls, .result-heading, .settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 .75rem;
}
.progress, .rank, .value { font: .84rem/1.35 var(--mono); }
main { margin-block: .9rem 1.25rem; }
main:empty { margin-block: 0; }
h2, p, ol { margin: 0; }
ol { list-style: none; padding: 0; }

.round {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .4rem;
}
.round h2 { font: 700 1.35rem/1.12 var(--display); }
.board { border-block: 1px solid var(--ink); }
.row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) minmax(0, auto);
  align-items: baseline;
  gap: .45rem;
  min-height: 2.45rem;
  padding: .46rem 0;
}
.row + .row, .sort-row + .sort-row, .result-row + .result-row { border-top: 1px solid var(--rule); }
.country { font-weight: 600; overflow-wrap: anywhere; }
.value { max-width: 11rem; min-width: 0; text-align: right; overflow-wrap: anywhere; }

button, input, select, textarea {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
button, input, select { min-height: 44px; }
button { cursor: pointer; padding: .45rem .65rem; font-weight: 650; }
button:not(.text-button):enabled:hover { background: var(--ink); color: var(--paper); }
button:not(.text-button):enabled:active { background: var(--accent); color: var(--paper); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.text-button {
  padding-inline: 0;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.text-button:hover, .text-button:active { color: var(--accent); }
button:disabled { border-color: var(--rule); cursor: default; }
form { display: flex; gap: .5rem; margin-top: .85rem; }
input { flex: 1; min-width: 0; padding: .45rem .55rem; }
input::placeholder { color: var(--ink); opacity: .72; }
select { padding: .25rem; max-width: 100%; }

.choices { display: grid; margin-block: .7rem .35rem; border: 1px solid var(--ink); }
.choices button { border: 0; text-align: left; }
.choices button + button { border-top: 1px solid var(--rule); }
.choices button:focus-visible { position: relative; outline-offset: -3px; }
.choices button:focus-visible:hover { outline-color: var(--paper); }

.message { font-size: .9rem; }
.guess-status { font-weight: 700; margin-top: .45rem; }
.guess-status:empty { margin-top: 0; }
.guess-status.is-wrong { border-left: 1px solid var(--ink); padding-left: .5rem; }
#guess-help { margin-top: .35rem; }
.controls { justify-content: space-between; margin-top: .7rem; }
.reveal {
  margin-top: .85rem;
  padding: .55rem 0 .2rem .65rem;
  border-left: 1px solid var(--ink);
}
.result-heading { justify-content: space-between; gap: .3rem .6rem; margin-block: .65rem .75rem; }
.outcome {
  font: 700 .79rem/1.3 var(--mono);
  text-transform: uppercase;
  letter-spacing: .045em;
}
.points-earned { font: 700 1rem/1.2 var(--mono); white-space: nowrap; }
.answer-title, .results h2, .welcome h2, dialog h2 { font: 700 1.9rem/1.1 var(--display); }
.answer-title { flex-basis: 100%; margin-top: .12rem; }
.ranking-credit-rule { flex-basis: 100%; }
.reveal p + p { margin-top: .35rem; }
.reveal p:empty + p { margin-top: 0; }
.reveal p:empty { display: none; }
.reveal a { display: inline-block; margin-top: .35rem; color: var(--accent); text-underline-offset: .2em; }
.reveal + .controls { justify-content: flex-end; }
.results > ol { margin-top: .75rem; }
.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
  padding-block: .5rem;
}
.result-row:first-child { border-top: 1px solid var(--ink); }
.result-note { font-size: .85rem; }
.result-points { font-weight: 700; font-variant-numeric: tabular-nums; }
#copy-status:not(:empty) { margin-top: .45rem; }
.share { width: 100%; min-height: 5rem; margin-top: .65rem; padding: .5rem; }

.welcome p, .welcome ol, dialog p { margin-block: .55rem .75rem; }
.welcome ol { list-style: decimal; padding-left: 1.35rem; }
.welcome li + li { margin-top: .4rem; }
dialog {
  width: min(100% - 2rem, 27rem);
  max-width: none;
  max-height: calc(100svh - 2rem);
  overflow-y: auto;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1rem;
}
dialog::backdrop { background: var(--ink); opacity: .56; }
.restart form { justify-content: flex-end; }
.onboarding .controls { justify-content: flex-start; }
.practice > .message:first-child { margin-bottom: .35rem; }

.sort-list { margin-block: .55rem; }
.sort-row {
  display: grid;
  grid-template-columns: 2.25rem 1.1rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: .3rem;
  padding-block: .25rem;
}
.drag-handle {
  display: grid;
  place-items: center;
  min-height: 44px;
  touch-action: none;
  user-select: none;
  cursor: grab;
  font-size: 1.25em;
}
.drag-handle:active { cursor: grabbing; }
.sort-row.is-dragging { opacity: .55; }
.sort-row button { min-width: 44px; }
.country-board { margin-block: .55rem; }
.country-slot { letter-spacing: .12em; }
.country-answer.is-hit { background: color-mix(in srgb, var(--accent) 10%, var(--paper)); }
.odd-choices { display: grid; grid-template-columns: minmax(0, 1fr); margin-block: .7rem .35rem; padding: 0; border-block: 1px solid var(--ink); list-style: none; }
.question-context { margin-block: .65rem .55rem; }
.context-lead { font-size: .82rem; }
.question-context h3 { margin: .08rem 0 .14rem; font: 700 1.3rem/1.15 var(--display); }
.question-context .message, #ranking-help { margin: 0; }
.odd-order { margin-top: .8rem; }
.odd-order h3 { margin-bottom: .15rem; font: 700 1.05rem/1.2 var(--display); }
.odd-order .message { margin-bottom: .3rem; }
.odd-choices li + li { border-top: 1px solid var(--rule); }
.odd-choices button { display: grid; grid-template-columns: 2rem 1.5rem minmax(0, 1fr); align-items: center; width: 100%; min-height: 3rem; gap: .45rem; padding-inline: .5rem; border: 0; text-align: left; }
.odd-choice-letter { font: .82rem/1 var(--mono); opacity: .72; }
.odd-choice .flag { width: 1.5em; }
.odd-choice-country { min-width: 0; overflow-wrap: anywhere; }
.odd-result-note { display: block; font-size: .82rem; }
.country-autocomplete { position: relative; flex: 1; min-width: 0; }
.country-autocomplete input { width: 100%; }
.country-suggestions {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 1px) 0 auto;
  max-height: min(15rem, var(--suggestion-space, 15rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}
.country-suggestions.opens-up { inset: auto 0 calc(100% + 1px); }
.country-suggestions li { min-height: 44px; padding: .65rem; cursor: pointer; }
.country-suggestions li + li { border-top: 1px solid var(--rule); }
.country-suggestions li[aria-selected="true"], .country-suggestions li:hover { background: var(--ink); color: var(--paper); }
.ranking-comparison { display: grid; gap: .75rem; margin-block: .75rem; }
.ranking-column { border-top: 1px solid var(--ink); }
.ranking-column h3 { margin-block: .5rem; font: 700 1.2rem/1.15 var(--display); }
.ranking-result {
  display: grid;
  align-content: start;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: .15rem .35rem;
  padding-block: .45rem;
  border-bottom: 1px solid var(--rule);
}
.ranking-result .rank { grid-row: 1 / span 2; }
.ranking-result .value { grid-column: 2; text-align: left; }
.position-result { grid-column: 2; font-size: .82rem; }
.position-mark { display: inline-block; width: 1em; font-weight: 700; }
.ranking-result.right .position-result { color: var(--accent); font-weight: 700; }

@media (width > 28rem) {
  .ranking-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@supports (grid-template-rows: subgrid) {
  @media (min-width: 22rem) {
    .ranking-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 0; }
    .ranking-column {
      display: grid;
      grid-row: 1 / span calc(var(--positions) + 1);
      grid-template-rows: subgrid;
    }
    .ranking-column ol {
      display: grid;
      grid-row: 2 / -1;
      grid-template-rows: subgrid;
    }
  }
}

.settings { border-top: 1px solid var(--rule); padding-block: .65rem 1.25rem; font-size: .875rem; }
.settings label { display: flex; align-items: center; gap: .35rem; }
.round-track { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 28rem) {
  .value { max-width: min(42vw, 9.5rem); }
  .ranking-column h3 { font-size: 1rem; }
  .ranking-result { grid-template-columns: .9rem minmax(0, 1fr); gap: .12rem .22rem; }
  .settings { row-gap: .4rem; }
}

.site-about {
  margin-block: 1.25rem 2rem;
  color: var(--paper);
  font-size: .84rem;
  line-height: 1.5;
}
.site-about h2 {
  margin-bottom: .35rem;
  font-size: .95rem;
  line-height: 1.25;
}
.site-about p + p { margin-top: .4rem; }
#game:has(> :is(.round, .results)) ~ .site-about { display: none; }
