/* ============================================================
   BLOCKBURG — in-game HUD (clean civic dashboard)
   ============================================================ */

:root {
  --card: #ffffff;
  --ink: #24333e;
  --ink-soft: #5a6b77;
  --sky: #3d9bd9;
  --sky-deep: #2b7fb8;
  --park: #62b74f;
  --park-deep: #4e9a3d;
  --sun: #f4a53d;
  --sun-deep: #dd8a1e;
  --danger: #e05656;
  --danger-deep: #bd3d3d;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(36, 51, 62, 0.16);
  --shadow-soft: 0 4px 14px rgba(36, 51, 62, 0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* the hidden attribute must always win over display rules below */
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #a9dcf5;
  touch-action: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.wordmark { font-weight: 900; letter-spacing: 0.5px; color: var(--ink); }
.wm-accent { color: var(--sky); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
  border-radius: 999px;
  transition: transform 0.12s ease, background 0.12s ease;
  font-size: 14px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sky); color: #fff; box-shadow: 0 4px 0 var(--sky-deep); }
.btn-ghost { background: #eef4f8; color: var(--ink); box-shadow: inset 0 0 0 2px #d7e3ec; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 0 var(--danger-deep); }
.btn-sm { padding: 8px 16px; }
.btn-block { width: 100%; padding: 13px 0; font-size: 16px; }

.icon-btn {
  border: none;
  background: #eef4f8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink-soft);
  flex: none;
}
.icon-btn:hover { background: #e2edf5; }
.icon-btn-sm { width: 26px; height: 26px; font-size: 12px; margin-left: 2px; }

/* ---------- overlays (night-city brand) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(76, 224, 135, 0.16), transparent 60%),
    radial-gradient(800px 400px at 10% 110%, rgba(255, 180, 84, 0.10), transparent 60%),
    linear-gradient(180deg, #0a111f 0%, #0d1526 55%, #101a30 100%);
  padding: 18px;
}

.loading-card { text-align: center; }
.loading-logo { font-size: 46px; color: #fff; }
.loading-logo .wm-accent { color: #4ce087; }
.loading-bar {
  width: 240px;
  height: 12px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  margin: 18px auto 10px;
  overflow: hidden;
}
#loading-fill {
  height: 100%;
  width: 15%;
  background: #4ce087;
  border-radius: 999px;
  transition: width 0.25s ease;
}
#loading-text { font-weight: 700; color: #9fb0c8; font-size: 14px; }

/* ---------- auth (dark card) ---------- */
.auth-card {
  background: #131d33;
  border: 1px solid rgba(120, 170, 255, 0.14);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 34px 30px 26px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  color: #eaf2ff;
}
.auth-icon { width: 84px; height: 84px; margin-bottom: 4px; }
.auth-logo { font-size: 38px; color: #fff; }
.auth-logo .wm-accent { color: #4ce087; }
.auth-tag { color: #4ce087; font-weight: 800; font-size: 14px; margin: 4px 0 22px; }

.btn-phantom {
  background: linear-gradient(135deg, #8a7bff 0%, #6c5ce7 100%);
  color: #fff;
  box-shadow: 0 6px 0 #4b3fbe, 0 10px 26px rgba(108, 92, 231, 0.35);
  font-size: 16px;
}
.btn-phantom:hover { filter: brightness(1.08); }
.btn-phantom:active { box-shadow: 0 2px 0 #4b3fbe; }
.btn-phantom:disabled { opacity: 0.6; cursor: wait; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  color: #5c6c85;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(120, 170, 255, 0.18);
}
#btn-demo { margin-top: 12px; background: rgba(255,255,255,0.06); color: #cdd9ec; box-shadow: inset 0 0 0 2px rgba(120,170,255,0.22); }
#btn-demo:hover { background: rgba(255,255,255,0.1); }

.fld { display: block; text-align: left; margin-bottom: 14px; }
.fld span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8fa2bd;
  margin-bottom: 6px;
}
.fld input {
  width: 100%;
  border: 2px solid rgba(120, 170, 255, 0.22);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #eaf2ff;
  outline: none;
  background: rgba(10, 18, 34, 0.7);
}
.fld input:focus { border-color: #4ce087; }

.auth-error {
  margin-top: 12px;
  background: rgba(224, 86, 86, 0.16);
  color: #ff9b9b;
  font-weight: 700;
  font-size: 13.5px;
  border-radius: 12px;
  padding: 10px 12px;
}
.offline-note {
  margin-top: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: #ffd591;
  background: rgba(255, 180, 84, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
}
.offline-note a { color: #4ce087; }
.auth-back {
  display: inline-block;
  margin-top: 16px;
  color: #8fa2bd;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}
.auth-back:hover { color: #4ce087; }

/* ---------- mayor creator ---------- */
.creator-card { max-width: 440px; }
.creator-card .panel-title { font-size: 20px; color: #fff; margin-bottom: 8px; }
.creator-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#creator-canvas {
  width: 220px;
  height: 260px;
  border-radius: 18px;
  background:
    radial-gradient(180px 120px at 50% 100%, rgba(76, 224, 135, 0.18), transparent 70%),
    linear-gradient(180deg, #0d1729 0%, #16233d 100%);
  border: 1px solid rgba(120, 170, 255, 0.16);
}
.creator-arrow {
  width: 44px;
  height: 44px;
  font-size: 17px;
  background: rgba(255,255,255,0.08);
  color: #eaf2ff;
}
.creator-arrow:hover { background: rgba(76, 224, 135, 0.25); }
.creator-skin-label {
  margin: 10px 0 14px;
  font-weight: 700;
  color: #8fa2bd;
  font-size: 13px;
}
.creator-skin-label b { color: #4ce087; }

/* ---------- HUD top ---------- */
.hud-top {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.hud-city {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  padding: 6px 16px 6px 8px;
  box-shadow: var(--shadow-soft);
}
.hud-rank { width: 34px; height: 34px; }
.hud-cityname { font-weight: 900; font-size: 15px; line-height: 1.15; }
.hud-level { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }

.hud-res { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 13.5px;
  box-shadow: var(--shadow-soft);
}
.chip-ico { font-size: 15px; }
.chip-img { width: 19px; height: 19px; object-fit: contain; }
.chip-mode { background: #fdf6e3; color: #8a6d1f; }

/* Kenney-rendered icons */
.dock-img { width: 30px; height: 30px; object-fit: contain; }
.build-tab img { width: 34px; height: 34px; object-fit: contain; }
.bi-img { width: 38px; height: 38px; object-fit: contain; flex: none; }
.mini-ico { width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; }
.tp-ico { width: 24px; height: 24px; object-fit: contain; vertical-align: -6px; margin-right: 4px; }

.hud-right { display: flex; align-items: center; gap: 8px; }

.xp-bar {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 7px;
  background: rgba(255,255,255,0.65);
  border-radius: 999px;
  z-index: 40;
  overflow: hidden;
}
#xp-fill {
  height: 100%;
  width: 0%;
  background: var(--park);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- dock ---------- */
.dock {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 8px;
  background: rgba(255,255,255,0.94);
  padding: 8px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 16px);
  overflow-x: auto;
}
.dock-btn {
  border: none;
  background: transparent;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.dock-btn span { font-size: 21px; }
.dock-btn:hover { background: #eef4f8; color: var(--ink); }
.dock-btn.active { background: #e3f2fc; color: var(--sky-deep); }

/* ---------- placement hint ---------- */
.place-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.96);
  border-radius: 999px;
  padding: 10px 12px 10px 20px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow);
}

/* ---------- panels ---------- */
.panel {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  width: min(560px, calc(100vw - 20px));
  max-height: min(58vh, 480px);
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-sm { width: min(360px, calc(100vw - 20px)); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.panel-title { font-weight: 900; font-size: 16px; }

/* build panel */
.build-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
}
.build-tab {
  flex: 1;
  border: none;
  background: #eef4f8;
  border-radius: 12px;
  font-size: 20px;
  padding: 8px 0;
  cursor: pointer;
}
.build-tab.active { background: #e3f2fc; box-shadow: inset 0 0 0 2px var(--sky); }

.build-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 4px 16px 16px;
}
.b-item {
  border: 2px solid #e3ecf2;
  background: #fbfdfe;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
}
.b-item:hover { border-color: var(--sky); }
.b-item.locked { opacity: 0.55; cursor: not-allowed; }
.b-item .bi-top { display: flex; align-items: center; gap: 8px; }
.b-item .bi-ico { font-size: 24px; }
.b-item .bi-name { font-weight: 800; font-size: 13.5px; line-height: 1.1; }
.b-item .bi-info { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; margin-top: 5px; }
.b-item .bi-cost { font-size: 12px; font-weight: 800; margin-top: 4px; }
.b-item .bi-lock { font-size: 11px; color: #b03030; font-weight: 800; margin-top: 3px; }

/* tile popup */
.tp-body { padding: 0 16px 16px; }
.tp-stats { font-size: 13.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.7; }
.tp-stats b { color: var(--ink); }
.tp-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* world panel */
.world-tabs { display: flex; gap: 6px; padding: 0 16px 10px; }
.world-tab {
  flex: 1;
  border: none;
  background: #eef4f8;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  padding: 9px 0;
  cursor: pointer;
  color: var(--ink-soft);
}
.world-tab.active { background: #e3f2fc; color: var(--sky-deep); box-shadow: inset 0 0 0 2px var(--sky); }
.world-body { overflow-y: auto; padding: 4px 16px 16px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.lb-row:hover { background: #f2f7fb; }
.lb-row.me { background: #e9f6e4; }
.lb-pos { font-weight: 900; width: 26px; text-align: center; color: var(--ink-soft); }
.lb-name { flex: 1; min-width: 0; }
.lb-name .n1 { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name .n2 { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
.lb-val { font-weight: 800; font-size: 13px; color: var(--sky-deep); }
.lb-visit { font-size: 12px; }

/* chat */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 160px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 2px;
}
.chat-msg { font-size: 13.5px; line-height: 1.45; }
.chat-msg b { color: var(--sky-deep); }
.chat-msg.mine b { color: var(--park-deep); }
.chat-form { display: flex; gap: 8px; padding-top: 10px; }
.chat-form input {
  flex: 1;
  border: 2px solid #d7e3ec;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
}
.chat-form input:focus { border-color: var(--sky); }

/* NPC chat */
.npc-log {
  padding: 0 16px;
  max-height: 220px;
  min-height: 120px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.npc-msg { background: #f2f7fb; border-radius: 12px; padding: 8px 12px; align-self: flex-start; max-width: 85%; }
.npc-msg.mine { background: #e9f6e4; align-self: flex-end; }
#npc-panel .chat-form { padding: 10px 16px 8px; }
.npc-quota { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); text-align: center; padding-bottom: 12px; }

/* visit banner */
.visit-banner {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 999px;
  padding: 8px 10px 8px 18px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 14px;
  max-width: calc(100vw - 20px);
}

/* mayor hint */
.mayor-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: var(--shadow-soft);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mayor-hint img { width: 26px; height: 26px; }

/* joystick (mobile mayor mode) */
#joystick {
  position: fixed;
  left: 22px;
  bottom: 90px;
  width: 120px;
  height: 120px;
  z-index: 46;
  opacity: 0.85;
  touch-action: none;
}
#joy-pad { width: 120px; height: 120px; }
#joy-nub {
  position: absolute;
  left: 40px;
  top: 40px;
  width: 40px;
  height: 40px;
  pointer-events: none;
}

/* toasts */
#toasts {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(36, 51, 62, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 22px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.6s forwards;
  max-width: calc(100vw - 30px);
  text-align: center;
}
.toast.good { background: rgba(78, 154, 61, 0.95); }
.toast.bad { background: rgba(189, 61, 61, 0.95); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-8px); opacity: 0; } }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .hud-top { flex-wrap: wrap; }
  .hud-res { order: 3; width: 100%; }
  .chip { padding: 6px 11px; font-size: 12.5px; }
  .xp-bar { top: 108px; width: 150px; }
  .dock-btn { padding: 7px 10px; font-size: 11px; }
  .dock-btn span { font-size: 19px; }
  .panel { bottom: 84px; max-height: 52vh; }
  .build-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
