Pinout difference between ATMegax8 TQFP

x8 such as the popular 328 in TQFP has 4 more pins than DIP counterpart. 2 extra pins are A6 and A7 (analog input only) and 2 more power pins. The 'B' variant changed pin 3 and 6 from power to 2 digital GPIO.

I am designing a project that will use ATMega48 (4k flash memory) and I found some non-B variant on Digikey that are very cheap but those are non-stock item so when they run out, the next cheapest are the B variant.

Can I safely leave pin 3 and 6 unconnected or do I absolutely need to tie in both ground (3 and 5) and Vcc (4 and 6)? If I can leave those unconnected, then the PCB can be used with either older or newer variants without any change.

GPIO Pin 3 and 6 in my project aren't used anyway and I have no idea what could happen if I tied 3 to GND and 6 to VCC on power on before the code runs making those 2 pins input. If the pins are output by default on power on, it could short.

I assume you're mean the *PB variant. You as far as I know you can use these as a dropin replacement for AtmegaX8/P/PA, as long as you don't use the IO pins that's directly connected to Vcc and Gnd. All pins are always set to inputs by default so it shouldn't be a problem.
You can use MiniCore if you want to use the new *PB series.

Thanks that works for me. And yeah I meant PB.