/* Dedicated utility footer: music stays outside menu actions and the fitted playfield. */
:root{--cr-radio-h:156px}
html #rsc-radio,html.cr-q-on #rsc-radio,html.cr-running #rsc-radio,html.tc-gutters #rsc-radio{left:50%;right:auto;top:auto;bottom:calc(8px + env(safe-area-inset-bottom));transform:translateX(-50%);box-sizing:border-box;max-width:calc(100vw - 24px)}
#rsc-radio .rr-body{width:236px;gap:4px;flex-wrap:wrap}
#rsc-radio span#rr-title{order:5;max-width:220px;width:100%}
#rsc-radio .rr-volume{order:6}
#rsc-radio #rr-list-btn{order:4}
#rsc-radio:not(.collapsed){width:300px}
.runner-screen{bottom:calc(var(--cr-radio-h) + env(safe-area-inset-bottom))}
@media(pointer:fine){#phaser-game-container{height:calc(100% - var(--cr-play-head) - var(--cr-radio-h) - env(safe-area-inset-bottom))}#gb-btn{bottom:148px}}
@media(pointer:coarse){
 :root{--cr-hud-h:214px;--tc-h:200px}
 #cr-hud:not([hidden]){grid-template-rows:repeat(5,22px) auto}
 #cr-hud .cr-boss{grid-column:1/-1;white-space:normal;font-size:14px;line-height:18px;align-self:start}
 html.cr-q-on #cr-quick{top:auto;bottom:calc(var(--cr-radio-h) + 8px + env(safe-area-inset-bottom));left:0;right:0;width:min(720px,100%);padding:0 12px;margin:auto;overflow:auto;max-height:calc(100dvh - 200px)}
 html.cr-q-on #phaser-game-container{top:var(--cr-head);height:calc(100% - var(--cr-head) - var(--cr-radio-h) - 164px)}
 html.cr-run-hud #phaser-game-container{top:calc(var(--cr-head) + var(--cr-hud-h));height:calc(100% - var(--cr-head) - var(--cr-hud-h) - var(--tc-h) - var(--cr-radio-h) - env(safe-area-inset-bottom))}
 #touch-controls,#touch-controls:not(.tc-narrow){top:auto;bottom:calc(var(--cr-radio-h) + env(safe-area-inset-bottom));height:var(--tc-h);display:flex;padding:8px 12px;align-items:center;justify-content:space-between}
 #tc-joy,#touch-controls:not(.tc-narrow) #tc-joy{width:110px;height:110px}
 #tc-btns,#touch-controls:not(.tc-narrow) #tc-btns{display:grid;grid-template-columns:repeat(3,52px);gap:8px;align-items:end;margin:0;align-self:flex-end}
 #tc-laser-wrap{gap:8px}
 .tc-btn,.tc-main,#touch-controls:not(.tc-narrow) .tc-btn,#touch-controls:not(.tc-narrow) .tc-main{width:52px;height:52px;min-width:44px;min-height:44px;font-size:12px}
 #tc-missile,#tc-emp{margin-bottom:0!important}
 .tc-pill,#touch-controls:not(.tc-narrow) .tc-pill{width:52px;min-width:44px;height:44px;padding:0}
 #tc-pause,#touch-controls:not(.tc-narrow) #tc-pause{top:8px;right:12px;width:48px;height:48px;min-width:48px;min-height:48px}
}
/* A running game only reserves the small music button; opening it pauses play. */
html.cr-running:has(#rsc-radio.collapsed){--cr-radio-h:76px}
#rsc-radio:has(#rr-list:not([hidden])) .rr-body{visibility:hidden}
#rsc-radio #rr-list{position:absolute!important;top:6px!important;bottom:6px!important;left:58px!important;right:6px!important;max-height:114px;width:auto;padding:0}
#cr-hud .cr-missiles::before{content:'➤ ';font-size:18px}
/* The optional orientation hint also stays out of the music/menu bands. */
html.cr-q-on #turn-hint{bottom:calc(var(--cr-radio-h) + 164px + env(safe-area-inset-bottom));max-width:calc(100vw - 24px);box-sizing:border-box}
#rsc-radio .rr-row{width:100%;height:auto;min-height:44px}
html.cr-q-on:has(.runner-screen) #cr-quick{display:none}
@media(pointer:coarse) and (orientation:landscape){
 :root{--cr-hud-h:100px;--tc-h:0px}
 #cr-hud:not([hidden]){grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(2,22px) auto;gap:4px}
 #cr-hud .cr-boss{line-height:16px}
 #touch-controls,#touch-controls:not(.tc-narrow){height:112px}
 #tc-pause,#touch-controls:not(.tc-narrow) #tc-pause{right:196px}
}
/* Phone cockpit: two status rows, one control band including music. */
@media(pointer:coarse){
 :root{--cr-hud-h:56px;--tc-h:144px}
 #cr-hud:not([hidden]){grid-template-columns:repeat(5,minmax(0,1fr));grid-template-rows:22px 22px;gap:0 4px;padding:6px 8px;font-size:13px;line-height:22px}
 #cr-hud .cr-missiles::before{content:''}
 #cr-hud .cr-boss{font-size:13px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 html.cr-boss-active{--cr-hud-h:74px}
 html.cr-run-hud #phaser-game-container{top:calc(var(--cr-head) + var(--cr-hud-h));height:calc(100% - var(--cr-head) - var(--cr-hud-h) - var(--tc-h) - env(safe-area-inset-bottom))}
 #touch-controls,#touch-controls:not(.tc-narrow){bottom:env(safe-area-inset-bottom);height:144px;padding:8px 12px;align-items:flex-end}
 #tc-joy,#touch-controls:not(.tc-narrow) #tc-joy{width:96px;height:96px}
 #tc-btns,#touch-controls:not(.tc-narrow) #tc-btns{grid-template-columns:repeat(3,48px);gap:8px}
 .tc-btn,.tc-main,#touch-controls:not(.tc-narrow) .tc-btn,#touch-controls:not(.tc-narrow) .tc-main,.tc-pill,#touch-controls:not(.tc-narrow) .tc-pill{width:48px;height:44px;font-size:13px}
 #tc-pause,#touch-controls:not(.tc-narrow) #tc-pause{top:8px;right:12px;width:48px;height:44px;min-height:44px}
 html.cr-running #rsc-radio.collapsed{left:12px;bottom:calc(108px + env(safe-area-inset-bottom));transform:none;max-width:48px;padding:0;min-height:44px;height:44px}
 html.cr-running #rsc-radio.collapsed #rr-toggle{width:44px;height:44px;min-width:44px}
 html.cr-q-on #cr-quick{top:auto;bottom:calc(var(--cr-radio-h) + 8px + env(safe-area-inset-bottom));max-height:none;overflow:visible;pointer-events:auto}
 html.cr-q-on #cr-quick .crq-row{flex-direction:row;gap:8px}
 html.cr-q-on #cr-quick .crq-b{width:auto;min-height:44px;height:56px;flex:1 1 0}
}
@media(pointer:coarse) and (orientation:portrait){
 html.cr-running #rsc-radio.collapsed{bottom:calc(100px + env(safe-area-inset-bottom))}
 #touch-controls,#touch-controls:not(.tc-narrow){padding-bottom:8px}
 #tc-joy,#touch-controls:not(.tc-narrow) #tc-joy{width:88px;height:88px}
}
@media(pointer:coarse) and (orientation:landscape){
 #turn-hint{display:none!important}
 :root{--cr-hud-h:30px;--tc-h:0px}
 html.cr-boss-active{--cr-hud-h:48px}
 #cr-hud:not([hidden]){grid-template-columns:repeat(10,minmax(0,1fr));grid-template-rows:22px;padding:4px 8px;gap:0 6px}
 html.cr-run-hud #phaser-game-container{top:calc(var(--cr-head) + var(--cr-hud-h));height:calc(100% - var(--cr-head) - var(--cr-hud-h) - env(safe-area-inset-bottom))}
 html.cr-q-on #cr-quick{top:calc(var(--cr-head) + 40px);bottom:auto;left:12px;right:12px;width:min(720px,calc(100% - 24px));padding:0;gap:8px}
 html.cr-q-on #phaser-game-container{top:var(--cr-head);height:calc(100% - var(--cr-head) - var(--cr-radio-h))}
 #touch-controls,#touch-controls:not(.tc-narrow){top:calc(var(--cr-head) + var(--cr-hud-h));bottom:0;height:auto;align-items:center;padding:8px 12px}
 #tc-btns,#touch-controls:not(.tc-narrow) #tc-btns{align-self:center;grid-template-columns:repeat(3,48px)}
 #tc-pause,#touch-controls:not(.tc-narrow) #tc-pause{top:8px;right:12px}
 html.cr-running #rsc-radio.collapsed{left:12px;top:calc(var(--cr-head) + var(--cr-hud-h) + 8px);bottom:auto}
}
@media(pointer:coarse) and (orientation:portrait){
 #tc-pause,#touch-controls:not(.tc-narrow) #tc-pause{left:180px;right:auto}
 html.cr-running #rsc-radio.collapsed{left:124px;bottom:calc(92px + env(safe-area-inset-bottom))}
 #tc-laser-wrap{gap:8px}
}
@media(pointer:coarse){
 #cr-hud:not([hidden]){grid-template-columns:repeat(5,max-content);justify-content:space-between;column-gap:4px;box-sizing:border-box;width:100%;max-width:100vw}
 #cr-hud .cr-boss{min-width:0;contain:inline-size;max-width:100%}
}
@media(pointer:coarse) and (orientation:landscape){
 #cr-hud:not([hidden]){grid-template-columns:repeat(10,max-content)}
}
@media(pointer:coarse) and (orientation:landscape){
 html.cr-q-on #gb-btn{top:calc(var(--cr-head) + 176px);bottom:auto;min-height:44px}
}

/* Run state wins over inline menu-button polling at every viewport size. */
html.cr-running #gb-btn,html.cr-running #cr-quick{display:none!important}
@media(pointer:coarse) and (orientation:landscape){
 html.cr-playing{--cr-head:env(safe-area-inset-top,0px)}
 html.cr-playing #rsc-bar{display:none}
}

/* Translucent fills, opaque labels: targets and gaps retain their dimensions. */
@media(pointer:coarse) and (orientation:landscape){
 #touch-controls.tc-narrow{opacity:1}
 #touch-controls .tc-btn,#touch-controls .tc-pill,#touch-controls #tc-pause{background:rgba(23,24,32,.65);color:var(--cr-bone);text-shadow:0 1px 2px #050608}
 #touch-controls .tc-main,#touch-controls .tc-pill.on,#touch-controls .tc-btn:active,#touch-controls #tc-pause.on{background:rgba(255,107,44,.65);color:#fff;border-color:var(--cr-accent)}
}

/* Keep the landscape title clear between the complete header stack and play rows. */
@media(pointer:coarse) and (orientation:landscape){
 html.sn-on.cr-q-on #gb-btn{top:auto;bottom:calc(16px + env(safe-area-inset-bottom));left:24px;transform:none}
}

/* Storyboard round 1: use the shared bar height and CSS-pixel targets. */
html.sn-on .runner-screen{top:calc(var(--sn-h,90px) + 8px);bottom:calc(12px + env(safe-area-inset-bottom));z-index:2100;box-sizing:border-box}
html.sn-on #global-board{top:calc(var(--sn-h,90px) + 8px);bottom:8px;height:auto;z-index:2200;align-items:center;overflow:auto}
html.sn-on #global-board .gb-card{max-height:100%;margin:0 auto;overflow:auto}
.runner-menu-sheet>h2{position:sticky;top:-20px;z-index:2;background:var(--cr-panel);padding-right:80px;min-height:44px;margin-bottom:8px}
.runner-menu-header{position:sticky;top:24px;z-index:3;margin:0;padding:0;text-align:right}
.runner-menu-header .runner-menu-back{margin-top:-60px;vertical-align:top}
.runner-screen .runner-primary{background:var(--cr-accent);color:var(--cr-ink);font-weight:800}
.runner-load-title{font:900 clamp(28px,5vw,64px)/1 var(--type-display);border-top:3px solid var(--cr-accent);padding-top:16px}
#runner-loading progress,.runner-run-loading progress{width:min(320px,85%);height:12px;accent-color:var(--cr-accent)}
/* Run loader (gameScene.showRunLoader): the page loader's look over the black playfield while a run's art downloads. */
.runner-run-loading{position:absolute;inset:0;z-index:2;display:flex;flex-direction:column;gap:16px;align-items:center;justify-content:center;text-align:center;padding:24px;background:#080b15;color:#ece4d3;font:600 20px/1.4 var(--type-body,'Barlow Condensed',sans-serif)}
#runner-loading progress[hidden],.runner-load-actions[hidden]{display:none}
#runner-loading small{font:400 16px/1.4 var(--type-caption);max-width:340px}
.runner-load-actions a{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 16px;margin:4px;color:var(--cr-bone);border:1px solid var(--cr-accent);font-family:var(--type-button)}
.cr-lock-hint{margin:4px 0 0;font:600 16px/1.3 var(--type-caption);color:var(--cr-bone)}
html.sn-on .runner-screen.runner-pause{top:calc(var(--sn-h,90px) + 16px);bottom:auto;max-height:50dvh;left:max(12px,calc((100vw - 520px)/2));right:max(12px,calc((100vw - 520px)/2));padding:20px;background:rgba(11,12,16,.95)}
.runner-pause-actions{display:flex;flex-wrap:wrap;gap:4px 8px}
.runner-pause button+button{margin-left:0}
html.sn-on .runner-pause #rsc-radio,html.sn-on body.sn-songs-open .runner-pause #rsc-radio{display:block!important;position:static!important;inset:auto!important;transform:none!important;width:100%!important;max-width:100%!important;margin:8px 0;z-index:auto!important}
.runner-pause #rsc-radio .rr-body{width:100%;visibility:visible;display:flex}
.runner-pause #rsc-radio #rr-list{position:static!important;width:100%;max-height:140px;overflow:auto}
.runner-pause #rsc-radio #rr-title{max-width:none}
html:has(.runner-screen) #touch-controls{visibility:hidden}
@media(pointer:coarse) and (orientation:landscape){
 html.sn-on.cr-running{--sn-bar:44px;--sn-mb:44px;--cr-head:calc(var(--sn-h) + env(safe-area-inset-top));--cr-play-head:var(--cr-head)}
 html.sn-on.cr-running .sn-bar{display:flex}
 html.sn-on.cr-running .sn-mb{top:calc(var(--sn-bar) + env(safe-area-inset-top));left:0;right:0;transform:none;width:100%;height:44px;padding:0 8px;background:var(--cr-panel);border-bottom:1px solid var(--cr-line)}
 html.sn-on.cr-running .sn-mb>:not(.sn-mb-toggle){display:flex}
 html.cr-running #rsc-bar{display:flex}
 /* Production run layout: the playfield spans the full width and the touch controls sit on top of it. */
 #touch-controls,#touch-controls:not(.tc-narrow){pointer-events:none}
 #touch-controls>*{pointer-events:auto}
 html.sn-on .runner-screen{padding:12px;top:calc(var(--sn-h) + 8px);bottom:8px}
 .runner-menu-sheet>h2{top:-12px;font-size:26px;margin:0;min-height:44px}
 .runner-menu-header{top:32px;height:0}
 .runner-menu-header .runner-menu-back{margin-top:-44px}
 .runner-hangar-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
 .runner-hangar-grid img{height:72px}
 .runner-help-row{margin:4px 0;min-height:40px}
 .runner-help-row p{line-height:1.2}
 html.sn-on .runner-screen.runner-pause{max-height:calc(100dvh - var(--sn-h) - 24px);padding:12px}
}
.runner-help-tabs{display:flex;gap:8px;position:sticky;top:44px;background:var(--cr-panel);z-index:2}
.runner-help-tabs button[aria-pressed=true]{background:var(--cr-accent);color:var(--cr-ink)}
.runner-power-grid:not([hidden]){display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.runner-power-grid h3{font-size:20px}.runner-power-grid .runner-help-row{margin:0}
.runner-selected-preview{display:flex;align-items:center;gap:16px;margin:8px 0}
.runner-selected-preview img{width:140px;height:88px;object-fit:contain}
.runner-hangar-grid progress{width:90%;height:6px;accent-color:var(--cr-accent)}
.runner-pause #rsc-radio{height:auto!important;min-height:0!important;padding:8px!important}
.runner-pause #rsc-radio .rr-body{height:auto!important;min-height:44px!important;visibility:visible!important}
.runner-pause #rsc-radio #rr-list{margin-top:8px!important;height:120px!important}
@media(pointer:coarse) and (orientation:landscape){.runner-selected-preview{display:none}.runner-help-tabs{top:44px}.runner-help-row{min-height:32px}.runner-help-row h3{margin:8px 0}}
/* A single landscape utility row leaves at least 270px for the playfield. */
@media(pointer:coarse) and (orientation:landscape){
 html.sn-on.cr-running{--sn-bar:44px;--sn-mb:0px;--sn-h:44px;--cr-head:calc(44px + env(safe-area-inset-top));--cr-play-head:var(--cr-head)}
 html.sn-on.cr-running .sn-bar{display:flex;width:210px;right:auto;justify-content:space-between;gap:4px}
 html.sn-on.cr-running .sn-mid,html.sn-on.cr-running .sn-log{display:none}
 html.sn-on.cr-running .sn-mb{top:env(safe-area-inset-top);left:210px;right:0;width:calc(100% - 210px);height:44px;padding:0 8px}
}

@media(pointer:coarse) and (orientation:landscape){
 .runner-menu-sheet:has(.runner-hangar-grid)>p{display:inline-block;font-size:14px;line-height:20px;margin:2px 12px 4px 0}
 .runner-hangar-grid img{height:48px}
 .runner-hangar-grid button{gap:4px;font-size:14px;line-height:1.2;padding:4px}
 .runner-hangar-grid .runner-ship-state{font-size:14px}
}

/* The music bar owns transport. Songs owns title, volume and the full setlist. */
html.sn-on body.sn-songs-open #rsc-radio.runner-songs-sheet{display:flex!important;flex-direction:column;position:fixed!important;left:50%!important;right:auto!important;top:calc(var(--sn-h) + env(safe-area-inset-top) + 8px)!important;bottom:auto!important;transform:translateX(-50%)!important;width:min(520px,calc(100vw - 24px))!important;max-width:none!important;max-height:calc(100dvh - var(--sn-h) - 24px)!important;box-sizing:border-box;padding:12px!important;background:var(--cr-panel);border:2px solid var(--cr-accent);opacity:1;z-index:1900!important;overflow:auto}
#rsc-radio.runner-songs-sheet .rr-body{display:flex!important;visibility:visible!important;flex-direction:column;align-items:stretch;width:100%!important;height:auto!important;min-height:0!important;gap:4px}
#rsc-radio.runner-songs-sheet #rr-prev,#rsc-radio.runner-songs-sheet #rr-play,#rsc-radio.runner-songs-sheet #rr-next,#rsc-radio.runner-songs-sheet #rr-list-btn{display:none!important}
#rsc-radio.runner-songs-sheet #rr-title{order:0;width:100%;max-width:none!important;font:600 18px/24px var(--type-caption);white-space:normal}
#rsc-radio.runner-songs-sheet .rr-volume{order:1;display:flex;font:500 14px/24px var(--type-caption)}
html.sn-on #rsc-radio.runner-songs-sheet #rr-list{display:block!important;position:static!important;inset:auto!important;flex:none;width:100%;height:264px!important;max-height:calc(100dvh - var(--sn-h) - 152px)!important;min-height:0;margin:4px 0 0!important;padding:0;overflow:auto;box-sizing:border-box}
#rsc-radio.runner-songs-sheet .rr-row{height:44px;min-height:44px;box-sizing:border-box;font:500 16px/20px var(--type-caption);color:var(--cr-bone);border-bottom:1px solid var(--cr-line)}
#rsc-radio.runner-songs-sheet .rr-row span{font:inherit;max-width:none;white-space:normal}
html.sn-on #rsc-radio.runner-songs-sheet #rr-list{height:266px!important}
/* Nested Songs stays below pause actions; only its setlist scrolls. */
html.sn-on .runner-pause #rsc-radio.runner-songs-sheet{display:flex!important;flex-direction:column;position:static!important;inset:auto!important;transform:none!important;width:100%!important;max-width:100%!important;max-height:none!important;box-sizing:border-box;opacity:1;overflow:visible;z-index:auto!important}
html.sn-on .runner-pause #rsc-radio.runner-songs-sheet #rr-list{height:120px!important;max-height:120px!important;overflow:auto}

/* Phone landscape menu (layout only, no new art): the floating cadets and title get the left side,
   the same EASY / MEDIUM / HARD / ACE and HANGAR / HOW TO PLAY / TOP SCORES / BOSS FILE buttons stack
   two-wide on the right, so nothing sits on top of the cadets or under the Cadet Bar. */
@media(pointer:coarse) and (orientation:landscape) and (max-height:540px){
 html.cr-q-on #phaser-game-container{position:fixed;top:var(--cr-head);left:env(safe-area-inset-left,0px);right:auto;width:56%;height:calc(100% - var(--cr-head) - env(safe-area-inset-bottom,0px))}
 html.cr-q-on #cr-quick{position:fixed;top:calc(var(--cr-head) + 8px);bottom:calc(8px + env(safe-area-inset-bottom,0px));left:auto;right:calc(12px + env(safe-area-inset-right,0px));width:calc(44% - 24px);margin:0;padding:0;gap:8px;justify-content:center;overflow-y:auto;overflow-x:hidden}
 html.cr-q-on #cr-quick .crq-row{display:grid;grid-template-columns:1fr 1fr;gap:8px;flex:none}
 html.cr-q-on #cr-quick .crq-b{width:100%;height:clamp(44px,calc((100dvh - var(--cr-head) - 56px) / 4),60px);min-height:44px;font-size:20px}
 /* GALAXY TOP 50 sits above the title, centred on the left panel, as it does on an upright phone. */
 html.sn-on.cr-q-on #gb-btn{top:calc(var(--cr-head) + 8px);bottom:auto;left:calc(env(safe-area-inset-left,0px) + 28%);transform:translateX(-50%)}
}

/* RT-06: in phone landscape the fire buttons (EMP, MISSILE, LASER, AUTO, pause) get their own right-hand gutter,
   so enemies and bosses enter the playfield on clear sky instead of under the buttons. Same buttons, same look:
   only the playfield's right edge moves in (3 x 48px buttons + 2 x 8px gaps + 12px padding each side = 184px). */
@media(pointer:coarse) and (orientation:landscape){
 html.cr-run-hud #phaser-game-container{left:0;right:auto;width:calc(100% - 184px - env(safe-area-inset-right,0px))}
}
