:root {
  --bg: #020305;
  --ink: #ffffff;
  --muted: #a9b3c7;
  --soft: #dfe7f7;
  --line: rgba(255, 255, 255, 0.13);
  --panel: rgba(11, 15, 24, 0.9);
  --excellent: #42f5b0;
  --good: #7ee06d;
  --mixed: #ffd166;
  --strained: #ff8a4c;
  --risky: #ff4d6d;
  --unknown: #4a5363;
  --water: #05070d;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.5);
}

body {
  background:
    radial-gradient(circle at 50% 0%, rgba(66, 245, 176, 0.12), transparent 28%),
    radial-gradient(circle at 80% 15%, rgba(255, 77, 109, 0.1), transparent 24%),
    linear-gradient(180deg, #05070d 0%, #020305 48%, #000 100%);
  color: var(--ink);
  font-family:
    "Aptos Display", "SF Pro Display", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  background: rgba(2, 3, 5, 0.76);
  backdrop-filter: blur(22px);
  border-bottom-color: var(--line);
  min-height: 92px;
  padding: 16px 28px;
}

.brand {
  min-width: 250px;
}

.brand-mark {
  background:
    radial-gradient(circle at 50% 50%, #020305 0 28%, transparent 30%),
    conic-gradient(from 215deg, var(--excellent), var(--mixed), var(--risky), var(--good), var(--excellent));
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 36px rgba(66, 245, 176, 0.32);
  height: 46px;
  width: 46px;
}

h1 {
  color: #fff;
  font-size: 25px;
  font-weight: 850;
}

.brand p,
.compare-head p,
.section-heading span,
.rank-row span,
.method,
.empty-state,
.details-meta {
  color: var(--muted);
}

.toolbar {
  gap: 12px;
}

.search span,
.select-control span,
.compare-selectors span {
  color: #c9d4e8;
  font-weight: 800;
}

input,
select {
  appearance: none;
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  min-height: 42px;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, #dfe7f7 50%),
    linear-gradient(135deg, #dfe7f7 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 34px;
}

option {
  background: #0b0f18;
  color: #fff;
}

input::placeholder {
  color: #7d8799;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: rgba(66, 245, 176, 0.78);
  box-shadow: 0 0 0 4px rgba(66, 245, 176, 0.14);
}

.primary-button,
.icon-button {
  background: linear-gradient(135deg, #ffffff, #c8fce7);
  border-color: rgba(255, 255, 255, 0.28);
  color: #06100c;
  font-weight: 850;
  min-height: 42px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover,
.icon-button:hover {
  box-shadow: 0 0 34px rgba(66, 245, 176, 0.18);
  transform: translateY(-1px);
}

.layout {
  grid-template-columns: minmax(0, 1fr) 360px;
  padding-top: 92px;
}

.map-stage {
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% 48%, rgba(66, 245, 176, 0.09), transparent 35%),
    var(--water);
  background-size: 92px 92px, 92px 92px, auto, auto;
}

.map-stage::after {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  bottom: 18px;
  content: "";
  left: 18px;
  pointer-events: none;
  position: absolute;
  right: 18px;
  top: 18px;
}

.map-title {
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.96), rgba(5, 7, 13, 0.72) 70%, transparent);
  left: 0;
  max-width: none;
  padding: 22px 24px 28px;
  pointer-events: none;
  position: absolute;
  right: 0;
  text-align: center;
  top: 0;
  z-index: 4;
}

.map-title p {
  color: var(--excellent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.map-title h2 {
  color: #fff;
  font-size: clamp(26px, 4vw, 54px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  margin-top: 7px;
  text-shadow: 0 14px 50px rgba(0, 0, 0, 0.75);
}

.mode-switcher {
  display: none;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  pointer-events: auto;
}

.mode-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #dfe7f7;
  cursor: pointer;
  min-height: 38px;
  min-width: 128px;
  padding: 0 14px;
  pointer-events: auto;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mode-button.active {
  background: linear-gradient(135deg, #ffffff, #c8fce7);
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 0 28px rgba(66, 245, 176, 0.18);
  color: #06100c;
  font-weight: 850;
}

#worldMap {
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.42));
  height: calc(100% - 120px);
  margin-top: 120px;
  padding: 0 18px 12px;
}

.country {
  stroke: rgba(3, 5, 9, 0.74);
  stroke-width: 0.7;
  transition: fill 160ms ease, opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease, filter 160ms ease;
}

.country:hover,
.country.active {
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.42));
  stroke: #ffffff;
  stroke-width: 1.45;
}

.country.dimmed {
  opacity: 0.18;
}

.legend,
.loading-state,
.toast {
  background: rgba(8, 12, 20, 0.78);
  backdrop-filter: blur(18px);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.legend {
  bottom: 28px;
  gap: 10px;
  left: 28px;
  padding: 14px;
}

.legend div {
  color: var(--soft);
}

.swatch {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.12);
  width: 27px;
}

.excellent {
  background: var(--excellent);
}

.good {
  background: var(--good);
}

.mixed {
  background: var(--mixed);
}

.strained {
  background: var(--strained);
}

.risky {
  background: var(--risky);
}

.unknown {
  background: var(--unknown);
}

.map-tooltip {
  background: rgba(8, 12, 20, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  max-width: 280px;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  transform: translate(12px, -50%);
  z-index: 8;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.map-tooltip p {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.insights {
  background: rgba(4, 6, 10, 0.92);
  border-left-color: var(--line);
  padding: 24px;
}

.section-heading h2,
.method h2,
.compare-head h2,
.rank-row strong,
.details-title h2,
.factor-label strong {
  color: #fff;
}

.rank-row {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
  border-color: rgba(255, 255, 255, 0.13);
  color: #fff;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.rank-row:hover {
  background: linear-gradient(135deg, rgba(66, 245, 176, 0.14), rgba(255, 255, 255, 0.06));
  border-color: rgba(66, 245, 176, 0.32);
  transform: translateY(-1px);
}

.score-pill {
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.12);
  color: #05070d;
  font-weight: 900;
}

.details-panel,
.compare-panel {
  background: rgba(9, 13, 22, 0.96);
  backdrop-filter: blur(22px);
  border-color: var(--line);
  color: #fff;
}

.details-panel {
  max-width: 450px;
  padding: 24px;
  top: 92px;
  width: min(450px, 100vw);
}

.details-title {
  padding-right: 52px;
  text-align: center;
}

.details-title h2 {
  font-size: 34px;
  font-weight: 900;
}

.details-meta {
  justify-content: center;
}

.details-meta span,
.chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 9px;
}

.hero-score strong {
  color: #fff;
  display: block;
  margin-bottom: 7px;
  text-transform: capitalize;
}

.score-ring {
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 42px rgba(66, 245, 176, 0.18);
  color: #05070d;
  font-weight: 950;
}

.summary {
  color: var(--soft);
}

.factor-label {
  color: var(--soft);
}

.bar {
  background: rgba(255, 255, 255, 0.1);
  height: 10px;
}

.bar span {
  border-radius: inherit;
  box-shadow: 0 0 16px currentColor;
}

.source-dropdown {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px 14px;
}

.source-dropdown summary {
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.source-dropdown summary::-webkit-details-marker {
  display: none;
}

.source-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.source-list li {
  display: grid;
  gap: 4px;
}

.source-list a {
  color: var(--excellent);
  text-decoration: none;
}

.source-list a:hover {
  text-decoration: underline;
}

.source-list span {
  color: var(--muted);
  font-size: 12px;
}

.compare-panel {
  max-height: 52vh;
  padding: 20px 28px;
}

.compare-head {
  text-align: center;
}

.compare-selectors,
.chips {
  gap: 10px;
  justify-content: center;
}

.chip {
  color: var(--soft);
}

.chip button {
  color: #fff;
}

.compare-table {
  min-width: 720px;
}

.compare-row {
  border-bottom-color: var(--line);
  color: var(--soft);
  grid-template-columns: 230px repeat(3, minmax(130px, 1fr));
  text-align: center;
}

.compare-row strong {
  text-align: left;
}

.compare-row b {
  color: var(--excellent);
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    gap: 14px;
    min-height: 166px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 166px;
  }

  .map-stage {
    min-height: 62vh;
  }

  .insights {
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 18px;
  }

  .details-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    inset: auto 0 0 0;
    max-width: none;
    max-height: 58vh;
    top: auto;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 0;
    padding: 12px;
  }

  .brand {
    min-width: 0;
  }

  .brand p {
    max-width: 34ch;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .layout {
    padding-top: 242px;
  }

  .map-title {
    padding: 16px 14px 20px;
  }

  .map-title h2 {
    font-size: 28px;
  }

  #worldMap {
    height: calc(100% - 138px);
    margin-top: 138px;
    min-height: 320px;
    padding: 0 8px 72px;
  }

  .legend {
    bottom: 10px;
    font-size: 12px;
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .insights {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 16px 12px 92px;
  }

  .details-panel {
    max-height: 64vh;
    padding: 18px 14px 28px;
  }

  .hero-score {
    align-items: flex-start;
    flex-direction: column;
  }

  .details-title h2 {
    font-size: 28px;
  }

  .compare-panel {
    max-height: 72vh;
    padding: 16px 14px 24px;
  }

  .compare-table {
    min-width: 560px;
  }
}
