/* Rusun 30an: a night-time pixel game shell around the building. One look on purpose (no light theme). */
:root {
  --bg: #0d1017; --panel: #161a26; --panel2: #1e2333; --line: #2c3246; --ink: #f4f1e8; --muted: #9aa0b4;
  --gold: #ffd34d; --teal: #35d0ba; --red: #ff6a6a; --blue: #4fb3ff; --ol: #1a1020;
  --pix: "Silkscreen", "Courier New", monospace; --body: "Plus Jakarta Sans", system-ui, sans-serif;
  --top: calc(52px + env(safe-area-inset-top, 0px)); --nav: calc(58px + env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.top { position: fixed; inset: 0 0 auto; height: var(--top); padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border-bottom: 2px solid var(--ol); z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--pix); font-size: 15px; white-space: nowrap; }
.brand b { font-weight: 400; color: var(--gold); text-shadow: 2px 2px 0 var(--ol); }
.day { font-size: 11px; background: var(--ink); color: var(--ol); padding: 2px 6px; }
.stats { display: flex; gap: 10px; font-family: var(--pix); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.stats #clock { color: var(--ink); }
@media (max-width: 420px) { .stats #st-lit { display: none; } }

main { position: fixed; top: var(--top); bottom: var(--nav); left: 0; right: 0; }
.view { position: absolute; inset: 0; display: none; }
.view.on { display: block; }
.page { overflow-y: auto; }
.wrap { max-width: 640px; margin: 0 auto; padding-block: 18px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 18px; }

#scroller { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
#scene { position: sticky; top: 0; display: block; margin: 0 auto; image-rendering: pixelated; touch-action: pan-y; cursor: pointer; }
#spacer { width: 1px; }

.float { position: absolute; top: 10px; right: max(10px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 5; }
.chip { font-family: var(--pix); font-size: 11px; background: var(--panel); border: 2px solid var(--ol); color: var(--ink); padding: 6px 9px; box-shadow: 2px 2px 0 var(--ol); }
.chip.gold { background: var(--gold); color: var(--ol); }
.findbox { position: absolute; top: 10px; left: max(10px, env(safe-area-inset-left, 0px)); right: 120px; max-width: 320px; background: var(--panel); border: 2px solid var(--ol); padding: 8px; z-index: 6; box-shadow: 3px 3px 0 var(--ol); }
.findbox input { width: 100%; background: var(--bg); border: 1px solid var(--line); padding: 7px 9px; }
#find-res { display: flex; flex-direction: column; margin-top: 6px; }
#find-res button { text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 7px 4px; }
#find-res small { color: var(--muted); }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 78%; overflow-y: auto; background: var(--panel); border-top: 2px solid var(--ol); z-index: 8;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px)); display: flex; gap: 14px; flex-wrap: wrap; box-shadow: 0 -6px 0 rgba(0,0,0,.25); }
.sheet .x { position: absolute; top: 6px; right: 10px; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); }
#zoom { width: 224px; height: 200px; max-width: 100%; image-rendering: pixelated; border: 2px solid var(--ol); background: var(--bg); flex: none; }
.sheet-body { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sheet-body h3 { margin: 0; font-family: var(--pix); font-weight: 400; font-size: 18px; color: var(--gold); }
.sheet-body .now { background: var(--panel2); border-left: 3px solid var(--teal); padding: 8px 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.tabs { position: fixed; inset: auto 0 0; height: var(--nav); padding-bottom: env(safe-area-inset-bottom, 0px); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 2px solid var(--ol); z-index: 20; }
.tabs button { background: none; border: 0; font-family: var(--pix); font-size: 12px; color: var(--muted); padding: 0 2px; }
.tabs button.on { color: var(--gold); background: var(--panel2); }

h1, h2 { font-family: var(--pix); font-weight: 400; margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 24px; color: var(--gold); }
h2 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--panel); border: 2px solid var(--ol); box-shadow: 3px 3px 0 var(--ol); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.lbl { font-family: var(--pix); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input[type=text] { background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; font-size: 16px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { background: var(--bg); border: 1px solid var(--line); padding: 7px 10px; font-size: 14px; }
.opt[aria-pressed=true] { border-color: var(--gold); background: #2a2614; color: var(--gold); }
.igrow { display: flex; align-items: stretch; }
.igrow span { background: var(--panel2); border: 1px solid var(--line); border-right: 0; padding: 10px 10px; color: var(--muted); }
.igrow input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; font-size: 16px; }
.opt.plat { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.opt.plat i { width: 14px; height: 14px; border: 2px solid var(--ol); display: inline-block; }
.opt.plat[aria-pressed=true] { border-color: var(--pc); background: var(--panel2); color: var(--ink); box-shadow: inset 0 -3px 0 var(--pc); }
.sw { width: 30px; height: 30px; border: 2px solid var(--ol); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw[aria-pressed=true] { box-shadow: 0 0 0 2px var(--gold); }
.look { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: start; }
@media (max-width: 480px) { .look { grid-template-columns: 1fr; } }
#preview { width: 150px; height: 180px; image-rendering: pixelated; border: 2px solid var(--ol); background: #2a2550; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--gold); flex: none; }
.btn { font-family: var(--pix); font-size: 14px; background: var(--gold); color: var(--ol); border: 2px solid var(--ol); box-shadow: 3px 3px 0 var(--ol); padding: 11px 16px; }
.btn.ghost { background: var(--panel2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.err { color: var(--red); font-size: 14px; min-height: 1em; }
#cardimg { width: 100%; max-width: 600px; image-rendering: pixelated; border: 0; display: block; }
.code { font-family: var(--pix); font-size: 22px; color: var(--gold); background: var(--bg); border: 2px dashed var(--gold); padding: 8px 12px; align-self: flex-start; user-select: all; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.habit { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; }
.habit input { width: 22px; height: 22px; accent-color: var(--gold); margin: 1px 0 0; }
.habit b { font-weight: 600; }
.habit details { grid-column: 2; font-size: 13px; color: var(--muted); }
.habit summary { cursor: pointer; color: var(--teal); }
.body { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.part { background: var(--bg); border: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 13px; }
.part canvas { width: 72px; height: 72px; image-rendering: pixelated; }
.part b { font-family: var(--pix); font-weight: 400; font-size: 12px; }
.stat3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat3 div { background: var(--panel); border: 2px solid var(--ol); padding: 10px 12px; }
.stat3 b { display: block; font-family: var(--pix); font-weight: 400; font-size: 22px; color: var(--gold); font-variant-numeric: tabular-nums; }
.stat3 span { font-size: 13px; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.hist li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.hist .d { font-family: var(--pix); font-size: 11px; color: var(--gold); padding-top: 3px; }
.hist .p { color: var(--muted); }
.hist small { display: block; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 14px); transform: translateX(-50%); background: var(--gold); color: var(--ol); font-family: var(--pix); font-size: 12px; padding: 9px 14px; border: 2px solid var(--ol); z-index: 30; max-width: calc(100% - 32px); text-align: center; }
a { color: var(--teal); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* chat */
.badge { display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px; background: var(--red); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.chat { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 9; background: var(--panel); border-left: 2px solid var(--ol); display: flex; flex-direction: column; box-shadow: -6px 0 0 rgba(0,0,0,.25); }
.chat header { display: flex; align-items: baseline; gap: 8px; padding: 12px 44px 10px max(14px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); position: relative; }
.chat header b { font-family: var(--pix); font-weight: 400; color: var(--gold); font-size: 14px; }
.chat header small { color: var(--muted); font-size: 12px; }
.chat .x { position: absolute; top: 4px; right: 8px; background: none; border: 0; font-size: 26px; color: var(--muted); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.msg .who { display: flex; align-items: baseline; gap: 8px; }
.msg .nm { font-family: var(--pix); font-size: 11px; background: none; border: 0; padding: 0; color: var(--pc, var(--muted)); text-align: left; }
.msg .tm { font-size: 11px; color: var(--muted); }
.msg .rp { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 11px; padding: 0 2px; }
.msg .rp:hover { color: var(--red); }
.msg p { overflow-wrap: anywhere; }
.msg.mine p { color: var(--gold); }
.chat-empty { color: var(--muted); font-size: 14px; text-align: center; margin: auto 0; }
.chat-form { border-top: 1px solid var(--line); padding: 10px max(14px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) 14px; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.chat-form textarea { flex: 1 1 200px; min-width: 0; resize: none; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; font: 15px/1.4 var(--body); color: var(--ink); height: 42px; }
.chat-form .btn { padding: 9px 12px; font-size: 12px; }
.chat-form small { width: 100%; color: var(--muted); font-size: 12px; }

/* belanja */
.disclose { font-size: 13px; color: var(--muted); border-left: 3px solid var(--gold); padding: 6px 10px; background: var(--panel); }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prod { background: var(--panel); border: 2px solid var(--ol); box-shadow: 3px 3px 0 var(--ol); padding: 12px; display: grid; grid-template-columns: 60px 1fr; gap: 4px 12px; align-content: start; }
.prod canvas { grid-row: span 3; width: 60px; height: 60px; image-rendering: pixelated; background: var(--bg); border: 1px solid var(--line); }
.prod b { font-weight: 700; line-height: 1.3; }
.prod .price { font-family: var(--pix); font-size: 13px; color: var(--gold); }
.prod p { grid-column: 1 / -1; font-size: 14px; color: var(--muted); margin-top: 6px; }
.prod .buy { grid-column: 1 / -1; margin-top: 8px; text-align: center; text-decoration: none; display: block; font-family: var(--pix); font-size: 13px; padding: 9px 10px; border: 2px solid var(--ol); box-shadow: 2px 2px 0 var(--ol); }

/* walk mode */
.chip.on { background: var(--teal); color: var(--ol); }
.walkui { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; pointer-events: none; display: flex; align-items: flex-end; gap: 10px;
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) 10px max(10px, env(safe-area-inset-left, 0px)); }
.joy { pointer-events: auto; flex: none; width: 104px; height: 104px; border-radius: 50%; background: rgba(13,16,23,.55); border: 2px solid rgba(244,241,232,.35); position: relative; touch-action: none; }
.joy span { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ol); box-shadow: 2px 2px 0 var(--ol); }
@media (hover: hover) and (pointer: fine) { .joy { display: none; } }
.walkbar { pointer-events: auto; flex: 1; min-width: 0; background: rgba(22,26,38,.94); border: 2px solid var(--ol); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.walkbar .hint { font-size: 12px; color: var(--muted); }
.walkbar .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.walkbar .acts button { font-family: var(--pix); font-size: 11px; background: var(--panel2); border: 2px solid var(--ol); color: var(--ink); padding: 6px 8px; }
.walkbar .acts button.do { background: var(--gold); color: var(--ol); }
.walkbar .acts button.sapa { background: var(--teal); color: var(--ol); }
.walkbar .acts button.end { background: none; color: var(--muted); }
.greet { display: flex; flex-direction: column; gap: 4px; }
body.walking #btn-mine, body.walking #btn-find, body.walking #btn-ground { display: none; }
@media (pointer: coarse), (max-width: 600px) {
  .walkbar { padding: 6px; }
  .walkbar .hint { display: none; }
  .walkbar .acts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .walkbar .acts button { flex: none; }
}
