In this post in the Van Life Q&A, a user asks:
Does it have to be next to the bed? If, say it could be past your head on a counter or something? Or make a small pocket for the phone and have a cup holder for your cup? Etc.
Also, don’t use 2×4. It’s a waste of weight and it will bow so you need to support it anyway. Plywood or solid wood that is thinner (3/4″ pine for example) has more than enough strength on it’s edge if it’s tall enough. Go take a look at how motorhomes are built. They generally don’t use 2×4 at all.