Struggling with attaching desired colors to scatterplot

Hi, guys! I hope you could help me with this issue that I have been stuck with for a few days now. Iā€™m trying to figure out how to attach a particular color to certain data points satisfying certain conditions on a plotly.graph_objects scatterplot.

Here I plot one or more series of participants with respect to time and value. I can select participants to focus on by creating a pandas column that contains 1ā€™s for selected participants 0 otherwise.

For each of these series, I want colors to be assigned to the participants based on two conditions:

  1. Are they a selected participant; if so, either assign color green for taking initiative, red otherwise.

  2. If they are not selected, they are not in focus, so assign color gray.

here is how I choose colors:

Lastly, and this is not that important, but ideally, I would love if there was a way to rather indicate which point is selected using conditional opacity (lower opacity for participants that are not selected) rather than just coloring them gray (rgba() coloring would not work, since overlapping non-selected participants could be visually indicated to be selected by simply overlapping with multiple points).