In a few weeks, fireflies will emerge from the grasses in the warmth of Minnesota's early summer nights. They'll emit their soft light in the intricate flashes and coded blinks they need to find each other during their short lives.

Those flashes, however, may be invisible under the growing glare of artificial light.

That's part of the reason firefly populations are falling across the continent. As many as one in three firefly species may be at risk of extinction in the United States and Canada. Scientists are trying to find out by exactly how much in Minnesota, where data on the bugs has been scarce. But much like native bees, butterflies and other pollinators, fireflies here are in a clear and unmistakable decline, according to the U.S. Fish and Wildlife Service.

The lightning bugs that once flashed so commonly in backyards and parks across the state are succumbing to some of the same perils that have devastated other insects, said Jill Utrup, a biologist with the Fish and Wildlife Service.

The intensive use of pesticides such as neonicotinoids, for instance, that began in the early 2000s can kill the bugs, especially when they're in their larval stage. Other pesticides destroy the snails and slugs they need as prey in the early part of their lives. The creatures have also lost a fair amount of habitat, Utrup said.

But the bioluminescent beetles also have to contend with an additional problem of their own: light pollution. Lights from new houses, businesses and urban sprawl are keeping fireflies from finding each other during the critical four- or five-week window they have to mate.

The night sky in Minnesota has been brightening for years. Worldwide, it brightened 9.6% annually from 2011 to 2022.

"What all that light does to them is different depending on the species of firefly," Utrup said. "In some, it interferes with their communication. Others are triggered by darkness, and they won't produce their own light until there's a suitable level of darkness."

Firefly flashes are not random.

Each species and sex emits a specific pattern, with subtle differences in the intensity, speed and color of the glow. There are seven firefly species in Minnesota and more than 100 in the U.S. When a female sees blinks that are just right, that are emitted by males of her species, she calls it over with a specialized code of her own.

Some predator species of fireflies have even learned to mimic the patterns of the others to lure them in and attack.

It doesn't take much light to upset their courtship. Even a full moon can make it hard for the beetles to display to one another, biologists have found.

Light pollution is particularly damaging because they have so little time to mate successfully, Utrup said.

They spend the vast majority of their lives in the soil, as glow worms that hunt smaller critters. They pupate in the spring a few inches underground and emerge as mature adults in late June. By early August, the fireflies will mostly be dead.

The next generation depends on whether the beetles can find each other during their brief window with wings and successfully lay eggs.

The best thing most people can do to keep fireflies around on summer nights is nothing, Utrup said.

Don't turn on outdoor lights in July. Don't pick up some fallen leaves and branches, but leave them in the yard for the bugs to shelter in. Close shades at night. Keep native shrubs and wildflowers in gardens, she said.