why not use the user-agent?
We used to do this before responsive design took over.
Consider an iPad which can display a website at three vastly different sizes. Full-width, half-width, and roughly 1/5th width docked to the site. They should have at least two different layouts.