/* Giao diện trong chùa (ui/hud.js): thanh số liệu, nút chức năng, thông báo, cần gạt */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; animation: fadeIn .6s ease; }
#hud button, #hud .panel { pointer-events: auto; }

#hud .top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
#hud .top span { display: flex; align-items: center; gap: 5px; }
#hud .top i { font-style: normal; font-size: 12px; }
#hud .top em { font-style: normal; color: var(--muted); }
#hud .top b { color: var(--gold); font-variant-numeric: tabular-nums; }

/* Hướng dẫn lúc mới vào: giữa dưới màn hình, không che tượng Phật */
#hud .tip { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text); background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); padding: 8px 8px 8px 14px; border-radius: 12px;
  max-width: calc(100% - 24px); width: max-content; transition: opacity .6s; animation: rise .5s var(--ease) .4s backwards; }
#hud .tip.fade { opacity: 0; }
#hud .tip button { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08);
  color: var(--muted); cursor: pointer; font-size: 12px; }
#hud .tip button:hover { color: var(--text); background: rgba(255,255,255,.16); }
#hud kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 1px; border-radius: 5px; border: 1px solid var(--line);
  border-bottom-width: 2px; font: 600 11px/1.4 system-ui, sans-serif; text-align: center; color: var(--gold); background: rgba(0,0,0,.25); }

/* Gợi ý theo chỗ đứng (ui/prompt.js) */
#hud .prompt { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--gold); background: rgba(36,24,12,.85); color: #fff3d6; font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 0 0 0 rgba(232,181,74,.5), var(--shadow); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: glow 2s ease-in-out infinite; transition: transform .12s var(--ease); white-space: nowrap; }
#hud .prompt.pop { animation: rise .3s var(--ease), glow 2s ease-in-out .3s infinite; }
#hud .prompt:active { transform: translateX(-50%) scale(.96); }
#hud .prompt kbd { margin-left: 6px; }
#hud:has(.panel:not([hidden])) .prompt, #hud:has(.chant:not([hidden])) .prompt, #hud:has(.chat.open) .prompt,
#hud:has(.tip:not([hidden]):not(.fade)) .prompt { display: none; }
/* Điện thoại: đang mở hàng nút "Thêm" thì cất gợi ý, hướng dẫn, khung chat cho khỏi đè lên */
#hud:has(.actions.more) .prompt, #hud:has(.actions.more) .tip, #hud:has(.actions.more) .chat { display: none; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(232,181,74,0), 0 0 18px rgba(232,181,74,.35), var(--shadow); } }
#hud .actions button.near { border-color: var(--gold); animation: glow 2s ease-in-out infinite; }
@media (hover: none) { #hud kbd { display: none; } }

#hud .toast { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(232,181,74,.95);
  color: #2a1a08; padding: 9px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); max-width: 90%;
  text-align: center; opacity: 0; translate: 0 -8px; transition: opacity .3s, translate .35s var(--ease); }
#hud .toast.show { opacity: 1; translate: 0 0; }

#hud .actions { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); right: max(14px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 8px; }
#hud .actions button { display: flex; align-items: center; gap: 10px; min-width: 140px; padding: 10px 14px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font-size: 14px;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .2s, border-color .2s, transform .15s var(--ease), color .2s; }
#hud .actions button i { font-style: normal; font-size: 17px; width: 22px; text-align: center; }
#hud .actions button:hover { border-color: var(--gold); background: rgba(48,32,18,.85); transform: translateX(-3px); }
#hud .actions button:active { transform: scale(.96); }
#hud .actions button.on { background: linear-gradient(#f0c35e, #c8902f); color: #2a1a08; border-color: transparent; font-weight: 600; }

#hud .actions .moreBtn { display: none; }

#hud .joy { position: absolute; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.25); transform: translate(-50%,-50%); pointer-events: none; }
#hud .joy .knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(232,181,74,.6); }

/* Điện thoại: số liệu chỉ còn biểu tượng, nút chức năng thành một thanh ngang dưới cùng */
@media (max-width: 600px) {
  #hud .top { gap: 12px; padding: 6px 14px; }
  #hud .top em { display: none; }
  #hud .tip { bottom: calc(var(--bar-h) + max(8px, env(safe-area-inset-bottom)) + 62px); font-size: 12.5px; }
  #hud .prompt { bottom: calc(var(--bar-h) + max(8px, env(safe-area-inset-bottom)) + 12px); font-size: 14px; padding: 9px 16px; }
  #hud .toast { top: 88px; font-size: 14px; }
  #hud .actions { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); flex-direction: row; gap: 2px;
    padding: 4px; height: var(--bar-h); background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
    box-shadow: var(--shadow); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); pointer-events: auto; }
  #hud .actions button { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 0;
    border: 0; border-radius: 14px; background: none; box-shadow: none; font-size: 10px; letter-spacing: -.2px; line-height: 1.15;
    -webkit-backdrop-filter: none; backdrop-filter: none; }
  #hud .actions button span { max-width: 100%; text-align: center; line-height: 1.05; overflow: hidden; max-height: 2.1em; }
  #hud .actions button i { font-size: 20px; width: auto; }
  #hud .actions button:hover { transform: none; background: none; }
  /* 5 nút đầu + "Thêm"; bấm "Thêm" thì các nút còn lại hiện thành hàng phía trên */
  #hud .actions button { flex: 0 0 calc((100% - 10px) / 6); height: 54px; }
  #hud .actions button:nth-child(n+6) { display: none; order: 2; }
  #hud .actions button.moreBtn { display: flex; order: 1; }
  #hud .actions.more { height: auto; flex-wrap: wrap-reverse; row-gap: 4px; }
  #hud .actions.more button:nth-child(n+6) { display: flex; animation: rise .2s var(--ease); }
  #hud .actions.more button.moreBtn { background: rgba(232,181,74,.18); }
}
