The reason your smartphone ruins your sleep is basically because your body is a big dumb machine that still thinks it’s living in caveman times.
Back in those days the sun would set and your body, sensing darkness, would release the sleep hormone melatonin. At sunrise, sensing bright light (via photoreceptors in your eyes called intrinsically photosensitive retinal ganglion cells), your body would block melatonin to wake you up.
Nowadays, bright artificial light — like the comforting glow of your phone — more or less tricks your body into thinking it’s daytime all the time, keeping you alert instead of sending you off to sleep.