When the car dies does everything go out i.e. it looses 12V? If that is the case then you need to check the following wires::
12V+
Battery to starter solenoid
Starter solenoid to starter
12V-
Battery to chassis ground
Battery to block ground
There is also a ground for the ECU behind the stock battery location that can cause issues as well (courtesy of jrichker):
Basically you could be having a power wire problem that is causing the car to loose 12V and then when things cool off the continuity comes back just enough to start and/or run. This will also make the car hard to start when hot. A very good way to determine the health of the wires is to do a voltage drop test. Good video on this here:
View: https://youtu.be/qPpHRuddhh4?si=kMHdtKB_DRzXKMVg