function find_matches(self)
    local matches = {}

    -- Check horizontal matches
    for row = 1, self.rows do
        local count = 1
        for col = 2, self.cols do
            if self.grid[row][col].type ==
               self.grid[row][col-1].type then
                count = count + 1
            else
                if count >= 3 then
                    for i = col-count, col-1 do
                        table.insert(matches,
                            {x=i, y=row})
                    end
                end
                count = 1
            end
        end
        if count >= 3 then
            for i = self.cols-count+1, self.cols do
                table.insert(matches, {x=i, y=row})
            end
        end
    end

    -- Check vertical matches (same logic, different axis)
    -- ... similar code for columns

    return matches
end