What is the science behind Magic Cake? Magic Cake has a seemingly simple batter, that is mixed and baked as a single entity.  (See link for the full recipe and method).  When it is baked, it separates into three distinct layers: 


A dense bottom layer
A custard middle layer
A cakey top layer



(Photo and baking by Rfusca)

What is the science behind this?  How does the single batter separate and create three separate and well defined layers?

As many photos of various magic cakes show (such as those at the recipe author's Part II,  page), there is a definite edge effect on the layers, so it is not simply separation of components due to differing density.
In case you are interested, the magic comes at least partly from the milk.
I accidentally forgot to add it (but other than that, I followed the recipe to the letter), and I ended up with a regular vanilla cake, no layers at all.
I imagine this cake part should've been the (partly) the upper layer.

As milk is heavier than some of the other ingredients, it sinks to the bottom and creates the custard layer. I would like to expand this answer, with a remark on what we call 'flantaart', translated as 'custard pie'. There is one batter, and after baking, a well defined crust and a custard on top. I'll look it up when I get home, to look for similarities between the two recipes.