How to handling overlapping small elements?

To be straight to the point, this is what my ideal UI will look like, two squares with information inside them: ui

Unfortunately, sometimes it won't always work this way and there will be some overlap resulting in this:

second ui

The information needs to be visually present in case of an overlap, i've tried thinking of a lot of solutions but this is one is a mind block for me. Does anyone have any ideas?

Thanks for your time!