Help!Need working 1.21.7 datapack or template for team-based minigame

I'm making a small 2-team PvP minigame in Minecraft Java 1.21.7.

Players should click an item (e.g. boots or bow) to join a team (Run or Shoot), then after both teams have at least one player, the game starts with a countdown and ends when one team is eliminated.

I've tried using custom items (with CustomModelData + display name) and functions, but many commands or NBT just don't seem to work in 1.21.7. I also tried using click detection but failed.

Is there any working datapack template for this kind of game? Or is anyone open to helping me fix or rebuild a basic version?

Thanks a lot!

Continue to help post