Learn the lists of which article for which case and gender of by heart. I did this at 16 and still know it now many decades later.
Remember subject nominative, direct object accusative.
Learn main prepositions which cause dative, genitive and those which cause accusative:
Dative: aus, außer, bei, dank, seit, mit, nach, von, zu
Accusative: bis, durch, ohne, für, gegen, ohne, um, wider, entlang
Gen: außerhalb, innerhalb, trotz, während, wegen, anstatt. Note: you will hear native speakers use wegen with dative, that’s fine, they can, but I would learn it correctly as a non native speaker.
Then there are either / or prepositions- for these in general it’s dative rest, accusative motion - so ich bin in der Stadt, but ich gehe ich die Stadt. Note: there are exceptions
Then there are phrases, verbs, that cause either dative or accusative. You will learn these over many years and still make mistakes, but less and less with time - duolingo will never get you to a level of fluency to master this, you will need to spend time immersed in German, ideally where it is spoken, but also reading and using the language.
German is not easy, I speak it fluently, passed the Goethe C2 exam, but still make mistakes. I lived there, use the language all the time, read novels, watch films in German. You will improve, but have to enjoy the journey as there is no end to learning a language.