:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --panel: #fffdfa;
  --ink: #1e2a32;
  --muted: #667078;
  --line: #d8d3c8;
  --state: #dbe8e1;
  --state-hover: #bddbcc;
  --selected: #276b78;
  --correct: #3a7d44;
  --wrong: #b84a3f;
  --button: #243b53;
  --button-hover: #172a3d;
  --focus: #dd8a1f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.game-panel {
  width: min(1120px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 32px);
  box-shadow: 0 18px 50px rgb(30 42 50 / 0.12);
}

.is-hidden {
  display: none;
}

.home-screen {
  width: min(880px, 100%);
}

.home-heading {
  margin-bottom: 22px;
}

.home-heading h1 {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
}

.map-tile {
  position: relative;
  display: grid;
  width: min(360px, 100%);
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: #fffdfa;
  box-shadow: 0 18px 50px rgb(30 42 50 / 0.12);
}

.map-tile:hover,
.map-tile:focus {
  background: #fffdfa;
}

.map-tile-art {
  display: grid;
  min-height: 176px;
  place-items: center;
  background: linear-gradient(180deg, #eaf5f4, #f9fbf5);
}

.map-tile-art svg {
  width: 82%;
  max-width: 270px;
}

.flag-base {
  fill: #ffffff;
  stroke: rgb(30 42 50 / 0.14);
  stroke-width: 2;
}

.flag-stripes rect {
  fill: #b84a3f;
}

.flag-canton {
  fill: #243b53;
}

.flag-stars circle {
  fill: #ffffff;
}

.map-tile-copy {
  display: grid;
  gap: 4px;
  padding: 18px;
  text-align: left;
}

.map-tile-copy strong {
  font-size: 1.35rem;
}

.map-tile-copy span {
  color: var(--muted);
  font-weight: 700;
}

.map-tile-action {
  position: absolute;
  inset: auto 18px 18px auto;
  display: grid;
  min-width: 88px;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--button);
  font-weight: 800;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.map-tile:hover .map-tile-action,
.map-tile:focus .map-tile-action {
  opacity: 1;
  transform: translateY(0);
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.game-start-row {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 14px;
}

.play-area {
  filter: none;
  opacity: 1;
  transition:
    filter 180ms ease,
    opacity 180ms ease;
}

.game-panel.is-not-started .play-area {
  filter: blur(4px);
  opacity: 0.46;
  pointer-events: none;
  user-select: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: #a25528;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.scoreboard {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.95rem;
}

.scoreboard span {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 88px;
  padding: 9px 12px;
  background: #fbf7ef;
  text-align: center;
}

.scoreboard strong {
  color: var(--ink);
}

.map-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #eaf5f4, #f9fbf5);
  overflow: hidden;
}

.state-map {
  display: block;
  width: 100%;
  height: auto;
  min-height: 390px;
  padding: 10px;
}

.state-shape {
  fill: var(--state);
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 1.25;
  cursor: pointer;
  transition:
    fill 160ms ease,
    filter 160ms ease;
}

.state-group:hover .state-shape,
.state-group:focus .state-shape {
  fill: var(--state-hover);
  filter: drop-shadow(0 6px 8px rgb(30 42 50 / 0.2));
}

.state-group.selected .state-shape {
  fill: var(--selected);
}

.state-group.flash-selected .state-shape {
  animation: selected-flash 850ms ease;
}

.state-group.correct .state-shape {
  fill: var(--correct);
  animation: correct-flash 700ms ease;
}

.state-group.revealed .state-shape {
  fill: #8a735c;
}

.state-group.wrong .state-shape {
  fill: var(--wrong);
  animation: wrong-flash 700ms ease;
}

.state-label {
  fill: #ffffff;
  font-size: 15px;
  font-weight: 800;
  paint-order: stroke;
  pointer-events: none;
  stroke: rgb(30 42 50 / 0.7);
  stroke-linejoin: round;
  stroke-width: 4px;
  dominant-baseline: central;
}

.state-label-group {
  transition: opacity 180ms ease;
}

.callout-layer,
.label-layer {
  pointer-events: none;
}

.state-callout-group {
  transition: opacity 180ms ease;
}

.state-callout {
  fill: none;
  stroke: rgb(36 59 83 / 0.55);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.hidden-callout {
  display: none;
}

.guess-form {
  margin-top: 20px;
}

.guess-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
}

input:focus,
button:focus,
.state-group:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--button);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease;
}

button:hover {
  background: var(--button-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.icon-button.listening {
  background: #a25528;
}

.icon-button.muted {
  color: var(--button);
  background: #e6edf1;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.secondary {
  color: var(--button);
  background: #e6edf1;
}

.secondary:hover {
  background: #d7e3ea;
}

.status-message {
  min-height: 28px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.status-message.success {
  color: var(--correct);
}

.status-message.error {
  color: var(--wrong);
}

.game-modal {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.game-modal::backdrop {
  background: rgb(30 42 50 / 0.45);
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 24px 70px rgb(30 42 50 / 0.24);
}

.modal-content h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
}

.modal-content p:not(.eyebrow) {
  margin: 14px 0 20px;
  color: var(--muted);
  font-weight: 700;
}

@keyframes correct-flash {
  0%,
  100% {
    filter: none;
  }

  45% {
    filter: drop-shadow(0 0 18px rgb(58 125 68 / 0.7));
  }
}

@keyframes selected-flash {
  0%,
  100% {
    filter: none;
  }

  40% {
    filter: drop-shadow(0 0 20px rgb(39 107 120 / 0.8));
  }
}

@keyframes wrong-flash {
  0%,
  100% {
    filter: none;
  }

  45% {
    filter: drop-shadow(0 0 18px rgb(184 74 63 / 0.78));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    place-items: start center;
  }

  .top-bar {
    display: grid;
  }

  .game-start-row {
    justify-content: stretch;
  }

  .game-start-row button {
    width: 100%;
  }

  .scoreboard {
    justify-content: flex-start;
  }

  .map-wrap {
    overflow-x: auto;
  }

  .state-map {
    width: 900px;
  }

  .guess-row {
    grid-template-columns: minmax(0, 1fr) 74px;
  }

  .guess-row button[type="submit"] {
    grid-column: 1 / -1;
  }
}
