Improved tooltip positioning, preventing them from being truncated at the screen edges.