I get the intended logic behind the system, which is to incentivize cheap sources (if you run cheap sources, you keep the difference with respect to gas as pure profit), but IMO it's prone to gaming (a lot of incentive to have that single MW of gas up, and electricity companies are an oligopoly...) and doesn't work well even without gaming (if the price of gas is disproportionately high with respect to the rest of sources, things begin to just not make sense).
Spain and Portugal negotiated to (temporarily, I think) get out of this system and change it to something saner (with the same basic principles but some compensations so that gas price doesn't dominate anything). The so-called Iberian exception. And it's working: while our prices are still high with respect to historical standards (due to Ukraine and the general underlying energy crisis), they now tend to be much lower than the rest of the EU most of the time.