This can be a problem for me and I have had some experiences of really painful cramping and trapped wind, potentially from sitting down for most of the day but we have never found a definitive reason as to the cause. It does not happen often, but when it does it has knocked me out of kilter for a couple of days.
The first time I had severe bloating it caused lots of pain, my stomach was distended and hard, I couldn’t eat and the gp even suggested hospitalisation because of it. Fortunately, the problem went away on its own but it is important to manage as the problem can be very acute. We have since found out and come up with strategies to reduce the problem.
Lying down and using a hot water bottle were two things that have provided some relief when an episode occurs. Taking a medicine called Mebeverine has proved to be very effective for me on the last two episodes of bloating. It was recommended and prescribed by my gp so it may be worth asking about it if you have problems. Also, I did alter my diet to have more beans and legumes but it is difficult to know how effective it is.