Note the detailed heading. The subtitle should be "It's a miracle I got it to work at all". What follows are notes that I hope will help the next time I have to set this up, although I know they probably won't. They probably won't work for you either. Sorry.
Make sure you're in an xorg, not wayland, session.
- Remove any existing nvidia packages:
sudo apt autoremove nvidia* --purge
and/orsudo /usr/bin/nvidia-uninstall
- Make sure the system is up to date:
sudo apt update && sudo apt upgrade
- Check for drivers:
ubuntu-drivers devices
- Install the system recommended driver:
sudo ubuntu-drivers install
Reboot.
Check the "Additional Drivers" tab in Software Updater verify the currently running driver. For me that's currently "NVIDIA driver metapackage from nvidia-driver-535 (proprietary, tested)".
Use .deb package from https://store.steampowered.com/about/ (steam_latest.deb).
In Gnome display properties make sure your primary (you know, the big one) monitor is set as... primary.
In Steam, go to Library. Right click on the game you're going to play and select Properties.
Then choose Properties and, finally, Compatibility.
Choose Proton 8.0-2 from the dropdown menu. Check "Force the use of a specific Steam Play compatibility tool.
Let Steam install/update the selected Proton library.
Launch the game, go to its graphics configuration and verify that the NVIDIA card is selected.
If it isn't, or something else doesn't work, go to https://steamcommunity.com or https://forums.developer.nvidia.com for further assistance. Be sure to ignore anything that doesn't directly refer to your operating system version (e.g. "Ubuntu 22.04"). Steer clear of reddit, stackoverflow and askubuntu: these are all worse than useless, they're misleading.