:root {
  color-scheme: light;
  --bg: #eef1eb;
  --panel: #fbfcf7;
  --panel-strong: #ffffff;
  --ink: #18201c;
  --muted: #66716c;
  --line: #cfd8d1;
  --green: #4d7f52;
  --green-soft: #dcebd9;
  --blue: #426f8f;
  --blue-soft: #d8e6ee;
  --gold: #9b7938;
  --gold-soft: #f0e3c3;
  --red: #a4493f;
  --red-soft: #f4d9d4;
  --black: #151a16;
  --shadow: 0 14px 36px rgba(24, 32, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

button:hover {
  border-color: #9dad9f;
  transform: translateY(-1px);
}

button.primary {
  background: var(--black);
  border-color: var(--black);
  color: white;
}

button.danger {
  border-color: #c99189;
  background: var(--red-soft);
  color: #6e241d;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(248, 250, 244, 0.72), rgba(238, 241, 235, 0.92)),
    linear-gradient(135deg, #dce2d6 0%, #eef1eb 48%, #d8e6ee 100%);
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
}

.login-brand {
  display: grid;
  gap: 4px;
}

.login-brand h1 {
  font-size: 28px;
}

.login-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h2,
.login-card p {
  margin: 0;
}

.login-button {
  width: 100%;
}

.login-help {
  text-align: center;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: #f8faf4;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  background: #f3f6ef;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-width: 118px;
}

.tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

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

.panel-header h2,
.section-title {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
  max-height: calc(100vh - 170px);
  overflow: auto;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.map-panel {
  overflow: hidden;
}

.mobile-status-bar {
  display: none;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 700;
}

.city-column {
  display: grid;
  gap: 14px;
  min-width: 0;
  align-content: start;
}

.notice-center {
  overflow: hidden;
}

.notice-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #f8faf4;
  text-align: left;
}

.notice-toggle:hover {
  transform: none;
}

.notice-toggle span:first-child {
  display: grid;
  gap: 2px;
}

.notice-toggle small {
  color: var(--muted);
}

.notice-list {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  max-height: 190px;
  overflow: auto;
}

.notice-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.notice-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.notice-item time,
.chat-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.notice-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0 14px 12px;
  color: var(--muted);
  font-size: 12px;
}

.notice-filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.conversation-center {
  overflow: hidden;
}

.city-chat-log {
  margin: 12px 14px 0;
  max-height: 170px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map {
  position: relative;
  height: calc(100vh - 188px);
  min-height: 560px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.3)),
    radial-gradient(circle at 72% 18%, rgba(66, 111, 143, 0.22), transparent 28%),
    radial-gradient(circle at 18% 78%, rgba(77, 127, 82, 0.2), transparent 30%),
    linear-gradient(135deg, #dce2d6 0%, #ecede1 48%, #d7ddd2 100%);
}

.map-world {
  position: absolute;
  inset: 0;
  transform-origin: center;
  transition: transform 180ms ease;
}

.map::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(83, 99, 87, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(83, 99, 87, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
}

.map-controls {
  position: absolute;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(24, 32, 28, 0.18);
  border-radius: 8px;
  background: rgba(248, 250, 244, 0.9);
  box-shadow: 0 10px 28px rgba(24, 32, 28, 0.16);
  cursor: grab;
  user-select: none;
}

.map-controls:active {
  cursor: grabbing;
}

.map-control {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--panel-strong);
}

.map-control.up {
  grid-column: 2;
  grid-row: 1;
}

.map-control.left {
  grid-column: 1;
  grid-row: 2;
}

.map-control.fit {
  grid-column: 2;
  grid-row: 2;
  font-size: 11px;
}

.map-control.right {
  grid-column: 3;
  grid-row: 2;
}

.map-control.zoom-in {
  grid-column: 1;
  grid-row: 3;
}

.map-control.down {
  grid-column: 2;
  grid-row: 3;
}

.map-control.zoom-out {
  grid-column: 3;
  grid-row: 3;
}

.lot {
  position: absolute;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 3px;
  padding: 8px;
  border: 2px solid rgba(24, 32, 28, 0.38);
  border-radius: 6px;
  background: rgba(251, 252, 247, 0.72);
  text-align: left;
  box-shadow: 0 5px 16px rgba(24, 32, 28, 0.08);
  overflow: hidden;
}

.lot > span:not(.lot-picture) {
  position: relative;
  z-index: 1;
}

.lot.selected {
  border-color: var(--black);
  outline: 3px solid rgba(21, 26, 22, 0.12);
}

.lot.public {
  background: rgba(216, 230, 238, 0.88);
}

.lot.private {
  background: rgba(251, 252, 247, 0.78);
}

.lot.auction {
  background: rgba(240, 227, 195, 0.9);
}

.lot.cityhall {
  background: rgba(220, 235, 217, 0.96);
  border-color: var(--green);
}

.map-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 244, 0.92);
  color: var(--muted);
  font-size: 13px;
}

.lot-id {
  font-weight: 700;
  font-size: 13px;
}

.lot-kind {
  color: var(--muted);
  font-size: 11px;
}

.lot-owner {
  align-self: end;
  font-size: 11px;
}

.lot-picture {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.82;
  background-image: url("./assets/building-sprites.png");
  background-size: 400% 300%;
  background-repeat: no-repeat;
  background-position: 0% 0%;
}

.lot-preview {
  position: relative;
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  margin: 10px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  overflow: hidden;
}

.lot-preview .lot-picture {
  position: relative;
  inset: auto;
  width: 96px;
  height: 52px;
  border-radius: 5px;
  border: 1px solid rgba(24, 32, 28, 0.16);
  opacity: 1;
}

.lot-preview span:last-child {
  font-size: 12px;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.lot-picture .sky,
.lot-picture .ground,
.lot-picture .building,
.lot-picture .detail {
  display: none;
}

.sprite-0 { background-position: 0% 0%; }
.sprite-1 { background-position: 33.333% 0%; }
.sprite-2 { background-position: 66.666% 0%; }
.sprite-3 { background-position: 100% 0%; }
.sprite-4 { background-position: 0% 50%; }
.sprite-5 { background-position: 33.333% 50%; }
.sprite-6 { background-position: 66.666% 50%; }
.sprite-7 { background-position: 100% 50%; }
.sprite-8 { background-position: 0% 100%; }
.sprite-9 { background-position: 33.333% 100%; }
.sprite-10 { background-position: 66.666% 100%; }
.sprite-11 { background-position: 100% 100%; }

.lot-picture .sky {
  inset: 0 0 42%;
  background: linear-gradient(#cfe4ec, #ecf3ed);
}

.lot-picture .ground {
  inset: 58% 0 0;
  background:
    linear-gradient(135deg, rgba(79, 125, 83, 0.28), transparent 36%),
    linear-gradient(#9fb779, #6f8d55);
}

.visual-land .ground,
.stage-raw .ground {
  background:
    repeating-linear-gradient(15deg, rgba(84, 91, 72, 0.24) 0 7px, transparent 7px 14px),
    linear-gradient(#b8a978, #80734f);
}

.lot-picture .building {
  left: 34%;
  right: 24%;
  bottom: 26%;
  height: 24%;
  border-radius: 3px 3px 1px 1px;
  background: rgba(129, 106, 82, 0.82);
}

.stage-raw .building {
  left: 24%;
  right: 20%;
  bottom: 27%;
  height: 8%;
  background: rgba(92, 79, 62, 0.72);
}

.stage-build .building,
.stage-finish .building {
  border: 2px solid rgba(91, 74, 58, 0.86);
  background:
    linear-gradient(90deg, transparent 46%, rgba(91, 74, 58, 0.55) 46% 54%, transparent 54%),
    rgba(216, 194, 158, 0.55);
}

.stage-complete.visual-house .building,
.stage-finish.visual-house .building {
  height: 30%;
  background: #e8d6b2;
  border: 1px solid rgba(96, 68, 52, 0.55);
}

.visual-house .detail {
  left: 31%;
  right: 21%;
  bottom: 55%;
  height: 18%;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #8f4e45;
}

.visual-business .building {
  left: 28%;
  right: 18%;
  height: 36%;
  background: #cdd7d8;
}

.visual-business .detail {
  left: 35%;
  right: 24%;
  bottom: 37%;
  height: 7%;
  background: #426f8f;
}

.visual-farm .building {
  left: 8%;
  right: 8%;
  bottom: 18%;
  height: 34%;
  background:
    repeating-linear-gradient(90deg, rgba(67, 103, 52, 0.76) 0 8px, rgba(177, 193, 95, 0.82) 8px 16px);
}

.visual-farm .detail {
  left: 62%;
  right: 20%;
  bottom: 48%;
  height: 20%;
  border-radius: 50% 50% 8px 8px;
  background: #7d4836;
}

.visual-solar .building {
  left: 18%;
  right: 16%;
  bottom: 26%;
  height: 26%;
  transform: skewX(-12deg);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 10px),
    #234f68;
}

.visual-civic .building {
  left: 26%;
  right: 18%;
  bottom: 25%;
  height: 34%;
  background: #dde3dd;
  border: 1px solid rgba(65, 91, 72, 0.5);
}

.visual-civic .detail {
  left: 22%;
  right: 14%;
  bottom: 59%;
  height: 9%;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #6e8b72;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 6px;
  padding: 8px;
}

.metric b {
  display: block;
  font-size: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.action-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.notice {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.notice.warning {
  background: var(--gold-soft);
  border-color: #d3bd82;
}

.notice.danger {
  background: var(--red-soft);
  border-color: #d9a8a0;
}

.notice.success {
  background: var(--green-soft);
  border-color: #a5c49f;
}

.feed {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.compact-feed {
  max-height: 170px;
}

.feed-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  padding: 10px;
}

.feed-item strong {
  display: block;
  font-size: 13px;
}

.feed-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #f8faf4;
}

.command input,
.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
}

.form-row {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
}

.compact-row {
  margin-top: 10px;
  margin-bottom: 8px;
}

.form-row label {
  font-size: 12px;
  color: var(--muted);
}

.mayor-layout {
  grid-template-columns: 310px 1fr 380px;
}

.list {
  display: grid;
  gap: 9px;
  max-height: 340px;
  overflow: auto;
}

.list-card {
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 7px;
}

.list-card h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.list-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.split-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.mute-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.chat-box {
  display: grid;
  gap: 8px;
}

.chat-log {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: white;
}

.chat-message {
  font-size: 12px;
  line-height: 1.35;
}

.chat-message b {
  color: var(--blue);
}

@media (max-width: 1120px) {
  .workspace,
  .mayor-layout {
    grid-template-columns: 1fr;
  }

  .map {
    height: 620px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .status-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    grid-template-rows: auto 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 8px 10px;
    gap: 8px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .status-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .status-strip .pill:nth-of-type(n + 5) {
    display: none;
  }

  .tabs {
    display: none;
  }

  .workspace {
    display: grid;
    grid-template-columns: 280px 760px 340px;
    gap: 10px;
    padding: 10px;
    width: 100vw;
    height: 100%;
    min-width: 0;
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .workspace > .panel,
  .notice-center,
  .conversation-center {
    display: block;
  }

  .workspace.profile-layout {
    overflow: auto;
    padding: 10px;
  }

  .workspace.mayor-layout {
    overflow: auto;
    padding: 10px;
  }

  .workspace.profile-layout > .panel {
    display: block;
    margin-bottom: 10px;
  }

  .workspace.mayor-layout > .panel {
    display: block;
    margin-bottom: 10px;
  }

  .city-column {
    display: grid;
    height: auto;
    align-content: start;
  }

  .map-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }

  .map-panel .panel-header {
    padding: 8px 10px;
  }

  .map-toolbar {
    display: none;
  }

  .map {
    height: 620px;
    min-height: 620px;
  }

  .command {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
  }

  .inline-check {
    display: none;
  }

  .mobile-status-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(248, 250, 244, 0.96);
    box-shadow: 0 -10px 28px rgba(24, 32, 28, 0.14);
  }

  .mobile-status-lines {
    min-width: 0;
  }

  .mobile-status-lines strong,
  .mobile-status-lines p {
    display: block;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
  }

  .mobile-status-lines p {
    color: var(--muted);
    line-height: 1.35;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .mobile-actions button {
    min-height: 40px;
    padding: 8px 10px;
  }

  .map-controls {
    transform: scale(0.86);
    transform-origin: top left;
  }
}
