:root {
  --bg: #10151c;
  --panel: #1b232e;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #3fb68b;
  --accent-dark: #2d8f6c;
  --error: #ff7a7a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

button, select {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid #2c3746;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #08130e;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--accent-dark); }
button:disabled { opacity: 0.45; cursor: default; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; }

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  text-align: center;
}

h1 { margin: 0; font-size: 2.2rem; }
.sub, .note { color: var(--muted); margin: 0; }
.error { color: var(--error); min-height: 1.4em; margin: 0; max-width: 520px; }

#options { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
#options label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.9rem; }
#options .note { flex-basis: 100%; max-width: 520px; font-size: 0.9rem; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid #2c3746;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Игра */
#game, #result { position: fixed; inset: 0; }
#pano, #pano > div, #result-map { position: absolute; inset: 0; }

#hud {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  display: flex; gap: 12px;
}
#hud span { background: rgba(16, 21, 28, 0.85); padding: 6px 12px; border-radius: 8px; }

#guess-box {
  position: absolute; right: 16px; bottom: 16px; z-index: 10;
  width: 320px;
  display: flex; flex-direction: column; gap: 8px;
  transition: width 0.15s;
}
#guess-box:hover, #guess-box:focus-within { width: min(560px, calc(100vw - 32px)); }
#guess-map {
  height: 220px;
  border-radius: 10px;
  border: 2px solid #2c3746;
  transition: height 0.15s;
}
#guess-box:hover #guess-map, #guess-box:focus-within #guess-map { height: min(400px, 55vh); }

@media (max-width: 640px) {
  #guess-box, #guess-box:hover, #guess-box:focus-within { left: 8px; right: 8px; bottom: 8px; width: auto; }
  #guess-map, #guess-box:hover #guess-map { height: 38vh; }
}

/* Итог раунда */
.panel {
  position: absolute; left: 50%; bottom: 24px; z-index: 1000;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#result-country { font-size: 1.4rem; font-weight: 600; }
#result-distance { color: var(--muted); }
#result-points { font-size: 1.2rem; color: var(--accent); margin-bottom: 6px; }

/* Итог игры */
#final-table { border-collapse: collapse; min-width: min(420px, 100%); }
#final-table td { padding: 6px 10px; border-bottom: 1px solid #2c3746; text-align: left; }
#final-table td:last-child { text-align: right; color: var(--accent); }
.buttons { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
