Change of bin magnitude when phase of signal changes when doing FFT?

I am working on an implementation in which I need to apply an FFT to determine which of 4 frequencies are present in a signal.

I am doing a 64 point FFT on a buffer which only is partly filled (the remainder of the buffer is zero-ed).

When looking at the screenshots of the signal in the time domain, you will notice that the signal is roughly the same in each screenshot, but it has different phase in each screenshot.

When looking at the screenshots of the FFT of the two versions of the signal, you will notice that the magnitude for bin 4, which corresponds to the signal frequency, is 874.83 in one of the screenshots but 366.94 in the other, even though the only difference between the two versions of the signal is a phase difference (?)

I don't understands why this happens and how to deal with this. I am generating the signal myself and want to make sure that phase doesn't play a role here. When the signals are more or less the same in amplitude, I would expect their magnitude after calculating the FFT to stay the same.

In case you need this information, the sampling frequency is 7800 Hz and the actual frequency involved is 487.5 Hz which is exactly 7800/64*4, or the start of bin 4.

In the screenshots of the FFT, the magnitude data is plotted upside down (i.e. zero is the top of the screenshot).

Can anyone please shed some light on this? Thanks for helping! B