I've ranted about "don't use viewport size as a proxy to guess other things, such as 'touch only' (which nowadays is meaningless anyway, as you can have keyboard/mouse paired even with a nominally 'touch only' phone), slow network connection, etc" for aeons. There are now much better/cleaner APIs to determine those aspects.
However, in terms of layout decisions, I'd say that "it depends". The approach of making a decision of how best to use the available viewport space should be driven by the nature of the content, and what the designer thinks is the best use of the space. I personally have no problem with layout adapting to a more "vertical/portrait aspect" friendly approach, as long as it's well considered.
On the "getting the actual real screen size", beware also that this doesn't take into account expected/average viewing distance - so yes, it might detect that you're in fact using an enormous 50" screen...but it won't be able to tell you that it's wall mounted and 5 metres away from the user - which is what in an ideal world the CSS reference pixel should all paper over, since it assumes that dpi, scaling, etc have been set so that 1 CSS px is set to a roughly standardised visual angle for the average/expected viewing distance ... something I ranted about aeons ago when "web on tv" was still supposedly a thing https://patrickhlauke.github.io/web-tv/ideal-viewport/index.html
So once again, taking this with a grain of salt.