I think the key to avoiding this is much like what you described but more focused on technology. Right now, today, the Chinese military simply could not win a head to head conventional war with us. While it would be certainly a bloody conflict, China just doesn't yet have the global force projection they need to beat us in a 1 on 1 war. They have substantial problems with their logistical support forces and inter-service cooperation. They have very limited blue water naval capabilities with their naval aviation especially lacking decades behind ours, their air power is based primarily on obsolete Russian aircraft and they have only at present 5 Ballistic Missile Subs and they lack the technology to hide them from us completely. Force on force numbers, i.e. number of tanks, troops aircraft, etc. matter little unless you can project that force onto your adversary. In short, China would have to get their forces across the Pacific and land massive numbers of troops, armor, support implements etc. on US soil to subdue not only our military defenses but a heavily armed populace. That simply cannot be done by them. In fact, there is no nation on the planet that has the military capability to win a 1 on 1 conventional war against the United States. Now bring in nukes, things get more messy however even then we'd still beat them as we'd be able to shoot down many of their ICBMS and them none of ours not to mention the fact that our nuclear forces substantially outnumber China's. China's overall military forces also have next to zero recent actual combat experience and that plays a huge advantage to us as anyone who studies warfare understands the best laid plans rarely survive first contact with the enemy. "Fighting experience" can win almost any war over technology as proven by history.
That's all in a 1 to 1 conflict. In reality if China went to war with us, Russia may or may not get involved and beyond them China has zero allies that would really turn the tide in their favor, whereas we have the entirety of the nuclear armed Western world, NATO etc that would ally with us. If it happened, it would be a long bloody war with multiple tactical nuke exchanges but in the end, the west would win whatever is left of the world which would be a lot of wasteland and irradiated cities to rebuild from provided neither side uses the big strategic world ending nukes.
All that being said China's military capabilities/technology is rapidly gaining. They are close to outpacing us in technological advancement. Today they are behind us by about 10 years according to everything averaged out but are on the cusp of surpassing us in anti-ship and anti-aircraft missile tech. Some of their brand new aircraft are certainly impressive and could pose a threae yet they have few of them. They have a substantial cyber-warfare capability and their space forces are nothing to sneeze at. However, all those gains conceded, despite all the hooplah, China, militarily simply is incapable of fighting and sustaining complex overseas military operations. They would have to be able to beat us in that arena to beat us in war.
In my opinion the likelihood of the United States and China getting into a direct hot war with each other anytime in the near future is very low and will become even lower if we continue to renew and bolster our own military forces and continue to wage economic warfare with them. Are they becoming a more substantial threat? Absolutely! However they are a long long ways away from being able to defeat us in open warfare.