AFAIK this problem only applies when working with Wayland, but you can use this solution in Xorg as well if it occurs.
There is a close button in Firefox titlebar:
It looks kinda out of place, especially when using a standalone Wayland compositor such as Niri or Hyprland.
You can remove this button and spacing to the left of it with the following CSS.
