:root{--s2047-gold:#ffe078;--s2047-blue:#123950;--s2047-deep:#061421;--s2047-cyan:#63c9ef}
html,body{overscroll-behavior:none}
#s2047-reference-hud{position:fixed;inset:0;z-index:2147481200;pointer-events:none;font-family:Arial,Helvetica,sans-serif;color:#fff}
.s2047-reference-topbar{position:absolute;top:max(10px,env(safe-area-inset-top));left:0;right:0;height:84px;border-bottom:4px solid var(--s2047-gold);display:grid;grid-template-columns:minmax(120px,180px) minmax(180px,260px) 1fr;align-items:center;gap:16px;padding:0 28px;background:rgba(5,37,56,.94);pointer-events:auto}
.s2047-reference-pill{height:58px;border:3px solid var(--s2047-gold);border-radius:18px;background:#153d54;color:#fff;font-size:clamp(20px,3vw,30px);font-weight:900;box-shadow:0 3px 0 rgba(0,0,0,.35);cursor:pointer}
.s2047-reference-options{justify-self:center;width:100%}
.s2047-reference-terminal{font-size:clamp(20px,2.8vw,32px);font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.s2047-reference-logo{position:absolute;top:96px;left:50%;transform:translateX(-50%);display:grid;text-align:center;line-height:.78;text-shadow:0 5px 3px #000;pointer-events:none}
.s2047-reference-logo span{font-size:32px;font-weight:900;letter-spacing:2px}.s2047-reference-logo strong{font-size:48px;color:var(--s2047-gold)}
.s2047-reference-player{position:absolute;top:188px;left:12px;width:min(58vw,520px);min-height:116px;display:grid;grid-template-columns:52px 72px 1fr 52px;align-items:center;gap:8px;padding:10px;border:3px solid var(--s2047-gold);border-radius:24px;background:rgba(8,30,44,.92);pointer-events:auto}
.s2047-reference-switch{width:42px;height:64px;border:2px solid var(--s2047-cyan);border-radius:16px;background:#19465f;color:#fff;font-size:38px}
.s2047-reference-portrait{width:72px;height:86px;border-radius:14px;background:linear-gradient(#173c53,#0b2130);display:grid;place-items:center;font-size:44px;overflow:hidden}
.s2047-reference-player-info{min-width:0}.s2047-reference-player-info>strong{display:block;font-size:24px;margin-bottom:8px}.s2047-reference-energy-row{display:flex;justify-content:space-between;font-size:14px;margin-bottom:4px}.s2047-reference-energy{height:12px;border-radius:8px;background:#102231;overflow:hidden}.s2047-reference-energy i{display:block;height:100%;width:100%;background:linear-gradient(90deg,#4ec2ee,#5de0a0)}.s2047-reference-lives{display:flex;gap:12px;align-items:center;margin-top:8px;font-size:14px}.s2047-reference-lives b{color:#ff334f;letter-spacing:1px;font-size:20px;white-space:nowrap;overflow:hidden}
.s2047-reference-location{position:absolute;top:188px;right:12px;width:min(35vw,320px);padding:14px 18px;border:3px solid #728b9a;border-radius:24px;background:rgba(8,30,44,.92);pointer-events:none}.s2047-reference-location strong,.s2047-reference-location span{display:block}.s2047-reference-location strong{font-size:22px;color:var(--s2047-gold)}.s2047-reference-location span{font-size:16px;margin-top:4px}
.s2047-reference-dpad{position:absolute;left:14px;bottom:max(70px,calc(env(safe-area-inset-bottom) + 64px));width:210px;height:210px;border:4px solid var(--s2047-gold);border-radius:50%;background:rgba(5,27,41,.92);display:grid;grid-template:1fr 1fr 1fr/1fr 1fr 1fr;place-items:center;pointer-events:auto}.s2047-reference-dpad button{width:64px;height:64px;border:2px solid var(--s2047-cyan);border-radius:50%;background:#17455f;color:#fff;font-size:32px;touch-action:none;user-select:none}.s2047-reference-dpad button[data-direction=up]{grid-area:1/2}.s2047-reference-dpad button[data-direction=left]{grid-area:2/1}.s2047-reference-dpad-centre{grid-area:2/2!important;background:#ef2d2d!important;border:9px solid #f4b32d!important;box-shadow:0 0 0 4px #8e2525!important}.s2047-reference-dpad button[data-direction=right]{grid-area:2/3}.s2047-reference-dpad button[data-direction=down]{grid-area:3/2}
.s2047-reference-instruction{position:absolute;left:0;right:0;bottom:0;min-height:54px;padding:14px 18px calc(10px + env(safe-area-inset-bottom));background:rgba(5,27,41,.95);border-top:3px solid #24516b;font-size:18px;font-weight:800;text-align:center}
/* Keep the stable renderer, but replace the newer HUD chrome. */
.s2047-hud,.s2047-status,.s2047-help,.s2047-action-cluster,#s2047-hamburger-shell-v51217,#s2047-main-options-shell-v5300{display:none!important}
.s2047-joystick-zone{opacity:0!important;pointer-events:none!important}
#s2047-minimap-wrap,.s2047-minimap-wrap{display:block!important;visibility:visible!important;opacity:1!important;position:fixed!important;right:12px!important;top:auto!important;bottom:max(62px,calc(env(safe-area-inset-bottom) + 58px))!important;width:204px!important;height:auto!important;padding:9px!important;border:3px solid var(--s2047-cyan)!important;border-radius:24px!important;background:rgba(8,30,44,.94)!important;z-index:2147481300!important;box-sizing:border-box!important}
#s2047-minimap-wrap canvas,.s2047-minimap-wrap canvas{display:block!important;width:180px!important;height:142px!important;border-radius:15px!important;object-fit:cover!important;background:#07111d!important}
#s2047-minimap-wrap span,.s2047-minimap-wrap span{font-size:15px!important;color:#fff!important;padding-top:8px!important}
.s2047-world-asset-markers{z-index:2147481000!important}
@media(max-width:760px){
 .s2047-reference-topbar{top:0;height:96px;grid-template-columns:140px 1fr;padding:8px 26px;gap:14px}.s2047-reference-terminal{position:absolute;left:180px;right:10px;top:34px;z-index:-1;opacity:.7}.s2047-reference-pill{height:70px;font-size:24px}.s2047-reference-options{width:220px;max-width:100%}
 .s2047-reference-logo{top:104px}.s2047-reference-logo span{font-size:28px}.s2047-reference-logo strong{font-size:44px}
 .s2047-reference-player{top:188px;width:calc(100% - 268px);min-width:390px;max-width:520px;grid-template-columns:42px 64px 1fr 42px}.s2047-reference-location{top:188px;width:246px}.s2047-reference-player-info>strong{font-size:20px}
 .s2047-reference-dpad{width:190px;height:190px;bottom:74px}.s2047-reference-dpad button{width:58px;height:58px}
 #s2047-minimap-wrap,.s2047-minimap-wrap{width:208px!important;bottom:62px!important}#s2047-minimap-wrap canvas,.s2047-minimap-wrap canvas{width:184px!important;height:142px!important}
 .s2047-reference-instruction{font-size:16px}
}
@media(max-width:560px){
 .s2047-reference-topbar{grid-template-columns:140px 1fr;padding:8px 12px}.s2047-reference-options{width:100%}.s2047-reference-terminal{display:none}
 .s2047-reference-logo{top:102px}
 .s2047-reference-player{top:186px;left:10px;right:10px;width:auto;min-width:0;grid-template-columns:38px 58px 1fr 38px;padding:8px;border-radius:20px}.s2047-reference-location{top:306px;right:10px;width:220px;padding:9px 12px;border-radius:18px}.s2047-reference-location strong{font-size:17px}.s2047-reference-location span{font-size:13px}
 .s2047-reference-player-info>strong{font-size:18px}.s2047-reference-energy-row,.s2047-reference-lives{font-size:12px}.s2047-reference-lives b{font-size:16px}
 .s2047-reference-dpad{left:12px;width:172px;height:172px;bottom:76px}.s2047-reference-dpad button{width:52px;height:52px;font-size:25px}
 #s2047-minimap-wrap,.s2047-minimap-wrap{right:10px!important;width:196px!important;bottom:70px!important}#s2047-minimap-wrap canvas,.s2047-minimap-wrap canvas{width:172px!important;height:130px!important}
}

/* v6.2.5: centre location and only show Exit inside buildings/rooms. */
.s2047-reference-topbar-no-exit{grid-template-columns:1fr!important}
.s2047-reference-topbar-no-exit .s2047-reference-options{justify-self:center;width:min(72vw,390px)}
.s2047-reference-topbar-no-exit .s2047-reference-terminal{display:none!important}
.s2047-reference-exit[hidden]{display:none!important}
.s2047-reference-location{left:50%!important;right:auto!important;transform:translateX(-50%)!important;text-align:center!important}
@media(max-width:760px){
 .s2047-reference-topbar-no-exit{grid-template-columns:1fr!important;padding-left:12px!important;padding-right:12px!important}
 .s2047-reference-topbar-no-exit .s2047-reference-options{width:min(76vw,390px)!important}
 .s2047-reference-location{left:50%!important;right:auto!important;transform:translateX(-50%)!important}
}
@media(max-width:560px){
 .s2047-reference-location{top:306px!important;left:50%!important;right:auto!important;width:min(78vw,280px)!important;transform:translateX(-50%)!important}
}


/* v6.2.6: make the core Options menu visible and usable above the reference HUD. */
#s2047-menu.s2047-reference-options-open,
#s2047-menu:not([hidden]){
  display:block!important;
  visibility:visible!important;
  opacity:1!important;
  pointer-events:auto!important;
  position:fixed!important;
  z-index:2147483600!important;
  top:max(12px,env(safe-area-inset-top))!important;
  left:50%!important;
  right:auto!important;
  bottom:max(12px,env(safe-area-inset-bottom))!important;
  width:min(620px,calc(100vw - 24px))!important;
  max-width:620px!important;
  max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
  margin:0!important;
  padding:22px 18px 26px!important;
  transform:translateX(-50%)!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
  border:3px solid var(--s2047-gold)!important;
  border-radius:24px!important;
  background:rgba(5,25,39,.985)!important;
  color:#fff!important;
  box-shadow:0 24px 80px rgba(0,0,0,.8)!important;
  box-sizing:border-box!important;
}
#s2047-menu[hidden]{display:none!important}
#s2047-menu .s2047-panel-close{
  position:sticky!important;top:0!important;float:right!important;z-index:3!important;
  width:48px!important;height:48px!important;border:2px solid var(--s2047-cyan)!important;
  border-radius:14px!important;background:#173f56!important;color:#fff!important;font-size:32px!important;
}
#s2047-menu h2{margin:0 60px 16px 0!important;color:var(--s2047-gold)!important;font-size:28px!important}
#s2047-menu .s2047-menu-grid{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
#s2047-menu .s2047-menu-grid>button{min-height:48px!important;padding:10px!important;border:2px solid #4da8cc!important;border-radius:12px!important;background:#153d54!important;color:#fff!important;font-weight:800!important}
html.s2047-reference-menu-open::before{
  content:'';position:fixed;inset:0;z-index:2147483500;background:rgba(0,7,13,.72);pointer-events:auto;
}
@media(max-width:560px){
  #s2047-menu.s2047-reference-options-open,#s2047-menu:not([hidden]){top:6px!important;bottom:6px!important;width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px)!important;padding:16px 12px 22px!important;border-radius:18px!important}
  #s2047-menu .s2047-menu-grid{grid-template-columns:1fr!important}
}


/* v6.2.7: brighter Options panel with permanent close button. */
#s2047-menu.s2047-reference-options-open,
#s2047-menu:not([hidden]){
  padding:76px 18px 26px!important;
  background:linear-gradient(180deg,rgba(25,78,108,.985),rgba(10,47,70,.985))!important;
  border-color:#ffe078!important;
  box-shadow:0 18px 54px rgba(0,0,0,.48),inset 0 0 36px rgba(99,201,239,.12)!important;
}
#s2047-menu::before{
  content:'';position:absolute;left:18px;right:18px;top:62px;height:1px;background:rgba(255,224,120,.55);pointer-events:none;
}
#s2047-menu .s2047-reference-menu-close{
  display:grid!important;place-items:center!important;position:absolute!important;top:14px!important;right:14px!important;z-index:20!important;
  width:50px!important;height:50px!important;margin:0!important;padding:0 0 5px!important;border:3px solid #ffe078!important;border-radius:15px!important;
  background:#245d7b!important;color:#fff!important;font:900 39px/1 Arial,sans-serif!important;box-shadow:0 3px 0 rgba(0,0,0,.25)!important;cursor:pointer!important;
}
#s2047-menu .s2047-reference-menu-close:active{transform:translateY(2px)!important;box-shadow:none!important}
#s2047-menu .s2047-reference-menu-title,
#s2047-menu h1,#s2047-menu h2{
  margin:0 58px 18px!important;text-align:center!important;color:#fff1a7!important;text-shadow:0 2px 2px rgba(0,0,0,.45)!important;
}
#s2047-menu p,#s2047-menu .s2047-save-summary,#s2047-menu .s2047-menu-description{
  color:#f3f9fc!important;background:rgba(7,34,51,.46)!important;border-color:rgba(99,201,239,.55)!important;
}
#s2047-menu button:not(.s2047-reference-menu-close):not(.s2047-panel-close){
  background:linear-gradient(180deg,#286783,#194b65)!important;color:#fff!important;border-color:#72d5f4!important;opacity:1!important;
}
#s2047-menu button:disabled{opacity:.62!important;color:#d9e8ef!important}
html.s2047-reference-menu-open::before{background:rgba(2,17,27,.38)!important}
html.s2047-reference-menu-open #s2047-hamburger-shell-v51217,
html.s2047-reference-menu-open .s2047-menu-launcher,
html.s2047-reference-menu-open .s2047-hamburger{display:none!important}
@media(max-width:560px){
 #s2047-menu.s2047-reference-options-open,#s2047-menu:not([hidden]){padding:70px 12px 20px!important}
 #s2047-menu .s2047-reference-menu-close{top:10px!important;right:10px!important;width:48px!important;height:48px!important}
 #s2047-menu .s2047-reference-menu-title,#s2047-menu h1,#s2047-menu h2{margin-left:52px!important;margin-right:52px!important;font-size:27px!important}
}

/* v6.2.9: keep the Options panel and its close control above every hamburger/launcher. */
html.s2047-reference-menu-open #s2047-menu,
body.s2047-reference-menu-open #s2047-menu,
#s2047-menu.s2047-reference-options-open,
#s2047-menu:not([hidden]){
  z-index:2147483646!important;
  isolation:isolate!important;
  pointer-events:auto!important;
}
html.s2047-reference-menu-open::before{
  z-index:2147483644!important;
}
html.s2047-reference-menu-open #s2047-reference-hud,
body.s2047-reference-menu-open #s2047-reference-hud{
  pointer-events:none!important;
}
html.s2047-reference-menu-open #s2047-reference-hud *,
body.s2047-reference-menu-open #s2047-reference-hud *{
  pointer-events:none!important;
}
html.s2047-reference-menu-open #s2047-hamburger-shell-v51217,
body.s2047-reference-menu-open #s2047-hamburger-shell-v51217,
html.s2047-reference-menu-open #s2047-main-options-shell-v5300,
body.s2047-reference-menu-open #s2047-main-options-shell-v5300,
html.s2047-reference-menu-open .s2047-menu-launcher,
body.s2047-reference-menu-open .s2047-menu-launcher,
html.s2047-reference-menu-open .s2047-hamburger,
body.s2047-reference-menu-open .s2047-hamburger,
html.s2047-reference-menu-open [class*="hamburger-toggle"],
body.s2047-reference-menu-open [class*="hamburger-toggle"]{
  display:none!important;
  visibility:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}
#s2047-menu .s2047-reference-menu-close{
  position:fixed!important;
  top:max(12px,env(safe-area-inset-top))!important;
  right:max(18px,calc((100vw - min(620px,calc(100vw - 24px)))/2 + 18px))!important;
  z-index:2147483647!important;
  display:grid!important;
  visibility:visible!important;
  opacity:1!important;
  pointer-events:auto!important;
  touch-action:manipulation!important;
  -webkit-tap-highlight-color:transparent!important;
}
@media(max-width:560px){
  #s2047-menu .s2047-reference-menu-close{
    top:max(10px,env(safe-area-inset-top))!important;
    right:14px!important;
  }
}

/* v6.3.0: true top-level Options layer. The menu is moved directly under body
   so transformed game containers cannot trap it below the HUD. */
html.s2047-reference-menu-open::before{content:none!important;display:none!important;pointer-events:none!important}
#s2047-options-backdrop-v630{
 position:fixed!important;inset:0!important;z-index:2147483644!important;
 display:block!important;background:rgba(2,17,27,.42)!important;
 pointer-events:auto!important;touch-action:none!important;
}
#s2047-options-backdrop-v630[hidden]{display:none!important}
body>#s2047-menu.s2047-reference-options-open,
body>#s2047-menu:not([hidden]){
 position:fixed!important;z-index:2147483646!important;
 pointer-events:auto!important;touch-action:pan-y!important;
 isolation:isolate!important;transform:translateX(-50%)!important;
}
body.s2047-reference-menu-open #s2047-reference-hud{visibility:hidden!important;pointer-events:none!important}
body.s2047-reference-menu-open>#s2047-menu,
body.s2047-reference-menu-open>#s2047-menu *{visibility:visible!important;pointer-events:auto!important}
body.s2047-reference-menu-open>#s2047-menu .s2047-reference-menu-close{
 position:fixed!important;z-index:2147483647!important;pointer-events:auto!important;
}
body.s2047-reference-menu-open>#s2047-menu button,
body.s2047-reference-menu-open>#s2047-menu input,
body.s2047-reference-menu-open>#s2047-menu select,
body.s2047-reference-menu-open>#s2047-menu textarea,
body.s2047-reference-menu-open>#s2047-menu label{
 position:relative;z-index:2;pointer-events:auto!important;touch-action:manipulation!important;
}
