/* Single-screen gameplay. Desktop remains on the existing presentation. */
.mg-active,.mg-active body{height:100%;overflow:hidden;overscroll-behavior:none}
.mg-active #app{height:min(100dvh,var(--mg-vh,100dvh));min-height:0;position:relative;top:var(--mg-top,0px)}
.mg-shell.shell{display:block!important;height:100%;min-height:0!important;margin:0!important;padding:0!important;max-width:none!important;overflow:hidden}
.mg-shell>.topbar,.mg-shell>.nav,.mg-shell .gb-page-toolbar{display:none!important}
.mg-shell>main{display:flex!important;flex-direction:column;gap:4px;height:100%;width:100%;max-width:none!important;min-height:0;margin:0!important;padding:max(6px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))!important;overflow:hidden!important;animation:none}
.mg-shell main>#trade-inbox-alert{display:none}
.mg-shell main>.banner{flex:none;padding:4px 8px;margin:0;font-size:12px;display:flex;align-items:center;gap:8px}
.mg-shell main>.banner p{display:none}
.mg-shell main>.banner button{min-height:36px;padding:4px 8px}
.mg-shell #gb-root,.mg-shell .gb-page{display:flex;flex:1;flex-direction:column;min-height:0;gap:4px}
.mg-shell .gb-page>p{margin:0;padding:4px;font-size:12px;flex:none}
.mg-screen{display:grid;grid-template-rows:auto minmax(0,1fr) auto auto;gap:6px;min-width:0;min-height:0;flex:1;width:100%;color:#edf3fa;container-type:size;font-size:14px}
.mg-screen *{box-sizing:border-box;min-width:0}
.mg-screen button,.mg-screen select{min-height:44px;border-radius:10px;font-size:13px;line-height:1.2;padding:8px 10px;touch-action:manipulation;white-space:normal}
.mg-screen button:disabled{opacity:.55}
.mg-screen button:focus-visible,.mg-dialog button:focus-visible{outline:3px solid #f1d472;outline-offset:2px}
.mg-header{display:grid;gap:5px}
.mg-title{display:flex;align-items:center;gap:8px;min-height:44px;padding-right:94px}
.mg-title>img{height:40px;width:40px;object-fit:contain}
.mg-title>div{flex:1;display:flex;flex-direction:column}
.mg-title span{font-size:11px;color:#a7b8c9}
.mg-title strong{font-size:15px;line-height:1.2}
.mg-title>button{padding:6px;min-width:44px}
.mg-scores{display:grid;grid-template-columns:repeat(auto-fit,minmax(0,1fr));gap:4px}
.mg-scores>div{display:flex;align-items:center;justify-content:space-between;gap:4px;padding:5px 7px;background:#102b3d;border:1px solid #294458;border-radius:8px}
.mg-scores .is-me{border-color:#cfac55;background:#30301f}
.mg-scores span{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:11px}
.mg-scores strong{font-size:18px;font-variant-numeric:tabular-nums}
.mg-scores:has(>div:nth-child(4)){grid-template-columns:repeat(3,minmax(0,1fr))}
.mg-scores:has(>div:nth-child(4))>div{padding:3px 6px}
.mg-scores:has(>div:nth-child(4)) strong{font-size:15px}
.mg-arena{min-height:0;display:flex;flex-direction:column;gap:5px;position:relative}
.mg-mission{text-align:center;flex:none}
.mg-mission>span{font-size:10px;letter-spacing:.08em;color:#d4ba70}
.mg-mission h1{font-size:clamp(16px,4.6vw,23px);line-height:1.15;margin:3px 0}
.mg-mission p{font-size:12px;line-height:1.2;margin:4px 0}
.mg-card{min-height:0;display:flex;flex:1;flex-direction:column;align-items:stretch;gap:3px;max-width:100%}
.mg-card-label{font-size:11px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:none;color:#bfccd8}
.mg-card .vehicle-card{display:flex;flex:1;flex-direction:column;min-height:0!important;max-width:280px;width:100%;height:auto;aspect-ratio:auto;margin:0 auto!important;border-radius:12px;overflow:hidden}
.mg-card .card-top{flex:none;padding:4px 7px;font-size:9px;min-height:18px}
.mg-card .card-art-wrap{flex:1;min-height:0;height:auto!important;aspect-ratio:auto;margin:0;overflow:hidden}
.mg-card .car-image,.mg-card .car-art{width:100%;height:100%!important;object-fit:contain!important;max-height:100%;transform:none!important}
.mg-card .card-copy{padding:4px 7px;flex:none;min-height:0}
.mg-card .card-copy h3{font-size:12px;line-height:1.15;margin:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.mg-card .card-copy>small{font-size:9px;line-height:1.1}
.mg-card .card-version,.mg-card .card-stars,.mg-card .card-victories,.mg-card .card-status,.mg-card .dev-mark{display:none}
.mg-card .special-label{font-size:9px;margin:0;padding:0}
.mg-card .special-seal,.mg-card .victory-seal{max-height:18px;width:auto}
.mg-card .treasure-edition{font-size:9px;margin:0}.mg-card .treasure-number{font-size:11px}
.mg-secret{display:flex;min-height:0;flex:1;flex-direction:column;align-items:center;justify-content:center;border:1px solid #527083;border-radius:12px;background:radial-gradient(ellipse at top,#193e53,#071625);padding:8px}
.mg-secret img{height:60%;min-height:0;max-width:100%;object-fit:contain}.mg-secret span{font-size:11px;color:#c1cdd7}
.mg-duel-cards{display:grid;grid-template-columns:1fr 1fr;gap:8px;flex:1;min-height:0}
.mg-choice-title{font-size:13px;line-height:1.2;font-weight:700;text-align:center;flex:none}
.mg-attributes{display:grid;grid-template-columns:1fr 1fr;gap:5px;flex:none}
.mg-attributes button{display:flex;flex-direction:column;text-align:left;padding:7px 9px;min-height:48px;gap:2px;background:#112b3d;border-color:#36566b}
.mg-attributes span{font-size:11px;color:#c7d5e1}.mg-attributes strong{font-size:14px;color:#f0d582}.mg-attributes small{color:#d9c170}
.mg-result{display:flex;flex-direction:column;justify-content:center;gap:3px;min-height:62px;border-left:3px solid #d6b65f;padding:6px 9px;background:#102333;border-radius:6px;font-variant-numeric:tabular-nums}
.mg-result>strong{font-size:13px;line-height:1.2}.mg-result>span{font-size:12px;line-height:1.3;color:#bacbd9}
.mg-actions{display:flex;flex-wrap:wrap;gap:5px;align-content:end;min-height:44px}
.mg-actions>button{flex:1}.mg-actions>.primary{flex-basis:100%;font-size:14px}
.mg-support{display:flex;flex-wrap:wrap;gap:4px;width:100%}.mg-support>button{flex:1;padding:5px;min-height:44px;font-size:11px;margin:0}.mg-support .ability-button small{display:none}.mg-support .ability-button{font-size:10px}.mg-support .moto-ability{max-width:40%}
.mg-support>button[data-mg-detail]{flex:0 1 64px;font-size:10px}
.mg-formation{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;flex:none}
.mg-formation button{display:flex;flex-direction:column;gap:2px;align-items:center;min-height:72px;padding:3px 2px;background:#102738;border:1px solid #3c5667;overflow:hidden}
.mg-formation .car-image,.mg-formation .car-art{width:100%;height:32px;object-fit:contain;flex:none;transform:none}
.mg-formation button>span{font-size:9px;line-height:1.1;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-formation small{font-size:9px;line-height:1.1;color:#ccba83}
.mg-formation button.selected{border:2px solid #edc86c;background:#3c3825}.mg-formation .mg-used{filter:grayscale(1);opacity:.45}
.mg-prizes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;min-height:0;flex:1}.mg-prizes>div{display:flex;flex-direction:column;min-height:0;gap:4px}.mg-prize-back{display:flex;flex-direction:column;justify-content:center;align-items:center;background:linear-gradient(140deg,#214858,#081623);border:1px solid #d7b866}.mg-prize-back img{width:100%;min-height:0;object-fit:contain;flex:1}.mg-prize-back span{font-size:11px}.mg-prizes .mg-card .card-top{font-size:8px;padding:3px}.mg-prizes .mg-card .card-copy{padding:4px}.mg-prizes .mg-card .card-copy h3{font-size:10px}.mg-prizes .mg-card-label{font-size:10px}
.mg-select{display:flex;align-items:center;gap:6px;flex:none;font-size:12px}.mg-select select{flex:1;width:0;padding:6px}
.mg-round-complete{font-size:26px;line-height:1;flex:none;text-align:center;color:#d6bf7b}
.mg-round-values{flex:none;font-size:12px}.mg-round-values>div{display:grid;grid-template-columns:repeat(3,1fr);gap:4px}.mg-round-values span{display:flex;flex-direction:column;overflow:hidden;font-size:10px}.mg-round-values b{font-size:12px}
.mg-dialog{padding:0;width:min(640px,calc(100vw - 16px));max-height:calc(var(--mg-vh,100dvh) - 16px);border:1px solid #496378;background:#091e2e;color:#eff5fc;border-radius:15px;overflow:hidden}
.mg-dialog[open]{display:flex;flex-direction:column}.mg-dialog::backdrop{background:#000b}.mg-dialog-head{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;flex:none;background:#142e40}.mg-dialog-head button{min-height:44px}.mg-dialog-body{padding:12px;overflow:auto;min-height:0;overscroll-behavior:contain}.mg-dialog .vehicle-card{max-width:300px;margin:8px auto}.mg-dialog .gm-result-grid{grid-template-columns:1fr}.mg-dialog .gm-round-result h2{font-size:18px}
.mg-active .cx-dock{top:max(7px,env(safe-area-inset-top));bottom:auto!important;right:max(8px,env(safe-area-inset-right));gap:3px}
.mg-active .cx-dock button{min-width:40px;min-height:40px;padding:5px!important;font-size:15px}.mg-active .cx-dock button span,.mg-active .cx-dock button small{display:none!important}
.mg-active .cx-panel{top:max(6px,env(safe-area-inset-top));bottom:auto;max-height:calc(var(--cx-vh,100dvh) - 12px);height:calc(var(--cx-vh,100dvh) - 12px);z-index:1000}
.mg-active .cx-alert{top:56px;bottom:auto}.mg-active .music-mini,.mg-active #music-mini{display:none!important}
@media(max-height:650px){.mg-screen{gap:4px}.mg-title{min-height:40px}.mg-title>img{height:32px;width:32px}.mg-title strong{font-size:14px}.mg-result{min-height:54px;padding:5px 8px}.mg-result>span{font-size:11px}.mg-formation button{min-height:64px}.mg-formation .car-image,.mg-formation .car-art{height:26px}.mg-mission h1{font-size:16px}.mg-support>button{min-height:44px}.mg-card .card-copy>small{display:none}}
@media(min-width:540px) and (max-height:500px){
 .mg-screen{grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;gap:5px 9px}
 .mg-header{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;align-items:center;padding-right:92px}.mg-title{padding:0}.mg-title>img{width:30px;height:30px}.mg-title strong{font-size:13px}.mg-title span{font-size:10px}
 .mg-scores:has(>div:nth-child(4)){grid-template-columns:repeat(3,1fr)}
 .mg-arena{grid-column:1;grid-row:2/4}.mg-result{grid-column:2;grid-row:2;align-self:stretch;min-height:0;font-size:12px}.mg-actions{grid-column:2;grid-row:3}.mg-formation button{min-height:58px}.mg-formation .car-image,.mg-formation .car-art{height:24px}.mg-card .card-copy h3{font-size:11px}
 .mg-mission h1{font-size:16px}.mg-result>strong{font-size:16px}.mg-result>span{font-size:12px}.mg-attributes button{min-height:44px;padding:4px 7px}.mg-attributes{gap:3px}.mg-screen button{padding:6px;font-size:12px}
}
/* Large fonts and very short viewports: keep actions/score visible, allow only the
   central decision region to scroll, never silently clip an indispensable choice. */
@media(max-height:460px) and (max-width:539px){.mg-arena{overflow:auto;overscroll-behavior:contain}.mg-arena>.mg-card,.mg-duel-cards{min-height:80px}.mg-title>img{display:none}}
@media(prefers-reduced-motion:reduce){.mg-screen *{animation:none!important;transition:none!important}}
.mg-active #music-x{position:fixed;top:0;right:0;border:0;padding:0;background:transparent;z-index:1100}
.mg-active #music-x .mx-bar{display:none}
.mg-active #music-x .mx-panel{position:fixed;top:max(8px,env(safe-area-inset-top));right:8px;max-height:calc(var(--mg-vh,100dvh) - 16px)}
.mg-active .mg-shell.online-screen{top:0!important;position:relative!important}
.mg-shell .gb-page>p[role=status]{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
.mg-screen button{letter-spacing:normal;text-transform:none}
.mg-formation small{overflow:hidden;text-overflow:ellipsis;max-width:100%}
.mg-shell main>.banner{order:1}
.mg-active #tracking-dock:not(.is-open){display:none}
.mg-active #tracking-dock.is-open{inset:max(8px,env(safe-area-inset-top)) 8px auto auto;max-height:calc(var(--mg-vh,100dvh) - 16px);width:calc(100vw - 16px);overflow:auto;z-index:1200}
.mg-active #tracking-dock .tracking-content{max-height:calc(var(--mg-vh,100dvh) - 88px);overflow:auto}
.mg-active #modal{max-height:calc(var(--mg-vh,100dvh) - 16px);max-width:calc(100vw - 16px);overscroll-behavior:contain}
/* Overflow is confined to the decision region only for extreme zoom/height. */
.mg-arena{overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.mg-screen button{font-size:.8125rem}.mg-title strong{font-size:.9375rem}.mg-result>strong{font-size:.8125rem}.mg-result>span{font-size:.75rem}
.mg-attributes strong{font-size:.875rem}.mg-attributes span{font-size:.6875rem}.mg-choice-title{font-size:.8125rem}
.mg-formation button{font-size:.5625rem}.mg-actions>.primary{font-size:.875rem}
.mg-active #cx-panel{top:max(6px,env(safe-area-inset-top));max-height:calc(min(100dvh,var(--cx-vh,100dvh)) - 12px);height:calc(min(100dvh,var(--cx-vh,100dvh)) - 12px)}
@media(min-height:501px){.mg-result{min-height:72px}}
/* Reserve one compact chat control in the HUD, clear of the exit button. */
.mg-active #cx-dock{display:flex}
.mg-title{padding-right:56px}.mg-header{padding-right:0}
@media(min-width:540px) and (max-height:500px){.mg-header{padding-right:56px}.mg-title{padding-right:0}}
.mg-screen button{overflow-wrap:anywhere}
.mg-dialog-head>strong{font-size:14px}
/* Compact headings must not inherit desktop negative tracking (-1.5px on h1).
   Keep natural letter widths and let complete words wrap instead of squeezing. */
.mg-screen :is(h1,h2,h3),.mg-dialog :is(h1,h2,h3){letter-spacing:normal;word-spacing:normal;word-break:normal;overflow-wrap:break-word}
.mg-mission h1{font-size:clamp(1.125rem,4.6vw,1.4375rem);line-height:1.3;white-space:normal;text-wrap:balance;margin:4px 0}
.mg-title strong,.mg-choice-title,.mg-result>strong{letter-spacing:normal;line-height:1.35;word-break:normal;overflow-wrap:break-word}
.mg-dialog :is(h1,h2,h3){line-height:1.3}
@media(max-height:650px){.mg-mission h1{font-size:1.0625rem}}
