/* Phone layouts keep setup menus in the page and reserve the track for driving. */
@media(max-width:720px), (max-width:1000px) and (max-height:540px){
  #game{min-width:0}#game button,#game select,#game summary{min-height:44px}#game button{touch-action:manipulation}#game canvas{touch-action:pan-y pinch-zoom}
  .game-top{padding:2px 10px;min-height:48px;gap:6px}.game-top>div{gap:4px}.game-top button{padding:8px;font-size:11px}.game-top strong{font-size:11px;line-height:1.3;max-width:48%}
  .career-strip{padding:4px 10px;gap:10px;flex-wrap:wrap;font-size:10px}.career-strip button{margin-left:auto;font-size:11px;padding:8px}.career-strip strong{font-size:15px}
  .scoreboard{padding:9px 11px;gap:8px;grid-template-columns:minmax(0,1.35fr) repeat(3,minmax(0,1fr))}.scoreboard span{font-size:8px;letter-spacing:.6px}.scoreboard strong{font-size:18px;white-space:nowrap}.scoreboard small{font-size:9px}
  #game[data-screen="playing"] .stage{height:clamp(210px,33svh,285px)}
  #game[data-screen]:not([data-screen="playing"]) .stage{height:auto;min-height:0;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:12px 9px;backdrop-filter:none}
  #game[data-screen]:not([data-screen="playing"]) .panel{max-height:none;overflow:visible}
  .panel{min-width:0;padding:20px 15px}.panel h2{font-size:30px}.panel p,.garage-heading>p{font-size:13px;line-height:1.6}.panel .eyebrow{font-size:9px}.panel .small-note{font-size:11px!important;line-height:1.5}
  .choice strong{font-size:12px}.choice small{font-size:10px;line-height:1.4}.primary,.secondary{font-size:12px;min-height:46px;padding:12px 14px}.button-row{gap:8px}.button-row>button{flex:1 1 42%;white-space:normal}
  .briefing-details{flex-wrap:wrap;font-size:11px;gap:7px}.briefing-details span{padding:8px}.track-note{font-size:11px;max-width:94%;white-space:normal;text-align:center}
  .controls{display:grid;grid-template-columns:54px minmax(0,1fr) 54px;gap:7px;padding:0 10px 12px}.controls .shift{width:100%;min-width:0}.controls .throttle{width:100%;min-width:0;max-width:none;font-size:13px}#game .controls button{min-height:64px;touch-action:none}.controls button span{font-size:9px;letter-spacing:.3px}
  .gauges{padding:10px 11px;gap:9px}.gauge label,.gauge label strong{font-size:8px;letter-spacing:0}.gauge label{flex-wrap:wrap;gap:3px}meter{height:10px}.game-bottom{padding:2px 10px;align-items:center;font-size:10px}.game-bottom button{font-size:11px}.game-bottom span{font-size:9px;line-height:1.4;max-width:65%}
  /* A preview taller than the screen should never pin over the parts being chosen. */
  .tractor-preview-slot,.workshop-panel .tractor-preview-slot{position:static;margin-bottom:16px}.garage-actions{position:static;transform:none;left:auto;bottom:auto;width:100%;margin:16px 0 0;padding:12px 0 calc(12px + env(safe-area-inset-bottom,0px));border:0;border-top:1px solid #ccd8bf;border-radius:0;box-shadow:none;backdrop-filter:none}
  .garage-open .overlay{padding-bottom:12px}.garage-actions>p{font-size:11px;max-width:none}.garage-actions>p span{font-size:12px}.garage-actions .button-row{flex-wrap:wrap}.garage-actions .primary,.garage-actions .secondary{font-size:12px;min-height:46px}
  .garage-body,.workshop-body{display:block}.setup-preview{grid-template-columns:42% minmax(0,1fr)}.setup-info h3{font-size:18px}.setup-stats dt,.workshop-panel .setup-stats dt{font-size:10px}.setup-stats dd,.workshop-panel .setup-stats dd{font-size:16px}.setup-info .tractor-tradeoffs p{font-size:11px}.tractor-tradeoffs strong{font-size:9px}.setup-info .best-for{font-size:11px}.mobile-ratings{font-size:11px}.mobile-ratings summary{padding:10px 0}.mobile-ratings .setup-stats dt{font-size:10px}.mobile-ratings .setup-stats dd{font-size:15px}
  .tractor-choices .choice strong{font-size:13px}.tractor-choices .choice small,.tractor-choices .card-strength{font-size:11px}.parts-tabs button,.workshop-view-tabs button,.event-view-tabs button{min-height:46px;font-size:11px}.workshop-chassis{flex-wrap:wrap}.workshop-chassis select{max-width:100%;font-size:16px}.part-actions{flex-wrap:wrap}.part-actions button{flex:1 1 42%;font-size:12px;min-height:46px}.workshop-dock .button-row{flex-wrap:wrap}.workshop-dock .primary{flex-basis:42%}
  .circuit-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.event-card,.circuit-grid .event-card{min-width:0}.event-card strong{font-size:13px}.event-card small,.cup-card .cup-note{font-size:11px}.cup-heading{min-width:0}.cup-heading h3{font-size:24px}.cup-heading p{font-size:12px}.cup-prize>div>strong{font-size:25px}.competition-panel .garage-actions .button-row{flex-wrap:wrap}.cup-events .event-card small{font-size:11px}
}
@media(max-width:360px){
  .app{padding:0 7px}.brand span,.title-row>.tag{display:none}.game-top strong{font-size:10px;max-width:42%}.game-top>div{gap:0}.game-top button{font-size:10px;padding:7px}.scoreboard strong{font-size:16px}.scoreboard small{font-size:8px}.career-strip{gap:8px}.career-strip button{flex-basis:100%;margin:0;text-align:left}.controls{grid-template-columns:49px minmax(0,1fr) 49px;gap:6px}.controls .throttle{font-size:12px}.controls button span{font-size:8px}.panel h2{font-size:27px}.choices{grid-template-columns:1fr}.choice{display:flex;gap:8px;align-items:center;text-align:left}.choice small{margin:0}.tractor-choices{grid-template-columns:repeat(2,minmax(0,1fr))}.tractor-choices .choice{display:block}.setup-preview{display:block}.setup-info{padding:13px}.tractor-hero img{max-height:165px;object-fit:contain}.circuit-grid{grid-template-columns:1fr}.parts-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-height:540px) and (min-width:600px) and (max-width:1000px){
  #game[data-screen="playing"]{display:grid;grid-template-columns:minmax(0,1fr) 174px;grid-template-areas:"top top" "score controls" "track controls" "gauges bottom"}
  #game[data-screen="playing"] .game-top{grid-area:top;padding:0 10px;min-height:44px}#game[data-screen="playing"] .career-strip{display:none}
  #game[data-screen="playing"] .scoreboard{grid-area:score;padding:6px 13px;gap:12px}#game[data-screen="playing"] .scoreboard>div{gap:2px}#game[data-screen="playing"] .scoreboard strong{font-size:16px}
  #game[data-screen="playing"] .stage{grid-area:track;height:clamp(160px,calc(100svh - 220px),230px)}#game[data-screen="playing"] .gauges{grid-area:gauges;padding:6px 13px 9px;gap:15px}
  #game[data-screen="playing"] .controls{grid-area:controls;display:flex;flex-direction:column;gap:6px;padding:8px 10px 6px}#game[data-screen="playing"] .controls .shift{width:100%;min-height:44px;flex:0 0 44px;font-size:21px}#game[data-screen="playing"] .controls .throttle{min-height:66px;flex:1;font-size:12px}#game[data-screen="playing"] .controls button span{font-size:8px}#game[data-screen="playing"] .controls kbd{display:none}
  #game[data-screen="playing"] .game-bottom{grid-area:bottom;padding:0 9px;border:0;justify-content:center}#game[data-screen="playing"] .game-bottom span{display:none}#game[data-screen="playing"] .game-bottom button{font-size:11px;min-height:44px}
  .garage-actions,.tractor-preview-slot,.workshop-panel .tractor-preview-slot{position:static;transform:none;width:100%;left:auto;bottom:auto}.garage-actions{margin-top:16px;box-shadow:none}.garage-open .overlay{padding-bottom:16px}
}
