/* Shared top/bottom glass rails leave the model canvas clear. */
body{display:flex;flex-direction:column;height:100dvh;overflow:hidden}
body>main,body.mobile-device>main{width:100%;height:auto;min-width:0;min-height:0;flex:1 1 0}
body{--top-rail-height:72px;--bottom-rail-height:var(--top-rail-height)}
@media(max-width:1000px){body{--top-rail-height:60px}}
@media(max-width:640px){body{--top-rail-height:52px}}
@media(max-height:650px){body{--top-rail-height:48px}}
body>header,body.mobile-device>header{flex:0 0 auto;height:calc(var(--top-rail-height) * .4);min-height:calc(var(--top-rail-height) * .4);padding-top:0;padding-bottom:0}
body>header .brand-sub,body>header #fullscreenToggle{display:none}
body>header .difficulty-current{margin-left:auto}
body>header #help,body.mobile-device>header #help{position:relative;width:32px;height:32px;min-width:32px;flex:0 0 32px;font-size:20px}
body>header #changeDifficulty{position:relative}
body>header #help::before,body>header #changeDifficulty::before{content:'';position:absolute;left:0;right:0;top:50%;height:44px;transform:translateY(-50%)}
#gameStatusBar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex:0 0 auto;height:calc(var(--bottom-rail-height) * .8);min-height:calc(var(--bottom-rail-height) * .8);margin:0;padding:3px 20px;color:#dceefb;background:linear-gradient(110deg,#173950dc,#102c42e8);border-top:1px solid #96cee570;box-shadow:inset 0 1px 0 #f1fbff12,0 -6px 24px #03111e26;backdrop-filter:blur(22px) saturate(115%);-webkit-backdrop-filter:blur(22px) saturate(115%);font-size:14px;line-height:1.2;z-index:4}
#gameStatusBar .status-legend,#gameStatusBar .status-progress{display:flex;align-items:center;justify-content:center;gap:16px;flex-wrap:wrap}
#gameStatusBar span{display:inline;white-space:nowrap}
#gameStatusBar .key-dot{width:7px;height:7px;margin-right:5px}
#gameStatusBar #viewLabel{color:#a8d5ef}
body.mobile-device>header{gap:6px;padding-left:8px;padding-right:8px}
body.mobile-device #changeDifficulty{font-size:0;height:32px;min-height:32px;padding:4px 8px}
body.mobile-device #changeDifficulty::after{content:attr(data-current) ' ▾';font-size:12px}
body.mobile-device>header .brand-sub{display:none}
body.mobile-device #gameStatusBar{padding:3px 10px;font-size:12px;gap:3px}
body.mobile-device #gameStatusBar .status-legend{gap:10px}
body.mobile-device #gameStatusBar .status-progress{gap:10px}
@media(orientation:portrait){
 body.mobile-device{--bottom-rail-height:var(--top-rail-height)}
 body.mobile-device #gameStatusBar{flex-direction:column;justify-content:center}
 body.mobile-device>header .brand{font-size:21px}
}
@media(orientation:landscape){
 body.mobile-device{--top-rail-height:46px;--bottom-rail-height:var(--top-rail-height)}
 body.mobile-device #gameStatusBar{padding:3px 12px}
}

/* Level completion: frosted blue glass, light rim and restrained cyan highlights. */
dialog#levelCompleteDialog{width:min(540px,calc(100vw - 28px));max-height:calc(100dvh - 28px);overflow:auto;margin:auto;padding:0;border:1px solid #b4e3f29e;border-radius:28px;color:#f0f9ff;background:linear-gradient(145deg,#426b87b3 0%,#20435bbf 45%,#102c43cc 100%);box-shadow:inset 0 1px 0 #f5ffff85,inset 0 -1px 0 #72b9d84a,0 24px 80px #00101db3;backdrop-filter:blur(20px) saturate(115%);-webkit-backdrop-filter:blur(20px) saturate(115%);font-family:Manrope,Arial,sans-serif}
#levelCompleteDialog::backdrop{background:#05121f52;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px)}
.level-result{position:relative;padding:30px}
.level-result .result-close{position:absolute;top:14px;right:14px;width:36px;height:36px;display:grid;place-items:center;padding:0;border:1px solid #a4d0e342;border-radius:50%;background:#c3ecff0c;color:#d8edfa;font-size:23px;line-height:1}
.result-seal{display:grid;place-items:center;width:54px;height:54px;margin:0 0 16px;border-radius:17px;border:1px solid #acf0ffad;background:linear-gradient(140deg,#a4f2ff38,#3599bf29);box-shadow:inset 0 1px 0 #efffff6b,0 4px 22px #3ec5eb14;color:#c3f7ff;font-size:28px;font-weight:500}
.result-eyebrow{margin:0 0 8px;color:#a9d5ed;font-size:12px;letter-spacing:1.8px;font-weight:700}
.level-result h2{margin:0;color:#f3fbff;font-size:30px;line-height:1.15;letter-spacing:-.8px;font-weight:750}
.level-result .result-description{margin:10px 0 22px;color:#c5dce9;font-size:15px;line-height:1.55}
.result-stats{display:grid;grid-template-columns:1fr 1.5fr;gap:10px;margin:0 0 18px}
.result-stat{padding:17px 18px 15px;border-radius:17px;border:1px solid #b3deed40;background:linear-gradient(145deg,#b5e8ff19,#6899bf09);box-shadow:inset 0 1px 0 #effaff17}
.result-value{display:block;margin-bottom:7px;font-size:34px;line-height:1.1;font-weight:600;color:#f3fbff;font-variant-numeric:tabular-nums;letter-spacing:-1px}
.result-value small{font-size:19px;font-weight:400;letter-spacing:0;color:#a8cadd}
.result-stat-label{display:block;font-size:13px;line-height:1.35;color:#bdd6e7}
.result-next{display:flex;justify-content:space-between;gap:18px;align-items:center;margin:0 0 22px;padding:17px 0;border-top:1px solid #a5d7ef38;border-bottom:1px solid #a5d7ef38}
.result-next-label{display:block;margin-bottom:5px;color:#98bed5;font-size:11px;letter-spacing:1.4px;font-weight:700}
.result-next-title{font-size:17px;font-weight:600;color:#e4f6ff}
.result-next-count{text-align:right;font-size:15px;line-height:1.4;color:#c2dce9}
.result-next-count strong{font-size:23px;color:#e9f9ff;font-weight:600}
.result-continue{display:flex;align-items:center;justify-content:center;gap:16px;width:100%;min-height:50px;padding:13px 18px;border:1px solid #b1eeffc2;border-radius:14px;background:linear-gradient(125deg,#56acd9cc,#2b789fe0);box-shadow:inset 0 1px 0 #ffffff63,0 5px 20px #061c3059;color:#f3fcff;font:600 15px/1.3 Manrope,Arial,sans-serif}
.result-continue:hover{filter:brightness(1.08)}
.result-note{margin:0 0 16px;color:#b9d2e2;font-size:12px;line-height:1.5}
.result-note[hidden]{display:none}
@media(max-width:420px){
 .level-result{padding:24px 20px}
 .level-result h2{font-size:27px}
 .result-stat{padding:15px 13px}
 .result-value{font-size:31px}
}
@media(orientation:landscape) and (max-height:500px){
 dialog#levelCompleteDialog{width:min(580px,calc(100vw - 32px));border-radius:22px}
 .level-result{padding:19px 24px}
 .result-seal{position:absolute;top:20px;left:24px;width:42px;height:42px;border-radius:13px;font-size:24px}
 .result-eyebrow,.level-result h2{margin-left:58px}
 .result-eyebrow{font-size:10px;margin-bottom:4px}
 .level-result h2{font-size:25px}
 .level-result .result-description{margin:12px 0;font-size:13px}
 .result-stats{margin-bottom:12px;gap:10px}
 .result-stat{padding:10px 15px}
 .result-value{font-size:28px;margin-bottom:4px}
 .result-stat-label{font-size:12px}
 .result-next{padding:10px 0;margin-bottom:12px}
 .result-next-label{font-size:10px;margin-bottom:3px}
 .result-next-title{font-size:15px}
 .result-next-count{font-size:13px}
 .result-next-count strong{font-size:19px}
 .result-continue{min-height:44px;padding:10px 16px;font-size:14px}
}
@media(prefers-reduced-motion:no-preference){
 #levelCompleteDialog[open]{animation:result-enter .26s ease-out}
 @keyframes result-enter{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
}

/* Clean phone artwork contains no baked progress UI: the live panel is the only one. */
body.mobile-device #startScreen{position:fixed;inset:0 0 auto;width:100%;height:var(--myo-screen-height,100dvh);min-height:0;padding:0;background:#102235}
body.mobile-device #startScreen .loading-artwork{inset:0;width:100%;height:100%;aspect-ratio:auto;transform:none}
body.mobile-device #startScreen.is-loading .ready-art{display:none}
body.mobile-device #startScreen.is-loading .loading-scene{inset:auto;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,calc(var(--myo-screen-height,100dvh) * 1846 / 852));height:auto;aspect-ratio:1846/852;container-type:inline-size}
body.mobile-device #startScreen.is-loading .loading-scene>img{width:100%;height:100%;object-fit:cover;object-position:center}
body.mobile-device #startScreen .loading-scene .loading-live{display:grid;grid-template-columns:1fr auto;grid-template-rows:auto auto;align-content:center;align-items:center;gap:1cqw;left:52.15%;top:66%;bottom:auto;width:29.15%;height:19.2%;transform:none;padding:2cqw;border:1px solid #b4e3f28c;border-radius:2.3cqw;background:linear-gradient(145deg,#19364d,#0e2135);box-shadow:inset 0 1px 0 #f3ffff59,0 10px 40px #06132230;backdrop-filter:none;-webkit-backdrop-filter:none;font-size:2cqw}
body.mobile-device #startScreen .loading-live progress{position:static;grid-column:1;grid-row:1;width:100%;height:1.3cqw;margin:0}
body.mobile-device #startScreen .loading-live .loading-percent{display:block;position:static;grid-column:2;grid-row:1;font-size:2.2cqw;line-height:1;font-variant-numeric:tabular-nums}
body.mobile-device #startScreen .loading-live #loadingMessage{position:static;grid-column:1 / -1;grid-row:2;width:auto;font-size:1.8cqw;line-height:1.3;text-align:center}
body.mobile-device #startScreen .loading-live::after{display:none}
@media(orientation:portrait){
 body.mobile-device #startScreen.is-loading .loading-scene{width:max(100%,calc(var(--myo-screen-height,100dvh) * 853 / 1843));aspect-ratio:853/1843}
 body.mobile-device #startScreen .loading-scene .loading-live{left:12%;top:82%;width:76%;height:8%;padding:3cqw;gap:1.5cqw;border-radius:2.5cqw}
 body.mobile-device #startScreen .loading-live progress{height:2.4cqw}
 body.mobile-device #startScreen .loading-live .loading-percent{font-size:4.5cqw}
 body.mobile-device #startScreen .loading-live #loadingMessage{font-size:4cqw}
}

body>main,body.mobile-device>main{padding-top:0;padding-bottom:0}
body>main .workspace,body.mobile-device>main .workspace{height:100%;min-height:0;margin:0}
body>main .game-grid,body.mobile-device>main .game-grid{height:100%;min-height:0;align-items:stretch}
body>main .task-panel,body.mobile-device>main .task-panel{height:100%;min-height:0;background:linear-gradient(145deg,#214a6bc9,#17374bd9 55%,#102b43c9);backdrop-filter:blur(20px) saturate(115%);-webkit-backdrop-filter:blur(20px) saturate(115%)}

/* Full-bleed artwork also stays behind the difficulty chooser. */
body.mobile-device #startScreen .ready-art{width:100%;height:100%;object-fit:cover;object-position:center}
body.mobile-device #startScreen .start-card{max-height:calc(var(--myo-screen-height,100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px)}
/* Extend the rail surfaces to screen edges; keep text clear of system controls. */
html,body.mobile-device{width:100%;height:100%;min-height:100%;background:#102235}
html.myo-mobile{height:var(--myo-screen-height,100%);min-height:var(--myo-screen-height,100%);background:var(--myo-edge-background) center bottom/cover no-repeat;overflow:hidden;overscroll-behavior:none}
body.mobile-device{inset:0 0 auto;height:var(--myo-screen-height,100dvh);min-height:0;max-height:none;padding:0}
body.mobile-device #mobileRoomBackground{bottom:auto;height:var(--myo-screen-height,100dvh)}
body.mobile-device>header,body.mobile-device #gameStatusBar{box-sizing:border-box;height:calc(var(--top-rail-height) * .4 + var(--rail-safe-inset));min-height:calc(var(--top-rail-height) * .4 + var(--rail-safe-inset));padding-left:max(10px,env(safe-area-inset-left));padding-right:max(10px,env(safe-area-inset-right))}
body.mobile-device>header{padding-top:env(safe-area-inset-top)}
body.mobile-device #gameStatusBar{padding-bottom:env(safe-area-inset-bottom)}
body.mobile-device>main{padding:0 max(0px,env(safe-area-inset-right)) 0 max(0px,env(safe-area-inset-left))}

/* The same translucent glass on both rails, in either orientation. */
body>header,body #gameStatusBar,body.mobile-device>header,body.mobile-device #gameStatusBar{
 background:linear-gradient(110deg,rgba(23,57,80,.52),rgba(16,44,66,.62));
 backdrop-filter:blur(10px) saturate(110%);
 -webkit-backdrop-filter:blur(10px) saturate(110%);
 text-shadow:0 1px 3px #03111e80;
}

/* Halve the usable rail thickness; system cutouts retain their own clear space. */
body>header{--rail-safe-inset:env(safe-area-inset-top)}
body #gameStatusBar{--rail-safe-inset:env(safe-area-inset-bottom);height:calc(var(--bottom-rail-height) * .4);min-height:calc(var(--bottom-rail-height) * .4);padding-top:0;padding-bottom:0}
body>header .brand,body.mobile-device>header .brand{font-size:18px;line-height:1}
body>header #help,body.mobile-device>header #help{width:20px;height:20px;min-width:20px;flex-basis:20px;font-size:16px;line-height:1;padding:0;border-radius:6px}
body>header #changeDifficulty,body.mobile-device #changeDifficulty{height:20px;min-height:20px;line-height:1;padding:1px 7px;border-radius:6px}
body.mobile-device #changeDifficulty::after{font-size:11px}
body #gameStatusBar{font-size:12px;line-height:1}
body.mobile-device #gameStatusBar{font-size:10px;line-height:1;gap:0;padding-top:0;padding-bottom:env(safe-area-inset-bottom)}
body.mobile-device #gameStatusBar .status-legend,body.mobile-device #gameStatusBar .status-progress{gap:8px}
@media(orientation:landscape){body.mobile-device #gameStatusBar{font-size:11px}}
body.mobile-device>header,body.mobile-device #gameStatusBar{position:relative;isolation:isolate;background:none;backdrop-filter:none;-webkit-backdrop-filter:none}
body.mobile-device>header::before,body.mobile-device #gameStatusBar::before{content:'';position:absolute;inset:0;z-index:-1;pointer-events:none;background:linear-gradient(110deg,rgba(23,57,80,.52),rgba(16,44,66,.62));backdrop-filter:blur(10px) saturate(110%);-webkit-backdrop-filter:blur(10px) saturate(110%)}
body.mobile-device>header::before{top:env(safe-area-inset-top)}
body.mobile-device #gameStatusBar::before{bottom:env(safe-area-inset-bottom)}

/* Restore both rails to their pre-halving thickness. */
body>header,body.mobile-device>header{height:calc(var(--top-rail-height) * .8 + var(--rail-safe-inset,0px));min-height:calc(var(--top-rail-height) * .8 + var(--rail-safe-inset,0px))}
body #gameStatusBar,body.mobile-device #gameStatusBar{height:calc(var(--bottom-rail-height) * .8 + var(--rail-safe-inset,0px));min-height:calc(var(--bottom-rail-height) * .8 + var(--rail-safe-inset,0px));font-size:14px;line-height:1.2}
body.mobile-device #gameStatusBar{font-size:12px;gap:3px}
body.mobile-device #gameStatusBar .status-legend,body.mobile-device #gameStatusBar .status-progress{gap:10px}

body>header .brand,body.mobile-device>header .brand{font-size:21px}
body>header #help,body.mobile-device>header #help{width:32px;height:32px;min-width:32px;flex-basis:32px;font-size:20px;border-radius:9px}
body>header #changeDifficulty,body.mobile-device #changeDifficulty{height:32px;min-height:32px;padding:3px 9px;border-radius:9px}
body.mobile-device #changeDifficulty::after{font-size:13px}

/* Portrait rails include the complete status/home areas. Only header controls
   need a top inset; footer text is centered in the entire visible glass panel. */
@media(orientation:portrait){
 body.mobile-device>header,body.mobile-device #gameStatusBar{
  --rail-safe-inset:max(env(safe-area-inset-top),env(safe-area-inset-bottom));
  width:100%;max-width:none;margin:0;align-self:stretch;
 }
 body.mobile-device>header::before,body.mobile-device #gameStatusBar::before{inset:0}
 body.mobile-device #gameStatusBar{
  padding-top:0;padding-bottom:0;
  flex-direction:column;align-items:center;justify-content:center;text-align:center;
 }
 body.mobile-device #gameStatusBar .status-legend,body.mobile-device #gameStatusBar .status-progress{
  width:100%;justify-content:center;align-items:center;text-align:center;
 }
}

/* The landscape footer surface covers the home-indicator area too. Symmetric
   horizontal insets keep its combined text centered even with a side cutout. */
@media(orientation:landscape){
 body.mobile-device #gameStatusBar{
  width:100%;max-width:none;margin:0;align-self:stretch;
  padding-left:max(12px,env(safe-area-inset-left),env(safe-area-inset-right));
  padding-right:max(12px,env(safe-area-inset-left),env(safe-area-inset-right));
  flex-direction:row;justify-content:center;text-align:center;column-gap:clamp(12px,3vw,28px);
 }
 body.mobile-device #gameStatusBar::before{inset:0}
 body.mobile-device #gameStatusBar .status-legend,body.mobile-device #gameStatusBar .status-progress{
  width:auto;justify-content:center;text-align:center;
 }
}

/* Enlarge the phone portrait artwork without stretching it. The live loading
   panel stays below the bust and within the visible 9:16–9:19.5 composition. */
@media(orientation:portrait) and (max-aspect-ratio:3/5){
 body.mobile-device #startScreen.is-loading .loading-scene{
  width:max(120%,calc(var(--myo-screen-height,100dvh) * 1023.6 / 1843));
  top:57.5%;transform:translate(-50%,-57.5%);
 }
 body.mobile-device #startScreen .loading-scene .loading-live{
  left:14.5833%;top:73.75%;width:70.8334%;height:9.8%;
 }
}

/* All three status groups share one centered footer. Reuse the live counter
   here so it updates after a placement, a stage change and saved-game restore. */
body #gameStatusBar,body.mobile-device #gameStatusBar{
 justify-content:center;align-items:center;text-align:center;padding-top:0;padding-bottom:0;
}
body #gameStatusBar #viewPrompt{
 position:static;display:block;flex:0 0 auto;width:auto;margin:0;padding:0;
 font:inherit;letter-spacing:normal;color:inherit;background:none;white-space:nowrap;text-align:center;
}
@media(orientation:portrait){
 body #gameStatusBar,body.mobile-device #gameStatusBar{
  flex-direction:column;gap:3px;
  min-height:max(calc(var(--bottom-rail-height) * .8 + var(--rail-safe-inset,0px)),calc(3.6em + 12px));
 }
}
@media(orientation:landscape){
 body #gameStatusBar,body.mobile-device #gameStatusBar{flex-direction:row;column-gap:clamp(10px,2vw,22px)}
 body #gameStatusBar .status-legend,body #gameStatusBar .status-progress{flex-wrap:nowrap;flex-shrink:0}
}
@media(orientation:landscape) and (max-width:700px){
 body.mobile-device #gameStatusBar{font-size:11px;column-gap:10px}
 body.mobile-device #gameStatusBar .status-legend,body.mobile-device #gameStatusBar .status-progress{gap:8px}
}
