@media (any-pointer:coarse),(max-width:1050px){
 html,body,#root{width:100%;min-height:var(--game-height);overflow-x:hidden}.game-page{height:var(--game-height)!important;min-height:0!important;display:flex;flex-direction:column;overflow:hidden!important}.game-page .game-header{height:48px!important;min-height:48px!important;padding:4px 10px!important;padding-right:90px!important}.game-header .brand{font-size:14px}.game-header .brand-mark{width:30px;height:30px}.level-pill{font-size:11px;padding:5px}.game-page .equation-banner{height:auto!important;min-height:54px!important;flex:none;margin:0!important;padding:5px 10px!important;gap:6px;grid-template-columns:1fr auto!important}.equation-banner .eyebrow{font-size:10px}.math-words{font-size:11px}.math-words span{font-size:11px!important}.math-words b{font-size:15px!important}.game-page .play-layout,.game-page .play-layout.build-mode{display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:auto minmax(100px,1fr) auto!important;flex:1;min-height:0!important;height:auto!important;max-height:none!important;width:100%!important;max-width:100%!important;gap:6px!important;padding:6px!important;overflow:hidden!important;--matrix-guide-width:36px;--matrix-fit-height:calc(var(--game-height) - 270px)}.game-page .mission-card{grid-column:1!important;grid-row:1!important;display:grid!important;grid-template-columns:70px minmax(0,1fr)!important;align-items:center;gap:6px;height:auto!important;min-height:0!important;padding:6px!important;max-height:88px;overflow:auto}.mission-card .progress,.mission-card .tip{grid-column:2}.mission-card .target-picture{grid-column:1;grid-row:1/4}.target-picture img{max-height:58px!important;width:100%;object-fit:contain}.target-picture h2{font-size:10px!important;margin:2px 0}.mission-card .multiplication-table{display:none!important}.mission-card .tip{font-size:11px;line-height:1.2;margin:0}.mission-card .progress-label{font-size:11px}.game-page .board-wrap{grid-column:1!important;grid-row:2!important;min-height:0!important;height:100%!important;display:flex;justify-content:center;padding:0!important}.game-page .matrix-with-guides{min-height:0!important;height:100%!important;max-height:100%!important;width:100%!important;overflow:hidden}.game-page .play-layout .puzzle-board{width:min(calc(100% - 36px),calc(var(--matrix-fit-height)*var(--matrix-ratio)))!important;max-width:calc(100% - 36px)!important;max-height:var(--matrix-fit-height)!important;min-height:0!important;padding:3px;gap:2px;border-radius:8px}.column-guide b,.row-guide b{font-size:12px!important;padding:2px 4px!important}.row-guide small{font-size:9px!important}.matrix-caption{font-size:12px!important;margin:2px 0!important}.square-number{font-size:11px}.game-page .tray-card,.game-page .building-instruction-side{grid-column:1!important;grid-row:3!important;height:auto!important;min-height:0!important;max-height:105px!important;padding:6px!important;overflow:auto!important}.tray-title{font-size:12px}.tray-title h2{font-size:14px;margin:0}.piece-tray{display:flex!important;gap:8px;padding:4px!important;overflow-x:auto;overflow-y:hidden}.loose-piece{flex:0 0 54px!important;width:54px!important;height:54px!important;min-height:54px!important;border-width:2px!important;border-radius:6px}.building-instruction-side{font-size:13px!important;line-height:1.25}.building-instruction-side p{margin:4px 0!important}.modal{max-width:calc(100vw - 24px);max-height:calc(var(--game-height) - 24px);overflow:auto}
}
@media (any-pointer:coarse) and (orientation:landscape),(max-width:1050px) and (orientation:landscape){
 .game-page .game-header{height:40px!important;min-height:40px!important}.game-page .equation-banner{min-height:42px!important}.game-page .play-layout,.game-page .play-layout.build-mode{grid-template-columns:minmax(110px,20%) minmax(0,1fr) minmax(100px,20%)!important;grid-template-rows:minmax(0,1fr)!important;--matrix-fit-height:calc(var(--game-height) - 130px)}.game-page .mission-card{grid-column:1!important;grid-row:1!important;display:flex!important;flex-direction:column;max-height:100%!important;height:100%!important}.target-picture img{max-height:80px!important}.game-page .board-wrap{grid-column:2!important;grid-row:1!important}.game-page .tray-card,.game-page .building-instruction-side{grid-column:3!important;grid-row:1!important;max-height:100%!important;height:100%!important}.piece-tray{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;overflow:auto}.loose-piece{width:100%!important;height:auto!important;min-height:38px!important;aspect-ratio:1}.math-words{display:none}
}
/* Phone rows fit the visible viewport; board size uses the space left after labels. */
@media(max-width:1050px),(any-pointer:coarse){
 html body.im-native-game #root .game-page{box-sizing:border-box!important;height:var(--game-height,100dvh)!important;min-height:0!important;padding:0!important}
 html body.im-native-game #root .game-page .game-header{box-sizing:border-box!important;flex:0 0 44px!important;height:44px!important;min-height:44px!important;overflow:hidden!important}
 html body.im-native-game #root .equation-banner{box-sizing:border-box!important;flex:0 0 50px!important;height:50px!important;min-height:50px!important;width:100%!important;gap:4px!important;padding:3px 8px!important}
 html body.im-native-game #root .equation-banner strong{font-size:25px!important;line-height:28px!important}
 html body.im-native-game #root .play-layout{box-sizing:border-box!important;flex:1 1 0!important;height:auto!important;min-height:0!important;margin:0!important;padding:4px!important;gap:4px!important}
 html body.im-native-game #root .board-wrap{box-sizing:border-box!important;min-width:0!important;min-height:0!important;height:100%!important;gap:0!important;overflow:hidden!important}
 html body.im-native-game #root .matrix-with-guides{box-sizing:border-box!important;flex:1 1 0!important;min-height:0!important;height:auto!important;margin:0!important;padding:30px 0 0 36px!important;display:flex!important;align-items:center!important;justify-content:center!important}
 html body.im-native-game #root .puzzle-board{box-sizing:border-box!important;flex:none!important;width:var(--phone-board-width,100%)!important;max-width:100%!important;height:auto!important;max-height:100%!important;margin:0!important;padding:2px!important;gap:1px!important}
 html body.im-native-game #root .column-guide{left:36px!important;height:26px!important}
 html body.im-native-game #root .row-guide{width:32px!important;top:30px!important}
 html body.im-native-game #root .matrix-caption{flex:0 0 auto!important;min-height:20px!important;font-size:10px!important;gap:4px!important;margin:2px 0!important;flex-wrap:wrap!important}
 html body.im-native-game #root .mission-card,html body.im-native-game #root .tray-card,html body.im-native-game #root .building-instruction-side{box-sizing:border-box!important;min-width:0!important}
}
@media(max-width:700px) and (orientation:portrait){
 html body.im-native-game #root .play-layout{grid-template-columns:minmax(0,1fr)!important;grid-template-rows:64px minmax(0,1fr) 96px!important}
 html body.im-native-game #root .mission-card{max-height:64px!important;height:64px!important;padding:3px!important}
 html body.im-native-game #root .tray-card,html body.im-native-game #root .building-instruction-side{max-height:96px!important;height:96px!important;padding:4px!important}
 html body.im-native-game #root .target-picture img{max-height:42px!important}
}
@media(max-width:700px) and (orientation:portrait){
 html body.im-native-game #root .play-layout{grid-template-rows:100px minmax(0,1fr) 104px!important}
 html body.im-native-game #root .mission-card{height:100px!important;max-height:100px!important;grid-template-columns:90px minmax(0,1fr)!important;grid-template-rows:auto auto!important;gap:4px 8px!important;padding:6px!important;overflow:visible!important}
 html body.im-native-game #root .target-picture{grid-column:1!important;grid-row:1/3!important;display:flex!important;flex-direction:column!important;align-items:center!important;margin:0!important;gap:2px!important}
 html body.im-native-game #root .target-picture img{width:76px!important;max-height:55px!important;height:55px!important;object-fit:contain!important}
 html body.im-native-game #root .target-picture h2{margin:0!important;font-size:9px!important;line-height:10px!important}
 html body.im-native-game #root .target-picture small{font-size:9px!important;letter-spacing:0!important}
 html body.im-native-game #root .mission-card .progress{grid-column:2!important;grid-row:1!important;margin:0!important;min-width:0!important}
 html body.im-native-game #root .mission-card .tip{grid-column:2!important;grid-row:2!important;display:block!important;font-size:12px!important;line-height:15px!important;margin:0!important;overflow-wrap:anywhere!important}
 html body.im-native-game #root .tray-card{height:104px!important;max-height:104px!important}
 html body.im-native-game #root .piece-tray{min-height:62px!important;flex-shrink:0!important;touch-action:pan-x!important}
 html body.im-native-game #root .loose-piece{pointer-events:auto!important;touch-action:manipulation!important}
 html body.im-native-game #root .square-number{width:24px!important;height:24px!important;font-size:11px!important;min-width:0!important;min-height:0!important}
}
@media(max-width:1050px),(any-pointer:coarse){
 html body.im-native-game #root .puzzle-board .cell>.square-number{position:absolute!important;inset:4px auto auto 4px!important;display:grid!important;place-items:center!important;width:auto!important;height:auto!important;max-width:calc(100% - 8px)!important;max-height:calc(100% - 8px)!important;border-radius:0!important;background:transparent!important;color:#123b70!important;font-size:min(32px,calc(var(--phone-cell-size,80px)*.4))!important;line-height:1!important;font-weight:900!important;text-shadow:none!important;border:0!important;box-shadow:none!important;box-sizing:border-box!important;pointer-events:none!important}
 html body.im-native-game #root .puzzle-board .cell:nth-child(3n+2)>.square-number{color:#123b70!important}
 html body.im-native-game #root .puzzle-board .cell:nth-child(3n)>.square-number{color:#123b70!important}
 html body.im-native-game #root .puzzle-board .cell.filled>.square-number{display:none!important}
}
@media(max-width:1050px),(any-pointer:coarse){
 html body.im-native-game #root .puzzle-board .cell:not(.building-cell)>.square-number{color:#123b70!important}
 html body.im-native-game #root .puzzle-board .cell:not(.building-cell):nth-child(3n+2)>.square-number{color:#123b70!important}
 html body.im-native-game #root .puzzle-board .cell:not(.building-cell):nth-child(3n)>.square-number{color:#123b70!important}
}

@media(max-width:1050px),(any-pointer:coarse){
 html body.im-native-game #root .puzzle-board{gap:0!important;padding:0!important;overflow:hidden!important}
 html body.im-native-game #root .puzzle-board .cell{border-radius:0!important}
 html body.im-native-game #root .puzzle-board .cell:not(.filled){border-width:1px!important}
 html body.im-native-game #root .puzzle-board .cell:not(.building-cell):not(.filled){background:#f5f7ff!important}
 html body.im-native-game #root .puzzle-board .cell.filled{border:0!important;padding:0!important;box-shadow:none!important}
 html body.im-native-game #root .puzzle-board .cell.filled>span{inset:0!important;border:0!important;border-radius:0!important}
}

/* Landscape: use the visible height, with independently scrolling panels. */
@media (any-pointer:coarse) and (orientation:landscape),(max-width:1050px) and (orientation:landscape){
html body.im-native-game #root .game-page .game-header{flex:0 0 40px!important;height:40px!important;min-height:40px!important}
html body.im-native-game #root .equation-banner{flex:0 0 36px!important;height:36px!important;min-height:36px!important;padding:2px 8px!important}
html body.im-native-game #root .equation-banner strong{font-size:22px!important;line-height:25px!important}
html body.im-native-game #root .play-layout,html body.im-native-game #root .play-layout.build-mode{grid-template-columns:minmax(110px,22%) minmax(0,1fr) minmax(110px,22%)!important;grid-template-rows:minmax(0,1fr)!important}
html body.im-native-game #root .mission-card{grid-column:1!important;grid-row:1!important;display:flex!important;flex-direction:column!important;height:100%!important;max-height:100%!important;min-height:0!important;overflow:auto!important;padding:5px!important;gap:5px!important}
html body.im-native-game #root .board-wrap{grid-column:2!important;grid-row:1!important;flex-direction:column!important}
html body.im-native-game #root .tray-card,html body.im-native-game #root .building-instruction-side{grid-column:3!important;grid-row:1!important;height:100%!important;max-height:100%!important;overflow:auto!important;padding:5px!important}
html body.im-native-game #root .piece-tray{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:5px!important;overflow:auto!important;min-height:0!important;touch-action:pan-y!important}
html body.im-native-game #root .loose-piece{width:100%!important;height:auto!important;min-height:0!important;aspect-ratio:1!important;touch-action:manipulation!important}
html body.im-native-game #root .target-picture img{height:auto!important;max-height:70px!important;object-fit:contain!important}
html body.im-native-game #root .mission-card .tip{font-size:11px!important;line-height:14px!important}
html body.im-native-game #root .mission-card .progress{width:100%!important;margin:0!important}
}
