/* Fit HUD cards to their contents, with money beneath the portrait. */
body.visor { --status-width: 260px; }
body.visor #hud #basic-info { width: var(--status-width); max-width: var(--status-width); align-items: flex-start; padding: 8px; gap: 8px; }
body.visor #hud #basic-info .bi-side { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 56px; flex: none; }
body.visor #hud #basic-info .bi-face, body.visor #hud #basic-info .bi-face canvas { width: 48px; height: 48px; }
body.visor #hud #basic-info .bi-face canvas { inset: 0; }
body.visor #hud #basic-info .bi-main { gap: 3px; }
body.visor #hud #basic-info .bi-id { flex-direction: column; align-items: flex-start; gap: 1px; padding-left: 0; min-height: 0; }
body.visor #hud #basic-info .bi-id b { font-size: 14px; line-height: 1.15; }
body.visor #hud #basic-info .bi-id span { font-size: 9px; line-height: 1.2; }
body.visor #hud #basic-info .bi-id span img { width: 11px; height: 11px; }
body.visor #hud #basic-info .bi-money { width: 100%; margin: 0; }
body.visor #hud #basic-info #bi-zeny { font-size: 10px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
body.visor #hud #basic-info .bi-foot { min-height: 0; }
body.visor #hud #basic-info .bi-foot:has(#bi-trait:not([hidden])) { flex-wrap: wrap; gap: 2px; }
body.visor #hud #basic-info #bi-trait { flex: 0 0 100%; margin: 0 !important; line-height: 1.2; }
body.visor #hud #basic-info .pt { padding: 1px 6px; font-size: 10px; }
body.visor #hud #basic-info .gauge.hp { height: 12px; }
body.visor #hud #basic-info .gauge.sp { height: 11px; }
body.visor #hud #basic-info .xrow { grid-template-columns: 44px minmax(0, 1fr) 32px; gap: 4px; }
body.visor #hud #basic-info .xrow label, body.visor #hud #basic-info .xrow > span { font-size: 9px; }
body.visor #hud #basic-info .bi-exp { gap: 2px; }
body.visor #hud #basic-info .bi-face em { min-width: 20px; height: 18px; font-size: 9px; line-height: 16px; padding: 0 4px; }

body.visor:not(.pad-mode) #hud #quest-track,
body.visor:not(.pad-mode) #hud:has(#buffs .buff) #quest-track { width: var(--status-width); padding: 6px 8px; }
body.visor:not(.pad-mode) #hud #quest-track .qt-tabs { gap: 4px; margin-bottom: 4px; padding: 2px !important; }
body.visor:not(.pad-mode) #hud #quest-track .qt-tab { min-height: 24px; padding: 2px 6px; font-size: 10px; }
body.visor:not(.pad-mode) #hud #quest-track .qt-ch { font-size: 10px; margin-bottom: 3px; }
body.visor:not(.pad-mode) #hud #quest-track .qt-title { font-size: 12px; line-height: 1.25; }
body.visor:not(.pad-mode) #hud #quest-track .qt-obj { font-size: 11px; line-height: 1.3; }

body.visor #hud #menubar .menu-panel { width: 200px; padding: 8px; }
body.visor #hud #menubar .menu-heading { font-size: 10px; margin-bottom: 6px; }
body.visor #hud #menubar .menu-grid { gap: 4px; }
body.visor #hud #menubar .menu-grid > button { height: 48px; padding: 4px 2px; }
@media (min-width: 761px) {
  body.visor:not(.pad-mode) #hud #hud-toggle { left: calc(var(--status-width) + var(--hud-edge) + var(--sl) + 8px); top: calc(var(--hud-edge) + var(--st)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  body.visor { --status-width: min(230px, calc(100vw - 206px - var(--sl) - var(--sr))); }
  body.visor #hud #basic-info { padding: 6px; gap: 6px; }
  body.visor #hud #basic-info .bi-side { width: 42px; }
  body.visor #hud #basic-info .bi-face, body.visor #hud #basic-info .bi-face canvas { width: 36px; height: 36px; }
  body.visor #hud #basic-info .bi-id b { font-size: 12px; }
  body.visor #hud #basic-info .xrow { grid-template-columns: 34px minmax(0, 1fr) 25px; gap: 2px; }
  body.visor #hud #basic-info .xrow label, body.visor #hud #basic-info .xrow > span { font-size: 8px; }
  body.visor #hud #basic-info .pt { font-size: 9px; padding-inline: 3px; }
  body.visor #hud #menubar .menu-panel { width: min(240px, calc(100vw - var(--sl) - var(--sr) - 16px)); }
}
@media (orientation: landscape) {
  body.visor.pad-mode { --status-width: 208px; }
  body.visor.pad-mode #hud #basic-info { padding: 6px; gap: 6px; }
  body.visor.pad-mode #hud #basic-info .bi-side { width: 42px; }
  body.visor.pad-mode #hud #basic-info .bi-face, body.visor.pad-mode #hud #basic-info .bi-face canvas { width: 36px; height: 36px; }
  body.visor.pad-mode #hud #basic-info .bi-id b { font-size: 12px; }
  body.visor.pad-mode #hud #basic-info .xrow { grid-template-columns: 36px minmax(0, 1fr) 28px; gap: 3px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  body.visor:not(.pad-mode) { --status-width: 208px; }
  body.visor #hud #menubar .menu-panel { width: 208px; }
  body.visor #hud #menubar .menu-grid > button { height: 44px; }
}
@media (orientation: portrait) and (max-width: 360px) {
  body.visor #hud #basic-info { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 3px; }
  body.visor #hud #basic-info .bi-side, body.visor #hud #basic-info .bi-main { display: contents; }
  body.visor #hud #basic-info .bi-face { position: relative; inset: auto; grid-column: 1; grid-row: 1; }
  body.visor #hud #basic-info .bi-face, body.visor #hud #basic-info .bi-face canvas { width: 32px; height: 32px; }
  body.visor #hud #basic-info .bi-id { grid-column: 2; grid-row: 1; padding-right: 14px; }
  body.visor #hud #basic-info .bi-id b { font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
  body.visor #hud #basic-info .bi-main > .gauge, body.visor #hud #basic-info .bi-exp, body.visor #hud #basic-info .bi-foot { grid-column: 1 / -1; }
  body.visor #hud #basic-info .bi-money { grid-column: 1 / -1; grid-row: 6; }
}
/* ป้าย BASE/JOB กว้างตามตัวเลข (เจ้าของ 2026-10-11 "Base 25 ทับหลอด exp") — เลเวล 2–3 หลักไม่ล้นทับแถบ */
body.visor #hud #basic-info .xrow { grid-template-columns: max-content minmax(0, 1fr) max-content !important; }
body.visor #hud #basic-info .xrow label { width: auto !important; min-width: 0; }
