:root {
  color-scheme: light;
  --label-ink: #ffffff;
  --label-shadow: rgba(8, 20, 18, 0.72);
  --map-shift: -160px;
  --story-ink: #12201c;
  --story-muted: #5a6862;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f6f4ef;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.map-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #f6f4ef;
}

.city-map,
.zone-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translateX(var(--map-shift));
}

.city-map {
  object-fit: cover;
}

.title-image {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: clamp(180px, 19vw, 320px);
  height: auto;
  pointer-events: none;
}

.time-toggle {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 7;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(8, 20, 18, 0.72);
  box-shadow: 0 10px 22px rgba(8, 20, 18, 0.2);
  backdrop-filter: blur(12px);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.time-toggle:hover {
  background: rgba(8, 20, 18, 0.82);
}

.time-toggle-icon {
  width: 1em;
  text-align: center;
}

.zone-layer {
  pointer-events: auto;
}

.zone {
  pointer-events: none;
  fill: transparent;
  stroke: transparent;
  stroke-width: 0;
  vector-effect: non-scaling-stroke;
  transition:
    fill 160ms ease,
    filter 160ms ease;
}

.zone.is-active {
  filter: none;
  outline: none;
}

.zone-business.is-active {
  fill: rgba(133, 78, 255, 0.34);
}

.zone-work.is-active {
  fill: rgba(38, 130, 255, 0.31);
}

.zone-housing-north.is-active,
.zone-living.is-active {
  fill: rgba(241, 171, 38, 0.34);
}

.zone-culture.is-active {
  fill: rgba(13, 184, 207, 0.34);
}

.zone-waterfront.is-active {
  fill: rgba(237, 63, 49, 0.34);
}

.zone-campus.is-active {
  fill: rgba(231, 83, 155, 0.34);
}

.zone-park.is-active {
  fill: rgba(80, 178, 61, 0.34);
}

.zone-energy.is-active,
.zone-solar.is-active {
  fill: rgba(91, 170, 72, 0.34);
}

.route-image {
  pointer-events: none;
}

.route-image {
  display: none;
}

.route-line {
  fill: none;
  stroke: transparent;
  pointer-events: none;
}

.person-dot {
  stroke: rgba(8, 20, 18, 0.55);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  cursor: pointer;
  pointer-events: auto;
  transition:
    r 120ms ease,
    stroke-width 120ms ease,
    filter 120ms ease;
}

.person-dot.is-selected {
  stroke: rgba(0, 0, 0, 0.78);
  stroke-width: 1.4;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.55));
}

.dot-mint {
  fill: #7ff0d2;
}

.dot-sun {
  fill: #ffe36e;
}

.dot-white {
  fill: #ffffff;
}

.dot-blue {
  fill: #78b7ff;
}

.zone-label {
  pointer-events: auto;
  cursor: pointer;
  text-anchor: middle;
  paint-order: stroke fill;
}

.zone-label:focus-visible {
  outline: none;
}

.label-bg {
  fill: rgba(0, 0, 0, 0.68);
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1.5;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.24));
}

.story-panel {
  position: fixed;
  top: 16px;
  right: 24px;
  bottom: 16px;
  z-index: 6;
  width: min(418px, calc(100vw - 48px));
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  color: var(--story-ink);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 22px 60px rgba(8, 20, 18, 0.24);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateX(18px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.story-panel.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.story-kicker {
  margin: 0 0 5px;
  color: #1f766c;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.story-kicker:empty {
  display: none;
}

.story-header {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  flex: 0 0 auto;
}

.story-heading {
  min-width: 0;
}

.story-panel h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: normal;
  hyphens: none;
}

.story-face {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 112px;
  margin: 0;
  border: 3px solid rgba(18, 32, 28, 0.18);
  border-radius: 8px;
  image-rendering: pixelated;
  background: #cfe7db;
}

.story-face.is-visible {
  display: block;
}

.story-panel section + section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(18, 32, 28, 0.14);
}

.story-header + section {
  margin-top: 10px;
}

.chat-section[hidden] {
  display: none;
}

.chat-section {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overflow: auto;
  padding-right: 4px;
}

.chat-message {
  width: fit-content;
  max-width: 92%;
  padding: 9px 11px;
  border-radius: 8px;
  color: #1b2824;
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-message-model {
  justify-self: start;
  background: rgba(31, 118, 108, 0.12);
}

.chat-message-user {
  justify-self: end;
  color: #ffffff;
  background: #1f766c;
}

.chat-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-width: 52px;
  min-height: 34px;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #5a6862;
  animation: typing-pulse 900ms ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.chat-typing span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typing-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.chat-form textarea {
  min-width: 0;
  resize: none;
  padding: 9px 10px;
  border: 1px solid rgba(18, 32, 28, 0.2);
  border-radius: 8px;
  color: var(--story-ink);
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.3;
}

.chat-form textarea:focus {
  outline: 2px solid rgba(31, 118, 108, 0.38);
  outline-offset: 1px;
}

.chat-form button {
  align-self: stretch;
  min-width: 76px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #1f766c;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.chat-form button:disabled,
.chat-form textarea:disabled {
  cursor: wait;
  opacity: 0.68;
}

.chat-status {
  min-height: 1.1em;
  margin-top: 8px;
  color: #a13a2e;
  font-size: 0.78rem;
  line-height: 1.3;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-panel h2 {
  margin: 0 0 5px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.story-panel p {
  margin: 0;
  color: var(--story-muted);
  font-size: 0.88rem;
  line-height: 1.36;
}

.citizen-stats {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(18, 32, 28, 0.07);
}

.citizen-stats p,
.mood-row {
  margin: 0;
  color: #25342f;
  font-size: 0.82rem;
  line-height: 1.28;
}

.mood-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.mood-meter {
  min-width: 54px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(8, 20, 18, 0.16);
}

.mood-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f1ab26, #50b23d);
}

.zone-label text {
  fill: var(--label-ink);
  stroke: rgba(8, 20, 18, 0.78);
  stroke-width: 2px;
  stroke-linejoin: round;
  filter: none;
}

.label-title {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0;
}

.label-copy {
  font-size: 0;
  font-weight: 600;
  letter-spacing: 0;
}

.label-waterfront .label-title,
.label-campus .label-title,
.label-energy .label-title,
.label-solar .label-title {
  font-size: 20px;
}

.label-waterfront .label-copy,
.label-campus .label-copy,
.label-energy .label-copy {
  font-size: 16px;
}

@media (max-width: 520px) {
  :root {
    --map-shift: -120px;
  }

  .zone {
    stroke-width: 8;
  }

  .label-title {
    font-size: 31px;
  }

  .label-copy {
    font-size: 0;
  }

  .story-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    height: min(72vh, calc(100vh - 24px));
    max-height: none;
    padding: 16px;
    transform: translateY(18px);
  }

  .time-toggle {
    left: 12px;
    bottom: 12px;
    right: auto;
    width: fit-content;
    min-height: 46px;
    padding: 0 16px;
  }

  .story-panel.is-visible {
    transform: translateY(0);
  }

  .story-face {
    width: 100%;
    height: 100%;
    min-height: 104px;
  }

  .story-header {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px;
  }

  .story-panel h1 {
    font-size: 1.32rem;
  }

  .citizen-stats {
    padding: 8px;
  }

  .mood-row {
    grid-template-columns: 1fr auto;
  }

  .mood-row strong {
    grid-column: 1 / -1;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }
}
