@media(max-width:720px), (max-width:1000px) and (max-height:540px){
  #game{min-width:0}#game button,#game summary{min-height:44px;touch-action:manipulation}#game canvas{touch-action:pan-y pinch-zoom}
  .game-top{min-height:48px;padding:2px 11px;gap:8px;font-size:11px}.game-top>div{gap:5px}.game-top button{font-size:11px;padding:8px}.game-top>span{line-height:1.4;max-width:66%}
  .hud{padding:9px 12px;gap:9px}.hud span{font-size:8px;letter-spacing:.4px}.hud strong{font-size:17px}.hud>div{min-width:0;gap:4px}.personal-best{font-size:10px;padding:7px 12px}.field-challenges{padding:6px 11px;gap:6px}.live-field-badge strong{font-size:9px}.live-field-badge small{font-size:7px}.live-field-badge>svg{width:19px;height:24px}
  #game[data-screen="playing"] .stage{height:clamp(265px,38svh,350px)}#game[data-screen="playing"].planning-mode .stage{height:clamp(235px,33svh,300px)}
  #game[data-screen]:not([data-screen="playing"]) .stage{height:auto;min-height:0;aspect-ratio:auto;overflow:visible}#game[data-screen]:not([data-screen="playing"]) .stage>canvas{position:absolute;inset:0}
  #game[data-screen]:not([data-screen="playing"]) .overlay{position:relative;inset:auto;overflow:visible;padding:14px 10px;backdrop-filter:none}#game[data-screen]:not([data-screen="playing"]) .panel{max-height:none;overflow:visible}
  .panel,#game.browsing .panel{padding:22px 16px}.panel h2{font-size:30px}.panel p,#game.browsing .panel p{font-size:13px;line-height:1.6}.panel .eyebrow{font-size:9px}.panel .small-note{font-size:11px;line-height:1.5}.choice strong{font-size:12px}.choice small{font-size:10px}.primary,.secondary{font-size:12px;min-height:46px;padding:12px 14px}.button-row>button{flex:1 1 43%;white-space:normal}
  .status-line{padding:7px 12px;min-height:43px}.status-line p{font-size:11px;line-height:1.45}.control-row{padding:10px 12px;gap:10px;display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center}.assist-buttons{flex:1 1 155px;gap:6px;flex-wrap:wrap}.assist-buttons button{min-width:46px;min-height:52px;padding:6px}.assist-buttons span{font-size:10px}.assist-buttons small{font-size:10px}.dpad{gap:6px;margin-left:auto}.dpad button{width:48px;min-width:48px;height:48px;font-size:25px;touch-action:none}.game-bottom{padding:2px 12px calc(3px + env(safe-area-inset-bottom,0px));min-height:48px}.game-bottom>div{display:flex;gap:8px}.game-bottom button{font-size:11px;padding:8px}
  .route-planner{padding:13px 12px}.planner-heading span{font-size:8px}.planner-heading strong{font-size:14px}.route-planner p{font-size:11px;line-height:1.5}.route-planner .text-action{font-size:11px;padding:9px}.planner-actions{gap:7px}.planner-actions button{font-size:11px;min-height:44px;padding:10px 12px;flex:1 1 42%}.planner-directions button{min-width:48px;height:48px;font-size:24px}.plan-forecast span{font-size:9px}.plan-forecast strong{font-size:18px}
  .region-tabs strong{font-size:12px}.region-tabs small{font-size:10px}.browsing .field-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.browsing .field{min-width:0;min-height:180px}.field strong{font-size:13px}.browsing .field small{font-size:10px}.field-number{font-size:9px}.journal-actions button,.challenge-field>button,.challenge-view-tabs button,.decoration-preview button,.decoration-card button{font-size:12px;min-height:46px}.decoration-card p{font-size:10px}.finish-option strong{font-size:12px}.finish-option small{font-size:10px}.guide-list li{font-size:12px;line-height:1.6}.saved-field p{font-size:12px}.saved-field .primary{font-size:12px;min-height:46px}
}
@media(max-width:360px){
  .app{padding:0 7px}.brand span,.title-row .game-tag{display:none}.game-top>span{font-size:10px;max-width:58%}.hud{padding:9px 10px;gap:7px}.hud strong{font-size:15px}.hud span{font-size:7px}.choices{grid-template-columns:1fr}.choice{display:flex;align-items:center;gap:9px;padding:10px}.choice.active{padding:9px}.choice strong{margin:0}.panel h2{font-size:27px}.control-row{justify-content:center}.assist-buttons{flex-basis:100%;justify-content:center}.dpad{margin:0;justify-content:center;width:100%}.assist-buttons button{flex:1;max-width:75px}.field-challenges{flex-wrap:wrap}.live-field-badge{flex:1 1 31%;min-width:0}.live-field-badge strong{font-size:8px}.live-field-badge small{font-size:6px}.decoration-grid{grid-template-columns:1fr}.challenge-overview{grid-template-columns:1fr}.planner-heading{align-items:flex-start}
}
/* Reserve room for the fixed cabinet, HUD and two rows of thumb controls. */
@media(max-width:360px) and (max-height:650px){
  #game[data-screen="playing"] .stage,#game[data-screen="playing"].planning-mode .stage{height:clamp(180px,calc(100svh - 368px),205px)}
  #game[data-screen="playing"] .status-line{min-height:32px;padding:4px 10px}
  #game[data-screen="playing"] .status-line p{font-size:10px;line-height:1.2;margin:0}
  #game[data-screen="playing"] .control-row{padding:6px 10px;gap:6px}
  #game[data-screen="playing"] .assist-buttons{gap:6px}
  #game[data-screen="playing"] .assist-buttons button{min-height:44px;height:44px;padding:4px}
  #game[data-screen="playing"] .assist-buttons strong{font-size:17px;line-height:18px}
  #game[data-screen="playing"] .assist-buttons span,#game[data-screen="playing"] .assist-buttons small{font-size:9px;line-height:11px}
  #game[data-screen="playing"] .dpad{gap:6px}
  #game[data-screen="playing"] .dpad button{height:48px;min-height:44px;min-width:48px}
}
@media(max-height:540px) and (min-width:600px) and (max-width:1000px){
  #game[data-screen="playing"]:not(.planning-mode){display:grid;grid-template-columns:minmax(0,1fr) 206px;grid-template-areas:"top top" "hud hud" "field controls" "status bottom"}
  #game[data-screen="playing"]:not(.planning-mode) .game-top{grid-area:top;min-height:44px;padding:0 12px}#game[data-screen="playing"]:not(.planning-mode) .game-top button{min-height:44px;padding:8px;font-size:11px}
  #game[data-screen="playing"]:not(.planning-mode) .hud{grid-area:hud;padding:6px 13px;gap:12px}#game[data-screen="playing"]:not(.planning-mode) .hud>div{gap:2px}#game[data-screen="playing"]:not(.planning-mode) .hud strong{font-size:15px}#game[data-screen="playing"]:not(.planning-mode) .hud span{font-size:8px}
  #game[data-screen="playing"]:not(.planning-mode) .personal-best,#game[data-screen="playing"]:not(.planning-mode) .field-challenges{display:none}
  #game[data-screen="playing"]:not(.planning-mode) .stage{grid-area:field;height:clamp(165px,calc(100svh - 200px),260px);aspect-ratio:auto}#game[data-screen="playing"]:not(.planning-mode) .status-line{grid-area:status;min-height:36px;padding:5px 12px}#game[data-screen="playing"]:not(.planning-mode) .status-line p{font-size:10px;margin:0}
  #game[data-screen="playing"]:not(.planning-mode) .control-row{grid-area:controls;display:flex;flex-direction:column;justify-content:center;gap:9px;padding:8px}#game[data-screen="playing"]:not(.planning-mode) .assist-buttons{flex:0 0 auto;gap:5px;justify-content:center}#game[data-screen="playing"]:not(.planning-mode) .assist-buttons button{min-width:46px;min-height:50px;padding:5px}#game[data-screen="playing"]:not(.planning-mode) .assist-buttons span{font-size:9px}#game[data-screen="playing"]:not(.planning-mode) .dpad{margin:0;gap:4px}#game[data-screen="playing"]:not(.planning-mode) .dpad button{width:44px;height:48px;min-width:44px;font-size:23px}
  #game[data-screen="playing"]:not(.planning-mode) .game-bottom{grid-area:bottom;padding:0 7px;min-height:44px;border:0;justify-content:center}#game[data-screen="playing"]:not(.planning-mode) .game-bottom>span{display:none}#game[data-screen="playing"]:not(.planning-mode) .game-bottom>div{gap:3px}#game[data-screen="playing"]:not(.planning-mode) .game-bottom button{font-size:10px;min-height:44px;padding:6px}
}
