I already said how gyms would work in the OP.
Have each gym scale based on the number of badges you’ve collected. So the more badges you have, the tougher gyms get. The teams, and levels of the gym leaders all have 8 variations.
To avoid overlevelling, introduce soft caps on leveling that are unlocked with each gym badge you get.
Thus, until you beat the first gym, you won’t be able to make it to Lvl20, and getting past 14 will be tough as your exp gains get smaller and smaller past a certain level. Once you beat said gym, th cap unlocks, and you can resume as normal.
As for the evil team, perhaps it’s time to retire that lame and tired concept, and handle it more intelligently.
Divide the region into self-contained modules, each with their own side quests, problems, dungeons, and so on... Baldurs Gate did this, Dragon Quest 3 did this, most DnD campaigns work this way.
If you wanna have an overarching antagonist, then make events happen by triggering flags. When you’ve beaten X numbers of key quests regardless of location, event Y triggers. Look at how Sengoku Rance is designed. The main quest triggers are 8 gourds hidden in 8 different regions you can conquer, out of the like 20. The game forces you to conquer all of them as the main objective, so you’re gonna trigger the story event no matter what, however, the catch is you don’t know where the gourds are in your first play, you don’t know the gourds trigger the story event, AND it only takes 5/8 gourds for the event to trigger, most of which are in surrounding regions.
That’s how you handle the story antagonist. You place flags in the player’s path that they’re bound to trigger forced quests, and you make it so that knowledgeable players will know how to avoid them for as long as possible.
Thus, your actions on the world have an effect which trigger consequences that set you down the main story.