People who spend more time looking at a screen in bed are more likely to report insomnia and sleep loss, a study has found.