/* Kerajaan Kaisar — GAME fullscreen: canvas 100vw x 100vh, HUD ramping di atasnya. */
:root {
  --gold: #d4af37;
  --gold-dim: #a8871f;
  --gold-soft: #f0d878;
  --maroon: #3d0c11;
  --maroon-2: #571420;
  --bg: #14090b;
  --panel: rgba(36, 16, 22, 0.96);
  --panel-2: #2e151b;
  --ink: #f3e9d2;
  --ink-dim: #cbb98f;
  --line: #4a2a30;
  --green: #7fc96b;
  --red: #e06c5a;
  --blue: #6db3e8;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0a2036;
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
.hidden { display: none !important; }

#game {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  display: block; touch-action: none; cursor: grab;
}
#game.dragging { cursor: grabbing; }
#game.hovering { cursor: pointer; }
/* Canvas kota 3D: menutupi canvas 2D saat mode 3D, di bawah HUD (z 10). */
#game3d {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  display: block; touch-action: none; cursor: grab; z-index: 1;
  background: #87b5d6;
}

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud button, .hud .overlay-panel, .hud .citizen-card { pointer-events: auto; }

/* ---------- tombol ikon ---------- */
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: rgba(20, 9, 11, 0.85); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--gold); color: #241203; }
.icon-btn.sm { width: 36px; height: 36px; font-size: 17px; }
.icon-btn.sm svg { width: 18px; height: 18px; }

/* ---------- HUD nusantara ---------- */
.brand-mini {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(20, 9, 11, 0.72); border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 999px; padding: 7px 16px 7px 9px;
  backdrop-filter: blur(4px);
}
.brand-mini .crown { width: 34px; height: 26px; flex: none; }
.brand-mini b { display: block; color: var(--gold); letter-spacing: 2px; font-size: 15px; line-height: 1.1; }
.brand-mini span { display: block; color: var(--ink-dim); font-size: 11px; line-height: 1.2; }
.mini-stats {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(20, 9, 11, 0.72); border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
  backdrop-filter: blur(4px); white-space: nowrap;
}
.mini-stats b { color: var(--gold-soft); }
.hint-chip {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55); color: #ffe9a8;
  padding: 6px 16px; border-radius: 999px; font-size: 13px;
  border: 1px solid rgba(212, 175, 55, 0.3); white-space: nowrap;
  animation: hintFloat 2.6s ease-in-out infinite;
}
@keyframes hintFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }
.hover-tip {
  position: absolute; z-index: 12; pointer-events: none;
  background: rgba(20, 9, 11, 0.94); border: 1px solid var(--gold-dim);
  border-radius: 10px; padding: 7px 12px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); white-space: nowrap;
}
.hover-tip b { color: var(--gold-soft); display: block; font-size: 14px; }
.hover-tip span { color: var(--ink-dim); }

/* ---------- HUD pulau ---------- */
#hud-island #btnBackMap { position: absolute; top: 14px; left: 14px; }
.island-tag {
  position: absolute; top: 16px; left: 70px;
  background: rgba(20, 9, 11, 0.72); border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 999px; padding: 7px 16px;
  backdrop-filter: blur(4px);
}
.island-tag b { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
.island-tag span { color: var(--ink-dim); font-size: 12px; margin-left: 8px; }

/* ---------- HUD kota ---------- */
.city-top {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; align-items: center; gap: 10px;
}
#hud-city #btnBackIsland { flex: none; }
.city-name {
  background: rgba(20, 9, 11, 0.72); border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 999px; padding: 6px 14px; backdrop-filter: blur(4px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.city-name b { color: var(--gold); font-size: 15px; }
.city-name span { color: var(--ink-dim); font-size: 12px; margin-left: 7px; }
.game-clock {
  margin-left: auto; background: rgba(20, 9, 11, 0.72);
  border: 1px solid rgba(212, 175, 55, 0.4); border-radius: 999px;
  padding: 6px 14px; font-weight: 700; font-size: 13px; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.game-clock #gamePhase { color: var(--gold-soft); }

.stat-pills {
  position: absolute; top: 64px; left: 10px; right: 10px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.pill {
  background: rgba(20, 9, 11, 0.72); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: var(--ink);
  backdrop-filter: blur(4px);
}
.pill:hover { border-color: var(--gold); }
.pill b { color: var(--gold-soft); }

.canvas-tools {
  position: absolute; top: 112px; right: 10px;
  display: flex; flex-direction: column; gap: 6px; z-index: 5;
}
.canvas-tools button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--gold-dim);
  background: rgba(20, 9, 11, 0.85); color: var(--gold); font-size: 18px; font-weight: 700;
}
.canvas-tools button.on { background: var(--gold); color: #241203; }
.canvas-tools #btnShot { font-size: 11px; }
.canvas-tools #btnView3D { font-size: 13px; }
/* Layar sentuh: zoom pakai cubit dua jari, bukan tombol + / −. */
@media (pointer: coarse) {
  #btnZoomIn, #btnZoomOut { display: none; }
}

/* dock bawah: tombol bulat berikon */
.dock {
  position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px 9px;
  background: rgba(61, 12, 17, 0.88); border: 1px solid var(--gold-dim);
  border-radius: 999px; backdrop-filter: blur(6px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock button {
  flex: none; width: 56px; min-height: 56px; background: transparent; border: none;
  color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 14px; font-size: 10px; padding: 4px 2px;
}
.dock button svg { width: 22px; height: 22px; fill: var(--gold); }
.dock button:hover, .dock button.on { background: rgba(212, 175, 55, 0.18); color: var(--gold-soft); }

/* Dock kota: 20 tombol dalam 2 baris (ronde 2 ide 7) — #bottomNav membungkus (flex-wrap), semua tombol terlihat tanpa scroll. */
#bottomNav {
  flex-wrap: wrap; justify-content: center; row-gap: 6px;
  width: max-content; max-width: 660px;
  overflow: visible; border-radius: 22px;
}
#bottomNav button { width: 56px; }
/* Dock kini 35 tombol: 660px membungkusnya jadi 4 baris (~260px) yang menutupi
   tengah kota di desktop. Lebarkan supaya tetap 2 baris (18 + 17). */
@media (min-width: 861px) {
  #bottomNav { max-width: min(1080px, calc(100vw - 220px)); column-gap: 2px; }
}
/* Di bawah ~1300px dock masih 3 baris (~200px): naikkan feed Kabar supaya bersih. */
@media (min-width: 861px) and (max-width: 1299px) {
  #hud-city .notif-feed { bottom: 220px; }
}

/* notifikasi */
.notif-feed {
  position: absolute; left: 10px; bottom: 184px; z-index: 9;
  display: flex; flex-direction: column; gap: 6px; max-width: 300px;
  pointer-events: none;
}
.notif-feed .notif {
  background: rgba(20, 9, 11, 0.9); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); border-radius: 8px;
  padding: 7px 10px; font-size: 12.5px; animation: fadeIn 0.3s ease;
}
#btnNotifToggle {
  position: absolute; left: 10px; bottom: 140px; z-index: 9;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* kartu warga */
.citizen-card {
  position: absolute; z-index: 14; right: 10px; bottom: 140px;
  width: 300px; max-width: calc(100vw - 20px);
  background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.citizen-card h3 { color: var(--gold); }
.citizen-card .role-line { color: var(--ink-dim); font-size: 13px; margin: 2px 0 8px; }
.citizen-card .kv { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; }
.citizen-card .kv span:last-child { color: var(--gold-soft); }
.citizen-card .close-x {
  position: absolute; top: 6px; right: 10px; background: none; border: none;
  color: var(--ink-dim); font-size: 20px; line-height: 1;
}
.citizen-card p.muted { color: var(--ink-dim); font-size: 13px; }
.citizen-card .sched { margin-top: 10px; font-size: 13px; }
.citizen-card .sched summary { cursor: pointer; color: var(--gold-soft); }
.citizen-card .sched table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.citizen-card .sched td { padding: 2px 0; vertical-align: top; }
.citizen-card .sched td:first-child { color: var(--ink-dim); white-space: nowrap; padding-right: 8px; }
.citizen-card .btn.block { margin-top: 10px; }

/* chip mode ikuti warga */
.follow-chip {
  position: absolute; z-index: 14; left: 50%; transform: translateX(-50%);
  bottom: 148px; background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: 20px; padding: 8px 14px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); white-space: nowrap;
}
.follow-chip button {
  margin-left: 8px; background: none; border: 1px solid var(--gold-dim);
  color: var(--gold-soft); border-radius: 12px; padding: 2px 8px; cursor: pointer;
}

/* panel overlay */
.overlay-panel {
  position: absolute; top: 64px; right: 10px; bottom: 140px; z-index: 13;
  width: 360px; max-width: calc(100vw - 20px);
  background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); display: flex; flex-direction: column;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.22s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { color: var(--gold); font-size: 16px; }
.panel-body { padding: 12px 14px; overflow-y: auto; }
.panel-body h4 { margin: 14px 0 6px; color: var(--gold-soft); font-size: 14px; }
.panel-body h4:first-child { margin-top: 0; }
.panel-body p { margin: 6px 0; font-size: 14px; }
.panel-body .muted { color: var(--ink-dim); font-size: 13px; }
/* Baris label-nilai di isi panel (.kv): dulu tanpa aturan flex sehingga
   label dan nilai berdempetan ("HewanmuAnjing — Bobi", "SaldoRp10.000").
   Samakan dengan .citizen-card .kv. */
.panel-body .kv { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 2px 0; }
.panel-body .kv span:last-child { color: var(--gold-soft); text-align: right; }
/* Tabel label-nilai di isi panel: batasi ke lebar panel supaya tidak
   meluber (panel Pertanian: tabel 5 kolom lebih lebar dari panel). */
.panel-body table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel-body table.kv th, .panel-body table.kv td { padding: 4px 3px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.panel-body table.kv th { color: var(--gold-soft); }

.list-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--panel-2); }
.list-row .avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--maroon-2);
  color: var(--gold-soft); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.list-row .who { flex: 1; min-width: 0; }
.list-row .who b { display: block; font-size: 14px; }
.list-row .who span { font-size: 12px; color: var(--ink-dim); }
.badge {
  flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.badge.gold { color: var(--gold-soft); border-color: var(--gold-dim); }
.badge.green { color: var(--green); }
.badge.red { color: var(--red); }

.bar { height: 8px; background: #12060a; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.bar.green > i { background: var(--green); }
.bar.red > i { background: var(--red); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 5px 11px; font-size: 13px;
}
.chip.on { background: var(--gold); color: #241203; border-color: var(--gold); font-weight: 700; }

.btn {
  background: var(--gold); color: #241203; border: none; border-radius: 8px;
  padding: 9px 16px; font-weight: 700;
}
.btn:hover { background: var(--gold-soft); }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold-dim); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.5; cursor: wait; }

.field { margin: 10px 0; }
.field label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; background: #12060a; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px;
}
.field textarea { resize: vertical; min-height: 64px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.role-grid .chip { text-align: center; }
.vote-btn { flex: none; }
.vote-count { font-weight: 800; color: var(--gold-soft); }

/* ---------- panel Fasilitas / Donatur / Pemerintahan (S7, S8, S9) ---------- */
.fac-row .who .bar { margin-top: 6px; }
.fac-row .badge { align-self: center; }
.saweria-btn {
  display: block; text-align: center; text-decoration: none;
  margin-top: 10px; padding: 12px 16px; font-size: 15px;
}
.verify-btn { align-self: center; margin-left: 6px; }
.apply-btn { align-self: center; }
.list-row .badge + .btn { margin-left: 4px; }

/* overlay transisi */
#transitionOverlay {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at center, rgba(61, 12, 17, 0.55), rgba(10, 4, 6, 0.88));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  pointer-events: none;
}
#transitionOverlay .crown.big { width: 72px; height: 54px; animation: crownPulse 1.1s ease-in-out infinite; }
@keyframes crownPulse { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.12); opacity: 1; } }
#transText {
  color: var(--gold-soft); font-size: 22px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 2px 12px #000; text-align: center; padding: 0 20px;
}

.toast {
  position: fixed; left: 50%; bottom: 148px; transform: translateX(-50%);
  background: var(--gold); color: #241203; font-weight: 700; padding: 10px 18px;
  border-radius: 999px; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- Kronik & Replay (fitur 8) ---------- */
#chroniclePanel { position: fixed; } /* di luar HUD: tampil di semua scene */
.chron-nav { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.chron-nav button { border: 1px solid var(--gold-dim); background: var(--panel-2);
  color: var(--gold); border-radius: 8px; padding: 6px 10px; font-size: 14px;
  font-weight: 700; cursor: pointer; }
.chron-nav button:hover { background: var(--gold); color: #241203; }
.chron-nav input { width: 72px; padding: 6px 8px; border: 1px solid var(--gold-dim);
  border-radius: 8px; background: var(--panel-2); color: var(--ink);
  font-size: 14px; text-align: center; }
.chron-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.chron-stat { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  background: var(--panel-2); }
.chron-stat span { display: block; font-size: 11.5px; color: var(--ink-dim); }
.chron-stat b { font-size: 14px; }
.chron-filters { display: flex; gap: 6px; margin: 10px 0; }
.chron-filters select { flex: 1; min-width: 0; padding: 7px 8px;
  border: 1px solid var(--gold-dim); border-radius: 8px;
  background: var(--panel-2); color: var(--ink); font-size: 13px; }
.chron-replay { display: flex; gap: 6px; align-items: center; margin: 10px 0; }
.chron-replay button { border: 1px solid var(--gold-dim); background: var(--panel-2);
  color: var(--gold); border-radius: 8px; padding: 7px 12px; font-size: 13px;
  font-weight: 700; cursor: pointer; }
.chron-replay button:hover { background: var(--gold); color: #241203; }

/* ---------- responsif HP ---------- */
@media (max-width: 860px) {
  .brand-mini span { display: none; }
  .brand-mini b { font-size: 13px; }
  /* Audit-E E1: mini-stats 96px, hint 140px (di atas mini-stats; dulu sama sehingga hint tertutup). */
  .mini-stats { font-size: 11.5px; padding: 5px 10px; bottom: 96px; left: 10px; }
  .hint-chip { font-size: 12px; bottom: 140px; }
  .island-tag span { display: none; }
  .stat-pills { top: 58px; }
  .canvas-tools { top: 104px; }
  .canvas-tools button { width: 44px; height: 44px; }
  .dock button { width: 52px; min-height: 52px; }
  /* #bottomNav di HP dibatasi ke lebar layar (max-content supaya membungkus 7 per baris). */
  #bottomNav { max-width: calc(100vw - 16px); }
  #bottomNav button { width: 40px; min-height: 46px; font-size: 9px; padding: 3px 1px; }
  #bottomNav button svg { width: 18px; height: 18px; }
  .dock { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .notif-feed { bottom: 220px; max-width: calc(100vw - 20px); left: 10px; }
  #btnNotifToggle { bottom: 176px; }
  .citizen-card { right: 10px; left: 10px; bottom: 176px; width: auto; }
  .overlay-panel { top: 58px; right: 8px; bottom: 176px; width: calc(100vw - 16px); }
  /* Panel selebar layar (≤860px) menutupi tombol audio di kiri — sembunyikan
     selama panel/kartu terbuka (kelas body.kk-panel-open dari sim-mobile.js).
     Di desktop (>860px) panel hanya 360px di kanan, audio tetap tampil. */
  body.kk-panel-open #audioBtns { display: none; }
  #btnInteraksiQuest { bottom: 182px; }
  .follow-chip { bottom: 178px; }
  .toast { bottom: 178px; }
  #transText { font-size: 18px; }
  .game-clock { font-size: 12px; padding: 6px 10px; }
  .city-name b { font-size: 13px; }
}

/* OPSI A — MODE MOBILE RINGKAS (≤480px) + perbaikan panel: kartu scroll, tutup sticky, FAB, sheet, layar penuh. */
/* --- kartu warga bisa di-scroll + tombol tutup sticky (semua ukuran) --- */
.citizen-card {
  max-height: calc(100dvh - 230px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.citizen-card .close-x {
  position: sticky; top: 0; right: auto; float: right; z-index: 2;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(36, 16, 22, 0.94); border: 1px solid var(--gold-dim);
  border-radius: 50%; color: var(--gold-soft); font-size: 20px;
}
/* Panel overlay sudah bisa di-scroll; kepala panel (tombol tutup) selalu terlihat. */
.overlay-panel .panel-head { position: sticky; top: 0; z-index: 2; background: var(--panel); }

/* --- FAB menu + tombol alat + tombol stat (dibuat sim-mobile.js) --- */
#kkMenuFab, #kkToolsBtn, #kkStatsToggle, #kkMenuSheet, #kkToolsSheet,
#kkSheetBackdrop, #kkHudRestore { display: none; }
#kkMenuFab {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; border-radius: 50%; z-index: 40;
  border: 1px solid var(--gold-dim); background: var(--maroon);
  color: var(--gold); font-size: 24px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  align-items: center; justify-content: center;
}
#kkToolsBtn {
  position: fixed; right: 10px; top: 104px; width: 44px; height: 44px;
  border-radius: 50%; z-index: 40;
  border: 1px solid var(--gold-dim); background: rgba(20, 9, 11, 0.85);
  color: var(--gold); font-size: 22px; font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  align-items: center; justify-content: center;
}
#kkStatsToggle {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--gold-dim); background: rgba(20, 9, 11, 0.85);
  color: var(--gold-soft); font-size: 16px; font-weight: 800;
  align-items: center; justify-content: center; padding: 0;
}
#kkSheetBackdrop {
  position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.55);
}
.kk-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 66;
  background: var(--panel); border-top: 1px solid var(--gold-dim);
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
  max-height: 72vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.kk-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px; flex: none;
}
.kk-sheet-head h3 { color: var(--gold); font-size: 16px; }
.kk-sheet-head .kk-sheet-close {
  background: none; border: 1px solid var(--gold-dim); color: var(--gold-soft);
  border-radius: 50%; width: 30px; height: 30px; font-size: 18px; line-height: 1;
}
.kk-sheet-body { overflow-y: auto; padding: 4px 12px 14px; }
#kkMenuGrid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
#kkMenuGrid button {
  background: transparent; border: 1px solid transparent; border-radius: 12px;
  color: var(--ink); display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 9px 2px 7px; font-size: 10.5px;
}
#kkMenuGrid button svg { width: 22px; height: 22px; fill: var(--gold); }
#kkMenuGrid button:active, #kkMenuGrid button.on { background: rgba(212, 175, 55, 0.18); color: var(--gold-soft); }
.kk-tool-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  color: var(--ink); padding: 13px 6px; font-size: 14.5px; text-align: left;
}
.kk-tool-row:last-child { border-bottom: none; }
.kk-tool-row .kk-tool-ic { flex: none; width: 26px; text-align: center; font-size: 18px; color: var(--gold); }
.kk-tool-row .kk-tool-st { margin-left: auto; color: var(--gold-soft); font-size: 13px; font-weight: 700; }
/* --- tombol pulihkan HUD (mode layar penuh) --- */
#kkHudRestore {
  position: fixed; right: 12px; top: 12px; z-index: 100;
  border: 1px solid var(--gold-dim); background: rgba(20, 9, 11, 0.85);
  color: var(--gold); border-radius: 999px; padding: 8px 14px; font-size: 13px;
  font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
/* --- mode layar penuh: sembunyikan semua HUD --- */
body.kk-hud-hidden .hud,
body.kk-hud-hidden #audioBtns,
body.kk-hud-hidden #kkCamDock,
body.kk-hud-hidden #transport3dLayer,
body.kk-hud-hidden #kkMenuFab,
body.kk-hud-hidden #kkToolsBtn,
body.kk-hud-hidden #kkMenuSheet,
body.kk-hud-hidden #kkToolsSheet,
body.kk-hud-hidden #kkSheetBackdrop,
body.kk-hud-hidden .toast,
body.kk-hud-hidden #chroniclePanel { display: none !important; }
body.kk-hud-hidden #kkHudRestore { display: block; }
/* Panel/kartu terbuka (semua ukuran): sembunyikan kolom alat kanan —
   panel menutupinya (tombol tampak samar di balik panel & tidak bisa
   diklik). Pola yang sama sudah dipakai di HP (≤480px) untuk
   FAB/alat/chip/pill; kelas body.kk-panel-open dipasang sim-mobile.js. */
body.kk-panel-open #hud-city .canvas-tools { display: none; }

/* --- aturan khusus HP (≤480px, atau HP landscape: layar sentuh pendek) ---
   Landscape dulu memakai dock 35 tombol 2 baris + kolom alat + dock kamera
   (dock kamera bahkan di luar layar) di tinggi ~400px; mode ringkas jauh lebih
   lega. Kueri sama dengan kkIsMobile() di sim-mobile.js. */
@media (max-width: 480px), (max-height: 500px) and (pointer: coarse) {
  /* Dock 20 tombol disembunyikan; diganti FAB menu. */
  #bottomNav { display: none !important; }
  /* Audit-E E2: FAB + tombol alat HANYA di scene kota (body.kk-scene-city
     dari setHUD); sheet ikut disembunyikan di luar kota. */
  body.kk-scene-city #kkMenuFab, body.kk-scene-city #kkToolsBtn { display: flex; }
  body:not(.kk-scene-city) #kkMenuSheet,
  body:not(.kk-scene-city) #kkToolsSheet,
  body:not(.kk-scene-city) #kkSheetBackdrop { display: none !important; }
  #kkStatsToggle { display: flex; }
  /* Stat: sembunyikan pill, tampilkan bila tombol ⓘ diketuk. */
  .stat-pills { display: none; }
  #hud-city.kk-stats-open .stat-pills {
    display: flex; top: 58px; max-height: 34vh; overflow-y: auto;
  }
  /* Stat terbuka: geser tombol alat ke bawah supaya tidak menutupi pill
     baris kedua (pill berakhir ~140px, tombol alat di 160px). */
  body.kk-stats-open #kkToolsBtn { top: 160px; }
  /* Bar atas kota (audit-E E3): nama kota harus terbaca penuh di HP —
     sembunyikan span pulau + fase/cuaca jam; nama diberi lebar minimum
     supaya tidak menyusut jadi "M…" / "Yo…". */
  .city-name span { display: none; }
  .city-name { min-width: 84px; }
  .game-clock #gamePhase, .game-clock #gameWeather { display: none; }
  /* Tombol kanan dikelompokkan ke sheet "⋮" (aslinya disembunyikan). */
  .canvas-tools, #audioBtns, #kkCamDock { display: none !important; }
  /* Audit-E E4: chip selebar konten (width:max-content) — dulu selebar layar dan menutupi lonceng. */
  #hud-city #sosialOnlineChip { top: auto !important; bottom: 92px !important; right: 10px; left: auto !important; width: max-content; max-width: calc(100vw - 20px); }
  #btnInteraksiQuest { bottom: 142px !important; right: 10px !important; }
  /* Saat panel terbuka (HP): sembunyikan tombol melayang supaya tidak
     menutupi isi panel (audio sudah disembunyikan di atas; FAB/alat/
     chip/pill ikut disembunyikan — tutup panel untuk memunculkan lagi). */
  body.kk-panel-open #kkMenuFab,
  body.kk-panel-open #kkToolsBtn,
  body.kk-panel-open #sosialOnlineChip,
  body.kk-panel-open #btnInteraksiQuest { display: none !important; }
  /* Panel/kartu/notif: dock hilang, jadi bottom lebih rendah (di atas FAB). */
  .citizen-card { bottom: 80px; max-height: calc(100dvh - 170px); }
  .overlay-panel { top: 58px; bottom: 80px; }
  /* Audit-E E5: feed 186px supaya dasarnya bersih dari pil Misi. */
  .notif-feed { bottom: 186px; }
  #btnNotifToggle { bottom: 80px; }
  /* Audit-E E6: toast + chip ikut naik ke 186px (bersih dari pil Misi dan chip online). */
  .follow-chip { bottom: 186px; max-width: calc(100vw - 20px); }
  .toast { bottom: 186px; }
  /* Audit-E E7: baris alat lebih rapat supaya 11 baris muat tanpa scroll (tinggi 844px). */
  .kk-tool-row { padding: 10px 6px; }
  /* Sheet hanya di HP. */
  #kkMenuSheet.open, #kkToolsSheet.open { display: flex; }
  #kkSheetBackdrop.open { display: block; }
}

/* AUDIT-E + Audit-A — layar pendek / HP landscape (tinggi <=500px). Desktop
   (tinggi >500px) dan HP portrait TIDAK berubah. */
@media (max-height: 500px) {
  /* E10: feed — bawah 210px, maks 86px; lebar maks 100vw-200px supaya bersih dari chip online. */
  #hud-city .notif-feed { bottom: 210px; max-height: 86px; overflow: hidden; max-width: calc(100vw - 200px); }
  /* Audit-A: hanya kabar terbaru yang tampil di layar pendek. */
  .notif-feed .notif:nth-child(n+2) { display: none; }
  /* E12: chip online ke kanan atas (right:60px, bersih dari kolom alat). */
  #hud-city #sosialOnlineChip { left: auto !important; right: 60px !important; top: 96px !important; bottom: auto !important; width: max-content; max-width: calc(100vw - 20px); }
  /* E11: lonceng ke samping kanan tombol audio. */
  #btnNotifToggle { top: 170px; bottom: auto; left: 98px; }
  /* E9: dock 2 baris (18+17) + menepi dari kolom alat; tinggi ~112px. */
  #bottomNav { left: 8px; right: 62px; transform: none; max-width: 774px; column-gap: 4px; }
  #bottomNav button { width: 38px; }
  /* Panel lebih tinggi karena dock kini 2 baris. */
  .overlay-panel { bottom: 130px; }
  /* Audit-A: kolom alat 7 tombol tidak muat vertikal di layar pendek — tombol 36px + gap 4px. */
  .canvas-tools { top: 96px; gap: 4px; }
  .canvas-tools button { width: 36px; height: 36px; }
  /* Audit-A: pill Misi di layar pendek menutupi tombol "Aa" — geser ke kiri kolom alat. */
  #btnInteraksiQuest { right: 56px; }
}

/* Objek 3D sungguhan (city3d-objek.js) menggantikan gambar DOM 2D di atas
   kanvas 3D: sembunyikan gambarnya saja — label + klik tetap di DOM.
   Kelas kk-obj3d hanya ada saat modul 3D aktif; tanpa itu gambar 2D lama
   tampil (fallback mode 2D / WebGL gagal). */
body.kk-obj3d #pasarpagi3dLayer .r4b3d-tent,
body.kk-obj3d #memancing3dLayer .r4b3d-rod,
body.kk-obj3d #memancing3dLayer .r4b3d-bob,
body.kk-obj3d #memancing3dLayer .r4b3d-ripple,
body.kk-obj3d #kriminal3dLayer .krim-body,
body.kk-obj3d #kriminal3dLayer .krim-light,
body.kk-obj3d #cerita3dLayer .bang { display: none !important; }
body.kk-obj3d #cerita3dLayer .cerita3d-mark { animation: none !important; }
body.kk-obj3d #cerita3dLayer .cerita3d-mark .lbl { top: 0 !important; }
body.kk-obj3d #pertanian3dLayer .pertanian3d-plot {
  background: transparent !important; border-color: transparent !important;
  box-shadow: none !important; animation: none !important;
}
