:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #647084;
  --panel: rgba(255, 255, 255, 0.92);
  --line: rgba(22, 32, 42, 0.12);
  --blue: #1769e0;
  --green: #13895b;
  --red: #c43d43;
  --amber: #ad6c00;
  --shadow: 0 24px 80px rgba(38, 48, 64, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 105, 224, 0.14), transparent 30%),
    linear-gradient(315deg, rgba(19, 137, 91, 0.16), transparent 34%),
    #f4f7fb;
}

button,
a {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(8px, 1.8vmin, 22px);
  display: grid;
  place-items: center;
}

.game-board {
  width: 100%;
  height: calc(100vh - clamp(16px, 3.6vmin, 44px));
  height: calc(100svh - clamp(16px, 3.6vmin, 44px));
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto auto auto;
  gap: clamp(10px, 1.5vmin, 18px);
  padding: clamp(14px, 2vmin, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.top-bar,
.status-line,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vmin, 3.6rem);
  line-height: 0.95;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 8px;
}

.score-strip div {
  min-height: clamp(54px, 7vmin, 68px);
  padding: clamp(8px, 1.2vmin, 10px) 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.score-strip span {
  display: block;
  font-size: clamp(1.28rem, 2.5vmin, 1.65rem);
  font-weight: 850;
}

.score-strip small,
.result-label,
dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-line {
  min-height: clamp(32px, 4.5vmin, 40px);
  color: var(--muted);
  font-weight: 650;
}

.ghost-button,
.primary-button,
.map-link,
.choice-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.ghost-button {
  min-width: 80px;
  padding: 9px 13px;
  color: var(--ink);
  background: #e9eef6;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.flag-stage {
  min-height: 0;
  display: grid;
  place-items: center;
}

.flag-frame {
  position: relative;
  width: min(1040px, 100%, calc(50svh * 16 / 9));
  max-height: min(100%, 50svh);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.flag-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: clamp(10px, 2vw, 24px);
  filter: drop-shadow(0 16px 24px rgba(20, 35, 55, 0.18));
}

.loader {
  width: 54px;
  height: 54px;
  border: 5px solid #dbe4f0;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-button {
  min-height: clamp(56px, 7vmin, 72px);
  padding: clamp(12px, 1.8vmin, 16px) 18px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #ffffff;
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  font-weight: 750;
  text-align: left;
}

.choice-button:hover:not(:disabled),
.choice-button:focus-visible,
.ghost-button:hover:not(:disabled),
.primary-button:hover,
.map-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(34, 45, 60, 0.13);
}

.choice-button.correct {
  border-color: rgba(19, 137, 91, 0.36);
  background: #e8f7f0;
  color: var(--green);
}

.choice-button.wrong {
  border-color: rgba(196, 61, 67, 0.26);
  background: #fff0f1;
  color: var(--red);
}

.choice-button.removed {
  display: none;
}

.choice-button:disabled {
  cursor: default;
}

.hint-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.hint-panel {
  padding: 14px 16px;
  color: var(--amber);
  font-weight: 750;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.6fr);
  gap: clamp(10px, 1.6vmin, 18px);
  padding: clamp(12px, 1.7vmin, 20px);
}

.result-panel[hidden],
.hint-panel[hidden] {
  display: none;
}

.result-panel h2 {
  margin-top: 4px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.2vmin, 12px);
  margin: 0;
}

.facts div {
  padding: clamp(9px, 1.3vmin, 12px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

dd {
  margin: 5px 0 0;
  font-size: clamp(0.92rem, 1.7vmin, 1.04rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-actions {
  grid-column: 1 / -1;
}

.primary-button,
.map-link {
  display: inline-flex;
  min-height: clamp(40px, 5vmin, 46px);
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-weight: 800;
}

@media (max-height: 820px) and (min-width: 721px) {
  .eyebrow {
    font-size: 0.68rem;
  }

  .game-board {
    grid-template-rows: auto auto minmax(150px, 1fr) auto auto auto;
  }

  .flag-frame {
    width: min(880px, 100%, calc(42svh * 16 / 9));
    max-height: min(100%, 42svh);
  }

  .flag-frame img {
    padding: clamp(8px, 1.4vmin, 16px);
  }

  .choices {
    gap: 8px;
  }

  .choice-button {
    min-height: 50px;
  }

  .result-panel {
    grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.7fr);
  }

  .facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
}

.map-link {
  color: var(--blue);
  background: #eaf2ff;
}

.error-state {
  color: var(--red);
}

@media (max-width: 720px) {
  .top-bar,
  .status-line,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-bar {
    gap: 16px;
  }

  .score-strip,
  .choices,
  .result-panel,
  .facts {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: 62px;
    text-align: center;
  }

  .ghost-button,
  .primary-button,
  .map-link {
    width: 100%;
  }
}
