:root {
  --ink: #2a1c14;
  --paper: #fbf3df;
  --paper-2: #f1e3c2;
  --wood: #8a5a32;
  --wood-hi: #b07a4a;
  --wood-lo: #5a3a22;
  --accent: #3fa79a;
  --accent-lo: #2b7d73;
  --text: #3a2a1e;
  --muted: #7a6450;
  --night: #141a33;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1d2b1a;
  color: var(--text);
  font: 17px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game, #game canvas { position: fixed; inset: 0; display: block; }
#game canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: #f1e3c2; font-size: 22px; letter-spacing: 1px; background: #1d2b1a; z-index: 50;
}

/* Panel berbingkai kayu ala pixel (border tebal + bayangan bertingkat, tanpa sudut membulat) */
.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow:
    inset 0 0 0 2px var(--paper),
    inset 0 0 0 4px var(--wood-hi),
    inset 0 -4px 0 4px var(--paper-2),
    0 4px 0 0 rgba(20, 12, 6, 0.45);
}

.btn {
  font: inherit; color: var(--text); cursor: pointer; padding: 8px 14px; white-space: nowrap;
}
.btn:hover { background: #fff8e8; }
.btn:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px var(--wood-hi), 0 2px 0 0 rgba(20, 12, 6, 0.45); }
.btn.icon { width: 46px; padding: 8px 0; font-weight: 700; font-size: 20px; }
.btn.primary {
  background: var(--accent); color: #fff; border: 3px solid var(--ink); padding: 10px 18px;
  box-shadow: inset 0 -4px 0 var(--accent-lo), inset 0 3px 0 #69c8ba, 0 4px 0 rgba(20, 12, 6, 0.45);
}
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }

kbd {
  display: inline-block; min-width: 24px; padding: 0 5px; margin: 0 2px; text-align: center;
  font: 600 14px/22px var(--font); color: var(--paper); background: var(--wood-lo);
  border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 #3d2716;
}

/* ---------- HUD atas ---------- */
.hud-top {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 10;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.loc-card { display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 10px; min-width: 0; }
.loc-card strong { display: block; font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-card small { display: block; color: var(--muted); font-size: 15px; }
.sun {
  width: 38px; height: 38px; display: grid; place-items: center; flex-shrink: 0;
  background: #ffd34d; color: #8a4a1f; font-size: 22px; border: 3px solid var(--ink);
  box-shadow: inset 0 -3px 0 #e0a92a;
}
.hud-actions { display: flex; gap: 8px; }

/* ---------- Petunjuk interaksi ---------- */
.prompt {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  font: 600 17px var(--font); color: var(--text); padding: 8px 16px; cursor: pointer; white-space: nowrap;
  animation: bob 1.2s steps(2) infinite;
}
@keyframes bob { 50% { transform: translate(-50%, -2px); } }

/* ---------- Dialog ---------- */
.dialog {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  width: min(680px, calc(100vw - 32px)); padding: 18px 22px 22px; cursor: pointer;
}
.dlg-title {
  position: absolute; top: -18px; left: 16px; padding: 3px 12px;
  background: var(--wood); color: var(--paper); font-weight: 700; font-size: 17px;
  border: 3px solid var(--ink); box-shadow: inset 0 2px 0 var(--wood-hi), inset 0 -3px 0 var(--wood-lo);
}
.dialog p { margin: 6px 0 0; font-size: 18px; white-space: pre-line; min-height: 48px; }
.dlg-next { position: absolute; right: 16px; bottom: 8px; color: var(--wood); font-size: 13px; opacity: 0; }
.dialog.done .dlg-next { opacity: 1; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Bantuan ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 8, 20, 0.55);
}
.overlay[hidden], [hidden] { display: none !important; }
.help { width: min(520px, 100%); padding: 22px 24px 24px; max-height: calc(100vh - 32px); overflow: auto; }
.help h2 { margin: 0 0 8px; font-size: 24px; color: var(--wood-lo); }
.help p { margin: 0 0 12px; }
.help ul { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 8px; }
.help li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.help li kbd:last-of-type { margin-right: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 25;
  padding: 8px 16px; font-size: 16px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 560px) {
  html, body { font-size: 15px; }
  .loc-card strong { font-size: 16px; }
  .dialog p { font-size: 16px; }
}

button, kbd { font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'clig' 0; }

/* ---------- Peta ---------- */
#btn-map kbd { font-size: 12px; line-height: 18px; min-width: 20px; margin-left: 4px; }
.map-panel { width: min(900px, 100%); padding: 16px 18px 14px; max-height: calc(100vh - 32px); overflow: auto; }
.map-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.map-head h2 { margin: 0; font-size: 22px; color: var(--wood-lo); }
.map-where { color: var(--muted); font-size: 15px; flex: 1; }
.close-x { width: 40px; height: 40px; padding: 0; font-size: 24px; line-height: 1; border: 3px solid var(--ink); background: var(--paper); }
.map-frame {
  position: relative; border: 3px solid var(--ink); background: #2c5a29;
  box-shadow: 0 0 0 3px var(--wood-hi), 0 0 0 6px var(--ink);
  margin: 6px auto;
  /* peta 76×64 petak: lebarnya dibatasi tinggi layar agar tidak terpotong (rasio 76/64) */
  width: min(100% - 12px, calc((100vh - 170px) * 1.1875));
}
#map-canvas canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
#map-labels { position: absolute; inset: 0; pointer-events: none; }
.map-label {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  font: 600 14px/1.2 var(--font); padding: 2px 6px; color: var(--text);
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 2px 0 rgba(20, 12, 6, 0.4);
}
.map-label small { display: block; font-size: 11px; color: #9b5a1a; text-align: center; }
.map-label.bld { top: var(--out); }
.map-label.soon { background: #fff1c9; }
.map-label.open { background: #dff5ef; }
.map-label.area {
  transform: translate(-50%, -50%); background: transparent; border: 0; box-shadow: none; color: #fbf3df;
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink);
}
.map-me {
  position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%);
  background: #e2483d; border: 3px solid #fff; outline: 2px solid var(--ink);
  animation: me-pulse 0.9s steps(2) infinite;
}
@keyframes me-pulse { 50% { background: #ffd34d; } }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 12px; font-size: 15px; }
.map-legend .muted { color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border: 2px solid var(--ink); }
.lg.me { background: #e2483d; }
.lg.open { background: #dff5ef; }
.lg.soon { background: #fff1c9; }
.spacer { flex: 1; }
@media (max-width: 560px) {
  .map-label { font-size: 10px; padding: 1px 3px; border-width: 1px; }
  .map-label small { display: none; }
  .map-label.bld { top: var(--in); transform: translate(-50%, -50%); }
  .hud-top { left: 10px; right: 10px; gap: 6px; }
  .hud-actions { gap: 6px; }
  #btn-map { padding: 8px 9px; }
  .btn.icon { width: 40px; }
  .loc-card { padding: 6px 10px 6px 6px; gap: 8px; }
  .sun { width: 30px; height: 30px; font-size: 18px; }
  .map-label.area { font-size: 11px; }
  #btn-map kbd { display: none; }
  .map-head h2 { font-size: 18px; }
}

/* ---------- Jendela aplikasi (DrawSQL) ---------- */
#appwin { position: fixed; inset: 0; z-index: 45; display: flex; padding: 16px; background: rgba(12, 10, 20, 0.55); }
#appwin[hidden] { display: none; }
.app-window {
  margin: auto; width: 100%; height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: #fbf3df; border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--wood-hi), 8px 8px 0 rgba(10, 6, 2, 0.45);
}
.app-bar {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: #3f6b4f; border-bottom: 3px solid var(--ink); box-shadow: inset 0 3px 0 #5c8a6a, inset 0 -4px 0 #2f5240;
}
.app-logo {
  width: 36px; height: 36px; display: grid; place-items: center; flex-shrink: 0;
  background: #ffd34d; color: #6e4524; font-size: 20px; border: 3px solid var(--ink); box-shadow: inset 0 -3px 0 #e0a92a;
}
.app-titles { flex: 1; min-width: 0; }
.app-titles strong { display: block; color: #fbf3df; font-size: 19px; }
.app-titles small { display: block; color: #d8ecd9; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-btn {
  font: 600 15px var(--font); color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
  padding: 7px 12px; background: var(--paper); border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 var(--paper-2);
}
.app-btn:hover { background: #fff8e8; }
.app-close { background: #c4553f; color: #fff; box-shadow: inset 0 -3px 0 #8e3a2c; padding: 7px 12px; }
.app-close:hover { background: #d26a4e; }
.app-body { position: relative; flex: 1; background: #fff; }
.app-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.app-msg {
  position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; gap: 6px; text-align: center;
  background: var(--paper); color: var(--text); font-size: 17px; padding: 24px;
}
.app-msg[hidden] { display: none; }
.app-msg code { font-family: 'JetBrains Mono', monospace; background: #efe0bf; padding: 2px 6px; border: 1px solid #c9a878; }
.app-msg .btn { justify-self: center; margin-top: 10px; }
@media (max-width: 560px) {
  #appwin { padding: 0; }
  .app-window { border-width: 0; box-shadow: none; }
  #app-newtab { display: none; }
}

/* ---------- Kebun: koin, hotbar, toko ---------- */
.hud-left { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; min-width: 0; }
.coin-card { display: flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: 17px; white-space: nowrap; }
.coin-card span { color: var(--muted); font-size: 15px; }
.coin {
  display: inline-block; width: 14px; height: 14px; flex-shrink: 0; vertical-align: -2px; margin-left: 3px;
  background: #ffd34d; border: 2px solid #8a5a12; box-shadow: inset -2px -2px 0 #e0a92a, inset 2px 2px 0 #fff3b0;
}
.px-icon { width: 32px; height: 32px; image-rendering: pixelated; image-rendering: crisp-edges; }
.px-icon.big { width: 48px; height: 48px; }
.hotbar {
  position: fixed; left: 16px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10; display: flex; gap: 6px;
}
.hotbar .slot {
  position: relative; width: 50px; height: 50px; display: grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 var(--paper-2), 0 3px 0 rgba(20, 12, 6, 0.45);
}
.hotbar .slot.active { background: #fff3c4; outline: 3px solid #ffd34d; outline-offset: -1px; }
.hotbar .slot.empty img { opacity: 0.35; filter: grayscale(1); }
.hotbar .n { position: absolute; right: 3px; bottom: 1px; font: 700 14px var(--font); color: var(--ink); text-shadow: 1px 1px 0 #fff; }
.hotbar .k { position: absolute; left: 3px; top: 0; font: 600 11px var(--font); color: var(--muted); }
.shop-panel { width: min(640px, 100%); padding: 16px 18px 18px; max-height: calc(100vh - 32px); overflow: auto; }
.shop-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.shop-keeper {
  width: 52px; height: 52px; flex-shrink: 0; border: 3px solid var(--ink); background: #ffe7b8 center / 36px no-repeat;
  image-rendering: pixelated; box-shadow: inset 0 -4px 0 #f1cf8e;
}
.shop-titles { flex: 1; min-width: 0; }
.shop-titles h2 { margin: 0; font-size: 21px; color: var(--wood-lo); }
.shop-msg { margin: 2px 0 0; font-size: 15px; min-height: 20px; }
.shop-msg.ok { color: #2f6b2a; }
.shop-msg.err { color: #b8392f; }
.shop-wallet { display: flex; align-items: center; gap: 4px; font-size: 20px; padding: 6px 10px; border: 2px solid var(--ink); background: #fff3c4; }
.shop-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.shop-tab {
  font: 600 16px var(--font); color: var(--text); cursor: pointer; padding: 7px 14px;
  background: var(--paper-2); border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 #d9c49a;
}
.shop-tab.active { background: #2f8275; color: #fff; box-shadow: inset 0 -3px 0 #22635a; }
.shop-body { display: grid; gap: 8px; }
.shop-row {
  display: grid; grid-template-columns: 52px 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 10px; background: #fffaf0; border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(42, 28, 20, 0.18);
}
.shop-info { display: flex; flex-direction: column; min-width: 0; }
.shop-info strong { font-size: 17px; }
.shop-info small { font-size: 13px; color: var(--muted); }
.price { display: flex; align-items: center; font: 700 18px var(--font); }
.shop-btns { display: flex; gap: 6px; }
.sbtn {
  font: 600 14px var(--font); color: var(--text); cursor: pointer; padding: 6px 10px; white-space: nowrap;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 var(--paper-2);
}
.sbtn:hover:not(:disabled) { background: #fff8e8; }
.sbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.sbtn.primary { background: #2f8275; color: #fff; box-shadow: inset 0 -3px 0 #22635a; }
.shop-total { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-size: 16px; }
.shop-empty { margin: 8px 0; color: var(--muted); font-size: 16px; }
@media (max-width: 560px) {
  .shop-row { grid-template-columns: 40px 1fr auto; }
  .shop-row .shop-btns { grid-column: 1 / -1; }
  .px-icon.big { width: 40px; height: 40px; }
  .hotbar .slot { width: 44px; height: 44px; }
  .coin-card { padding: 8px 10px; }
}
@media (max-width: 700px) {
  .prompt { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px); }
}

/* ---------- Papan Target ---------- */
.board-panel { width: min(620px, 100%); padding: 16px 18px 18px; max-height: calc(100vh - 32px); overflow: auto; }
.board-icon {
  width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; font: 700 26px var(--font); color: #fff;
  background: #2f8275; border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 #22635a;
}
.bd-stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.bd-stat { padding: 8px 10px; background: #fffaf0; border: 2px solid var(--ink); display: flex; flex-direction: column; }
.bd-stat strong { font-size: 26px; line-height: 1.1; }
.bd-stat span { font-size: 13px; color: var(--muted); }
.bd-stat.main { background: #2f8275; color: #fff; box-shadow: inset 0 -4px 0 #22635a; }
.bd-stat.main span { color: #d6eee7; }
.bd-sec { margin-bottom: 10px; }
.bd-sec h3 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.bd-sec h3 span { font-size: 13px; padding: 0 6px; border: 2px solid var(--ink); background: #fff; }
.bd-sec h3.red { color: #b8392f; }
.bd-sec h3.amber { color: #a8661a; }
.bd-sec h3.blue { color: #3f66a8; }
.bd-sec h3.green { color: #2f6b2a; }
.bd-item {
  display: flex; flex-direction: column; width: 100%; text-align: left; cursor: pointer; margin-bottom: 6px; padding: 7px 10px;
  font: inherit; color: var(--text); background: #fffaf0; border: 2px solid var(--ink); box-shadow: 2px 2px 0 rgba(42, 28, 20, 0.18);
}
.bd-item:hover { background: #fff3c4; }
.bd-title { font-size: 16px; }
.bd-meta { font-size: 13px; color: var(--muted); }
.bd-empty { margin: 0 0 6px; color: var(--muted); font-size: 15px; }
.bd-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; color: var(--muted); }
@media (max-width: 560px) { .bd-stats { grid-template-columns: 1fr 1fr; } }

.shop-season { margin: 0 0 4px; font-size: 15px; color: var(--muted); }
.shop-row.off { opacity: 0.55; }
.hotbar { max-width: calc(100vw - 32px); overflow-x: auto; scrollbar-width: none; }
.hotbar .slot { flex-shrink: 0; }
@media (max-width: 700px) { .hotbar .slot { width: 40px; height: 40px; } .hotbar .px-icon { width: 26px; height: 26px; } }

/* ---------- Profil & multipemain ---------- */
.me-btn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; padding: 10px 12px; font-size: 16px; }
.me-btn b { font-weight: 700; }
.profile-panel { width: min(460px, 100%); padding: 16px 18px 18px; max-height: calc(100vh - 32px); overflow: auto; }
.pf-field { display: grid; gap: 6px; margin: 10px 0; font-size: 15px; color: var(--muted); }
.pf-field input { font: 600 18px var(--font); padding: 8px 10px; background: #fffaf0; color: var(--text); border: 2px solid var(--ink); }
.pf-looks { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; cursor: pointer; border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25); }
.swatch.active { outline: 3px solid #ffd34d; outline-offset: 2px; }
.pf-device { font-size: 15px; margin: 12px 0; }
.pf-device small { color: var(--muted); font-size: 13px; }
.pf-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.pf-online { margin: 14px 0 6px; font-size: 16px; color: var(--wood-lo); }
.pf-online span { font-size: 13px; padding: 0 6px; border: 2px solid var(--ink); background: #fff; color: var(--text); }
.online { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.online li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; background: #fffaf0; border: 2px solid var(--ink); font-size: 15px; }
.online li small { color: var(--muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 560px) { .me-btn { max-width: 140px; padding: 8px; } }

/* Petunjuk interaksi di atas hotbar (hotbar 9 slot cukup lebar) */
.prompt { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px); }
.dialog { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px); }

/* ---------- Kontrol sentuh & tata letak mobile ---------- */
#touch { display: none; }
.touch-only { display: none; }
body.touch .touch-only { display: grid; }
body.touch .key-only { display: none; }
body.touch #touch {
  display: block; position: fixed; inset: auto 0 0 0; height: 0; z-index: 12; pointer-events: none;
}
body.touch #touch.hidden { visibility: hidden; }
.joy {
  position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom));
  width: 128px; height: 128px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(255, 250, 240, 0.28) 0 55%, rgba(255, 250, 240, 0.16) 56% 100%);
  border: 3px solid rgba(42, 28, 20, 0.55); box-shadow: 0 4px 0 rgba(20, 12, 6, 0.35);
}
.joy.on { background: radial-gradient(circle, rgba(255, 250, 240, 0.4) 0 55%, rgba(255, 250, 240, 0.22) 56% 100%); }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fffaf0, #e8d7a8); border: 3px solid var(--ink);
  box-shadow: inset 0 -4px 0 #c9b07a, 0 3px 0 rgba(20, 12, 6, 0.4); pointer-events: none;
}
.tbtn {
  position: fixed; pointer-events: auto; touch-action: none; border-radius: 50%; border: 3px solid var(--ink);
  font: 800 20px var(--font); color: #fff; -webkit-tap-highlight-color: transparent;
}
.tbtn.act {
  right: max(20px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 84px; height: 84px; font-size: 30px;
  background: radial-gradient(circle at 35% 30%, #4fb3a4, #2f8275); box-shadow: inset 0 -6px 0 #22635a, 0 4px 0 rgba(20, 12, 6, 0.45);
}
.tbtn.run {
  right: calc(max(20px, env(safe-area-inset-right)) + 96px); bottom: max(26px, env(safe-area-inset-bottom)); width: 58px; height: 58px; font-size: 14px;
  background: radial-gradient(circle at 35% 30%, #9b8a74, #6e5e4a); box-shadow: inset 0 -4px 0 #4f4234, 0 3px 0 rgba(20, 12, 6, 0.45);
}
.tbtn.run.on { background: radial-gradient(circle at 35% 30%, #ffd34d, #e0a92a); color: var(--ink); box-shadow: inset 0 -4px 0 #b88a1a, 0 3px 0 rgba(20, 12, 6, 0.45); }
.tbtn.act.on, .tbtn.run:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3); }

/* HUD ringkas di layar sentuh */
body.touch kbd { display: none; }
body.touch .hud-top { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; gap: 6px; }
body.touch .hud-left { gap: 6px; flex-wrap: nowrap; min-width: 0; }
body.touch .loc-card { padding: 5px 9px 5px 5px; gap: 6px; min-width: 0; }
body.touch .loc-card strong { font-size: 14px; max-width: 34vw; }
body.touch .loc-card small { font-size: 12px; }
body.touch .sun { width: 26px; height: 26px; font-size: 15px; border-width: 2px; }
body.touch .coin-card { padding: 7px 9px; font-size: 15px; }
body.touch .coin-card span { display: none; }
body.touch .me-btn { padding: 7px 9px; font-size: 14px; max-width: 30vw; }
body.touch .hud-actions { gap: 5px; }
body.touch .hud-actions .btn { padding: 7px 9px; font-size: 14px; }
body.touch #btn-map, body.touch #btn-work { font-size: 0; width: 40px; height: 38px; padding: 0; }
body.touch #btn-map::before { content: '🗺'; font-size: 18px; }
body.touch #btn-work::before { content: '📒'; font-size: 18px; }
body.touch .btn.icon { width: 40px; height: 38px; padding: 0; font-size: 18px; }

/* Petunjuk, dialog & hotbar di atas area kontrol */
body.touch .prompt { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 140px); max-width: calc(100vw - 32px); white-space: normal; text-align: center; font-size: 15px; }
body.touch .dialog { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 140px); width: calc(100vw - 20px); padding: 16px 16px 18px; }
body.touch .dialog p { font-size: 16px; }
body.touch .hotbar { display: none; left: 8px; right: 8px; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 140px); justify-content: center; }
body.touch.in-field .hotbar { display: flex; }
body.touch.in-field .prompt { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 194px); }
body.touch .hotbar .slot { width: 44px; height: 44px; }
body.touch .hotbar .k { display: none; }

/* Panel penuh layar di HP */
@media (max-width: 640px) {
  .overlay { padding: 0; align-items: end; }
  .overlay > .panel { width: 100%; max-height: 88vh; border-left: 0; border-right: 0; border-bottom: 0; }
  .shop-row { grid-template-columns: 40px 1fr auto; }
  .sbtn { padding: 9px 12px; font-size: 15px; }
  .map-panel { max-height: 92vh; }
  #appwin { padding: 0; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .joy { width: 104px; height: 104px; bottom: 12px; }
  .joy-knob { width: 46px; height: 46px; }
  .tbtn.act { width: 70px; height: 70px; bottom: 16px; }
  .tbtn.run { width: 50px; height: 50px; bottom: 14px; right: calc(max(20px, env(safe-area-inset-right)) + 80px); }
  body.touch .prompt, body.touch .dialog { bottom: 14px; left: 50%; width: min(56vw, 520px); }
  body.touch .hotbar { bottom: 130px; }
}
.help ul.touch-only { display: none; }
body.touch .help ul.touch-only { display: grid; }
body.touch .help ul.key-only { display: none; }

/* Mobile: HUD dua baris yang lega, teks bantuan sentuh */
.touch-inline { display: none; }
body.touch .touch-inline { display: inline; }
body.touch .help ul.touch-only li { display: block; }
body.touch .hud-top { flex-wrap: wrap; }
body.touch .hud-left { flex: 1 1 100%; }
body.touch .loc-card { flex: 1 1 auto; }
body.touch .loc-card strong { max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch .loc-card small { white-space: nowrap; }
body.touch .part-wrap { display: none; }
body.touch .me-btn { flex: 0 1 auto; max-width: 38vw; white-space: nowrap; }
body.touch .hud-actions { flex: 1 1 100%; justify-content: flex-end; }
/* Hotbar di HP: rata kiri & bisa digeser (rata tengah memotong slot pertama saat meluap) */
body.touch .hotbar { justify-content: flex-start; -webkit-overflow-scrolling: touch; touch-action: pan-x; }

/* ================= Latar luar pulau (langit, pegunungan, awan, laut lepas) ================= */
/* #backdrop = laut (warna sama dengan tepi laut pulau). Ombak = lapisan penuh layar; .bd-world = wadah dengan garis bawah =
   cakrawala, digeser JS mengikuti kamera. Semua animasi memakai transform/translate (dikerjakan GPU, tanpa layout ulang). */
#backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; display: none; pointer-events: none; background: #245f9f; }
body.outdoor #backdrop { display: block; }
#backdrop > * { position: absolute; image-rendering: pixelated; }
.bd-waves { left: -768px; top: -384px; width: calc(100% + 1536px); height: calc(100% + 768px); background-repeat: repeat; will-change: transform; }
.bd-waves.w1 { background-size: 384px 192px; opacity: 0.9; animation: bd-w1 26s linear infinite; }
.bd-waves.w2 { background-size: 768px 384px; opacity: 0.55; animation: bd-w2 48s linear infinite; }
@keyframes bd-w1 { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(384px, 192px, 0); } }
@keyframes bd-w2 { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-768px, 384px, 0); } }
.bd-world { left: 0; right: 0; top: 0; height: 0; will-change: transform; }
.bd-world > * { position: absolute; image-rendering: pixelated; }
.bd-sky { left: 0; right: 0; bottom: 0; height: 400vh; }
.bd-stars { left: 0; right: 0; bottom: 0; height: 120vh; background-repeat: repeat; background-size: 256px 200px; opacity: 0; }
.bd-sun { width: 64px; height: 64px; margin-left: -32px; background-size: 64px 64px; }
.bd-moon { width: 40px; height: 40px; margin-left: -20px; background-size: 40px 40px; }
.bd-hills { left: 0; right: 0; bottom: 0; background-repeat: repeat-x; background-position: 0 100%; background-size: 1024px 100%; }
.bd-hills.far { height: 210px; opacity: 0.92; }
.bd-hills.near { height: 130px; }
.bd-cloud { left: 0; width: 100px; height: 40px; transform-origin: 0 100%; background-size: 100px 40px; animation: bd-drift linear infinite; will-change: translate; }
@keyframes bd-drift { from { translate: -260px 0; } to { translate: 110vw 0; } }
.bd-mist { left: -5%; right: -5%; bottom: -6px; height: 110px; opacity: 0; transition: opacity 2s; background: linear-gradient(to top, rgba(228, 230, 245, 0.9), rgba(228, 230, 245, 0.55) 40%, rgba(228, 230, 245, 0)); filter: blur(0.5px); }
.bd-haze { left: 0; right: 0; top: 0; height: 160px; background: linear-gradient(to bottom, rgba(205, 232, 246, 0.9), rgba(110, 175, 220, 0.4) 45%, rgba(36, 95, 159, 0)); }
.bd-boat { left: 0; top: 44px; width: 24px; height: 26px; background-size: 24px 26px; transform: scale(1.3); animation: bd-sail 340s linear infinite; will-change: translate; }
.bd-boat.b2 { top: 96px; transform: scale(1.9); animation-duration: 520s; animation-delay: -210s; }
@keyframes bd-sail { from { translate: -60px 0; } to { translate: 104vw 0; } }
@media (prefers-reduced-motion: reduce) { .bd-cloud, .bd-waves, .bd-boat { animation: none; } .bd-cloud { translate: 30vw 0; } }
