Environmental complexity mitigates the demographic impact of sexual selection

Sexual selection and the evolution of costly mating strategies can negatively impact population viability and adaptive potential. While laboratory studies have documented outcomes stemming from these processes, recent observations suggest that the demographic impact of sexual selection is contingent on the environment and therefore may have been overestimated in simple laboratory settings. Here we find support for this claim. We exposed copies of beetle populations, previously evolved with or without sexual selection, to a 10-generation heatwave while maintaining half of them in a simple environment and the other half in a complex environment. Populations with an evolutionary history of sexual selection maintained larger sizes and more stable growth rates in complex (relative to simple) environments, an effect not seen in populations evolved without sexual selection. These results have implications for evolutionary forecasting and suggest that the negative demographic impact of sexually selected mating strategies might be low in natural populations.


I N T RODUC T ION
Sexually selected traits offer benefits in reproductive competition but often impose costs on their bearers and may be regarded as wasteful in the eyes of natural selection (Andersson, 1994;Zahavi, 1975).Classic examples are the peacock's train and the giant antlers of the now-extinct Irish elk-traits that likely are both costly to develop and wield.Wasteful investments such as these have been suggested to impair population health and increase the risk of species' extinction by making the sex most exposed to sexual selection less viable (Kokko & Brooks, 2003;Rankin & López-Sepulcre, 2005).Indeed, the question of how sexual selection affects adaptive potential has a long history in evolutionary biology that is currently receiving muchrenewed interest due to contemporary climate change, which is forcing many species to rapidly adapt or otherwise face extinction (Parmesan, 2006;Urban, 2015).
Although there are many exceptions to the rule, males typically experience stronger sexual selection than females (Winkler et al., 2021), especially in species with mating systems prone to high levels of mate competition (Andersson, 1994;Clutton-Brock & Parker, 1992).However, correlative studies using phylogenetic methods to investigate the link between sexually selected male traits and extinction rate have provided disparate results (e.g. higher rates of extinction in ostracods (Martins et al., 2018) but no effect in birds (Janicke et al., 2018)).Part of the explanation for these discrepancies may be that sexual selection also can have positive genetic effects on population viability.This assumption relies on that sexually selected traits act as honest signals of the quality and condition of their bearers (Andersson, 1994;Zahavi, 1975).If so, sexual selection for elaborate traits could effectively weed out individuals carrying maladaptive alleles from the gene pool (Rowe & Houle, 1996;Tomkins et al., 2004), lowering genetic load and increasing population viability (Whitlock & Agrawal, 2009).Indeed, positive genetic effects of sexual selection on population viability have been observed in a range of experimental evolution studies (Cally et al., 2019), and theory shows that strong purifying sexual selection on male genetic quality can speed up adaptation to environmental change (Lorch et al. 2003).
Adding to this complexity, sexual selection can also impose direct fitness costs in populations via intense mate competition and sexual conflict over (re)mating rates, where the sex that competes most intensely (often males) evolves adaptations to gain extra matings at the viability cost of their mating partners (often females) (Arnqvist & Rowe, 2005).Known examples of such male adaptations include harmful genitalia that scar females during mating (Stutt & Siva-Jothy, 2001), or aggressive mate guarding to reassure paternity (Blum, 2012).Recent theoretical studies have shown that this type of sexual conflict could lead to increased extinction risk in already maladapted populations (Flintham et al., 2023;Gómez-Llano et al., 2023;Martínez-Ruiz & Knell, 2017).Moreover, as males of high genetic quality are likely to impose more harm to their female mates compared to males of low quality (Baur et al., 2022;Londoño-Nieto et al., 2022;Yun et al., 2017), this effect could cancel out or even outweigh any potential population benefits of purifying sexual selection on male genetic quality (Chenoweth et al., 2015;Flintham et al., 2023).
Due to this complexity, our understanding of how sexual selection impacts the resilience of threatened populations in demographic decline remains poor (García-Roa et al., 2020;Rowe & Rundle, 2021;Svensson, 2019).One contributing factor to this knowledge gap is the difficulty of systematically assessing the effects of sexual selection on population dynamics, limiting inferences to studies using laboratory settings that lack the typical complexity found in natural environments.Yet, some recent studies have found that sexual conflict can be reduced as environmental conditions become increasingly complex, leaving individuals with more opportunities to adjust their behaviours in accordance with the level of reproductive competition (MacPherson et al., 2018;Yun et al., 2017).This suggests that the negative demographic impact of sexual selection may be overestimated in simple laboratory settings.However, few studies have explored these effects while incorporating demographic processes at the level of whole populations.
Here, we, therefore, studied population dynamics in the seed beetle, Callosobruchus maculatus, to explore how a history of genetic adaptation under sexual selection impacts the potential for evolutionary rescue in simple and complex environments.To achieve this, we created 48 replicate populations from experimental evolution lines previously maintained either with both natural and sexual selection (N + S regime) or with only natural selection and sexual selection experimentally removed (N regime).We then exposed these populations to a multi-generational heatwave while maintaining half of them in a simple environment and the other half in a complex environment (Figure 1).

Predictions
The N + S regime has evolved increased fecundity and fertility, indicative of high genetic quality (Baur et al., 2023;Martinossi-Allibert et al., 2019).However, it has also evolved excessive expression of costly pre-and postcopulatory male traits (Bagchi et al., 2021;Baur et al., 2019;Baur & Berger, 2020;Koppik et al., 2023).For example, N + S males suffer reductions in fertility when reared together with other conspecific males (Baur et al., 2023), and N + S females have evolved immune responses as counteradaptations to the genital scaring caused by males during mating (Bagchi et al., 2021) (Figure 1b).We, therefore, predicted that N + S populations (relative to N populations) would be able to maintain higher potential growth rates and viability during the heatwave, due to their overall greater genetic quality and investment in reproduction.However, for the same reason, N + S populations should also be more negatively impacted by the costs of mating.We, therefore, further predicted that N + S populations would benefit (relative to N populations) from the complex environmental setting allowing more opportunities for individuals to modulate their behaviours and escape costly mating interactions.Hence, more generally, we expected that the net effect on population viability of the positive (genetic quality) and negative (cost of mating) effects of adaptation to sexual selection would be contingent on the complexity of the environment.

Study system
C. maculatus males are known to compete fiercely over access to females, leading to high levels of promiscuity and postcopulatory sexual selection.Both male mate search (Baur et al., 2019) and sperm regeneration rates (Baur & Berger, 2020) evolve in response to sexual selection in C. maculatus and are associated with increased metabolic expenditure (Immonen et al., 2016) and shortened lifespan (Maklakov & Bonduriansky, 2009).Females show a noticeable kicking behaviour upon a mating attempt by a male, and potentially cryptic female choice (Lieshout et al. 2014).Remating can have both positive and negative effects on female longevity and fecundity via substances in the male ejaculate (Goenaga et al., 2015;Yamane et al., 2015), and the male genital spines evolve to be more elaborated under postcopulatory sexual selection (Hotzy & Arnqvist, 2009)

Experimental evolution
To study mating system evolution in this species, experimental evolution lines were created in 2015 from a genetic stock isolated from a single natural population as 41 isofemale lines sampled from Lome, Togo (Berger et al., 2014).There is abundant standing genetic variation for male and female fitness traits in this population (Berger et al., 2016;Grieshop & Arnqvist, 2018), and sexual conflict over mating is rife in laboratory conditions (Berger et al., 2016).The 41 isofemale lines were mixed to create three large, outbred founder populations.From each of these founders, one experimental line was created and kept under a polygamous mating regime (including natural and sexual selection, henceforth: N + S lines) while another line was kept under enforced monogamy (including only natural selection, henceforth: N lines), resulting in six experimental lines in total (Figure 1a).Larval density and effective population size were controlled and equalized among the two evolution regimes (Martinossi-Allibert et al., 2019).All lines and experimental populations (see below) were maintained at a constant 29°C, a 12:12LD cycle and 50% humidity unless otherwise stated.For a more extensive description F I G U R E 1 Experimental evolution lines and design of the heatwave experiment.(a) Three founding populations were created from a lab stock newly sampled from Lome, Togo.The three founders were expanded to large size over two generations after which two lines were created from each founder; one kept under a monogamous mating regime, including only natural selection (N lines), and one kept under polygamy, including both natural and sexual selection (N + S lines), for a total of 90 generations of experimental evolution.(b) These lines have diverged significantly in their reproductive strategies, with N + S lines showing signs of higher genetic quality, but also more sexual conflict and greater investment in costly mating traits (see also Supporting Information S1).(c) Following experimental evolution, each of the six lines was split up into 8 replicate populations, four placed in a "simple environment" treatment and the other four placed in a "complex environment" treatment, where egg-laying substrate (host beans) had been diluted 4 times to provide a three-dimensional mase structure to lower population density and sociosexual interactions while increasing demands on mate and host search.(d) The 48 replicate populations were exposed to a 10-generational heatwave with a temperature rise according to the thick black line and the right-hand y axis (temperature changed in the following order across generation: 29, 33, 34, 35, 36, 36, 37, 36, 36, 36°C).Population dynamics were tracked in generations 2-7 (up until a major extinction event at generation 7) and extinction was recorded at the end of the experiment (generation 10).Reproductive traits (fecundity, egg hatchability and larval survival) were recorded in generations 5 and 7 to give insights into what caused populations to fluctuate and go extinct, respectively.Shown is the mean population size for replicate populations deriving from N + S (turquoise) and N (salmon) lines in the simple (hatched) and complex (full) environmental treatment.

Experimental heatwave
At the start of the experiment, the lines had undergone 84 generations of experimental evolution, interspaced with six generations of common garden polygamy selection, two of these generations occurring just prior to the artificial heatwave to remove parental effects (the other four due to logistic limitations on implementing the selection protocol throughout the 7 years of experimental evolution).We created eight replicate copies from each of the six experimental lines (48 populations in total) and exposed them to a simulated heatwave until a critical thermal limit was reached (Figure 1c).Half of the lines were placed in a "simple environment" treatment at an effective population size similar to that used in the original experimental evolution design (N = 240, in 1litre glass jars containing 150 mL of black-eyed beans) (Martinossi-Allibert et al., 2019).The other half of the lines were placed in a "complex environment" treatment, with the same amount of host beans and adult beetles transferred.To increase complexity, beans were diluted with 500 mL of non-palatable (but harmless) substrate (penne pasta) to create a structure including cavities and tunnels (Figure S2).This structure forced beetles to search for host beans and mates, with increased opportunities for individual beetles to seek shelter from sociosexual interactions.The 48 populations were then exposed to the experimental heatwave (Figure 1d).No manipulation of the mating system was done during the experimental heatwave.The populations thus engaged in mating interactions according to their mating system parameters shaped by the previous 84 generations of experimental evolution.C. maculatus is distributed throughout the tropical and subtropical regions of the world and preferred temperatures range from 25 to 33°C (Fox et al., 2006;Vasudeva et al., 2014), with negative fitness effects appearing beyond this temperature (Lale & Vidal, 2003;Loganathan et al., 2011).We, therefore, acclimated all populations at 29°C with a natural (ancestral) polygamous rearing protocol before moving 240 newly emerged adults of each population replicate into 33°C for the first experimental generation of the heatwave whereupon temperature was raised gradually to chronically stressful 37°C (Berger et al., 2021) and then lowered again to 36°C (due to very high extinction rates-see below and Figure 1d).We tracked all 48 population replicates throughout 10 generations and registered the censused population sizes, population oscillations, reproductive traits, and extinction risk (see below).As an additional reference, we kept copies of the six ancestral lines at the same census size (N = 240) in the simple environmental treatment at the original 29°C throughout the heatwave.
All these 6 lines survived and prospered across the 10 generations (and beyond, producing >1000 new adults each generation), demonstrating that the population decline of the 48 experimental populations was induced by the heatwave (and its interaction with the mating system and environmental complexity) per se.
All analyses described below were carried out in R (v. 3.6.1;R Core Team, 2020).Figures were made with the R package ggplot2 (Wickham, 2016).

Censused population size
All but six populations went extinct following generation 7, when the temperature was raised to chronic 37°C.We, therefore, first analysed effects on population size over generations 2-7 by recording the number of emerged adults transferred to a new jar in each generation; with 240 individuals taken as the maximum, or as many as possible if this number was not reached.Development time in the studied temperature interval typically ranges between 19 and 24 days (Berger et al., 2021).We, therefore, transferred beetles at days 21 and 23, to make sure that early emerging beetles would not age too much before the transfer, and that late developing populations would not go extinct.We applied a nested ANOVA to estimate the effects of mating regime, environmental complexity, and generation (fitted by a fifth-degree polynomial), including all interactions among these variables.Additionally, we included the effects of the four shelves where jars were placed in the climate cabinet and the identity of the three founding populations as fixed terms.Evolution line replicate (nested in regime) crossed with environmental treatment and generation were specified as error terms.The response variable was approximately normally distributed, and the data completely balanced (model summary in Supporting Information S3).

Population oscillations
We explored temporal population dynamics by calculating oscillations in per capita growth rates.Two petri dishes with ca.Thirty-five beans were isolated from each population once parental beetles had laid all their eggs and the number of adult offspring produced per bean was counted for each dish.Per capita growth rate was then calculated as: [estimated number of offspring produced for the whole jar] / [censused number of adults in the previous generation].This provided us with two repeated measures per population and generation that allowed us to estimate variability in growth rate of populations as these varied in size and density throughout the experiment.These population oscillations were quantified as both the range and standard deviation in growth rate values of each population throughout the heatwave (see Results).The data were analysed in nested ANOVAs with the same structure as described above.Both response variables were logtransformed prior to analysis to improve normality.As most populations crashed and went extinct after generation 7 (growth rate = 0 for 41/48 populations), we analysed oscillations in generations 2-6.

Reproductive traits
The isolation of beans in Petri dishes each generation allowed us to explore the mechanistic basis for variability in population size throughout our experiment.At generation 5 (temperature raised to 36°C), most populations experienced a decline in numbers but bounced back, and after generation 7, most populations went extinct.In these two generations, we, therefore, counted the number of eggs laid on 10 random beans from each petri dish, and the hatching success of those eggs.Three measures with impact on population viability were then calculated: fecundity (number of eggs per bean; analysed as a normally distributed response), egg hatchability (analysed as a binomial response) and larval survival (emerged adults / estimated number of larvae emerging from eggs; analysed as a normally distributed response after square-root transformation).In generation 5, larval survival was not possible to estimate for 7/96 dishes as no eggs had hatched, and in generation 7 there were many assays without any hatched eggs (most populations went extinct following this generation), precluding formal analysis of differences in larval survival.This unbalanced data was analysed in Bayesian mixed effects linear models using the MCMCglmm package (Hadfield, 2010).We used the same structure for the random effects as described for the nested ANOVAs above with the addition of adding the jar identity as an additional random effect, as there were two replicate assays per jar in each generation.We used weak and flat priors for all random effects as recommended (Hadfield, 2010).Additionally, we also performed additional analyses comparing the reproductive traits of the 6 surviving and 42 extinct populations.
We note here that, because time was given so that all offspring could emerge from the petri dishes before freezing the assays, early emerging offspring may have mated and laid eggs on the beans in the assay.The time until the assays were frozen was likely not long enough for the eggs of the offspring generation to have hatched.The reported measures of fecundity and egg hatchability therefore likely represent over-and underestimations of the true trait values, respectively.It is thus possible that healthy populations having high fecundity could be scored as having lower egg hatchability.However, we correlated the total number of eggs laid in each dish with the hatching success, and that correlation was positive for all 8 combinations of regime, treatment and generation, suggesting that this issue was minor.We, therefore, chose to present this data but caution against making too strong inferences from it.

Extinction risk
We analysed the effects of mating regime, environmental treatment and founder on extinction risk at the tenth (final) generation of the experiment.We used the MCMCglmm package, with a binomial response (extant or extinct) and the same structure for fixed and random terms as described above.

R E SU LT S Evolution under sexual selection results in both high genetic quality and increased costs of mating
To first confirm that the experimental evolution regimes have diverged along phenotypic axes associated with both genetic quality as well as costly mating traits, we calculated line means for reproductive phenotypes previously scored throughout generations 16-68 of experimental evolution and performed a multivariate analysis on these (Supporting Information S1).Variation in these traits was mainly described by a single principal component, which clearly separates N + S and N lines (Figure 1b; Table S1).This separation in multivariate trait space is unlikely due to chance (p-value based on randomization: p = 0.002) and shows that N + S lines have evolved increased reproductive capacity but also greater investment in costly mating traits.

Environmental complexity modulates the effect of sexual selection on population dynamics
There was a significant interaction between mating system evolution and environmental treatment on the census population size (regime: treatment: F 1,4 = 8.73; p = 0.042).Moreover, there was a significant three-way interaction highlighting that the effect was most pronounced in generations 4-6, where raised temperatures caused reductions in population size (regime:treatment:generation: F 5,20 = 4.77, p = 0.005).In accordance with our hypothesis, these population dynamics were driven by larger census sizes of N + S populations when in the complex environment compared to the simple environment, an effect not seen in the N populations (Figure 2).We also analysed these data by treating generation as a discrete variable and zooming in on generations 4-6, which rendered the same qualitative results (Supporting Information S3).
Our estimates of per capita growth rate indicated that there were also more oscillations and instability in populations reared in the simple environment compared to the complex environment (Figure 3), as expected if environmental complexity buffers the negative effects of harmful sociosexual interactions at high population density.Indeed, formal analysis of these dynamics provided evidence for greater oscillations in the simple environment than the complex environment, when oscillations were analysed both as each replicate population's standard deviation (F 1,4 = 12.0, p = 0.026, Figure 3a) or range between its minimum and maximum recorded growth rate (F 1,4 = 8.34, p = 0.045, Figure 3b).Moreover, F I G U R E 2 Population census size throughout the heatwave experiment.At each generation, 240 individuals (or as many that had survived) were transferred to a new jar.As the temperature increased, populations were not able to maintain a positive growth rate and finally crashed.However, population dynamics were dependent on both environmental complexity and mating system evolution, with N + S populations maintaining a higher growth rate in the complex environment compared to the simple environment during generations 4-6 (where temperatures increased from 34 to 36°C), an effect not seen in the N populations.At generation 7, temperature was increased to 37°C, after which all but six populations eventually went extinct.Shown are the mean censused population size for N (salmon) and N + S (turquoise) populations in the simple (hatched lines) and complex (full lines) treatments.The shaded area around each line represents one standard error according to the default "loess" smoothing function of the ggplot2 package, based on the four replicate populations for each founder and regime: treatment combination.

F I G U R E 3
Population growth rates throughout the heatwave experiment.As the temperature increased, populations were not able to maintain positive growth and finally crashed.However, population dynamics during generations 2-6 were dependent on both environmental complexity and mating system evolution, with population oscillations and instability reduced in N + S populations when maintained in the complex environment compared to the simple environment, an effect not seen in the N populations.This was true when population instability was analysed as the standard deviation in recorded growth rate over generations 2-6 for each population (a), or its range for the same period (difference between minimum and maximum growth rate) (b).In (c), growth trajectories are shown for all individual N (salmon) and N + S (turquoise) populations in the simple (hatched lines) and complex (full lines) treatments, separately for each of the three founders.At generation 7, the temperature was increased to 37°C, after which only six populations eventually survived (highlighted in black colour).Five of these six survivors derived from founder 3. populations deriving from N + S showed significantly greater differences in oscillations between the simple and complex environment, both when analysed as the standard deviation (regime: treatment interaction: F 1,4 = 8.90, p = 0.041) and the range (regime: treatment interaction: F 1,4 = 8.29, p = 0.045) in growth values (Supporting Information S3).
Our detailed census of reproductive traits in generation 5 revealed no differences in fecundity between mating regimes (P MCMC = 0.76) or environments (P MCMC = 0.77), nor any interaction between the two (P MCMC = 0.64), with high fecundity and an average of ca.Eleven eggs laid per inspected bean (Figure 4a).For egg hatchability, there was a tendency for lower hatchability in the simple environment, but the effect was not significant (P MCMC = 0.10), nor were there any significant effects of regime (P MCMC = 0.23) or the interaction between regime and environmental treatment (P MCMC = 0.56; Figure 4b).For larval survival, there was a non-significant tendency for lower viability in the simple environment (P MCMC = 0.066) but no effect of regime (P MCMC = 0.72), or the interaction between regime and environmental treatment (P MCMC = 0.79; Figure 4c), echoing the results on egg hatchability.We combined the information on egg and larval viability to calculate a composite measure of juvenile viability for each petri dish (i.e.egg-toadult survival), and this metric did indeed demonstrate significantly lower viability in the simple environment (P MCMC = 0.01).

Extinction risk under lethal temperature is contingent on founding genetic variation
Following generation 7, when the temperature had been raised to 37°C, most populations were either severely bottlenecked or went extinct.Only six populations survived the entire heat wave experiment, with half of these deriving from N lines (one from the simple and two from the complex environment) and half from N + S lines (two from the simple and one from the complex environment).As follows, there were no effects of environmental complexity nor regime on extinction risk (all p > 0.9).However, five populations were derived from founder 3, and the probability that this biased contribution would have happened by chance is 0.035, suggesting that the survival of these populations was contingent on segregating ancestral genetic variation (Figure 3c).
Our census in generation 7 showed that fecundity was generally very low (eggs per bean, mean = 1.66, median = 0.90) but revealed no differences between regimes or environments (all P MCMC >0.5, Figure 5a).However, for egg hatchability, there was a significant interaction between regime and environmental treatment (P MCMC = 0.026).This effect was to large extent driven by N + S populations showing higher hatchability in the simple environment (Figure 5c), an observation that was counter to our predictions and opposite to the patterns detected for population size and reproductive traits in generations 4-6 (Figures 2-4).The comparison of reproductive traits between extinct (n = 42) and extant (n = 6) populations in generations 5 and 7 revealed a strong and significant interaction between status (extinct or extant) and generation, for both fecundity (P MCMC <0.001, Figure 5b) and egg hatchability (P MCMC <0.001, Figure 5d).The 6 surviving populations showed higher viability than the extinct populations at generation 7, but surprisingly, lower viability at generation 5.

DI SC US SION
Sexual selection can have both positive and negative effects on population viability.Positive genetic effects are expected due to a reduction in genetic load via genic capture of sexually selected traits (Rowe & Houle, 1996; F I G U R E 4 Reproductive traits at generation 5. To gain insights into what caused variability in population size among experimental populations in generations 5-6 (temperature kept at sublethal 36°C), we scored fecundity (a), egg hatchability (b) and larval survival (c) in generation 5. Shown are means ± 1SE for each founder 1-3 separately, based on the 4 replicate populations deriving from the N (salmon) or N + S (turquoise) regime, for the complex and simple treatment.Note that shelf effects have not been removed in the figure.Tomkins et al., 2004) whereas negative genetic effects can from trade-offs and excessive expression of sexually selected weapons, ornaments, displays or other mating behaviours (Andersson, 1994;Zahavi, 1975).Experimental evolution studies comparing populations evolving under monogamy and polygamy are a testament to the fact that these two effects often simultaneously impact population viability (Chenoweth et al., 2015;Whitlock & Agrawal, 2009) and the multivariate comparison of our experimental evolution lines confirms that evolution under sexual selection in C. maculatus follow these general predictions closely (Figure 1b).Recently, theoretical studies have highlighted the additional role of sexual selection in impacting population demography via costly sociosexual interactions arising from mating competition (Flintham et al., 2023;Gómez-Llano et al., 2023;Martínez-Ruiz & Knell, 2017).Such demographic impact is predicted to be particularly important when it coincides with episodes of rapid environmental change that necessitate evolutionary rescue (Martínez-Ruiz & Knell, 2017;Svensson & Connallon, 2019).
We predicted that this negative demographic impact can be mitigated by environmental complexity and increased opportunities for individuals to modulate behaviour in response to the intensity of mating interactions and that this effect would become more apparent and of greater importance during rapid environmental change and population decline (Londoño-Nieto et al., 2022;Martínez-Ruiz & Knell, 2017;Svensson & Connallon, 2019).We found evidence for this prediction, with N + S populations derived from sexually selected experimental evolution lines maintaining higher census sizes (Figure 2) and more stable growth rates (Figure 3) when reared in complex environments under the heatwave, compared to N population derived from monogamous lines.The maintenance of larger population size and reduced population oscillations limits demographic stochasticity and the risk of genetic F I G U R E 5 Reproductive traits at generation 7. To gain insights into what caused populations to go extinct (or survive) in the final generations of the heatwave following acute thermal stress, we scored fecundity (a) and egg hatchability (c) in generation 7. Shown are means ±1SE for each founder 1-3 separately, based on the extant 3-4 replicate populations deriving from the N (salmon) or N + S (turquoise) regime, for the complex and simple treatment.In (b) and (d), differences between the 6 surviving and 42 extinct populations are compared in generations 5 and 7.  bottlenecks that otherwise can place small populations in an extinction vortex (Bürger & Lynch, 1995;Kokko et al., 2017), suggesting environmental complexity may protect polygamous species from extinction.More generally, our results illustrate how the complexity of the environment can impact the balance between sexual selection's positive genetic effects through the purging of deleterious alleles in males (Lorch et al. 2003;Whitlock & Agrawal, 2009), and its negative demographic effects via costly mating interactions (Arnqvist & Rowe, 2005;Rankin & López-Sepulcre, 2005), shifting its net effect on population viability.Our assays of reproductive traits in generation 5 provided some further qualitative support to these results, with higher trait values in the complex environment, especially in N + S populations (Figure 4).However, only the composite measure of juvenile viability (combining information on egg and larval viability) showed statistically significant improvement in the complex environment, while for fecundity there were no clear effects.Given that these data may have been influenced by eggs laid by the offspring generation (see Methods) these results should be interpreted with some caution.Nevertheless, taken at face value, they may suggest that environmental complexity mainly reduced the severity of male-male competition (which has been shown to impair fertility in previous studies of C. maculatus (Baur et al., 2023;Koppik et al., 2023)), and to lesser extent male harassment of females as stronger environmental effects on fecundity would have been expected in this scenario.Current research themes suggest that male fertility is particularly sensitive to heat (Parratt et al., 2021;Walsh et al., 2019), and our results could thus in part be driven by male-male competition exacerbating such effects (see also: (Moiron et al., 2022).
At the end of our experiment, following the application of acute thermal stress, extinction was highly stochastic and independent of both mating system evolution and environmental complexity, with only 6 out of the original 48 populations remaining.Yet, five out of the six surviving populations were derived from founder 3, suggesting that the fate of these populations was contingent on segregating genetic variation specific to this founder (Figure 3c).Another characteristic of the surviving populations was their low viability at the first episode of stunted growth during generations 4-5 (Figure 3c), and the substantial improvement compared to extinct populations in generation 7 (Figure 5b,d).We can think of two explanations for these results, which are not mutually exclusive.First, theory predicts that more specialized genotypes have the potential to adapt more rapidly to environmental change (Whitlock, 1996), and it could be envisioned that these populations underwent rapid exchange of some rare large-effect alleles during the first bout of population decline that contributed to them surviving the second bout of strong selection at generation 7. Second, it is possible that their low density (relative to other populations) at the second episode of acute temperature stress in generation 7 may have increased their viability by reducing both adult sociosexual interactions and larval competition inside beans.Such a density-dependent mechanism may also explain the peculiar differences in egg hatchability between the N and N + S regime across the simple and complex environment found at generation 7, which went opposite to the patterns found in prior generations 4-6.Further assays of the surviving lines together with genome sequencing of temporal population samples would likely be required to explore these hypotheses in detail.We conclude that the founder effect was the only factor that explained population survival at acute thermal stress and that any putative evolutionary rescue from ancestral standing variation in the 6 survivors seems independent of previous mating system evolution.
A range of other studies have explored the interacting effects of temperature and sexual selection on population viability and extinction risk (García-Roa et al., 2020;Leith et al., 2022).Of particular interest are studies assessing effects on whole populations, hence incorporating demographic effects.Parrett and Knell (2018) manipulated sex-ratios to study population dynamics under a heatwave in the Indian meal moth.Females from populations maintained with a male-biased sex ratio (increasing the strength of sexual selection) coped better with the heatwave when assayed individually, but results were dependent on whether females were housed with one or several males.However, sex ratio did not affect the final survival of whole populations (Parrett & Knell, 2018).Godwin et al. (2020) found that flour beetle populations with a history of strong sexual selection did indeed survive better than their monogamous counterparts when exposed to conditions cycling intergenerationally between nutritional, genetic (inbreeding) and thermal stress (Godwin et al., 2020).However, it remains somewhat unclear whether temperature per se was a strong driver of the result as much of the effect seems to have been mediated by differential effects of inbreeding in polyandrous and monogamous lines (Lumley et al., 2015).On the contrary, Lukasiewicz et al. ( 2023) recently found that lines of the mite Rhizoglyphus robini selected for exaggerated development of a male weapon were more prone to extinction during a heatwave than lines selected for reduced expression (Łukasiewicz et al., 2023).The somewhat disparate results from these three studies suggest that the impact of sexual selection on extinction risk is highly contingent on mating system and the environmental conditions used during assessment.Accordingly, we here showed that environmental conditions incorporating more complexity can alter the effects of sexual selection on population viability.Moreover, if our complex environmental setting had its main effects on population dynamics by reducing the intensity of sociosexual interactions, it seems highly plausible that such effects may occur urally even in simple environmental settings once species face climate change and population size declines.
We argue that this qualitative result may apply under many types of abiotic environmental change.However, the detailed mechanistic basis may differ with regard to whether the intensity of same-sex versus opposite-sex mating interactions is most affected, and which traits that show the strongest responses.Long-term evolutionary dynamics remain less certain and depend on how particular abiotic stressors affect the relative efficacy of purifying sexual selection on genetic quality and its role in evolutionary rescue (Pilakouta & Ålund, 2021;Rowe & Rundle, 2021;Svensson, 2019).Moreover, our exact application of the experimental heat wave itself, while grounded in both empirically measured heat tolerance of this species (Berger et al., 2021) and thermal records from the founding populations sampling location (Baur et al., 2023), will have affected results by targeting certain traits and behaviours more than others (Kellermann et al., 2019;Terblanche et al., 2007).Our findings should thus not be directly extrapolated to natural populations but rather be seen as an empirical proof-of-concept for the tenet that environmental complexity can mould the demographic impact of sexual selection and shift the balance of population-level costs and benefits associated with sexual selection.This result has important consequences for evolutionary rescue that should be integrated into predictive frameworks for how sexual populations will cope with rapid environmental change.

AU T HOR CON T R I BU T ION S
DB conceived the general idea of the study.DB and JL-R designed and carried out the experiment.DB analysed the data and wrote the manuscript.JL-R commented on manuscript drafts.