@media (min-width:851px){
  body.mobile-controls .touch-controls{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;width:100%;max-width:400px;margin:14px auto 0}
  body.mobile-controls .touch-controls button{min-height:48px;border:1px solid var(--line);border-radius:6px;background:var(--card);color:var(--ink);font-size:18px;touch-action:manipulation;user-select:none}
  body.mobile-controls .touch-controls button:last-child{font-size:11px;background:var(--amber)}
  body.mobile-controls.embed-body>.touch-controls{flex:none;margin:0}
  body.mobile-controls .embed-shell .board-wrap{width:min(480px,calc((100dvh - 92px)*5/9),calc(100vw - 300px))}
}
.game-shell{grid-template-columns:minmax(0,480px) minmax(0,1fr)}
.board-wrap{width:100%;max-width:480px}
#game{width:100%;height:auto;aspect-ratio:5/9}
@media (min-width:851px) and (max-width:1100px){
  main{padding:30px 20px}
  .game-shell{gap:22px}
  h1{font-size:48px}
}
@media (max-width:850px) and (orientation:portrait){
  .board-wrap{width:min(100%,calc((100dvh - 285px)*5/9))}
}
@media (max-width:850px) and (max-height:700px) and (orientation:portrait){
  .bar{height:42px}
  main{padding-top:8px}
  .intro{display:none}
  .board-wrap{width:min(100%,calc((100dvh - 205px)*5/9))}
}
@media (max-height:500px) and (min-width:500px){
  .bar{height:40px}
  .home{font-size:15px}
  .intro{display:none}
  main{padding:8px 12px calc(8px + env(safe-area-inset-bottom))}
  .game-shell{display:flex;flex-direction:row;justify-content:center;align-items:flex-start;gap:12px}
  .board-wrap{width:min(400px,calc((100dvh - 116px)*5/9));max-width:none}
  .hud{order:initial;display:grid;grid-template-columns:1fr 1fr;width:min(280px,40vw);max-width:none;gap:6px}
  .hud .next,.hud .pressure,.hud .instructions{display:none}
  .hud .stat{padding:5px 8px}
  .hud .stat strong{font-size:18px}
  .hud .stat-row{gap:6px}
  #pause{display:block;grid-column:1/-1;min-height:32px;padding:6px}
  .hud .leaderboard-open,.hud #mute{grid-column:auto;width:100%;min-height:32px;padding:5px;font-size:9px}
  .touch-controls,.embed-body>.touch-controls{display:grid;grid-template-columns:repeat(5,1fr);gap:6px;width:100%;max-width:400px;margin:8px auto 0;padding-bottom:env(safe-area-inset-bottom)}
  .touch-controls button{min-height:40px}
  .embed-body{padding:8px;gap:8px;justify-content:center}
  .embed-shell{flex-direction:row;align-items:flex-start;gap:12px}
  .embed-shell .board-wrap{width:min(400px,calc((100dvh - 80px)*5/9));max-width:none}
  .embed-shell .hud{order:initial;width:min(280px,40vw)}
  .embed-body>.touch-controls{margin:0}
}
