/* hud.css — HUD adaptif (PC vs HP): panel dasar, kartu Bayangan, tombol kanan atas, bar boss,
   banner Terkapar, petunjuk keyboard, kontrol sentuh, chat, toast.
   hudV2.css (bingkai gaya contoh.jpg) & hudMobile.css (mode sentuh) menimpa sebagian aturan ini. */
#hud-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#hud-root > * { pointer-events: auto; }
body.ui-desktop .touch-only { display: none !important; }
body.ui-touch .desktop-only { display: none !important; }

/* Panel di atas dunia game: isi padat + satu bayangan pemisah dari seni dunia yang ramai.
   Tanpa blur (berat di GPU, tak terlihat di isi 94%) dan tanpa sorot dalam. */
.hud-panel { background: rgba(17, 24, 36, 0.94); border: 1px solid #33425e; border-radius: 10px; box-shadow: var(--shadow-hud); }

/* ---------- Nama, zona, bar ---------- */
.hud-name-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#hud-name { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-zone-chip { font-size: var(--fs-xs); font-weight: 800; color: var(--gold); padding: 1px 7px; border-radius: 6px; background: rgba(242, 204, 96, 0.1); border: 1px solid rgba(242, 204, 96, 0.25); white-space: nowrap; }
.hud-bar { position: relative; height: 16px; border-radius: 4px; overflow: hidden; background: #070a10; border: 1px solid #263248; }
/* Cukup tinggi untuk teks 11px di dalamnya (8px membuat angka EXP terpotong) */
.hud-bar.exp { height: 14px; }
.hud-bar-fill, .hud-bar-ghost { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transition: width 0.35s var(--ease-out); }
/* Isi datar + tepi bawah gelap (bevel pixel, sama dengan tombol). Putih di atas isi ≥5,3:1. */
.hud-bar-fill { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.hud-bar.hp .hud-bar-fill { background: #237a35; }
.hud-bar.hp.is-low .hud-bar-fill { background: #c4352d; animation: hpPulse 0.9s 3; }
.hud-bar-ghost { background: rgba(255, 226, 140, 0.7); transition: width 0.9s 0.35s ease-out; }
.hud-bar.exp .hud-bar-fill { background: #8b6ff0; box-shadow: none; }
/* Garis tepi hitam 1px: angka tetap terbaca di atas isi, sisa "ghost", maupun jalur kosong */
.hud-bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 900; line-height: 1;
  color: #fff; text-shadow: 0 1px 0 #000, 0 -1px 0 #000, 1px 0 0 #000, -1px 0 0 #000;
}
@keyframes hpPulse { 50% { filter: brightness(1.4); } }
.hud-gold { display: inline-flex; align-items: center; gap: 4px; color: var(--gold-hi); }
.hud-online { color: var(--good-hi); display: inline-flex; align-items: center; gap: 5px; }
.hud-online .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }

/* ---------- Kartu mini Bayangan (ungu = identitas Bayangan di seluruh game) ---------- */
#mercenary-hud-card { position: absolute; top: calc(124px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); width: 286px; padding: 8px 10px; display: flex; gap: 9px; align-items: center; border-color: rgba(180, 140, 255, 0.4); }
#mercenary-hud-card .merc-ava { flex: 0 0 40px; height: 40px; border-radius: 10px; padding: 2px; background: #4b2c8a; }
#mercenary-hud-card .merc-ava .gi { width: 100%; height: 100%; border-radius: 8px; background: #141026; }
#mercenary-hud-card .merc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#mercenary-hud-card .merc-top { display: flex; justify-content: space-between; gap: 6px; font-size: var(--fs-sm); font-weight: 900; color: #d2a8ff; }
#mercenary-hud-card .merc-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mercenary-hud-card .merc-meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); font-weight: 800; color: var(--text-2); }
#merc-hud-hp-track .hud-bar-fill { background: #6f4bd1; }
#btn-dismiss-merc { flex: 0 0 auto; }

/* ---------- Kanan atas: tombol HUD (bevel pixel, sama dengan .btn) ---------- */
#top-right-controls { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: flex; gap: 8px; }
.hud-top-btn {
  position: relative; height: 44px; min-width: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-ui); font-weight: 900; font-size: var(--fs-md); color: var(--text);
  border-radius: 8px; border: 1px solid #3d4f70; border-bottom: 3px solid #121a29; background: rgba(28, 38, 57, 0.95); box-shadow: var(--shadow-hud);
  transition: transform 0.1s var(--ease-out), background-color 0.15s;
}
.hud-top-btn:hover { background: rgba(43, 58, 84, 0.98); }
.hud-top-btn:active { transform: translateY(2px); border-bottom-width: 1px; }
.hud-top-btn.btn-bag { border-color: rgba(242, 204, 96, 0.55); border-bottom-color: #5a3d0c; color: var(--gold-hi); }
.hud-top-btn.btn-square { width: 44px; padding: 0; }
.hud-top-btn kbd { min-width: 20px; height: 20px; font-size: var(--fs-xs); }
.hud-ic { display: inline-flex; width: 24px; height: 24px; flex: none; }
.hud-ic .gi, .hud-ic svg { width: 100%; height: 100%; }
#btn-fullscreen > span { font-size: 20px; line-height: 1; }

/* ---------- Bar HP boss ---------- */
#boss-bar { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(440px, 44vw); padding: 6px 12px 9px; text-align: center; border-color: rgba(255, 106, 58, 0.55); }
#boss-bar .boss-name { font-weight: 900; font-size: var(--fs-md); color: #ffb38a; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#boss-bar .hud-bar-fill { background: #b8431c; }
#btn-sos-flare { position: absolute; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); }

/* ---------- Banner Terkapar ---------- */
#downed-banner { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); padding: 14px 20px; text-align: center; border-color: rgba(248, 81, 73, 0.6); background: rgba(46, 12, 16, 0.96); }
#downed-banner h3 { font-family: var(--font-title); color: var(--bad-hi); font-size: var(--fs-title); margin-bottom: 4px; }
#downed-banner p { color: var(--text-2); font-size: var(--fs-md); margin-bottom: 10px; }
#downed-count { font-size: 1.6rem; font-weight: 900; color: #fff; }

/* ---------- PC: petunjuk keyboard (kanan bawah) ---------- */
#key-hints { position: absolute; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: var(--fs-sm); font-weight: 800; color: var(--text-2); pointer-events: none; }
#key-hints .kh { display: inline-flex; align-items: center; gap: 5px; transition: color 0.2s; }
#key-hints .sep { color: var(--muted); }
/* Dekat bangunan: tombol E berwarna emas + mengangguk 3 kali (status, bukan hiasan abadi) */
#kh-interact.is-active { color: var(--gold-hi); }
#kh-interact.is-active kbd { color: #2a1a04; background: #e2b54a; border-color: #ffe9a3; border-bottom-color: #8a5a10; animation: keyNudge 0.9s 3; }
@keyframes keyNudge { 50% { transform: translateY(-2px); } }

/* ---------- HP: analog & tombol bulat (isi datar + tepi bawah gelap, sama dengan tombol UI) ---------- */
/* z-index -1: zona analog selalu di bawah panel HUD lain (Bubarkan, SOS, Menyerah, chat tetap bisa ditekan) */
#joy-zone { position: absolute; left: 0; bottom: 0; width: 42vw; height: 62vh; z-index: -1; touch-action: none; }
#joy-base { position: absolute; left: calc(26px + env(safe-area-inset-left)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; background: rgba(20, 28, 42, 0.45); border: 2px solid rgba(242, 204, 96, 0.35); }
#joy-thumb { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: #e2b54a; border: 2px solid #ffe9a3; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.45); transition: transform 0.08s; }
#joy-base.is-active #joy-thumb { transition: none; }
.touch-btn { position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-family: var(--font-ui); font-weight: 900; color: #fff; touch-action: none; transition: transform 0.1s, opacity 0.25s; }
.touch-btn .ic { display: inline-flex; width: 34px; height: 34px; }
.touch-btn .ic .gi, .touch-btn .ic svg { width: 100%; height: 100%; }
.touch-btn .lb { font-size: var(--fs-xs); line-height: 1.1; }
.touch-btn:active, .touch-btn.is-pressed { transform: scale(0.92); }
#btn-touch-attack { right: calc(28px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 104px; height: 104px; background: #c4352d; border: 3px solid #ff8a80; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.25), 0 6px 14px rgba(0, 0, 0, 0.4); }
#btn-touch-action { right: calc(150px + env(safe-area-inset-right)); bottom: calc(36px + env(safe-area-inset-bottom)); width: 80px; height: 80px; background: #e2b54a; border: 3px solid #ffe9a3; color: #2a1a04; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), 0 6px 14px rgba(0, 0, 0, 0.4); animation: actionPulse 0.8s 3; }
#btn-touch-action .lb { max-width: 70px; text-align: center; }
#btn-touch-action.is-hidden { opacity: 0; transform: scale(0.6); pointer-events: none; animation: none; }
/* Muncul = berdenyut 3 kali lalu diam (penanda "bisa berinteraksi") */
@keyframes actionPulse { 50% { transform: scale(1.08); } }

/* ---------- Chat & emoji ---------- */
#social-hud-dock { position: absolute; left: calc(10px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); width: 330px; display: flex; flex-direction: column; gap: 6px; }
#chat-box { overflow: hidden; }
.chat-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; font-size: var(--fs-sm); font-weight: 900; color: var(--gold); cursor: pointer; }
.chat-header .chat-actions { display: flex; gap: 6px; }
.chat-header button { position: relative; height: 30px; min-width: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.05); color: var(--text-2); font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-sm); }
.chat-header button:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }
#chat-preview { font-weight: 700; color: var(--text-2); font-size: var(--fs-sm); flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#chat-body.minimized { display: none; }
#chat-messages { height: 120px; overflow-y: auto; padding: 4px 10px 6px; font-size: var(--fs-md); line-height: 1.4; user-select: text; touch-action: pan-y; }
.chat-line { margin-bottom: 3px; word-break: break-word; }
.chat-author { color: #8cc4ff; font-weight: 800; }
.chat-text { color: var(--text); }
.chat-system { color: var(--muted); font-style: italic; }
.chat-error { color: var(--bad-hi); font-weight: 700; }
.chat-item-link { font: inherit; font-weight: 800; padding: 0 4px; border: 0; border-radius: 4px; background: rgba(255, 255, 255, 0.08); color: inherit; }
.chat-sos-btn { position: relative; margin-left: 6px; min-height: 26px; padding: 2px 10px; font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 900; color: #fff; background: #c4352d; border: 1px solid #ff8a80; border-bottom: 2px solid #6e1515; border-radius: 6px; }
.chat-input-row { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line-2); background: rgba(0, 0, 0, 0.25); }
#chat-input { flex: 1; min-width: 0; min-height: 36px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line-2); background: #0b1019; color: var(--text); font-family: var(--font-ui); font-size: var(--fs-md); outline: none; user-select: text; }
#chat-input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 204, 96, 0.35); }
#emoji-bar { display: none; flex-wrap: wrap; gap: 4px; padding: 6px; }
#emoji-bar.is-open { display: flex; }
.emoji-btn { width: 36px; height: 36px; font-size: 1.2rem; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.05); transition: transform 0.1s; }
.emoji-btn:hover { transform: scale(1.1); background: rgba(242, 204, 96, 0.12); }

/* ---------- Toast: hasil aksi pemain sendiri (bawah tengah) ---------- */
#toast-stack { position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(520px, 92vw); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 8px; font-size: var(--fs-md); font-weight: 800; color: var(--text); background: rgba(24, 32, 48, 0.97); border: 1px solid var(--line-2); box-shadow: var(--shadow-hud); animation: toastIn 0.3s var(--ease-out); }
.toast.ok, .toast.err { padding-left: 12px; }
.toast.ok { border-color: rgba(63, 185, 80, 0.6); }
.toast.err { border-color: rgba(248, 81, 73, 0.6); }
.toast.ok::before, .toast.err::before { flex: none; display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-size: var(--fs-sm); font-weight: 900; }
.toast.ok::before { content: '✓'; background: #237a35; }
.toast.err::before { content: '!'; background: #c4352d; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
