Hey, to chip in: try cardio, especially running. Men loose muscle mass with age, as you are already aware, resistance training is important, but cardio should be on top of your list.
I was there with you in terms of brain fog, general mental slowdown, what is called cognitive decline, and mind you, I presume we are healthy, without cognitive degeneration or serius injuries or conditions.
Running 3 times per week should get you on track in about a month. Try it and notice the difference. We are made for movement. If you're healthy and don't feel like running, in my case, i immediately know i should be doing the thing I don't feel like doing. Running. 1x interval training, 1x hill repeats, 1, long run in cardio zone 2. If you can, get s Garmin watch. Stats will help you maintain focus on the big picture. Streaks can help reframe for consistency.
I started training when corona hit, this is the best I've felt ever. Slowly progressed to cycling on off days for better recovery. Bought smart watches for friends, now we keep each other in check, we sometimes even meet at the pool at 6 am for a quick swim session. I now do some kind of activity 6 times per week. If i ever stop working on software, I'll help others train and get better to feel good and feel healthy - that's how much it gave me and i absolutely love it.
hint: optimize for training the next 20-30 years (I'm 39) which means injury prevention, recovery activities, everything else as nutrition and rest follows as you observe your own body and get in tune with what it needs. Honest good luck to you, I'm excited for you!