/* GL404 Casual Builder — style.css (Builder 1: core engine) */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #7ec8e3; /* air di sekeliling pulau */
  color: #2b1a08;
  font-size: 14px;
  /* Tinggi viewport PASTI (bukan min-height): tanpa ini flex container
    ikut membesar mengikuti map besar (tier 3-4) dan menu bar terdorong
    ke bawah fold. Scroll hanya di dalam #map-wrap & panel. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img { -webkit-user-drag: none; user-select: none; }

/* ---------- HUD atas (kecil, jangan menutupi map) ---------- */
#hud {
  background: rgba(255, 251, 235, 0.96);
  border-bottom: 2px solid #b45309;
  padding: 4px 6px 3px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.hud-row { display: flex; flex-wrap: wrap; gap: 3px 8px; align-items: center; }
.hud-res { overflow-x: auto; flex-wrap: nowrap; padding-top: 2px; scrollbar-width: none; }
.hud-res::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 1.4; white-space: nowrap;
  background: #fff; border: 1px solid #e7d8b8; border-radius: 10px;
  padding: 1px 6px;
}
.chip b { font-weight: 700; }
.chip.tier { background: #fef3c7; border-color: #d97706; }
.chip.tier img { width: 16px; height: 16px; object-fit: contain; }
.chip.boost { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.ic { width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; }
.welfare {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; cursor: pointer;
  background: #fff; border: 1px solid #e7d8b8; border-radius: 10px; padding: 1px 6px;
}
.wbar {
  display: inline-block; width: 56px; height: 8px;
  background: #e5e7eb; border-radius: 4px; overflow: hidden; vertical-align: middle;
}
.wbar i { display: block; height: 100%; background: #22c55e; }
.wbar i.mid { background: #f59e0b; }
.wbar i.bad { background: #ef4444; }

/* ---------- quest tracker ---------- */
#quest { padding: 4px 8px 0; }
.quest {
  display: inline-block;
  font-size: 12px; background: rgba(255, 251, 235, 0.95);
  border: 1px solid #d97706; border-left: 4px solid #d97706; border-radius: 6px;
  padding: 4px 8px; max-width: 100%;
}
.quest .q-reward { color: #92400e; }

/* ---------- map ---------- */
#map-wrap {
  flex: 1;
  min-height: 0; /* wajib: tanpa ini flex item tidak mau menyusut di bawah
    tinggi konten, map besar (tier 3-4) mendorong menu bar ke bawah fold */
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
#map {
  position: relative;
  flex: none;
  border: 3px solid #92400e;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  background: #4ade80;
  cursor: pointer;
}
.tile {
  position: absolute;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.tile.clearing { filter: grayscale(0.6) brightness(0.8); }
.bld { position: absolute; z-index: 2; }
.bld img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.bld.building img { opacity: 0.55; filter: sepia(0.4); }
.bld.ready { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35) drop-shadow(0 0 6px #facc15); } }
.bld.locked img { filter: grayscale(0.8) brightness(0.7); }
.bld .lvl {
  position: absolute; top: 1px; left: 1px;
  font-size: 9px; font-weight: 700; color: #fff;
  background: rgba(120, 53, 15, 0.85); border-radius: 6px; padding: 0 4px;
  pointer-events: none;
}
.bld .wker {
  position: absolute; bottom: 1px; right: 1px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9); border: 1px solid #d97706;
  overflow: hidden; pointer-events: none;
}
.bld .wker img { width: 100%; height: 100%; object-fit: cover; }
.bld .cd {
  position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; white-space: nowrap;
  background: rgba(0, 0, 0, 0.7); color: #fff; border-radius: 6px; padding: 0 4px;
  pointer-events: none;
}
.bld .prog {
  position: absolute; left: 6%; right: 6%; bottom: 10px; height: 4px;
  background: rgba(0, 0, 0, 0.35); border-radius: 2px; overflow: hidden; pointer-events: none;
}
.bld .prog i { display: block; height: 100%; background: #22c55e; }

/* ---------- menu bar modul (tombol dari economy/social/wallet via menu:add) ---------- */
#menu-bar {
  display: flex; gap: 4px; padding: 5px 6px;
  background: rgba(255, 251, 235, 0.97);
  border-top: 2px solid #b45309;
  overflow-x: auto; scrollbar-width: none;
  min-height: 0;
}
#menu-bar:empty { display: none; }
#menu-bar::-webkit-scrollbar { display: none; }
#menu-bar button {
  flex: 1 0 auto; min-width: 64px;
  font-size: 11px; font-weight: 700; color: #44403c;
  background: #fff; border: 1px solid #d6c9a8; border-radius: 8px;
  padding: 6px 8px; cursor: pointer; white-space: nowrap;
}
#menu-bar button:active { background: #fef3c7; }

/* ---------- nav bawah ---------- */
#bottomnav {
  display: flex; gap: 4px; padding: 6px;
  background: rgba(255, 251, 235, 0.97);
  border-top: 1px solid #e7d8b8;
  position: sticky; bottom: 0; z-index: 20;
  overflow-x: auto; scrollbar-width: none;
}
#bottomnav::-webkit-scrollbar { display: none; }
#bottomnav button {
  flex: 1 0 auto; min-width: 62px;
  font-size: 12px; font-weight: 700; color: #78350f;
  background: #fef3c7; border: 1px solid #d97706; border-radius: 8px;
  padding: 8px 6px; cursor: pointer;
}
#bottomnav button:active { background: #fde68a; }

/* ---------- panel (modal bawah) ---------- */
#panel-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45); z-index: 30;
}
#panel-overlay.show { display: block; }
#panels { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; pointer-events: none; }
.panel {
  display: none;
  pointer-events: auto;
  max-width: 640px; margin: 0 auto;
  max-height: 72vh; overflow-y: auto;
  background: #fffbeb; border: 2px solid #b45309; border-bottom: none;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
}
.panel.open { display: block; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid #e7d8b8;
  position: sticky; top: 0; background: #fffbeb; z-index: 1;
}
.panel-head b { font-size: 15px; }
.panel-head .x {
  background: none; border: none; font-size: 16px; cursor: pointer; color: #78350f;
}
.panel-body { padding: 10px 14px 18px; }
.panel-body h4 { margin: 12px 0 6px; color: #92400e; }
.panel-body p { margin: 6px 0; }
.hint { color: #6b7280; font-size: 12px; }
.warn { color: #b91c1c; }
.free { color: #15803d; }

/* kartu bangunan/bibit */
.card {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid #e7d8b8; border-radius: 8px; background: #fff;
  padding: 6px 8px; margin: 6px 0;
}
.card.dim { opacity: 0.55; }
.card img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.card-info { flex: 1; min-width: 0; }
.card-info .sz { color: #6b7280; font-size: 11px; }
.card-info .desc { font-size: 12px; color: #44403c; }
.card-info .cost { font-size: 12px; margin-top: 2px; }
.card-info .meta { font-size: 11px; color: #6b7280; }

.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.detail-head img { width: 72px; height: 72px; object-fit: contain; }
.detail-head b { font-size: 16px; }

.btn {
  font-size: 13px; font-weight: 700; color: #78350f;
  background: #fef3c7; border: 1px solid #d97706; border-radius: 8px;
  padding: 7px 12px; margin: 3px 2px; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: #f59e0b; color: #fff; border-color: #b45309; }
.btn.danger { background: #fee2e2; color: #b91c1c; border-color: #ef4444; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:active:not(:disabled) { filter: brightness(0.94); }

.prog.big { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.prog.big i { display: block; height: 100%; background: #22c55e; }

ul.checklist, ul.tasklist { list-style: none; padding: 0; margin: 6px 0; }
ul.checklist li, ul.tasklist li { padding: 3px 0; font-size: 13px; }
ul.checklist li.done { color: #15803d; }

.wrow { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.wrow span:first-child { min-width: 110px; }
.wrow small { width: 100%; color: #6b7280; font-size: 11px; }
.wrow .wbar { width: 120px; height: 10px; }

/* ---------- toast ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: min(92vw, 480px); pointer-events: none;
}
.toast {
  background: rgba(41, 26, 8, 0.92); color: #fffbeb;
  font-size: 13px; padding: 8px 14px; border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); text-align: center;
  transition: opacity 0.4s;
}
.toast.out { opacity: 0; }

/* ---------- responsif ---------- */
@media (min-width: 900px) {
  #map-wrap { padding: 16px; }
  .panel { border-radius: 14px; margin-bottom: 12px; border-bottom: 2px solid #b45309; }
}
@media (max-width: 480px) {
  .chip { font-size: 10px; padding: 1px 5px; }
  .card img { width: 44px; height: 44px; }
  .btn { padding: 6px 9px; font-size: 12px; }
}
