* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #efece7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  color: #23282f;
}

#city {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: grab;
  touch-action: none;          /* we handle pan + pinch ourselves */
}

/* ---------------------------------------------------------- camera controls */
#cam {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 5;
  user-select: none;
}
#cam button {
  width: 40px;
  height: 40px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  color: #3c4553;
  background: #fffffff2;
  border: 1px solid #dcd7cf;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(20, 26, 38, .14);
  cursor: pointer;
}
#cam button:hover { background: #fff; border-color: #b9c2d0; color: #1d2530; }
#cam button:active { transform: translateY(1px); }
#cam #zoomReset { font-size: 17px; }
#cam .camhint {
  font-size: 11px;
  font-weight: 700;
  color: #6d7684;
  background: #ffffffcc;
  border: 1px solid #e2ddd5;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- HUD */
#hud {
  position: fixed;
  top: 18px;
  left: 20px;
  pointer-events: none;
  user-select: none;
}
.skybtn {
  pointer-events: auto;
  display: block;
  margin-top: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #2f4bb5;
  background: #ffffffe6;
  border: 1px solid #cdd7f0;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(20, 26, 38, .12);
}
.skybtn:hover { background: #fff; border-color: #9fb2e8; }
.skybtn:active { transform: translateY(1px); }
#hud h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.5px;
  font-weight: 800;
  color: #1d2530;
  text-shadow: 0 2px 0 rgba(255,255,255,.7);
}
#hud .sub {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: #5d6675;
}
#hud .count {
  margin: 8px 0 0;
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  background: #ffffffcc;
  border: 1px solid #dcd7cf;
  border-radius: 999px;
  padding: 4px 12px;
  color: #3c4553;
}

/* ---------------------------------------------------------------- panel */
#panel {
  position: fixed;
  right: 24px;
  top: 24px;
  width: 300px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 18px 18px 20px;
  box-shadow: 0 18px 44px rgba(20, 26, 38, .22);
  transition: opacity .16s ease, transform .16s ease;
}
#panel.hidden {
  opacity: 0;
  transform: translateY(-8px) scale(.98);
  pointer-events: none;
}
#panel h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 800;
}
#close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: #97a0ad;
  cursor: pointer;
}
#close:hover { color: #444; }

.lbl {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8b94a2;
  margin: 14px 0 6px;
}

.pill {
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
  background: #eef3ff;
  color: #2f6df6;
  border-radius: 999px;
  padding: 3px 9px;
  margin-left: 4px;
}
.muted { color: #b3bac5; font-weight: 700; text-transform: none; letter-spacing: 0; }

/* scrollable catalog of unique buildings */
.catalog {
  max-height: 232px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 2px;
}
.bld {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 9px 9px;
  border: 2px solid #e6e2dc;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.bld:hover { border-color: #cfd6e2; }
.bld.sel { border-color: #2f6df6; background: #eef3ff; }
.bld .thumbwrap {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px dashed #e2ded7;
  margin-bottom: 3px;
}
/* little cream tower with blue glass bands, echoing the city render */
.bld .thumb {
  position: relative;
  background:
    repeating-linear-gradient(180deg,
      rgba(94,147,192,0) 0 2px,
      #7fb0d8 2px 5px,
      rgba(94,147,192,0) 5px 7px),
    linear-gradient(180deg, #f6efdf, #e6dabf);
  border-radius: 2px 2px 0 0;
  box-shadow: inset -4px 0 0 rgba(90,72,40,.14), 0 1px 0 rgba(0,0,0,.12);
  min-width: 8px;
  min-height: 6px;
}
.bld.sel .thumb {
  background:
    repeating-linear-gradient(180deg,
      rgba(47,109,246,0) 0 2px,
      #4f8cff 2px 5px,
      rgba(47,109,246,0) 5px 7px),
    linear-gradient(180deg, #ffffff, #e9eef8);
}
.bld .skythumb {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.18));
}
.bld .bn { font-size: 12px; font-weight: 700; line-height: 1.2; }
.bld .bp { font-size: 12px; font-weight: 800; color: #23a455; }
.bld .bt {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #a3abb8;
}
.catalog .empty { grid-column: 1 / -1; font-size: 13px; color: #8b94a2; padding: 8px 2px; }

.total {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #5d6675;
  background: #f6f5f2;
  border-radius: 10px;
  padding: 9px 11px;
}
.total b { color: #23282f; font-size: 15px; }

.colors { display: flex; flex-wrap: wrap; gap: 8px; }
.sw {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.sw.sel { border-color: #23282f; }

#name, #logo {
  width: 100%;
  font-size: 14px;
  padding: 9px 10px;
  border: 2px solid #e6e2dc;
  border-radius: 10px;
  background: #fafafa;
}
#logo { padding: 7px; font-size: 12px; }
#name:focus { outline: none; border-color: #2f6df6; }

.err { color: #d93b3b; font-size: 13px; font-weight: 600; min-height: 18px; margin: 8px 0 0; }

.buy {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #37c26a, #23a455);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1b8a46;
}
.buy:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b8a46; }
.buy[disabled] { opacity: .6; cursor: default; }

@media (max-width: 640px) {
  #panel { right: 12px; left: 12px; width: auto; }
  #hud h1 { font-size: 26px; }
}
