Decoration and selection

Is there a way to have the selection background color take precedence over the background color set by a decoration ?
Example: Try CodeMirror

I’d like “console” to be painted blue when selected, not yellow.

The selection is drawn behind the text, so not really, unless you add an additional decoration to the selected range you want to style, to make it conform to the selection style.

Recommendation is to only use partially transparent background colors on the content text, so that other colors behind them remain visible.

I’ve added additional decorations at the intersection of the old ones and the selection, with a different mark so that they can be styled differently (same background as the selection but with a border). This works well, but I wish the styles had some kind of api to get the background, foreground of regular text, selection and others. This way an extension that adds new marks could reference those colors in the theme extension.