[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1a14; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #f3ecd8; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(20,45,30,.75), rgba(5,12,8,.95)); z-index: 10; }
.card { width: 100%; max-width: 400px; background: #1b2a20; border: 2px solid #c9a24a; border-radius: 14px; padding: 26px 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6), inset 0 0 0 4px #13201a; }
h1 { margin: 0 0 4px; font-size: 30px; text-align: center; color: #f1c860; letter-spacing: 1px; text-shadow: 0 3px 0 #6b4a12; }
.sub { text-align: center; margin: 0 0 18px; color: #b9c7b2; font-size: 14px; }
label { display: block; font-size: 13px; color: #d8cfae; margin-bottom: 12px; }
input { width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 8px; border: 1px solid #50684f; background: #0f1913; color: #fff; font-size: 16px; outline: none; }
input:focus { border-color: #f1c860; }
.row { display: flex; gap: 10px; margin-top: 6px; }
button { flex: 1; padding: 11px; border: 0; border-radius: 8px; background: #d9a531; color: #2a1a00; font-weight: 700; font-size: 15px; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.secondary { background: #2f4a37; color: #f3ecd8; border: 1px solid #5d7d62; }
.err { color: #ff8a7a; min-height: 20px; font-size: 14px; margin: 10px 0 0; text-align: center; }
.help { margin-top: 12px; font-size: 12px; color: #9fb09a; line-height: 1.5; border-top: 1px solid #2f4535; padding-top: 12px; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.panel { background: rgba(12, 20, 15, .78); border: 1px solid rgba(201,162,74,.55); border-radius: 10px; }
#stats { position: absolute; top: 12px; left: 12px; width: 250px; padding: 10px 12px; }
.nameRow { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.lv { color: #f1c860; }
.bar { position: relative; height: 16px; background: #2a1414; border-radius: 8px; overflow: hidden; margin-bottom: 5px; }
.bar.exp { height: 11px; background: #14222a; }
.bar div { height: 100%; width: 0; transition: width .15s; }
.bar.hp div { background: linear-gradient(#ff6b5b, #c22f25); }
.bar.exp div { background: linear-gradient(#7fd4ff, #2f8ccc); }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.bar.exp span { line-height: 11px; font-size: 9px; }
.mini { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-top: 4px; }
.zone { font-size: 12px; margin-top: 6px; color: #b9c7b2; }

#right { position: absolute; top: 12px; right: 12px; width: 180px; display: flex; flex-direction: column; gap: 8px; }
#minimap { display: block; width: 180px; height: 180px; }
#lb { padding: 8px 10px; font-size: 12px; }
#lb .ttl { font-weight: 700; color: #f1c860; margin-bottom: 4px; display: flex; justify-content: space-between; }
#lb .ttl span { color: #8fd18f; font-weight: 400; }
#lbList { margin: 0; padding-left: 20px; }
#lbList li { padding: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lbList li.on::marker { color: #6fe07a; }
#lbList li.me { color: #ffe27a; }

#chat { position: absolute; left: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); padding: 6px; pointer-events: auto; }
#chatLog { height: 140px; overflow-y: auto; font-size: 13px; padding: 2px 4px; line-height: 1.35; overflow-wrap: anywhere; }
#chatLog .sys { color: #f1c860; }
#chatLog b { color: #9fd8ff; }
#chatInput { margin-top: 4px; padding: 6px 8px; font-size: 13px; }

#hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,.55); white-space: nowrap; }
#toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-size: 18px; font-weight: 700; text-align: center;
  color: #fff; text-shadow: 0 2px 4px #000; opacity: 0; transition: opacity .3s; padding: 0 16px; }
#toast.show { opacity: 1; }

#touch { position: absolute; inset: 0; pointer-events: none; }
#joy { position: absolute; left: 24px; bottom: 190px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.2); pointer-events: auto; touch-action: none; }
#knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(241,200,96,.55); }
#tbtns { position: absolute; right: 16px; bottom: 24px; display: grid; grid-template-columns: 64px 64px; gap: 10px; pointer-events: auto; }
#tbtns button { width: 64px; height: 64px; border-radius: 50%; font-size: 26px; background: rgba(217,165,49,.75); touch-action: manipulation; }
#tbtns #tAtk { background: rgba(220,70,60,.8); }
#tbtns #tHome { background: rgba(110,190,230,.8); }

@media (max-width: 700px) {
  #stats { width: 190px; padding: 8px; font-size: 13px; }
  .mini { font-size: 11px; gap: 2px 8px; }
  #right { width: 110px; }
  #minimap { width: 110px; height: 110px; }
  #lb { display: none; }
  #chat { width: calc(100vw - 180px); min-width: 150px; }
  #chatLog { height: 80px; font-size: 11px; }
  #hint { display: none; }
}

/* ---------- Tas, toko, gudang ---------- */
.win { position: absolute; pointer-events: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 24px); overflow-y: auto; }
#bagPanel { right: 12px; bottom: 12px; width: 300px; }
#npcPanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100vw - 24px)); }
.winHead { display: flex; align-items: center; gap: 8px; }
.winHead b { color: #f1c860; }
.winHead span { color: #b9c7b2; font-size: 12px; flex: 1; }
.winHead .x { flex: none; width: 28px; height: 28px; padding: 0; border-radius: 6px; background: #2f4a37; color: #f3ecd8; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; justify-content: center; }
.slot { position: relative; width: 40px; height: 40px; border-radius: 6px; background: #0f1913; border: 2px solid #34503d; padding: 0; cursor: pointer; }
.slot.sel { border-color: #f1c860; box-shadow: 0 0 0 2px rgba(241,200,96,.35); }
.slot.biasa { border-color: #5d7d62; } .slot.langka { border-color: #7fc4ff; } .slot.boss { border-color: #ff9f43; }
.slot.sel.biasa, .slot.sel.langka, .slot.sel.boss { box-shadow: 0 0 0 2px #f1c860; }
.ico { position: absolute; left: 2px; top: 2px; width: 32px; height: 32px; background-image: url(assets/art/items.png); background-size: 256px auto; image-rendering: pixelated; }
.slot .n { position: absolute; right: 2px; bottom: 0; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.slotInfo { min-height: 20px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.slotInfo .nm { flex: 1 1 100%; }
.slotInfo button, .shopRow button { flex: none; padding: 6px 10px; font-size: 13px; }
.shopRow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(201,162,74,.2); font-size: 14px; }
.shopRow .ico { position: static; flex: none; }
.shopRow .nm { flex: 1; min-width: 0; }
.shopRow .pr { color: #ffd84a; font-variant-numeric: tabular-nums; }
.npcNote { font-size: 12px; color: #b9c7b2; }
@media (max-width: 700px) {
  #bagPanel { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(300px, calc(100vw - 24px)); }
}
