:root {
  color-scheme: dark;
  --orange: #ff8a00;
  --orange-hot: #ff8a00;
  --orange-soft: #ff8a00;
  --orange-2: #ff8a00;
  --ink: #090909;
  --panel: #111111;
  --panel-raised: #181818;
  --line: rgba(255, 255, 255, 0.11);
  --line-orange: rgba(255, 138, 0, 0.38);
  --text: #f8f8f5;
  --muted: #a7a7a1;
  --shadow: 0 34px 100px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 82% 5%, rgba(255, 138, 0, 0.11), transparent 30rem),
    radial-gradient(circle at -8% 38%, rgba(255, 138, 0, 0.07), transparent 34rem),
    #090909;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 84px 84px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.page-shell {
  position: relative;
  width: min(1420px, calc(100% - 48px));
  margin: 0 auto;
  padding: 6px 0 52px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px solid var(--orange);
  transform: rotate(45deg);
}

.brand-mark span {
  position: absolute;
  inset: 7px;
  background: var(--orange);
}

.brand-name {
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0.17em;
}

.snapshot-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.snapshot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 12px var(--orange);
}

.hero {
  padding: 8px 0 24px;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--orange-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 5.3vw, 54px);
  font-weight: 830;
  line-height: 0.94;
  letter-spacing: -0.065em;
}

h1 span {
  color: var(--orange);
}

.market-stats {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
}

.market-stat {
  min-width: 150px;
  padding: 7px 18px 5px;
  border: 0;
  border-left: 2px solid rgba(255, 138, 0, 0.28);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.market-stat strong,
.market-stat span {
  display: block;
}

.market-stat strong {
  color: #d7d7d2;
  font-size: clamp(32px, 3.2vw, 46px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.market-stat span {
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.market-stat:hover {
  color: var(--text);
  background: rgba(255, 138, 0, 0.06);
}

.market-stat.is-active {
  border-left-color: var(--orange);
  color: var(--orange-soft);
  background: linear-gradient(90deg, rgba(255, 138, 0, 0.13), transparent);
}

.market-stat.is-active strong {
  color: var(--orange);
}

.map-card {
  overflow: hidden;
  border: 1px solid var(--line-orange);
  background: rgba(17, 17, 17, 0.96);
  box-shadow: var(--shadow);
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 62px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255, 138, 0, 0.07), transparent 42%);
}

.market-stat:focus-visible,
.zoom-controls button:focus-visible,
#detail-close:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.active-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-dot {
  width: 9px;
  height: 9px;
  border: 2px solid var(--orange);
  border-radius: 50%;
}

.map-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  min-height: 635px;
  background: #0d0d0d;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 635px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 138, 0, 0.08), transparent 42%),
    #0d0d0d;
  touch-action: none;
}

#city-map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 635px;
  cursor: grab;
  user-select: none;
}

#city-map:active {
  cursor: grabbing;
}

.state-shape {
  fill: #171717;
  stroke: rgba(255, 138, 0, 0.45);
  stroke-width: 0.95;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 160ms ease, stroke 160ms ease;
}

.state-shape:hover {
  fill: rgba(255, 138, 0, 0.09);
  stroke: rgba(255, 138, 0, 0.86);
}

.state-shape:focus,
.state-shape:focus-visible {
  outline: none;
  fill: rgba(255, 138, 0, 0.12);
  stroke: var(--orange);
  stroke-width: 2.3;
}

.state-shape.is-selected {
  fill: rgba(255, 138, 0, 0.16);
  stroke: var(--orange);
  stroke-width: 3.2;
  filter: drop-shadow(0 0 3px rgba(255, 138, 0, 0.72));
}

.nation-outline {
  fill: none;
  stroke: rgba(255, 138, 0, 0.95);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.state-border {
  fill: none;
  stroke: rgba(255, 138, 0, 0.42);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.city-marker {
  cursor: pointer;
  outline: none;
  stroke: rgba(255, 138, 0, 0.001);
  stroke-width: 8;
  vector-effect: non-scaling-stroke;
  transition: opacity 180ms ease;
}

.city-marker:focus,
.city-marker:focus-visible {
  outline: none;
}

.city-marker:hover {
  stroke: rgba(255, 138, 0, 0.72);
  stroke-width: 2;
}

.city-marker.is-selected {
  stroke: #fff1dd;
  stroke-width: 2.5;
  filter: url(#selected-glow);
}

.selection-ring {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: url(#selected-glow);
  pointer-events: none;
}

.map-hint,
.map-legend,
.zoom-controls,
.map-tooltip {
  position: absolute;
  z-index: 3;
}

.map-hint {
  top: 18px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

.map-hint span {
  width: 7px;
  height: 7px;
  border: 1px solid var(--orange);
  border-radius: 50%;
}

.zoom-controls {
  top: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: 40px 40px;
  gap: 5px;
}

.zoom-controls button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 138, 0, 0.3);
  background: rgba(8, 8, 8, 0.88);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  font-weight: 500;
}

.zoom-controls button:hover {
  border-color: var(--orange);
  background: #15110c;
}

.zoom-controls .zoom-reset {
  grid-column: 1 / -1;
  width: 85px;
  height: 32px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.map-legend {
  left: 20px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: rgba(7, 7, 7, 0.84);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}

.legend-circle {
  display: inline-block;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 7px rgba(255, 138, 0, 0.45);
}

.legend-small {
  width: 5px;
  height: 5px;
  margin-left: 2px;
}

.legend-medium {
  width: 9px;
  height: 9px;
}

.legend-large {
  width: 14px;
  height: 14px;
}

.map-tooltip {
  max-width: 230px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 138, 0, 0.7);
  background: rgba(5, 5, 5, 0.95);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
  transform: translate(12px, -50%);
}

.map-tooltip strong,
.map-tooltip span {
  display: block;
}

.map-tooltip span {
  margin-top: 3px;
  color: var(--orange-soft);
  font-variant-numeric: tabular-nums;
}

.city-detail {
  position: relative;
  display: flex;
  min-width: 0;
  padding: 24px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(155deg, rgba(255, 138, 0, 0.11), transparent 42%),
    #121212;
}

.city-detail::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 92px;
  background: linear-gradient(var(--orange), transparent);
  content: "";
}

.detail-idle {
  align-self: center;
  text-align: center;
}

.detail-target {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  border: 1px solid rgba(255, 138, 0, 0.45);
  border-radius: 50%;
}

.detail-target::before,
.detail-target::after {
  position: absolute;
  background: rgba(255, 138, 0, 0.45);
  content: "";
}

.detail-target::before {
  top: 50%;
  left: -9px;
  width: calc(100% + 18px);
  height: 1px;
}

.detail-target::after {
  top: -9px;
  left: 50%;
  width: 1px;
  height: calc(100% + 18px);
}

.detail-target span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 18px var(--orange);
  transform: translate(-50%, -50%);
}

.detail-idle strong {
  display: block;
  font-size: 18px;
}

.detail-idle p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.detail-selected {
  align-self: flex-end;
  width: 100%;
  padding-bottom: 8px;
}

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

.detail-tier {
  color: var(--orange-soft);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

#detail-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#detail-close:hover {
  border-color: var(--orange);
  color: var(--text);
}

.detail-selected h2 {
  margin: 20px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 3vw, 44px);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.detail-state {
  margin: 9px 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.population-block {
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.population-block span,
.population-block strong {
  display: block;
}

.population-block span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.population-block strong {
  margin-top: 7px;
  color: var(--orange);
  font-size: clamp(30px, 3vw, 43px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.state-results {
  align-self: stretch;
  width: 100%;
  min-width: 0;
}

.state-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.state-results-kicker {
  margin: 0 0 8px;
  color: var(--orange-soft);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.state-results-title-row {
  display: block;
}

.state-results-title-row h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.state-results-title-row span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clear-state {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: rgba(8, 8, 8, 0.7);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.clear-state:hover {
  border-color: var(--orange);
  color: var(--text);
}

.clear-state:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.state-city-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  max-height: 500px;
  margin: 16px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--line);
  scrollbar-color: var(--orange) #171717;
  scrollbar-width: thin;
}

.state-city-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 10px;
  background: #151515;
}

.state-city-card:hover {
  background: #1b1814;
}

.state-city-rank {
  color: #5f5f5a;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.state-city-name,
.state-city-population {
  min-width: 0;
}

.state-city-name strong,
.state-city-population strong,
.state-city-population span {
  display: block;
}

.state-city-name strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-city-name span {
  display: block;
  margin-top: 4px;
  color: #74746f;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.state-city-population {
  text-align: right;
}

.state-city-population span {
  color: #6e6e68;
  font-size: 8px;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.state-city-population strong {
  margin-top: 4px;
  color: var(--orange-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.state-city-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 44px 24px;
  background: #151515;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  color: #777771;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.map-footer a {
  color: #a6a69f;
  text-decoration-color: rgba(255, 138, 0, 0.5);
  text-underline-offset: 3px;
}

.map-footer a:hover {
  color: var(--orange-soft);
}

.loading-error {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(420px, calc(100% - 40px));
  padding: 22px;
  border: 1px solid #ff5f56;
  background: #18100f;
  color: #ffd5cf;
  text-align: center;
  transform: translate(-50%, -50%);
}

@media (max-width: 980px) {
  .page-shell {
    width: min(100% - 28px, 1100px);
  }

  .map-panel {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .map-stage,
  #city-map {
    min-height: 590px;
  }

  .city-detail {
    min-height: 168px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .detail-idle {
    display: flex;
    align-items: center;
    gap: 22px;
    width: 100%;
    text-align: left;
  }

  .detail-target {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    margin: 0;
  }

  .detail-selected {
    align-self: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 34px;
    align-items: end;
    padding: 0;
  }

  .detail-heading,
  .detail-selected h2,
  .detail-state {
    grid-column: 1;
  }

  .detail-selected h2 {
    margin-top: 9px;
  }

  .detail-state {
    margin-bottom: 0;
  }

  .population-block {
    grid-row: 1 / 4;
    grid-column: 2;
    min-width: 190px;
    padding: 0 0 0 26px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .state-city-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: 100%;
    padding: 4px 12px 28px;
  }

  .masthead {
    padding: 0 4px 20px;
  }

  .brand-name {
    font-size: 13px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .snapshot-chip {
    padding: 7px 9px;
    font-size: 9px;
  }

  .hero {
    padding: 6px 4px 18px;
  }

  .hero-title-row {
    gap: 16px;
  }

  h1 {
    font-size: clamp(38px, 11vw, 54px);
  }

  .market-stat {
    min-width: 82px;
    padding: 5px 9px 3px;
  }

  .market-stat strong {
    font-size: clamp(23px, 6vw, 30px);
  }

  .market-stat span {
    margin-top: 4px;
    font-size: 8px;
  }

  .map-toolbar {
    display: flex;
    padding: 12px;
  }

  .active-summary {
    font-size: 10px;
  }

  .map-stage,
  #city-map {
    min-height: 58vh;
    max-height: 620px;
  }

  .map-hint {
    top: 14px;
    left: 14px;
    max-width: 160px;
    line-height: 1.45;
  }

  .zoom-controls {
    top: 13px;
    right: 13px;
  }

  .map-legend {
    left: 12px;
    bottom: 12px;
  }

  .city-detail {
    min-height: 176px;
    padding: 22px;
  }

  .detail-selected {
    display: block;
  }

  .detail-heading {
    display: flex;
  }

  .detail-selected h2 {
    margin-top: 13px;
    font-size: 34px;
  }

  .detail-state {
    margin: 6px 0 18px;
  }

  .population-block {
    min-width: 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .population-block strong {
    font-size: 34px;
  }

  .map-footer {
    display: grid;
    gap: 6px;
    padding: 13px;
    line-height: 1.45;
  }

  .state-results-header {
    align-items: center;
    padding: 0 0 16px;
  }

  .state-results-title-row {
    display: block;
  }

  .state-results-title-row h2 {
    font-size: 28px;
  }

  .state-results-title-row span {
    display: block;
    margin-top: 7px;
    font-size: 9px;
  }

  .state-city-grid {
    grid-template-columns: 1fr;
    max-height: 420px;
    margin: 16px 0 0;
  }

  .state-city-card {
    min-height: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
