Here are a couple of tips which I use when I encounter similar problems:
1- Play the melody forte and legato, and the accompaniment (in the same hand) as pianissimo as possible, and staccato. Don't be afraid of the melody sounding harsh, since this is just a practice drill to instill this difference in dynamics.
2- Play the melody while "Ghosting/Miming" the accompaniment. This means that you actually play the melody, but instead of playing the accompaniment, you just move your fingers like you would, but without actually pressing the keys. Trust me when I say this works.
3- Always think about how you want to shape the melody. The idea of phrasing should remain with you and should be instilled by first playing the melody on its on. Later on, you can experiment with how to vary the dynamics of the accompaniment.