Near the summit of Cerro Galera in Panama lives a golden beetle that can turn itself brick red in under two minutes. While other bugs may change color due to external circumstances like temperature, the Panamanian tortoise beetle is one of the few creatures known to control its own color changing. The beetle’s secret? It can alter the flow of fluid in its exoskeleton, scientists recently revealed.

The key lies in the way light reflects off the beetle’s exoskeleton, which consists of 20 to 40 layers. When light of different wavelengths bounces off the multiple layers, the beetle displays its normal golden sheen—but only when the porous patches within the layers are wet. When the beetle dries out its exoskeleton, the light no longer bounces off evenly, foiling the shiny, golden, mirrorlike effect. Instead, light reflects off the layers in such a way that the shell becomes translucent, revealing red pigment beneath. Researchers do not know the purpose of the color change but they suspect it might scare off predators by mimicking a poisonous insect.

Jean-Pol Vigneron, a physicist from the University of Namur in Belgium who is studying the beetle, says, “The beetle teaches us that there is a possibility to develop materials that dramatically change color with humidity.” Among them: flowerpots whose color warns when the soil is drying out, blackboards using water instead of chalk that could be erased by a pulse of heat, and even cars that change color in the rain.