/* ============================================================
   GLOBAL STYLES
   Full-window canvas + floating, minimalist HUD panels.
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #141814; }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; user-select: none; }

canvas { display: block; cursor: grab; touch-action: none; }
canvas.dragging { cursor: grabbing; }

/* Shared floating panel look */
.panel {
  position: absolute;
  background: rgba(16, 20, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #e9e7db;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* --- Resource pools (top-left) --- */
#pools { top: 12px; left: 12px; min-width: 168px; }
.prow { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.prow .ico { font-size: 15px; width: 20px; text-align: center; }
.prow .n   { font-weight: 650; min-width: 38px; font-variant-numeric: tabular-nums; }
.prow .l   { opacity: 0.6; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; }

/* --- Villager roster (top-right) --- */
#vpanel { top: 12px; right: 12px; min-width: 210px; }
#vpanel h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  opacity: 0.6; margin-bottom: 6px; font-weight: 600;
}
.vrow { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.vdot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.vn   { font-weight: 650; width: 26px; }
.st   { flex: 1; opacity: 0.9; }
.c    { opacity: 0.55; font-size: 11px; font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }
.wait { opacity: 0.5; font-size: 12px; }

/* --- Day/time chip (top center) --- */
#clock {
  top: 12px; left: 50%; transform: translateX(-50%);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* --- Event bar (right of clock) --- */
#event-bar {
  top: 12px; left: calc(50% + 150px);
  white-space: nowrap; text-align: left;
  font-size: 12px; color: #f0d6a8;
}

/* --- Speed + pause control (below the clock) --- */
#speed {
  top: 56px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 4px;
}
.spd {
  pointer-events: auto; cursor: pointer;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e9e7db; border-radius: 6px; padding: 3px 0;
  min-width: 38px; text-align: center;
  font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.4;
}
.spd:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
#pause { min-width: 28px; }

/* --- Bottom hint bar --- */
#hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(16, 20, 16, 0.7); border: 1px solid rgba(255,255,255,0.07);
  color: #cfcdc0; border-radius: 8px; padding: 6px 14px;
  font-size: 11.5px; letter-spacing: 0.02em; pointer-events: none; white-space: nowrap;
}
#hint b { color: #fff; font-weight: 600; }

/* --- Building toolbar (bottom center, above the hint) --- */
#toolbar {
  position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(16, 20, 16, 0.8); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px; padding: 6px 10px;
}
#toolbar.hidden { display: none; }
.tbtn {
  display: flex; align-items: center; gap: 7px;
  background: #232a23; color: #e9e7db; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  font: inherit; font-size: 13px;
}
.tbtn:hover { background: #2c352c; }
.tbtn.sel { border-color: #8fce7a; box-shadow: 0 0 0 1px #8fce7a inset; background: #2a3a28; }
.tname { font-weight: 650; }
.tcost { opacity: 0.65; font-size: 11px; }
.tkbd { font-size: 10px; opacity: 0.5; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 0 4px; }
#t-stat { font-size: 11px; color: #cfcdc0; opacity: 0.85; white-space: nowrap; }

/* --- Help button & panel (bottom-right) --- */
#help-btn {
  position: absolute; bottom: 12px; right: 12px; z-index: 10;
  width: 30px; height: 30px; padding: 0;
  border-radius: 50%; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer;
  background: rgba(16, 20, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e9e7db;
  backdrop-filter: blur(4px);
}
#help-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }
#help-panel {
  position: absolute; bottom: 50px; right: 12px; z-index: 10;
  padding: 12px 14px; min-width: 220px;
  font-size: 12px; line-height: 1.6;
  pointer-events: none;
  background: rgba(16, 20, 16, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: #e9e7db;
  backdrop-filter: blur(4px);
}
#help-panel table { border-collapse: collapse; }
#help-panel td { padding: 2px 12px 2px 0; white-space: nowrap; }
#help-panel td:last-child { opacity: 0.7; }
#help-panel.hidden { display: none; }

/* --- Building popup --- */
#bldg-popup {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  background: rgba(15,20,30,0.92); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 12px 16px; color: #eee;
  font-size: 13px; min-width: 160px; pointer-events: auto;
}
#bldg-popup.hidden { display: none; }
#bldg-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: #ffd; }
#bldg-body .brow { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
#bldg-body .brow .val { color: #adf; }
#bldg-body .brow .val.full { color: #f96; }
#bldg-del { margin-top: 10px; width: 100%; padding: 5px 0; background: rgba(200,60,60,0.25); border: 1px solid rgba(200,60,60,0.6); border-radius: 4px; color: #f99; font-size: 12px; cursor: pointer; }
#bldg-del:hover { background: rgba(200,60,60,0.45); color: #fff; }
#bldg-del.hidden { display: none; }

/* --- Minimap (bottom-left) --- */
#minimap {
  position: absolute; bottom: 44px; left: 12px;
  width: 360px; height: 240px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: #1a2e1a;
  cursor: crosshair;
  image-rendering: pixelated;
}

/* --- Town Center placement banner --- */
#banner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding-top: 14vh;
  pointer-events: none; transition: opacity 0.3s;
}
#banner.hidden { opacity: 0; }
#banner .big {
  color: #f2efe2; font-size: 26px; font-weight: 650; letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}
#banner .sub {
  margin-top: 6px; color: #c9c7ba; font-size: 13px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}
