* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f6f4;
  color: #222;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem;
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  margin-bottom: 0.35rem;
}

.subtitle {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.description {
  max-width: 820px;
  margin: 0.75rem auto;
  color: #555;
  line-height: 1.5;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: start;
  justify-content: center;
  background: white;
  padding: 1rem;
  border-radius: 16px;
  margin-bottom: 1.5rem;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.07);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.year-control {
  min-width: 200px;
}

.year-label-display {
  font-size: 1rem;
  font-weight: 700;
}

.year-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.year-badge-a {
  background: #d0e9ff;
  color: #1a5fa8;
}

.year-badge-b {
  background: #fde3d0;
  color: #b23a0a;
}

.year-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #444;
}

input,
select,
button {
  font: inherit;
}

input[type="range"] {
  width: 240px;
}

select,
button {
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #bbb;
  background: white;
}

button {
  background: #222;
  color: white;
  cursor: pointer;
  border: none;
}

button:hover {
  background: #444;
}

#play-button {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viz-card,
.takeaway {
  background: white;
  border-radius: 18px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.07);
}

.section-heading h2 {
  margin: 0 0 0.25rem;
}

.section-heading p {
  margin-top: 0;
  color: #555;
}

#map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: #e9eef2;
  border-radius: 14px;
  overflow: hidden;
}

#map-canvas,
#map-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

#map-overlay {
  pointer-events: all;
}

.country {
  fill: none;
  stroke: rgba(80, 80, 80, 0.22);
  stroke-width: 0.5px;
}

.region-box {
  fill: rgba(255, 255, 255, 0.06);
  stroke: #222;
  stroke-width: 1.5px;
  stroke-dasharray: 5 4;
  pointer-events: none;
}

#legend {
  margin-top: 0.75rem;
}

.legend-axis text {
  font-size: 12px;
  fill: #444;
}

.legend-axis path,
.legend-axis line {
  stroke: #aaa;
}

#small-multiples {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.small-map-card {
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 0.75rem;
  background: #fafafa;
}

.small-map-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: center;
}

.small-map-card canvas {
  width: 100%;
  aspect-ratio: 2 / 1;
  display: block;
  border-radius: 10px;
  background: #e9eef2;
}

#line-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.axis text {
  font-size: 12px;
  fill: #444;
}

.axis path,
.axis line {
  stroke: #aaa;
}

.line {
  fill: none;
  stroke-width: 2.5;
}

.line-point {
  stroke: white;
  stroke-width: 1px;
}

.year-hover {
  cursor: pointer;
}

.no-data {
  font-size: 1rem;
  fill: #777;
}

#tooltip {
  position: absolute;
  background: white;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

.takeaway {
  border-left: 6px solid #d73027;
  line-height: 1.55;
}

@media (max-width: 800px) {
  main {
    padding: 1rem;
  }

  .controls {
    align-items: stretch;
  }

  .control-group,
  button {
    width: 100%;
  }

  input[type="range"] {
    width: 100%;
  }

  .year-row {
    flex-direction: column;
    align-items: stretch;
  }

  #small-multiples {
    grid-template-columns: 1fr;
  }
}

.hist-bar {
  shape-rendering: crispEdges;
}

.legend-bin-label {
  fill: #444;
}