.town-modal {
  width: min(1280px, calc(100vw - 16px));
  height: min(900px, calc(100vh - 16px));
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
}

.town-panel {
  width: auto;
  height: 100%;
  max-height: calc(100vh - 16px);
  gap: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #f4f4f5;
}

.town-panel > :not(.modal-head) {
  margin-right: 0;
  margin-left: 0;
}

.town-panel > :last-child:not(.modal-head) {
  margin-bottom: 0;
}

.town-hub-head {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: var(--brand);
  color: #ffffff;
}

.town-hub-head h2 {
  margin: 0;
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
}

.town-hub-head .icon-button {
  justify-self: end;
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.town-hub-head .icon-button:hover {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.16);
}

.town-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 18px;
  align-items: stretch;
  min-height: 0;
  padding: 22px 28px 18px;
  overflow: auto;
  background: #f4f4f5;
}

.town-main-area {
  display: grid;
  grid-template-rows: auto minmax(720px, 1fr);
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

.town-stage {
  display: grid;
  grid-template-areas:
    ". top ."
    "left map right"
    ". bottom .";
  grid-template-columns: minmax(84px, 120px) minmax(300px, 520px) minmax(84px, 120px);
  grid-template-rows: minmax(82px, auto) auto 72px;
  place-content: center;
  align-items: stretch;
  justify-items: center;
  justify-self: center;
  width: min(980px, 100%);
  min-width: 0;
  min-height: 720px;
  margin-top: 20px;
  gap: 12px;
  padding: 0;
  overflow: visible;
}

.town-map-frame {
  grid-area: map;
  width: 100%;
  display: grid;
  grid-template-rows: minmax(0, auto);
  align-content: center;
  align-items: center;
  justify-items: center;
}

.town-map-shell {
  width: min(clamp(300px, calc(100vh - 450px), 520px), 100%);
  align-self: center;
}

.town-map-nav-box {
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px dashed #c8cbd2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.town-map-nav-box-top {
  grid-area: top;
  align-content: center;
  gap: 8px;
}

.town-map-nav-box-left {
  grid-area: left;
  align-self: stretch;
}

.town-map-nav-box-right {
  grid-area: right;
  align-self: stretch;
}

.town-map-nav-box-bottom {
  grid-area: bottom;
  align-self: stretch;
}

.town-stage .game-map-arrow {
  position: static;
  transform: none;
}

.town-stage .game-map-arrow:disabled {
  border-style: dashed;
  background: #f1f1f2;
  color: #a6abb3;
  cursor: default;
  opacity: 1;
}

.town-stage .game-map-arrow[hidden] {
  display: none;
  pointer-events: none;
}

.town-region strong {
  font-size: 18px;
}

.town-map {
  border-color: #d4d5d9;
}

.town-map-cell.is-building {
  border-color: var(--brand);
  background: var(--ink);
  color: #ffffff;
}

.town-map-cell.is-building:hover {
  background: var(--brand-dark);
}

.town-map-cell.is-land {
  cursor: pointer;
  background: #ffffff;
  color: #737780;
}

.town-map-cell.is-land:hover {
  border-color: var(--ink);
  background: #eeeeef;
  color: var(--ink);
  transform: translateY(-1px);
}

.town-map-cell.is-land:focus-visible {
  border-color: var(--ink);
  outline: 3px solid rgba(43, 45, 49, 0.18);
}

.town-map-cell.is-land.is-owned-by-me {
  border-color: #2f7b4f;
  background: #e9f4ee;
  color: #2f7b4f;
}

.town-map-cell.is-water {
  background: #e2e7ea;
  color: #4d5963;
}

.town-map-cell.is-path {
  background: #eeeeef;
}

.town-map-cell.is-tree {
  background: #e7e8ea;
  color: var(--ink);
}

.town-map-cell.is-stone {
  background: #ececef;
  color: #666c75;
}

.town-map-cell.is-mountain {
  background: #dedfe3;
  color: #4a4f57;
}

.town-map-cell.is-field {
  background: #ededee;
  color: #5d6068;
}

.town-map.is-farm-map {
  border-color: #cfd9d0;
  background: #f6f8f5;
}

.town-map-cell.is-farm-grass {
  border-color: #cdd8cf;
  background: #eef5ee;
  color: #52735a;
  cursor: pointer;
}

.town-map-cell.is-farm-grass:hover {
  border-color: #56745d;
  background: #e3efe4;
  color: #2f5d3d;
  transform: translateY(-1px);
}

.town-map-cell.is-farm-loading {
  border-color: #d7ddd8;
  background: #f2f5f2;
  color: #8a918b;
  cursor: default;
}

.town-map-cell.is-farm-pond {
  border-color: #bccbd5;
  background: #dfe9ee;
  color: #4d6574;
}

.town-map-cell.is-farm-tilling {
  border-color: #c8c0b4;
  background: #eee9e0;
  color: #6d5d4b;
}

.town-map-cell.is-farm-tilled {
  border-color: #9a8a77;
  background: #d8ccbd;
  color: #514538;
}

.town-map.is-forest-map {
  border-color: #cad7cd;
  background: #f4f7f3;
}

.town-map.is-forest-map .town-map-cell.is-grass {
  background: #eef5ee;
  color: #597360;
}

.town-map.is-forest-map .town-map-cell.is-message-object {
  border-color: #7fa387;
  background: #dfecdf;
  color: #2f5d3d;
}

.town-map.is-mine-map {
  border-color: #d0d1d5;
  background: #f3f3f4;
}

.town-map-cell.is-message-object {
  border-color: #737780;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.town-map-cell.is-message-object:hover {
  border-color: var(--brand);
  background: #eeeeef;
  transform: translateY(-1px);
}

.town-map-cell.is-message-object:focus-visible {
  border-color: var(--ink);
  outline: 3px solid rgba(43, 45, 49, 0.18);
}

.town-map-cell.is-mine-cave-entrance {
  border-color: #4d525a;
  background: #d9dadd;
  color: #232428;
}

.town-building-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: hidden;
  background: #ffffff;
}

.town-building-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.town-building-card {
  min-height: 86px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.town-building-card:hover {
  background: #eeeeef;
}

.town-building-symbol {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.town-building-card span:nth-child(2) {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.town-building-card strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.town-building-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.town-building-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: normal;
}

.town-empty-entry {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  color: var(--muted);
}

.town-empty-entry strong {
  color: var(--ink);
  font-size: 14px;
}

.town-empty-entry span {
  font-size: 12px;
  font-weight: 800;
}

.town-office-dialog {
  display: grid;
  gap: 14px;
}

.town-office-mayor {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.town-office-mayor span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.town-office-mayor strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.town-office-campaign-button {
  width: 100%;
}

.town-panel > .message {
  min-height: 24px;
  margin: 0;
  padding: 0 28px 24px;
  background: #f4f4f5;
}
