/* =====================================================================
   UI fit + centre (2026-09-29) - loaded last.
   1) Every window opens in the middle of the screen. The older centring rules lost to the generic scale rule in
      <style id="novicia-cointh-scale"> (its :not(#id) parts count as ids), so windows opened with their top-left
      corner in the middle. A window the player drags (inline left / .dragging) stays where it was dropped until it
      is closed (the bundle forgets the spot on close, see Vf in main-*.js).
   2) Windows with the painted sky frame are sized like Settings: same width and scale, never taller than the
      screen, and their body scrolls (phones included) instead of the whole window shrinking.
   ===================================================================== */
#hud#hud#hud section.window:not(.minimap):not(#mm-profile-card):not(.death):not(#chat-window):not(.character):not([style*="left"]):not(.dragging) {
  inset: 50% auto auto 50% !important;
  margin: 0 !important;
  transform-origin: 50% 50% !important;
  transform: translate(-50%, -50%) scale(calc(var(--ui-zoom, 1) * var(--window-scale, 1) * var(--win-boost, 1) * var(--fit, 1))) !important;
}

/* same scale as Settings: 0.85 on computers, 0.62 on phones */
html body #hud#hud section.window:is(.painted-window, #settings-window, #bot-window) { --window-scale: 0.85 !important; --win-boost: 1 !important; }
@media (max-height: 520px), (max-width: 640px) {
  html body #hud#hud section.window:is(.painted-window, #settings-window, #bot-window) { --window-scale: 0.62 !important; }
}
html body #hud#hud section.window:is(.painted-window, #settings-window, #bot-window) {
  --nv-z: calc(var(--ui-zoom, 1) * var(--window-scale, 1));
  width: min(540px, calc((100vw - 16px) / var(--nv-z)), calc((100dvh - 24px) / var(--nv-z) * 1.5)) !important;
  max-width: none !important;
  max-height: calc((100dvh - 24px) / var(--nv-z)) !important;
}
html body #hud#hud section.window.painted-window .pw-body {
  max-height: calc((100dvh - 24px) / var(--nv-z) - var(--u) * 252) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* joystick a little lower (it sat too high above the EXP bar) */
html body #hud#hud #mobile-controls-layer .mobile-joystick { bottom: calc(var(--u) * 30) !important; }

/* FPS / Ping / players on the bottom line of the character card (hud_enhancements.js alignStatusUnderMinimap) */
#hud#hud #mm-profile-card .pc-status.has-net .pc-state { right: calc(var(--s) * 292) !important; }
#hud#hud #mm-profile-card .pc-status .pc-net {
  position: absolute !important; top: 50% !important; right: calc(var(--s) * 48) !important; left: auto !important; transform: translateY(-50%) !important;
  display: flex !important; align-items: center; gap: calc(var(--s) * 12); white-space: nowrap; pointer-events: none;
  font: 700 calc(var(--s) * 20) / 1 system-ui, 'Noto Sans Thai', sans-serif !important; color: #eaf3ff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#hud#hud #mm-profile-card .pc-net b { font: inherit !important; }
#hud#hud #mm-profile-card .pc-net b[hidden] { display: none !important; }
#hud#hud #mm-profile-card .pc-net b[data-q="good"] { color: #8dffb0; }
#hud#hud #mm-profile-card .pc-net b[data-q="ok"] { color: #ffe38a; }
#hud#hud #mm-profile-card .pc-net b[data-q="bad"] { color: #ff9a8d; }
#hud#hud #mm-profile-card .pc-net .pn-online { color: #cfe3ff !important; }
