What occurs for the delayed sway feeling is a downside of the compensating system in the boddy. Every time our sensors detect a movement or a change in load, position or gravity (so it's pretty continuous, otherwise you are dead or at least knocked out), the brain fine tunes its orders to adjust permanently all the muscles both in strength and length. Move an arm or rize the applied force, even a little, the muscles of the entire boddy adjust to follow the modification. Giant task for the brain, but mostly unnoticed by our conscious side. When a repeated influence affects us, like the wind's sway on a tree or the waves on a boat, the brain integrates progressively this periodic influence in his baseline. See that as a fluctuating zero on the scale.
That reduces the reaction time, smooths the moves and regularizes the stance, while saving a lot of computing resources. It really automatises the response at this part of all the variations monitored along the day.
But the brain doesn't modify his references easily. Otherwise, that would be counterproductive, saving nothing in his activity. Here comes the funny thing. Maybe not so funny, as you see it.
When we calm down, or go out of the periodic influence, the brain keeps his fluctuating baseline for a good while. So, the orders sent to the muscles still have this compensating part, now unnecessary. The sailors have the reputation to be subject to this problem when coming back on shore : they feel like drunk and have an hard time to walk straight on the quay, like they have initially an hard time to walk straigth on the ship at first.
Now, you are quiet in your bed, you are able to visualize all this compensation work, attenuated now because the brain has already began to rectify his baseline.
Actually, what you feel his that the surrounding doesn't move like your brain expects it through his sensors.
After some windy days on skinny trees, I even felt the wc seat moving at home. Weird feeling for sure!