To use the iPhone's sleep timer, set a time in the Clock app's timer, and set the When Timer Ends option to Stop Playing.
You can limit screen time on your iPhone using the "Screen Time" feature, which will lock your apps and make them temporarily unusable. Here's how.