The secret is to get the worthless country rock off the top of the pan without losing the gold. A good method is to use a screen. If the bigger rocks are screened out, panning goes much faster. The next step is to slosh and shake the pan back and forth while it has rocks and water inside. Here is where science comes in.
Gold has a high specific gravity so it settles to the bottom.
It also has more mass, so when you slosh the pan to get the lighter rocks off the top, the gold has more inertia that will carry it away underneath the country rock. The idea behind gold panning is no more complex than shaking a bowl of popcorn to let the heavier unpoped kernels settle to the bottom and the popped corn float to the top. If you can get some gold bearing sands, practice panning. Look at the materials on the bottom of the pan with a 10-20 power magnifier. There's a fascinating world down there.