Anyone who's tried to go to sleep in a heatwave knows the sweaty agony that rising temperatures can bring. And global warming won't make it any easier to find a cool spot on the bed.

According to billions of sleep measurements from smartwatches around the world, high temperatures caused by climate change are already linked to substantial losses in sleep duration, equivalent to about 11 nights of shortened sleep each year.

Increasing nighttime temperatures will only make matters worse. By 2099, if nothing is done to curb fossil fuel emissions, researchers predict hot nights could erode up to 58 hours of sleep per person per year.

The losses were seen right across seasons, social demographics, and different climates, although warmer climates did exacerbate the problem.

In lower-income nations, with reduced access to electrical fans or air conditioners, the authors found more sleep loss from nighttime temperatures. Elderly individuals and females were also particularly vulnerable.

"In this study, we provide the first planetary-scale evidence that warmer-than-average temperatures erode human sleep," says lead author and behavioral scientist Kelton Minor from the University of Copenhagen.

"We show that this erosion occurs primarily by delaying when people fall asleep and by advancing when they wake up during hot weather."

The findings are based on data from the sleep trackers of more than 47,000 people spread across 68 countries. Over 7 million of their records were then compared to global meteorological data.

On very warm nights, greater than 30 degrees Celsius (86 degrees Fahrenheit), the authors found sleep duration declined by an average of 14 minutes.

Meanwhile, nighttime temperatures greater than 25 degrees Celsius slightly increased the probability of getting less than 7 hours of sleep.

The lost minutes of sleep might not seem like much on a daily basis, but in the long-term, they could add up to negatively affect human health and productivity.

Even just one night of sleep loss can impact a person's mental, emotional, and physical well-being.

And once you've slipped into sleep debt, it's hard to climb back out, even with a big old sleep-in.

"Our bodies are highly adapted to maintain a stable core body temperature, something that our lives depend on," explains Minor.

"Yet every night they do something remarkable without most of us consciously knowing – they shed heat from our core into the surrounding environment by dilating our blood vessels and increasing blood flow to our hands and feet."

But if the surrounding environment is warmer than we are, our bodies cannot shed heat while we sleep. On humid nights, it becomes even harder to dispel heat from the body.

The authors admit that their sample size isn't perfect. Wearable technology tends to be worn more by middle-aged men in higher-income nations. That said, the data offers an unprecedented insight into natural sleep patterns over the course of years.

Using 21 different climate models, researchers have taken the losses of sleep already seen from nighttime heat and projected them into the future.

In the worst-case scenario, sleep losses from nighttime heat will result in over 15 short nights of sleep per year. In the best-case scenario, we can keep it to about 13 short nights of sleep.

But that's just the average. Adults in the warmest regions of the world could experience an additional 7 nights of short sleep per year. And given that smartwatches are not as available in these parts of the world, that could be an underestimate.

"Future planetary-scale research is needed that systematically investigates the impact of rising temperatures and other climate hazards on the sleep outcomes of vulnerable populations, particularly those residing in low-income countries and communities," the authors conclude.

The study was published in One Earth.