html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #ddd;
}

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

#particles, #circles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* dots fly over the country circles, like the original */
#circles { z-index: 1; }
#particles { z-index: 2; }

/* zoom controls sit below the toolbar, not under it */
.maplibregl-ctrl-top-right { top: 46px; }

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: rgba(10, 10, 12, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}

#topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0 6px 0 0;
  color: #fff;
  white-space: nowrap;
}

.group {
  display: flex;
  gap: 6px;
  align-items: center;
}

#topbar button, #topbar select {
  background: #1c1c22;
  color: #ccc;
  border: 1px solid #33333c;
  border-radius: 4px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
}

#topbar button:hover { border-color: #666; color: #fff; }

#topbar button.active, #topbar select.active {
  background: #ffce3a;
  border-color: #ffce3a;
  color: #111;
  font-weight: 600;
}

/* keep the wide-content dropdowns compact when closed; the opened list
 * still expands to fit the full option text */
#country-select { width: 238px; }
#event-select { width: 104px; }

#legend {
  position: absolute;
  left: 12px;
  bottom: 48px;
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: #bbb;
  background: rgba(10, 10, 12, 0.7);
  padding: 6px 10px;
  border-radius: 4px;
  z-index: 10;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}

.dot.in { background: rgba(64, 120, 255, 0.85); }
.dot.out { background: rgba(230, 55, 45, 0.85); }
.dot.flow { background: #ffce3a; box-shadow: 0 0 6px #ffce3a; }

#tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(15, 15, 18, 0.95);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  z-index: 20;
  max-width: 240px;
}

#tooltip .name { font-weight: 600; color: #fff; }
#tooltip .gain { color: #7da2ff; }
#tooltip .loss { color: #ff8177; }
#tooltip .sub { margin-top: 5px; font-weight: 600; color: #ffce3a; }
#tooltip .mini { color: #bbb; }

#credits {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 12px;
  font-size: 11px;
  color: #888;
  background: rgba(10, 10, 12, 0.82);
  z-index: 10;
}

/* Explore menu: crawlable event + country links behind a toolbar button */
#explore-btn { margin-left: auto; }

#explore-menu {
  display: none;
  position: absolute;
  top: 44px;
  right: 8px;
  z-index: 30;
  background: rgba(14, 14, 17, 0.97);
  border: 1px solid #33333c;
  border-radius: 6px;
  padding: 12px 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  gap: 26px;
}
#explore-menu.open { display: flex; }
#explore-menu .head {
  font-weight: 600;
  color: #ffce3a;
  font-size: 12.5px;
  margin-bottom: 6px;
}
#explore-menu a {
  display: block;
  color: #bbb;
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.75;
  white-space: nowrap;
}
#explore-menu a:hover { color: #fff; }
#explore-countries { columns: 3; column-gap: 22px; }

#credits a { color: #aaa; }

@media (max-width: 720px) {
  #topbar h1 { display: none; }
}

/* event overlay: bigger than the year watermark, stacked above it */
#event-label {
  display: none;
  position: absolute;
  right: 28px;
  bottom: 168px;
  text-align: right;
  pointer-events: none;
  z-index: 9;
}
#event-label.show { display: block; }
#event-label .t {
  font-size: 54px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: rgba(255, 206, 58, 0.55);
}
#event-label .y {
  font-size: 22px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
}

/* big year watermark, shown only for single-year views (not decades) */
#period-label {
  display: none;
  position: absolute;
  right: 28px;
  bottom: 96px;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 9;
}
#period-label.show { display: block; }

/* small transparent notice shown while a Meta-sourced year is selected */
#source-note {
  display: none;
  position: absolute;
  left: 12px;
  bottom: 86px; /* above the legend; keeps clear of the year/event overlay on the right */
  max-width: 300px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(10, 10, 12, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  pointer-events: none;
  z-index: 9;
}
#source-note.show { display: block; }

/* phone-size warning: shown via media query, dismissed with the button */
#mobile-warning {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#mobile-warning .box {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  background: #16161b;
  border: 1px solid #33333c;
  border-radius: 8px;
  padding: 22px 24px;
  text-align: center;
}

#mobile-warning h2 { margin: 0 0 10px; font-size: 20px; color: #fff; }
#mobile-warning p { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: #bbb; }

#mobile-warning button {
  background: #ffce3a;
  color: #111;
  border: none;
  border-radius: 5px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 820px) and (pointer: coarse), (max-width: 560px) {
  #mobile-warning:not(.dismissed) { display: flex; }
}
