Plague : one way of doing the ghosting would be to record the key presses (up or down) that a player does and record the time (relative to the start of the turn, current_time - beginning_time) when that event happened. You could store that info into a string by appending to the string every time that event happens, and separate the info with commas to separate events and a ! for separating the time from the event type. At the end of the turn, your string would eb something like:
Where L is a code for the Left key, D is key down, U is key is up and the numbers are the seconds since the start of the turn. Now for smarthphone, I am not sure what events you will use to move the player, but you can use the same idea. When the turn ends, you can send the string via AJAX to your custom server (you or somebody will have to write the server-side code) and when the other player (player2) can chooses to refresh his screen to receive any new data, your C2 code will need to do another Ajax request to ask for any new data.
Your server side code will need to return the string sent by the other player. Once the string arrives at player2 via Ajax, you can devise something to split the string into arrays and then call each of the events at the time associated with them by using the compare "Compare Time" condition to compare the relative time with the time registered in the string for the 1st event.
The above is a very high level overview of what you could do, it will take you some time to tune up by trial and error and may or not work for you.