:root {
  --bg-0: #06111a;
  --bg-1: #0d2230;
  --text: #e8f0f6;
  --muted: #9cb1c1;
  --glass: rgba(8, 18, 29, 0.7);
  --glass-strong: rgba(7, 14, 24, 0.88);
  --ok: #16c784;
  --bad: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  background: var(--bg-0);
  color-scheme: dark;
}

body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #143349 0%, var(--bg-0) 45%, #04090f 100%);
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
}

.hidden {
  display: none !important;
}

.welcome {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 14, 0.62);
  backdrop-filter: blur(5px);
}

.welcome-card {
  width: min(480px, calc(100vw - 28px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: linear-gradient(145deg, rgba(9, 25, 38, 0.95), rgba(5, 12, 21, 0.98));
  border: 1px solid rgba(156, 177, 193, 0.24);
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 177, 193, 0.2) transparent;
}

.welcome-brand {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.welcome-title {
  margin: 4px 0 4px;
  font-size: clamp(22px, 3.4vw, 30px);
  line-height: 1.1;
}

.welcome-subtitle {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.welcome-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.mode-select {
  width: 100%;
  border: 1px solid rgba(156, 177, 193, 0.34);
  border-radius: 10px;
  background: rgba(13, 28, 42, 0.95);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}

.text-input {
  width: 100%;
  border: 1px solid rgba(156, 177, 193, 0.34);
  border-radius: 10px;
  background: rgba(13, 28, 42, 0.95);
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 8px;
}

.auth-box {
  margin-bottom: 8px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.compact-btn {
  margin-top: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.signed-in-copy {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.leaderboard {
  padding: 10px;
  border: 1px solid rgba(156, 177, 193, 0.25);
  border-radius: 12px;
  background: rgba(8, 19, 30, 0.65);
}

.leaderboard-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.leaderboard-list {
  margin: 0;
  padding-left: 22px;
  max-height: 100px;
  overflow: auto;
  font-size: 14px;
}

.leaderboard-list li {
  margin: 4px 0;
}

.leaderboard-empty {
  color: var(--muted);
}

.welcome-message {
  min-height: 16px;
  margin: 6px 0 0;
  color: #fbbf24;
  font-size: 13px;
}

#start-btn,
#restart-btn,
.secondary-btn {
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

#start-btn,
#restart-btn {
  color: #042113;
  background: linear-gradient(180deg, #35e1a1, #1ca26f);
}

#start-btn:hover,
#restart-btn:hover {
  filter: brightness(1.07);
}

.secondary-btn {
  margin-top: 10px;
  color: var(--text);
  background: rgba(24, 45, 62, 0.9);
  border: 1px solid rgba(156, 177, 193, 0.36);
}

.secondary-btn:hover {
  filter: brightness(1.12);
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 900;
  width: min(420px, calc(100vw - 28px));
  padding: 14px 16px;
  border-radius: 16px;
  backdrop-filter: blur(9px);
  background: linear-gradient(145deg, var(--glass), var(--glass-strong));
  border: 1px solid rgba(156, 177, 193, 0.22);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
}

.brand {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.prompt-wrap .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
}

.target-country {
  font-size: clamp(20px, 3.2vw, 30px);
  line-height: 1.1;
  font-weight: 700;
}

.stats {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.k {
  font-size: 13px;
  color: var(--muted);
}

.v {
  font-size: 20px;
  font-weight: 700;
}

.hud-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.hud-actions .compact-btn {
  margin-top: 0;
}

.game-over {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 14, 0.56);
  backdrop-filter: blur(4px);
}

.game-over.hidden {
  display: none;
}

.game-over-card {
  width: min(420px, calc(100vw - 36px));
  background: linear-gradient(145deg, rgba(8, 22, 34, 0.95), rgba(6, 13, 22, 0.98));
  border: 1px solid rgba(156, 177, 193, 0.24);
  border-radius: 18px;
  padding: 26px 20px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}

.go-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
}

.go-score {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

#final-score {
  color: var(--text);
  font-weight: 700;
}

.leaflet-control-attribution {
  font-size: 10px;
}

/* Dark-theme Leaflet controls (zoom + reset view) */
.leaflet-bar a,
.leaflet-bar a:hover {
  background: rgba(7, 17, 28, 0.92) !important;
  color: var(--text) !important;
  border-bottom-color: rgba(156, 177, 193, 0.2) !important;
}
.leaflet-bar {
  border: 1px solid rgba(156, 177, 193, 0.28) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
}
.leaflet-bar a.leaflet-disabled {
  color: var(--muted) !important;
  opacity: 0.5;
}

@media (max-width: 560px) {
  #hud {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    border-radius: 14px;
    padding: 12px;
  }

  .v {
    font-size: 18px;
  }
}

.go-save-status {
  min-height: 18px;
  margin: 8px 0 2px;
  font-size: 13px;
  color: var(--muted);
}

.scoreboard-panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: start end;
  padding: 14px;
  pointer-events: none;
}

.scoreboard-card {
  width: min(360px, calc(100vw - 28px));
  border: 1px solid rgba(156, 177, 193, 0.24);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(8, 22, 34, 0.95), rgba(6, 13, 22, 0.98));
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.36);
  padding: 12px;
  pointer-events: auto;
}

.scoreboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leaflet-control.custom-scoreboard-control {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.map-scoreboard-btn {
  border: 1px solid rgba(156, 177, 193, 0.34);
  border-radius: 8px;
  background: rgba(7, 17, 27, 0.92);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
  min-height: 30px;
  cursor: pointer;
}

.map-scoreboard-btn:hover {
  filter: brightness(1.12);
}

.forgot-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.forgot-btn:hover {
  color: var(--text);
}

/* Strike dots */
.strikes-display {
  display: flex;
  gap: 4px;
  align-items: center;
}

.strike-dot {
  font-size: 16px;
  color: var(--muted);
  transition: color 0.15s;
}

.strike-dot--used {
  color: var(--bad);
}

.strike-dot--danger {
  color: var(--bad);
  animation: strike-pulse 0.4s ease;
}

@keyframes strike-pulse {
  0% { transform: scale(1.6); }
  100% { transform: scale(1); }
}

/* Game over - missed country reveal */
.go-missed {
  margin: 4px 0 0;
  font-size: 14px;
  color: #ffdd55;
  font-weight: 600;
}

/* Wikipedia link — used in fact card and game-over */
.wiki-link {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.8;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, opacity 0.15s;
}

.wiki-link:hover {
  color: var(--text);
  opacity: 1;
}

.go-wiki-link {
  display: block;
  margin-top: 4px;
}

/* ── Fact card ───────────────────────────────────────────────── */
.fact-card {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 880;
  width: min(420px, calc(100vw - 28px));
  padding: 12px 14px;
  border-radius: 16px;
  backdrop-filter: blur(9px);
  background: linear-gradient(145deg, var(--glass), var(--glass-strong));
  border: 1px solid rgba(156, 177, 193, 0.22);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
  animation: fact-slide-in 0.22s ease;
}

@keyframes fact-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fact-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.fact-name {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.fact-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fact-item--full {
  grid-column: 1 / -1;
}

.fact-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.fact-value {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.fact-blurb {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(156, 177, 193, 0.15);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 560px) {
  .fact-card {
    bottom: 10px;
    left: 10px;
    width: calc(100vw - 20px);
  }
}

/* Keyboard hint in HUD */
.hud-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

/* Guest play */
.guest-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  font-size: 12px;
  color: var(--muted);
}

.guest-hint span {
  flex-shrink: 0;
}

.guest-btn {
  background: none;
  border: 1px dashed rgba(156, 177, 193, 0.4);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.guest-btn:hover {
  color: var(--text);
  border-color: rgba(156, 177, 193, 0.7);
}

/* Small country dots — make them clearly tappable */
.small-country-dot {
  cursor: pointer;
}

/* Country name tooltip (shown when not playing) */
.country-tooltip {
  background: rgba(7, 17, 28, 0.92);
  border: 1px solid rgba(156, 177, 193, 0.28);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.country-tooltip::before {
  display: none;
}

/* Reset view button */
.reset-view-btn {
  font-size: 16px;
  line-height: 26px !important;
  color: var(--text) !important;
  text-decoration: none !important;
}

/* Loading pulse on target country text */
@keyframes loading-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.loading-pulse {
  animation: loading-fade 1.4s ease-in-out infinite;
  color: var(--muted) !important;
  font-size: 18px !important;
}

/* ── Two-column panels row ───────────────────────────────────── */
.panels-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* ── Analytics panel ────────────────────────────────────────── */
.analytics-panel {
  padding: 10px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  background: rgba(30, 8, 8, 0.45);
}

.analytics-list {
  max-height: 100px;
}

.analytics-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.ac-name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-stats {
  display: flex;
  gap: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.ac-miss {
  color: var(--bad);
  font-weight: 700;
}

.ac-ok {
  color: var(--ok);
}

.ac-pct {
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}

.ac-mode-label {
  color: var(--muted);
  font-weight: 400;
}

.analytics-tip {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Focus mode optgroup styling */
.mode-select optgroup {
  color: var(--muted);
  font-style: normal;
}

/* Leaflet attribution dark mode */
.leaflet-control-attribution {
  background: rgba(6, 17, 26, 0.75) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a {
  color: var(--muted) !important;
}
