:root {
  --ink: #202126;
  --muted-ink: #52617a;
  --sky: #9fc4f8;
  --paper: #fffdfa;
  --line: #2f3137;
  --focus: #174eb5;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  background: var(--sky);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
select {
  font: inherit;
}

button,
select,
.county {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
.county:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  padding: 28px clamp(10px, 3vw, 44px) 20px;
}

.map-board,
.map-actions {
  width: min(1200px, 100%);
  margin-inline: auto;
}

.map-board {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--line);
  background-color: var(--sky);
  background-image: radial-gradient(rgba(45, 61, 87, 0.12) 0.8px, transparent 0.8px);
  background-size: 16px 16px;
}

.california-map {
  position: absolute;
  top: 1.2%;
  left: 2%;
  width: 78%;
  height: 92%;
  overflow: visible;
  filter: drop-shadow(5px 6px 0 rgba(48, 58, 75, 0.15));
}

.county {
  cursor: pointer;
  stroke: var(--line);
  stroke-linejoin: round;
  stroke-width: 1.45;
  transition: filter 100ms ease, stroke-width 100ms ease;
  vector-effect: non-scaling-stroke;
}

.county:hover {
  filter: brightness(0.93);
  stroke-width: 2.4;
}

.county.is-selected {
  filter: brightness(0.9);
  stroke: #0a2969;
  stroke-width: 3.2;
}

.county-label {
  fill: #24262b;
  font-size: 8.4px;
  font-weight: 800;
  letter-spacing: 0.01em;
  paint-order: stroke;
  pointer-events: none;
  stroke: rgba(255, 255, 255, 0.96);
  stroke-linejoin: round;
  stroke-width: 2.7px;
  text-anchor: middle;
}

.county-label.is-compact {
  font-size: 6.9px;
}

.county-label.is-tiny {
  font-size: 5.9px;
}

.county-label.is-selected {
  fill: #0a2969;
}

.map-legend {
  position: absolute;
  z-index: 3;
  top: 8%;
  right: 3.5%;
  width: 31%;
  padding: clamp(14px, 2vw, 23px);
  border: 2px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 253, 250, 0.96);
}

.legend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow,
.map-title > p {
  margin: 0 0 6px;
  color: #334c74;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legend-heading h2 {
  margin: 0;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  letter-spacing: -0.025em;
}

.legend-heading > span {
  padding: 4px 8px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #e2ecfb;
  font-size: 0.72rem;
  font-weight: 850;
}

.legend-list {
  display: grid;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.legend-list li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 24px;
  gap: 10px;
  align-items: center;
  min-height: clamp(43px, 5vw, 55px);
  border-bottom: 1px solid #d5d8dd;
}

.legend-list li:last-child {
  border-bottom: 0;
}

.legend-swatch {
  width: 36px;
  height: 25px;
  border: 1.5px solid var(--line);
  border-radius: 2px;
}

.legend-copy strong,
.legend-copy small {
  display: block;
}

.legend-copy strong {
  overflow: hidden;
  font-size: clamp(0.7rem, 1.3vw, 0.9rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-copy small {
  margin-top: 2px;
  color: #646a74;
  font-size: clamp(0.58rem, 0.95vw, 0.72rem);
}

.legend-level {
  font-size: clamp(0.72rem, 1.2vw, 0.9rem);
  font-weight: 900;
  text-align: right;
}

.map-title {
  position: absolute;
  z-index: 2;
  bottom: 4.5%;
  left: 4.5%;
  width: 47%;
}

.map-title h1 {
  margin: 0;
  font-size: clamp(3rem, 7.2vw, 5.9rem);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 0.9;
  text-transform: uppercase;
  white-space: nowrap;
}

.map-title h1 span {
  margin-left: 0.1em;
  font-weight: 760;
  letter-spacing: -0.045em;
}

.map-title h1 strong {
  font-weight: inherit;
}

.map-title > div {
  margin-top: 12px;
  color: #304667;
  font-size: clamp(0.68rem, 1.25vw, 0.9rem);
}

.map-title > div strong {
  color: var(--ink);
}

.county-picker {
  position: absolute;
  z-index: 20;
  width: 232px;
  padding: 13px;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 5px 5px 0 rgba(32, 33, 38, 0.24);
}

.picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.picker-heading strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-heading button {
  width: 25px;
  height: 25px;
  padding: 0 0 2px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.county-picker label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-ink);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.county-picker select {
  width: 100%;
  padding: 9px 30px 9px 9px;
  border: 1.5px solid var(--line);
  border-radius: 3px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.map-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 0;
  color: #304667;
  font-size: 0.78rem;
}

.map-actions p {
  margin: 0;
}

.map-actions > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-actions button {
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.map-actions #downloadMap {
  background: #fac51c;
}

.map-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.map-actions button:disabled {
  cursor: default;
  opacity: 0.42;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .app-shell {
    padding: 8px 6px 14px;
  }

  .map-board {
    border-width: 1.5px;
  }

  .map-legend {
    top: 4%;
    right: 2%;
    width: 34%;
    padding: 6px;
    border-width: 1.2px;
    border-radius: 2px;
  }

  .eyebrow,
  .map-title > p {
    margin-bottom: 2px;
    font-size: clamp(0.38rem, 1.45vw, 0.58rem);
    letter-spacing: 0.08em;
  }

  .legend-heading h2 {
    font-size: clamp(0.55rem, 2.25vw, 0.78rem);
  }

  .legend-heading > span,
  .legend-copy small {
    display: none;
  }

  .legend-list {
    margin-top: 4px;
  }

  .legend-list li {
    grid-template-columns: clamp(14px, 4.5vw, 22px) minmax(0, 1fr) 10px;
    gap: 3px;
    min-height: clamp(21px, 5.7vw, 31px);
  }

  .legend-swatch {
    width: clamp(14px, 4.5vw, 22px);
    height: clamp(10px, 3.2vw, 15px);
    border-width: 1px;
  }

  .legend-copy strong,
  .legend-level {
    font-size: clamp(0.43rem, 1.7vw, 0.62rem);
  }

  .map-title {
    bottom: 3%;
    left: 3%;
    width: 54%;
  }

  .map-title h1 {
    font-size: clamp(1.65rem, 8.3vw, 3.2rem);
  }

  .map-title > div {
    margin-top: 4px;
    font-size: clamp(0.45rem, 1.75vw, 0.65rem);
  }

  .county-picker {
    width: min(220px, 76%);
  }

  .map-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 10px 2px 0;
  }

  .map-actions > div {
    flex-wrap: wrap;
  }

  #saveStatus {
    margin-right: auto;
  }
}

@media (max-width: 420px) {
  .california-map {
    left: 1%;
    width: 80%;
  }

  .map-actions > div {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  #saveStatus {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
