:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #607079;
  --paper: #f5f1e8;
  --panel: #fffaf0;
  --line: #d8cbb4;
  --water: #8cc9d8;
  --grass: #89bd70;
  --grass-dark: #6da65b;
  --road: #535a5f;
  --road-line: #e7d77f;
  --home: #e86e58;
  --shop: #4c8ed9;
  --factory: #8d7a69;
  --park: #2e9b69;
  --accent: #cf523f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(140, 201, 216, 0.45), transparent 42%),
    linear-gradient(180deg, #fff8ea 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: center;
  padding: 24px 0;
}

.city-stage {
  position: relative;
  min-width: 0;
}

.city-column {
  min-width: 0;
}

#city-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  height: auto;
  border: 2px solid #786f63;
  background: var(--water);
  image-rendering: pixelated;
  box-shadow: 0 18px 38px rgba(84, 76, 62, 0.22);
}

.tile-tooltip {
  position: absolute;
  z-index: 4;
  padding: 6px 9px;
  border-radius: 5px;
  background: rgba(23, 33, 38, 0.9);
  color: #fffaf0;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.status-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  pointer-events: none;
}

.status-bar > div {
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 250, 240, 0.88);
  border: 1px solid rgba(83, 90, 95, 0.22);
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(50, 45, 38, 0.12);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.05;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.title-block p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

button {
  min-height: 42px;
  border: 1px solid #7d7468;
  border-radius: 6px;
  background: #29343a;
  color: #fffaf0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #3c4a51;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #39464c;
  font-size: 14px;
}

.swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 1px solid rgba(23, 33, 38, 0.22);
  vertical-align: -3px;
}

.swatch.road {
  background: var(--road);
}

.swatch.rail {
  background: repeating-linear-gradient(
    90deg,
    #6b625d 0,
    #6b625d 4px,
    #d8d0c5 4px,
    #d8d0c5 7px
  );
}

.swatch.rail-road {
  background:
    linear-gradient(90deg, transparent 0 34%, #d8d0c5 34% 42%, transparent 42% 58%, #d8d0c5 58% 66%, transparent 66% 100%),
    linear-gradient(0deg, #535a5f 0 100%);
}

.swatch.home {
  background: var(--home);
}

.swatch.dense-home {
  background: #c75269;
}

.swatch.tower {
  background: #7156a8;
}

.swatch.shop {
  background: var(--shop);
}

.swatch.mall {
  background: #d26aa5;
}

.swatch.office {
  background: #316f97;
}

.swatch.school {
  background: #d9a441;
}

.swatch.hospital {
  background: #e9f4f1;
}

.swatch.police {
  background: #2d4f89;
}

.swatch.factory {
  background: var(--factory);
}

.swatch.park {
  background: var(--park);
}

.swatch.station {
  background: linear-gradient(90deg, #d9e4dd 0 60%, #77706b 60% 100%);
}

.log {
  height: 384px;
  margin: 0;
  padding: 0 12px;
  overflow-y: auto;
  list-style: none;
  color: #425057;
  font-size: 14px;
  line-height: 1.45;
}

.log-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.72);
}

.log li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(216, 203, 180, 0.75);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 38, 0.32);
}

.modal-panel {
  width: min(520px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 20px 48px rgba(50, 45, 38, 0.24);
}

.modal-close {
  width: 100%;
  margin-bottom: 14px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 16px 0 24px;
  }

  .side-panel {
    order: -1;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100vw - 20px, 1180px);
  }

  .status-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .title-block h1 {
    font-size: 28px;
  }

  strong {
    font-size: 17px;
  }
}
