:root {
  color-scheme: light;
  font-family: ui-monospace, "Courier New", monospace;
  color: #24243d;
  background: #d8d9eb;
}
* { box-sizing: border-box; }
body {
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100svh;
  margin: 0;
  padding: 10svh 10vw;
}
#map-backdrop {
  position: fixed;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.cabinet {
  --globe-height: max(180px, calc(80svh - 190px));
  width: 100%;
  background: #fffbea;
  border: 3px solid #24243d;
  box-shadow: inset 0 -5px 0 #e9e1d1, 8px 8px 0 #24243d;
  padding: clamp(12px, 3vw, 26px);
}
.masthead, .brand, .controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.masthead, .controls { justify-content: space-between; flex-wrap: wrap; }
.masthead {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 3px solid #24243d;
}
h1 {
  font-size: clamp(1.45rem, 5vw, 2.65rem);
  font-weight: 900;
  margin: 0;
  letter-spacing: -.075em;
  text-shadow: 2px 2px #c8baf2;
}
.mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid currentColor;
  background: #fbd97b;
  box-shadow: 3px 3px 0 #24243d;
}
.mark::before {
  content: "";
  width: 23px;
  height: 23px;
  background: #272740;
  clip-path: polygon(43% 0, 57% 0, 57% 28%, 72% 28%, 72% 43%, 100% 43%, 100% 57%,
                     72% 57%, 72% 72%, 57% 72%, 57% 100%, 43% 100%, 43% 72%,
                     28% 72%, 28% 57%, 0 57%, 0 43%, 28% 43%, 28% 28%, 43% 28%);
}
.viewport {
  position: relative;
  border: 3px solid #24243d;
  background: #171c39;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  touch-action: none;
  cursor: grab;
}
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline: 3px solid #fbd97b; outline-offset: -4px; }
output {
  position: absolute;
  pointer-events: none;
  color: #d5d9f8;
  font-size: .875rem;
}
output { bottom: 12px; right: 12px; }
.controls {
  margin-top: 16px;
  padding: 10px 12px;
  border: 2px solid #24243d;
  background: #e7e2f7;
  box-shadow: inset 0 -4px 0 #d8d0ef;
}
.controls p { margin: 0; font-size: .875rem; }
.controls span { color: #676493; }
button {
  min-height: 44px;
  border: 2px solid #24243d;
  box-shadow: 3px 3px 0 #24243d;
  background: #c5bdf3;
  color: inherit;
  font: bold .875rem ui-monospace, monospace;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover { background: #dad3ff; }
button:active { transform: translate(3px, 3px); box-shadow: none; }
button:focus-visible { outline: 3px solid #5042a2; outline-offset: 5px; }
@media (max-width: 420px) {
  #map-backdrop { object-position: left center; }
  output { bottom: 5px; right: 6px; }
}
#country-name {
  left: 12px;
  bottom: 12px;
  max-width: 55%;
  color: #fff4cc;
  background: #202442;
  padding: 4px 7px;
  border: 1px solid #7376a0;
}
#country-name:empty { display: none; }
#coordinates {
  background: #202442;
  padding: 4px 7px;
}
.crosshair {
  position: absolute;
  display: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: white;
  text-shadow: 1px 1px #171c39, -1px -1px #171c39;
}
canvas:focus-visible ~ .crosshair { display: block; }
.keyboard { display: block; margin-top: 4px; }
.map-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-actions button[aria-label] { min-width: 44px; font-size: 1.25rem; }
button:disabled { opacity: .55; cursor: default; box-shadow: none; transform: none; }
@media (max-width: 420px) {
  #country-name { left: 6px; bottom: 5px; }
}
[hidden] { display: none !important; }
.viewport {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  color: #fffbea;
  isolation: isolate;
}
#globe {
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  width: min(100%, calc(var(--globe-height) * 480 / 312));
}
.locked #globe { cursor: default; }
.launch {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #12163185;
  text-align: center;
}
.launch-card p { margin: 12px 0 0; font-size: .875rem; text-shadow: 1px 2px #171c39; }
#launch-status:empty, #game-status:empty { display: none; }
.primary {
  border: 2px solid #29233e;
  color: #20223c;
  background: #ffdc83;
  box-shadow: 0 4px 0 #0d1126, 0 7px 14px #0d1126aa;
}
.primary:hover { background: #ffe8aa; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #0d1126; }
.primary:focus-visible { outline-color: #fff0b9; outline-offset: 4px; }
.primary:disabled {
  background: #ded8d1;
  color: #45435d;
  opacity: 1;
  box-shadow: 0 3px 0 #0d1126;
}
.play {
  padding: .65em 1.4em;
  min-width: 7em;
  font-size: clamp(1.25rem, 5vw, 2.15rem);
}
.local-link {
  display: inline-block;
  font-weight: bold;
  text-decoration: none;
}
#game-hud { display: contents; }
.question-card {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  max-width: min(50%, 360px);
  background: #202442f2;
  padding: 10px 13px;
  border-left: 3px solid #a49adc;
}
#game-progress {
  margin: 0 0 5px;
  color: #ded7ff;
  font-size: .875rem;
}
#game-prompt {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  line-height: 1.3;
}
#game-clues {
  padding-left: 20px;
  margin: 8px 0 0;
  font-size: .875rem;
  line-height: 1.4;
}
#game-clues li + li { margin-top: 4px; }
.bonus .question-card {
  position: relative;
  inset: auto;
  grid-row: 1;
  grid-column: 1;
  max-width: none;
  border-left: 0;
  border-bottom: 2px solid #7772a4;
}
.scoreboard {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 51px;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: #efe9ff;
  background: #202442;
  padding: 10px 14px;
  border: 2px solid #7376a0;
  font-size: 1rem;
  pointer-events: none;
}
#score-total {
  color: #ffdc83;
  font-size: clamp(1.65rem, 3vw, 2rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
#score-meter {
  position: relative;
  width: clamp(19px, 2.3vw, 25px);
  height: clamp(72px, min(19vw, 34svh), 198px);
  border: 1px solid #8684a9;
  background: #13172f;
  overflow: hidden;
}
#score-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: var(--score-height, 0%);
  background: linear-gradient(0deg, #8bd893, #f9db79);
  transition: height 720ms cubic-bezier(.1, .65, .2, 1);
}
.score-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to top, transparent 0 calc(100% / 6 - 1px),
                                        #202442b8 calc(100% / 6 - 1px) calc(100% / 6));
}
.game-action {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
}
#game-selection {
  font-size: .875rem;
  line-height: 1.25;
  padding: 3px 6px;
  color: #fffbea;
  background: #202442;
}
#game-status {
  margin: 10px 0;
  color: #813a39;
}
#game-reveal {
  margin-top: 10px;
  padding: 12px 14px;
  border: 3px solid #24243d;
  box-shadow: 4px 4px 0 #24243d;
  background: #f8efce;
  font-size: .875rem;
  line-height: 1.45;
}
#game-reveal h3 { margin: 0; font-size: 1.05rem; }
#game-reveal p { margin: 6px 0 0; }
#game-reveal ul { margin: 7px 0; padding-left: 20px; }
#game-reveal .matched { color: #245339; }
#game-reveal .missed { color: #873a35; }
#celebration { position: absolute; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; }
#celebration i {
  position: absolute;
  width: 6px;
  height: 6px;
  animation: scatter 700ms cubic-bezier(.14, .64, .28, 1) both;
}
@keyframes scatter {
  0% { transform: scale(.5); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); opacity: 0; }
}
@media (max-width: 600px) {
  body { padding: 4svh 4vw; }
  .cabinet { --globe-height: 80svh; }
  .question-card {
    position: relative;
    inset: auto;
    grid-row: 1;
    grid-column: 1;
    max-width: none;
    border-left: 0;
    border-bottom: 2px solid #7772a4;
  }
  .scoreboard { right: 5px; bottom: 28px; padding: 5px 7px; gap: 4px; }
  .game-action { bottom: 8px; }
  .viewport:not(.locked) #country-name, .viewport:not(.locked) #coordinates { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #score-fill { transition: none; }
  #celebration i { animation: none; }
}

.viewport:not(.locked) #country-name { max-width: 26%; }
.player-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.player-nav button { background: #e1d8fa; }
.player-nav button:hover { background: #fbd97b; }
#player-dialog, #help-dialog {
  width: min(calc(100% - 32px), 460px);
  max-height: 85vh;
  overflow: auto;
  padding: 18px;
  color: #24243d;
  background: #fffbea;
  border: 3px solid #24243d;
  box-shadow: 6px 6px 0 #24243d, 10px 10px 0 #9d91c6;
}
#player-dialog::backdrop, #help-dialog::backdrop { background: #171c3999; }
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 14px;
  padding: 12px 18px;
  border-bottom: 3px solid #24243d;
  background: #d7cdf5;
}
.dialog-header h2 { margin: 0; font-size: 1.35rem; }
.dialog-header button { min-width: 44px; font-size: 1.25rem; }
#account-form, #account-form label { display: grid; gap: 6px; }
#account-form { gap: 10px; margin-bottom: 12px; }
#account-form input {
  width: 100%;
  min-height: 44px;
  font: inherit;
  border: 2px solid #24243d;
  padding: 8px;
}
#signup-note, #player-dialog-status { margin: 5px 0; font-size: .875rem; line-height: 1.4; }
#player-dialog-status:empty { display: none; }
#standings-table { width: 100%; border-collapse: collapse; text-align: left; }
#standings-table th, #standings-table td { padding: 7px; border-bottom: 1px solid #dfd8e4; }
#standings-table thead { background: #eee7fb; }
#standings-table th:last-child, #standings-table td:last-child { text-align: right; }
#standings-table .your-score { background: #e5dfff; font-weight: bold; }
#standings-periods { margin-top: 12px; }
#standings-periods button[aria-pressed="true"] { background: #c5bdf3; }
#game-reveal .percentile { font-weight: bold; }
#game-reveal .distribution-title { margin: 0; }
.distribution-chart {
  width: 100%;
  height: 190px;
  margin-top: 6px;
  cursor: default;
  touch-action: auto;
  image-rendering: auto;
}
#game-reveal.round-results {
  margin-top: 14px;
  padding: clamp(12px, 3vw, 20px);
  background: #fffbea;
}
.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-bottom: 8px;
  border-bottom: 3px solid #24243d;
}
#game-reveal .results-score {
  font-size: clamp(1.5rem, 6vw, 2.55rem);
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -.05em;
}
.personal-best-tag {
  margin-left: auto;
  margin-right: 3px;
  padding: 4px 8px;
  border: 2px solid #24243d;
  background: #fbd97b;
  box-shadow: 3px 3px 0 #24243d;
  color: #24243d;
  font-size: .8125rem;
  font-weight: 900;
  transform: rotate(6deg);
}
#game-reveal.round-results :is(.distribution-title, .recap-title) {
  margin: 14px 0 0;
  padding: 7px 9px;
  border: 2px solid #24243d;
  background: #e7e2f7;
}

#how-to-play {
  position: absolute;
  z-index: 5;
  top: 8px;
  right: 8px;
  background: #e1d8fa;
  color: #24243d;
}
#how-to-play:hover { background: #fbd97b; }
#help-dialog p, #help-dialog dd { line-height: 1.45; }
#help-dialog dt { font-weight: bold; }
#help-dialog dd { margin: 4px 0 12px; }
.bonus .question-card { padding-top: 60px; }
@media (max-width: 600px) {
  .question-card { padding-top: 60px; }
}

@media (pointer: coarse) {
  .controls .keyboard { display: none; }
  .map-actions { gap: 10px; }
  .map-actions button { min-height: 48px; }
}

.recovery-settings { margin: 10px 0 14px; padding: 8px; border: 2px solid #24243d; }
.recovery-settings summary { cursor: pointer; font-weight: bold; }
#recovery-settings { display: grid; gap: 8px; }
#recovery-settings input {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px;
  border: 2px solid #24243d;
  font: inherit;
}
#recovery-value {
  display: block;
  margin: 10px 0;
  padding: 8px;
  border: 2px solid #24243d;
  background: #e7e2f7;
  overflow-wrap: anywhere;
  user-select: all;
}

#game-reveal .recap-list { margin: 0; padding: 0 0 0 2rem; }
.recap-list > li { padding: 10px 0 10px 4px; border-bottom: 1px solid #ddd2b6; }
.recap-list > li:last-child { border-bottom: 0; }
.recap-list > li::marker { color: #514568; font-weight: bold; }
.recap-question { display: block; }
.recap-answer { display: flex; flex-wrap: wrap; column-gap: 10px; justify-content: space-between; margin-top: 3px; }
.recap-points { color: #4e3c83; white-space: nowrap; }
.recap-list details { margin-top: 5px; }
.recap-list summary { cursor: pointer; width: fit-content; }
