You need to eat when you get home to allow your muscles to rebuild, have a balanced meal of some protein, some carbs. Stretch. Have a bath. Be patient.

Use low gears to spin. Instead of push-pulling the pedals, aim for a round, spinning motion, i.e. push forward at the 12o'clock and and pull back (as if scraping mud off your sole) at the 6 position. and look out for easy loops that you can ride, 2-3x if it must be to build. Be patient at those hills and hope that the cooler weather will help.

Did you say trails? as in riding an MTB? How about sticking to roads for a while?

Don't go into a ride unfuelled.