I had a brief look into this (I'm by no means an expert), and there doesn't seem to be a straightforward answer.
As an example, I'd recommend checking out the Wikipedia page about legal issues with fan-fiction (https://en.wikipedia.org/wiki/Legal_issues_with_fan_fiction) because the cases mentioned all center around the issue of works that are "derivative" … Read more