:root {
  --bg: #101413;
  --panel: #f7f4ed;
  --panel-ink: #17201d;
  --muted: #64706a;
  --line: rgba(23, 32, 29, 0.16);
  --accent: #d24b26;
  --accent-dark: #a93618;
  --correct: #167a4a;
  --wrong: #b9332a;
  --map-edge: rgba(0, 0, 0, 0.35);
  --mobile-map-height: 440px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 100vh;
}

body.is-final .app-shell {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

body.is-final .play-area {
  display: none;
}

body.is-final .side-panel {
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  min-height: auto;
  width: min(100%, 680px);
}

body.is-final .panel-heading {
  display: grid;
  gap: 8px;
}

body.is-final h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
}

body.is-final #choices,
body.is-final #hintPanel {
  display: none;
}

.play-area {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

.map {
  background: #0b1110;
  height: 100%;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.satellite-image {
  display: block;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 1;
  transition: opacity 180ms ease;
  width: 100%;
}

.map.is-loading .satellite-image {
  opacity: 0;
}

.map-loader {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(132, 139, 134, 0.42), rgba(48, 56, 53, 0.62)),
    #788078;
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 140ms ease;
  z-index: 120;
}

.map.is-loading .map-loader {
  opacity: 1;
}

.loading-spinner {
  animation: spin 780ms linear infinite;
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 999px;
  height: 30px;
  width: 30px;
}

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

.map-zoom-controls {
  bottom: 18px;
  display: grid;
  gap: 6px;
  position: absolute;
  right: 18px;
  z-index: 520;
}

.map-zoom-button {
  align-items: center;
  background: rgba(247, 244, 237, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
  color: var(--panel-ink);
  display: inline-flex;
  font-size: 1.35rem;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 38px;
}

.map-zoom-button:hover:not(:disabled),
.map-zoom-button:focus-visible {
  background: #fffdf8;
  outline: 2px solid rgba(210, 75, 38, 0.58);
  outline-offset: 2px;
}

.map-shade {
  background:
    linear-gradient(90deg, transparent 64%, var(--map-edge)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.22), transparent 24%, transparent 72%, rgba(0, 0, 0, 0.18));
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 450;
}

.round-badge {
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(247, 244, 237, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  color: var(--panel-ink);
  display: flex;
  gap: 14px;
  left: 18px;
  padding: 10px 12px;
  position: absolute;
  top: 18px;
  z-index: 500;
}

.round-badge span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.round-badge strong {
  font-size: 0.96rem;
}

.round-badge #timeLabel {
  color: var(--accent-dark);
}

.side-panel {
  background: var(--panel);
  color: var(--panel-ink);
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 30px 26px;
}

.game-logo {
  display: block;
  height: auto;
  margin: 0 0 16px;
  max-width: 310px;
  width: min(100%, 310px);
}

h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 0.98;
  margin: 0;
}

.lede {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
  margin: 14px 0 0;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  align-items: center;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--panel-ink);
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 14px 14px;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  width: 100%;
}

.choice:hover:not(:disabled),
.choice:focus-visible {
  border-color: rgba(210, 75, 38, 0.7);
  box-shadow: 0 10px 26px rgba(41, 33, 24, 0.1);
  outline: none;
  transform: translateY(-1px);
}

.choice .label {
  display: grid;
  gap: 3px;
}

.choice strong {
  font-size: 1rem;
}

.choice span {
  color: var(--muted);
  font-size: 0.86rem;
}

.choice.correct {
  border-color: rgba(22, 122, 74, 0.8);
  box-shadow: inset 4px 0 0 var(--correct);
}

.choice.wrong {
  border-color: rgba(185, 51, 42, 0.75);
  box-shadow: inset 4px 0 0 var(--wrong);
}

.hint-panel {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
}

.hint-button {
  background: #fffdf8;
  border: 1px solid rgba(210, 75, 38, 0.42);
  border-radius: 8px;
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 900;
  min-height: 40px;
  padding: 8px 12px;
}

.hint-text {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
  margin: 0;
}

.result {
  background: rgba(23, 32, 29, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.4;
  min-height: 64px;
  padding: 14px;
}

.result.good {
  background: rgba(22, 122, 74, 0.11);
  border-color: rgba(22, 122, 74, 0.28);
  color: #0d5a34;
}

.result.bad {
  background: rgba(185, 51, 42, 0.1);
  border-color: rgba(185, 51, 42, 0.28);
  color: #84231d;
}

.score-matrix {
  align-self: start;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--panel-ink);
  display: grid;
  font-size: 1.42rem;
  font-weight: 900;
  gap: 7px;
  grid-template-columns: repeat(5, 1fr);
  line-height: 1;
  padding: 12px;
  text-align: center;
}

.score-matrix[hidden] {
  display: none;
}

.score-matrix span {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 1.35em;
}

.leaderboard-panel {
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.leaderboard-panel[hidden] {
  display: none;
}

.leaderboard-panel h2 {
  font-size: 1rem;
  line-height: 1.1;
  margin: 0;
}

.leaderboard-panel p {
  color: var(--muted);
  margin: 3px 0 0;
}

.leaderboard-form {
  display: grid;
  gap: 6px;
}

.leaderboard-form label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-form div {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.leaderboard-form input {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--panel-ink);
  font: inherit;
  font-weight: 900;
  min-height: 42px;
  padding: 8px 10px;
  text-transform: uppercase;
}

.leaderboard-form input:focus {
  border-color: rgba(210, 75, 38, 0.7);
  outline: none;
}

.leaderboard-status {
  font-size: 0.82rem;
}

.leaderboard-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 22px;
}

.leaderboard-list li {
  color: var(--panel-ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.leaderboard-list span {
  color: var(--muted);
  font-weight: 700;
}

.actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.actions.is-final {
  grid-template-columns: 1fr;
}

.share-panel {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.share-panel[hidden] {
  display: none;
}

.share-button {
  align-items: center;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--panel-ink);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 6px;
  justify-content: center;
  min-height: 42px;
  padding: 8px 10px;
  text-decoration: none;
}

.share-button span {
  color: var(--accent-dark);
  font-size: 1rem;
  line-height: 1;
}

.primary,
.secondary {
  border-radius: 8px;
  font-weight: 800;
  min-height: 48px;
  padding: 10px 12px;
}

.primary {
  background: var(--accent);
  color: #fffdf8;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--panel-ink);
}

.stats {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, 1fr);
  margin: auto 0 0;
  padding-top: 18px;
}

.stats div {
  display: grid;
  gap: 4px;
}

.stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats dd {
  font-size: 1.45rem;
  font-weight: 900;
  margin: 0;
}

.modal-backdrop {
  align-items: center;
  background: rgba(8, 12, 11, 0.7);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.intro-modal {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  color: var(--panel-ink);
  display: grid;
  gap: 14px;
  max-width: 430px;
  padding: 22px;
  width: 100%;
}

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

.intro-modal p {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.modal-check {
  align-items: center;
  color: var(--panel-ink);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 8px;
}

.modal-check input {
  accent-color: var(--accent);
  height: 18px;
  width: 18px;
}

@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: var(--mobile-map-height) minmax(0, 1fr);
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  body.is-final {
    overflow: auto;
  }

  body.is-final .app-shell {
    display: flex;
    height: auto;
    min-height: 100svh;
    overflow: visible;
    padding: 12px;
  }

  body.is-final .side-panel {
    height: auto;
    margin-top: 0;
    overflow: visible;
    padding: 16px;
  }

  .play-area {
    height: var(--mobile-map-height);
    min-height: 0;
  }

  .map {
    height: 100%;
    min-height: 0;
  }

  .map-zoom-controls {
    bottom: 24px;
    gap: 5px;
    right: 12px;
  }

  .map-zoom-button {
    height: 36px;
    width: 36px;
  }

  .map-shade {
    background: linear-gradient(0deg, var(--map-edge), transparent 30%);
  }

  .side-panel {
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.32);
    display: flex;
    gap: 8px;
    height: calc(100svh - var(--mobile-map-height) + 14px);
    margin-top: -14px;
    min-height: auto;
    overflow: hidden;
    padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
    position: relative;
    z-index: 700;
  }

  .game-logo {
    margin-bottom: 6px;
    max-height: 50px;
    max-width: 210px;
    object-fit: contain;
    object-position: left center;
    width: auto;
  }

  h1 {
    font-size: 1.45rem;
    line-height: 1.05;
  }

  .lede {
    font-size: 0.82rem;
    line-height: 1.25;
    margin-top: 5px;
  }

  .choices {
    gap: 7px;
  }

  .choice {
    min-height: 45px;
    padding: 8px 12px;
  }

  .choice .label {
    gap: 1px;
  }

  .choice strong {
    font-size: 0.95rem;
  }

  .choice span {
    font-size: 0.78rem;
  }

  .hint-panel {
    gap: 6px;
  }

  .hint-button {
    font-size: 0.76rem;
    min-height: 34px;
    padding: 6px 9px;
  }

  .hint-text {
    font-size: 0.76rem;
    max-height: 36px;
    overflow: hidden;
  }

  .result {
    font-size: 0.86rem;
    line-height: 1.25;
    max-height: 48px;
    min-height: 42px;
    overflow: hidden;
    padding: 8px 10px;
  }

  .score-matrix {
    font-size: 1.08rem;
    gap: 4px;
    padding: 8px;
  }

  .leaderboard-panel {
    gap: 7px;
    padding: 8px;
  }

  .leaderboard-panel h2 {
    font-size: 0.9rem;
  }

  .leaderboard-panel p,
  .leaderboard-list li,
  .leaderboard-status {
    font-size: 0.74rem;
  }

  .leaderboard-form input,
  .leaderboard-form button {
    min-height: 34px;
  }

  .share-panel {
    gap: 7px;
  }

  .share-button {
    font-size: 0.82rem;
    min-height: 36px;
    padding: 7px 8px;
  }

  .primary,
  .secondary {
    min-height: 40px;
    padding: 8px 10px;
  }

  .stats {
    margin-top: 0;
    padding-top: 8px;
  }

  .stats dt {
    font-size: 0.68rem;
  }

  .stats dd {
    font-size: 1.06rem;
  }

  .intro-modal {
    gap: 12px;
    padding: 18px;
  }

  .intro-modal h2 {
    font-size: 1.25rem;
  }

  .intro-modal p,
  .modal-check {
    font-size: 0.86rem;
  }

  .actions {
    gap: 8px;
    grid-template-columns: 1fr 1fr;
  }

  body.is-final .stats {
    display: none;
  }

  body.is-final .side-panel {
    gap: 6px;
  }

  body.is-final h1 {
    font-size: 1.55rem;
  }

  body.is-final .result {
    max-height: none;
  }

  body.is-final .share-button {
    min-height: 32px;
  }
}

@media (max-width: 520px) {
  .round-badge {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    left: 12px;
    top: 12px;
  }

  h1 {
    font-size: 1.38rem;
  }

  .choice {
    min-height: 43px;
  }
}

@media (max-width: 900px) and (max-height: 760px) {
  .game-logo {
    max-height: 40px;
  }

  .lede {
    display: none;
  }

  .choice {
    min-height: 40px;
  }

  .stats {
    display: none;
  }
}
