:root {
  --bg: #08111a;
  --bg-accent: #10273a;
  --surface: rgba(12, 24, 36, 0.88);
  --surface-strong: #122131;
  --border: rgba(166, 186, 208, 0.18);
  --text: #e8eef5;
  --text-muted: #9db0c3;
  --accent: #6ee7b7;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --radius: 20px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(61, 136, 197, 0.18), transparent 45%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

#loading-screen,
#error-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}

#loading-screen {
  color: var(--text-muted);
}

.loader-ring {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

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

.error-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 119, 119, 0.28);
  border-radius: var(--radius);
  background: rgba(21, 30, 41, 0.92);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-card h3 {
  margin-bottom: 8px;
  color: #fca5a5;
}

.error-card p {
  color: var(--text-muted);
  margin-bottom: 18px;
}

#retry-btn {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #042117;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

#app,
.map-page {
  min-height: 100vh;
}

.map-page {
  padding: 32px;
}

.map-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.map-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.map-header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
}

.map-description {
  max-width: 720px;
  color: var(--text-muted);
  font-size: 1rem;
}

.map-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 22px;
}

.map-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.map-card-header h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.map-card-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.map-controls {
  margin-left: auto;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.filter-field span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-field select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(8, 17, 26, 0.88);
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  outline: none;
}

.filter-field select:focus {
  border-color: rgba(110, 231, 183, 0.65);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.12);
}

.map-card code {
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9em;
}

.map-canvas {
  width: 100%;
  min-height: 420px;
}

.map-svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.06), transparent 42%),
    #091521;
}

.country-path {
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.country-path:hover {
  filter: brightness(1.08);
}

.marker-layer {
  pointer-events: auto;
}

.country-marker {
  cursor: default;
}

.marker-hit {
  fill: transparent;
}

.marker-halo {
  fill: rgba(9, 17, 27, 0.72);
  pointer-events: none;
}

.marker-dot {
  stroke: rgba(248, 250, 252, 0.72);
  stroke-width: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 18px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  color: var(--text-muted);
  font-size: 13px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.map-note,
.map-empty {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.map-empty code {
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.tooltip {
  position: fixed;
  max-width: 280px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(7, 17, 28, 0.95);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 999;
  font-size: 12px;
  line-height: 1.7;
  transition: opacity 0.1s ease;
}

.tooltip.hidden {
  opacity: 0;
}

.tooltip strong {
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
}

@media (max-width: 760px) {
  .map-page {
    padding: 18px;
  }

  .map-card {
    padding: 18px;
  }

  .map-card-header {
    flex-direction: column;
  }

  .map-controls {
    width: 100%;
    margin-left: 0;
  }

  .filter-field {
    min-width: 0;
    width: 100%;
  }
}

.tooltip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.tooltip .t-val {
  font-weight: 600;
  color: var(--text);
}

body.embed-page {
  overflow: hidden;
}

.embed-page .map-page {
  padding: 16px;
}

.embed-page .map-shell {
  gap: 14px;
}

.embed-page .map-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
}

.embed-page .map-description,
.embed-page .map-card-header p {
  font-size: 0.92rem;
}

.embed-page .map-card {
  padding: 16px;
  border-radius: 16px;
}

.embed-page .map-canvas {
  min-height: 320px;
}

@media (max-width: 760px) {
  .map-page {
    padding: 18px;
  }

  .map-card {
    padding: 16px;
  }

  .map-card-header {
    margin-bottom: 14px;
  }

  .legend-item {
    min-width: 100%;
  }

  .map-canvas {
    min-height: 300px;
  }
}
