One thing that can affect the 'z-index' display order of tokens is based on which tokens the viewing player has control over. So if a token is on the Object layer and the player has control of that token, it will be pushed to the top of the visibility list for that player. If there are multiple tokens stacked on top of each other that the player has control over, then the order is based on the z-index for each of those tokens, then it's stacked by layer. So the first piece of advice is to make sure you're using a Dummy Account to get a true player's view of the VTT while you're testing things out. That way you can see changes live while you make them, instead of trying to rely on 'Rejoin as Player' or Ctrl-L (which only provides a token's Line of Sight, not a player's view). Then check the Controlled By access for each of the tokens (the space ship and the overlaid gif). See what happens on the Dummy Account when you make changes to the tokens. It's also possible there is some other z-index ordering that happens for .gifs instead of .jpgs or .pngs, but I'm not sure about that.