I'm currently working on a bejeweled clone, written in odin using raylib. After several days of work, I have finally written (what I hope to be) reliable color chain detection code.
The code works by having a rectangle enquire about the color of its "neighbors" in each direction. It keeps track of how many neighbors have the same color. Using that information, we can establish if the rect is part of a horizontal or vertical chain, and update a status flag on the chained rects to indicate they should be "cleared" (aka, have their color set to something else).