[hidden]{display:none!important}
:root {color-scheme:dark;font-family:system-ui,-apple-system,BlinkMacSystemFont,sans-serif;background:#0b0e16;color:#f5f5f5}
* {box-sizing:border-box} html,body {margin:0} body {min-height:100dvh;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}
main {max-width:700px;margin:auto;padding:14px 16px} h1 {font-size:1.3rem;margin:4px 0 10px} small{font-size:.75rem;color:#aeb9c8;font-weight:400}
.notice,.footer{font-size:.88rem;color:#a9b6ca;line-height:1.4} .notice{border-left:3px solid #f0ab45;padding-left:12px}
#setup{background:#171d2a;border:1px solid #354056;padding:16px;border-radius:14px;display:grid;gap:13px}
label {font-size:.88rem;display:grid;gap:7px} input[type=file]{width:100%;font-size:.75rem} output{display:block;color:#cbd7ed;white-space:pre-wrap;line-height:1.5}
button,.upload {background:#2b3651;border:1px solid #4a5a7e;color:white;border-radius:12px;padding:12px 14px;touch-action:none;user-select:none;-webkit-user-select:none;font-weight:650}
button:disabled{opacity:.45} #start{background:#3762c2;font-size:1rem}
.screen {background:black;border:2px solid #41506f;border-radius:12px;overflow:hidden;display:flex;align-items:center;justify-content:center;aspect-ratio:4 / 3}
canvas{display:block;width:100%;height:100%;object-fit:contain;image-rendering:pixelated}.stats{display:flex;justify-content:space-between;color:#aeb9c8;font-size:.75rem;margin:6px}
.controls{display:flex;justify-content:space-between;align-items:center;gap:16px;margin:9px auto 8px;max-width:520px}.dpad{display:grid;grid-template-columns:repeat(3,48px);grid-template-rows:repeat(3,48px);gap:3px}.dpad button{padding:0}
.up{grid-column:2;grid-row:1}.left{grid-column:1;grid-row:2}.right{grid-column:3;grid-row:2}.down{grid-column:2;grid-row:3}
.actions{display:grid;grid-template-columns:repeat(2,57px);grid-template-rows:repeat(2,57px);gap:8px}.actions button {border-radius:50%}
.controls button:active,.controls button.pressed,.utility button:active{background:#d97b25}
.utility{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}.utility button,.utility .upload{font-size:.75rem;padding:9px 11px}
.upload input{display:none}.footer{font-size:.72rem;margin-top:22px;text-align:center}
@media (orientation:landscape) and (max-height:550px){main{max-width:950px;display:grid;grid-template-columns:1fr 200px;gap:12px}h1,.notice,.footer{display:none}#game{grid-column:1/-1;display:grid;grid-template-columns:minmax(0,1fr) 310px;grid-template-rows:auto auto;gap:4px}.screen{grid-column:1;grid-row:1/-1;aspect-ratio:auto;max-height:75dvh}.controls{grid-column:2;grid-row:1;margin:0}.dpad{grid-template-columns:repeat(3,36px);grid-template-rows:repeat(3,36px)}.actions{grid-template-columns:repeat(2,44px);grid-template-rows:repeat(2,44px)}.utility{grid-column:2;grid-row:2}.stats{display:none}}

.audio-status{font-size:.76rem;color:#b8d1f3;text-align:center;margin:9px 0 0;line-height:1.45}
#sound{background:#275075;border-color:#547ea2}

/* RC1 zh-TW dialogue verification: intentionally outside the SNES picture.
   Avoid displaying this as a completed HD translation overlay. */
.translation-card{margin:9px 0;border:1px solid #5a6b8c;border-left:3px solid #d6a95f;border-radius:10px;background:#172239;padding:10px 12px;min-height:75px}
.translation-heading{display:flex;justify-content:space-between;gap:8px;align-items:center;font-size:.7rem;color:#b9cee8}
#translation-key{font: .64rem ui-monospace,monospace;color:#8092ad;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.translation-text{white-space:pre-line;font-size:1rem;line-height:1.5;color:#fff2d9;margin-top:6px;font-weight:600;letter-spacing:.01em}
.translation-count{font-size:.68rem;color:#91a9c6;margin:4px 0 8px}
.footer a{color:#a8c7ff}

.preview-bar{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:8px 4px 10px;color:#c5d4ee}
.preview-bar .check-option{display:flex;flex-direction:row;align-items:center;gap:6px;font-size:.73rem;white-space:nowrap}
.preview-bar input[type="checkbox"]{accent-color:#d6a95f;width:17px;height:17px}
#hd-toggle{font-size:.73rem;padding:8px 10px;background:#325275}
#hd-info{font-size:.7rem;color:#99aec8;flex:1;min-width:100px}

.hd-import-panel{display:grid;gap:9px;background:#131e2b;border:1px solid #47617f;border-radius:12px;padding:12px;margin:4px 0}
.hd-import-panel strong{font-size:.88rem}
.hd-import-note{font-size:.72rem;color:#aabed4;line-height:1.5;margin:0}
.hd-import-buttons{display:flex;gap:6px;flex-wrap:wrap}
.hd-import-buttons button{font-size:.73rem;padding:9px 11px;flex:1}
#hd-verify{background:#34588c}
#hd-cache{background:#34644b}
#hd-remove{background:#493c4c}
#hd-progress{width:100%;accent-color:#e1b86b;height:10px}
#hd-status{font-size:.75rem;line-height:1.45;white-space:pre-wrap;overflow-wrap:anywhere}

#hd-preview-btn{background:#564975}
#hd-preview-panel{padding:10px;border:1px solid #3e526e;border-radius:9px;text-align:center}
#hd-preview-image{max-width:100%;max-height:180px;object-fit:contain;background:#111;image-rendering:auto}
#hd-preview-name{overflow-wrap:anywhere;text-align:left;margin-top:6px}

#hd-asset-browser{display:grid;gap:8px;padding:10px;background:#0e1725;border:1px solid #344c70;border-radius:10px}
#hd-asset-search{width:100%;background:#1c2b40;color:white;border:1px solid #586e8a;border-radius:8px;padding:10px;font:inherit;font-size:.85rem}
#hd-asset-list{width:100%;background:#101b2d;color:#e5efff;border:1px solid #526782;border-radius:8px;padding:7px;font-size:.72rem;min-height:106px}
#hd-preview-selected{background:#425775}
.hd-storage-experimental{border:1px dashed #526276;border-radius:10px;padding:10px;color:#b7c9e1}
.hd-storage-experimental summary{font-size:.77rem;cursor:pointer;font-weight:650}
.hd-storage-experimental .hd-import-buttons{margin-top:10px}
#hd-session-status{color:#c8e4c0;background:#152c26;border-radius:8px;padding:9px}

.hd-catalog{display:grid;gap:9px;padding:12px;background:#122136;border:1px solid #496487;border-radius:10px}
.hd-catalog select{width:100%;min-height:130px;background:#101a2a;color:#e7efff;border:1px solid #536987;border-radius:8px;padding:6px;font-size:.72rem}
#hd-bg-preview{background:#36577c}
#hd-bg-details{overflow-wrap:anywhere;line-height:1.55}

/* Keep the entire on-screen controller directly below the game canvas.
   Debug controls remain available in a collapsed disclosure below inputs.
   Layout-only: all game button IDs, pointer capture, and JS callbacks stay. */
.game-diagnostics {
  margin-top:14px;
  padding:10px 12px;
  border:1px solid #435775;
  border-radius:12px;
  background:#131e2b;
}
.game-diagnostics summary {
  font-size:.84rem;
  font-weight:650;
  color:#e2ecff;
  cursor:pointer;
  padding:4px 2px;
  min-height:36px;
  touch-action:manipulation;
}
.game-diagnostics[open] summary{margin-bottom:10px}
.game-diagnostics > .hd-import-note {
  margin:8px 0;
  overflow-wrap:anywhere;
}
.game-diagnostics .preview-bar{margin:12px 0 0}
@media (orientation:landscape) and (max-height:550px){
  #game > .audio-status,
  #game > .translation-card,
  #game > .translation-count,
  #game > .game-diagnostics {grid-column:1/-1}
}


/* Production PWA. Source game aspect ratio, NOT an invented 16:9 field. */
.setup-file-fields{display:grid;gap:11px;margin-top:12px}
#game-files-details{background:#111c2a;border:1px solid #455b77;border-radius:10px;padding:10px}
#game-files-details summary{font-weight:650;cursor:pointer;touch-action:manipulation}
#clear-game-files{font-size:.76rem;background:#394051}
#local-files-status{line-height:1.5;padding:6px 0}
#setup>.hd-import-panel>.hd-catalog,
#setup #hd-asset-browser,
#setup #hd-bg-catalog,
#setup #hd-preview-panel,
#setup #hd-preview-btn{display:none!important}
#setup{max-width:620px;margin:0 auto}
#setup .hd-import-panel{margin:0}
.playing h1,.playing .notice,.playing .footer{display:none!important}
.playing{overflow:hidden;padding:0;background:#090c14}
.playing main{max-width:none;width:100%;height:100dvh;padding:0}
.playing #game{display:grid;grid-template-areas:"screen" "buttons" "bar";grid-template-rows:minmax(0,auto) auto auto;
  align-content:start;gap:6px;width:100%;height:100dvh;padding:0}
.playing #game > :not(.screen):not(.controls):not(.playbar){display:none!important}
.playing #game .screen{grid-area:screen;aspect-ratio:var(--game-ratio,512 / 478);height:auto;
  width:100%;max-height:calc(100dvh - 235px);border-radius:0;border:0;margin:0 auto;background:#000}
.playing #game .screen canvas{width:100%;height:100%;object-fit:contain}
.playing #game .controls{grid-area:buttons;display:flex;justify-content:space-between;
  margin:5px auto;gap:10px;width:100%;max-width:470px;padding:0 14px}
.playing #game .dpad{grid-template-columns:repeat(3,min(14vw,52px));
  grid-template-rows:repeat(3,min(14vw,52px));gap:3px}
.playing #game .actions{grid-template-columns:repeat(2,min(15vw,60px));
  grid-template-rows:repeat(2,min(15vw,60px));gap:8px}
.playing #game .playbar{grid-area:bar;display:flex;gap:7px;justify-content:center;
  align-items:center;padding:0 12px max(5px,env(safe-area-inset-bottom))}
.playing #game .playbar button{touch-action:manipulation;min-height:40px;
  font-size:clamp(.7rem,2.9vw,.86rem);padding:8px 10px;white-space:nowrap}
.playing #game #hd-toggle{background:#325275}
.playing #game #locale-toggle{background:#4c4672}
@media (orientation:landscape) and (max-height:650px){
  .playing main{max-width:none;display:block;padding:0}
  .playing #game{display:grid;grid-template-areas:"dpad screen actions" "bar bar bar";
    grid-template-columns:minmax(100px,1fr) minmax(0,3.2fr) minmax(100px,1fr);
    grid-template-rows:minmax(0,1fr) 50px;gap:4px;
    width:100%;height:100dvh;padding:env(safe-area-inset-top) 10px env(safe-area-inset-bottom)}
  .playing #game .controls{display:contents}
  .playing #game .screen{grid-area:screen;width:min(100%,calc((100dvh - 70px)*1.07));
    height:auto;max-height:calc(100dvh - 60px);place-self:center;
    aspect-ratio:var(--game-ratio,512 / 478);border:0}
  .playing #game .dpad{grid-area:dpad;display:grid;place-self:center;
    grid-template-columns:repeat(3,min(5.4vw,48px));
    grid-template-rows:repeat(3,min(5.4vw,48px));gap:3px}
  .playing #game .actions{grid-area:actions;display:grid;place-self:center;
    grid-template-columns:repeat(2,min(6.2vw,58px));
    grid-template-rows:repeat(2,min(6.2vw,58px));gap:7px}
  .playing #game .playbar{grid-area:bar;display:flex;justify-content:center;
    align-items:center;gap:8px;padding:2px max(10px,env(safe-area-inset-left)) 2px max(10px,env(safe-area-inset-right))}
  .playing #game .playbar button{min-height:35px}
}

/* v46: launcher, two-row portrait toolbar, and native iPhone safe areas */
#setup{position:relative}
.launch-cover{display:grid;justify-items:center;gap:10px;width:100%;text-align:center}
.launch-cover img{display:block;width:min(100%,450px);height:auto;object-fit:contain;border-radius:5px}
.launch-cover #start{width:min(100%,450px);min-height:50px;font-size:1.06rem}
#setup.launch-ready{display:flex;flex-direction:column;justify-content:flex-start;
 align-items:center;min-height:0;padding:12px 10px;gap:8px}
#setup.launch-ready #setup-files{display:none!important}
#setup.launch-ready > #status{display:none}
#setup.launch-ready.launching > #status,
#setup.launch-ready.launch-failed > #status{display:block;max-width:450px}
#setup.launch-ready #setup-edit{position:static;align-self:flex-end;order:-2;padding:6px 10px;
 background:#161d2b;font-size:.7rem;opacity:.8}
#setup:not(.launch-ready) .launch-cover{display:contents}
#setup:not(.launch-ready) .launch-cover img{max-width:min(66vw,250px);justify-self:center}
#setup:not(.launch-ready) .launch-cover #start{order:2}
#setup:not(.launch-ready) #setup-files{order:1}
#setup:not(.launch-ready) #status{order:3}
#setup #hd-cache{display:none!important}
.playing #game .playbar-upload{display:flex;align-items:center;justify-content:center;
 margin:0;cursor:pointer;white-space:nowrap;border-radius:10px;
 background:#2b3651;border:1px solid #4a5a7e;color:#fff;font-weight:650}
.playing #game .playbar{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
 gap:6px;width:min(100%,490px);max-width:100%;margin:0 auto;
 padding:0 max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom))
 max(12px,env(safe-area-inset-left))}
.playing #game .playbar button,.playing #game .playbar .playbar-upload{
 font-size:clamp(10px,2.6vw,13px);min-height:39px;padding:6px 3px;
 border-radius:9px;line-height:1.2;touch-action:manipulation}
@media (orientation:portrait){
 .playing #game{padding-top:max(56px,env(safe-area-inset-top));
  grid-template-rows:minmax(0,auto) auto auto;align-content:start;gap:4px}
 .playing #game .screen{max-height:min(calc(100dvh - 350px),
  calc(100vw * 478 / 512));width:100%;max-width:100%;height:auto;
  aspect-ratio:var(--game-ratio,512 / 478)}
 .playing #game .controls{margin:4px auto;max-width:520px}
}
@media (orientation:landscape) and (max-height:650px){
 .playing #game{position:relative;grid-template-areas:"dpad screen actions";
  grid-template-columns:minmax(130px,1fr) minmax(0,4fr) minmax(175px,1.15fr);
  grid-template-rows:minmax(0,1fr);gap:4px;
  padding:6px max(10px,env(safe-area-inset-right))
  max(6px,env(safe-area-inset-bottom))
  max(66px,calc(env(safe-area-inset-left) + 12px))}
 .playing #game .screen{grid-area:screen;place-self:center;
  width:min(100%,calc((100dvh - 12px)*512 / 478));
  max-height:calc(100dvh - 12px);height:auto;max-width:100%;
  aspect-ratio:var(--game-ratio,512 / 478)}
 .playing #game .dpad{grid-area:dpad;place-self:center;transform:translateX(8px)}
 .playing #game .actions{grid-area:actions;place-self:end center;
  margin-bottom:max(8px,env(safe-area-inset-bottom))}
 .playing #game .playbar{grid-area:unset;position:absolute;top:max(7px,env(safe-area-inset-top));
  right:max(9px,env(safe-area-inset-right));width:min(196px,24vw);max-width:none;
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;margin:0;padding:0}
 .playing #game .playbar button,.playing #game .playbar .playbar-upload{
  font-size:clamp(9px,1.45vw,12px);min-height:30px;padding:4px 1px;border-radius:7px}
}


/* v47 — Super Famicom coloured diamond keys, retaining the original input bits */
.playing #game .actions{
  display:grid;grid-template-columns:repeat(3,min(12vw,49px));
  grid-template-rows:repeat(3,min(12vw,49px));gap:3px;
  align-items:center;justify-items:center;
}
.playing #game .actions button{width:100%;height:100%;padding:0;border-radius:50%;
  border:2px solid rgba(255,255,255,.32);font-weight:800;
  text-shadow:0 1px 1px rgba(0,0,0,.2);box-shadow:0 2px 4px rgba(0,0,0,.28)}
.playing #game .actions .sfc-x{grid-column:2;grid-row:1;background:#366bc5;color:white}
.playing #game .actions .sfc-y{grid-column:1;grid-row:2;background:#248e51;color:white}
.playing #game .actions .sfc-a{grid-column:3;grid-row:2;background:#df4e38;color:white}
.playing #game .actions .sfc-b{grid-column:2;grid-row:3;background:#edc33d;color:#28241a;text-shadow:none}
.playing #game .actions button:active,
.playing #game .actions button.pressed{filter:brightness(.77);transform:scale(.94)}
.playing #game #sound{background:#4b644d}
.playing #game #play-toast{position:absolute;z-index:4;left:50%;bottom:calc(100% + 5px);
  width:max-content;max-width:75vw;transform:translateX(-50%);padding:5px 10px;
  border:1px solid #6a82aa;border-radius:8px;font-size:12px;
  background:#1b2740;color:#e4f2ff;pointer-events:none}
.playing #game .playbar{position:relative}
@media (orientation:landscape) and (max-height:650px){
  /* Preserve the native game rectangle. Move the pad away from its left
     edge and shrink the right utility group so neither overlaps the canvas. */
  .playing #game{column-gap:max(11px,1.2vw)}
  /* Both controller clusters share a comfortable lower centreline. The
     horizontal pad inset also clears iPhone landscape sensor cutouts. */
  .playing #game .dpad{
    grid-template-columns:repeat(3,min(5.15vw,46px));
    grid-template-rows:repeat(3,min(5.15vw,46px));
    transform:translate(2px,16px)
  }
  .playing #game .actions{
    grid-template-columns:repeat(3,min(5.7vw,49px));
    grid-template-rows:repeat(3,min(5.7vw,49px));gap:3px;
    align-self:center;justify-self:center;transform:translateY(16px)
  }
  .playing #game .playbar{position:absolute;
    width:clamp(152px,19.5vw,172px);max-width:172px;
    right:max(9px,env(safe-area-inset-right));top:max(7px,env(safe-area-inset-top));
    grid-template-columns:repeat(2,minmax(0,1fr));gap:3px}
  .playing #game .playbar button,
  .playing #game .playbar .playbar-upload{font-size:clamp(9px,1.35vw,11px);
    padding:3px 1px;min-height:28px}
}


/* v50 — thumb-safe control placement on iPhone portrait and landscape.
   Pure layout: do not change game canvas resolution, controller bits,
   audio, or language. Reserve space before moving the entire controls
   group so the sound-reconnect row still fits within the viewport. */
@media (orientation:portrait){
  .playing #game .screen{
    max-height:min(calc(100dvh - 430px),calc(100vw * 478 / 512));
  }
  /* Moving this grid row also moves the following settings row. */
  .playing #game .controls{
    margin:clamp(12px,2.3dvh,24px) auto clamp(8px,1.4dvh,14px);
  }
  .playing #game .playbar{
    margin:clamp(7px,1.4dvh,14px) auto 0;
  }
}
@media (orientation:landscape) and (max-height:650px){
  /* Align both thumb clusters to the same lower baseline; respect the
     home-indicator inset rather than translating past the screen edge. */
  .playing #game .dpad,
  .playing #game .actions{
    align-self:end;
    justify-self:center;
    margin-bottom:max(14px,env(safe-area-inset-bottom));
  }
  .playing #game .dpad{transform:translateX(2px)}
  .playing #game .actions{transform:none}
  /* Keep settings above the thumb area, clear of X even when the
     seventh "reconnect audio" button adds a fourth row. */
  .playing #game .playbar{
    position:absolute;
    top:max(14px,calc(env(safe-area-inset-top) + 8px));
  }
}

/* v50 cheat panel: pause gameplay while editing, never cover a game control
   with an additional floating button. The launch toolbar remains 3 columns in
   portrait and 2 in landscape (max 4 rows, including audio recovery). */
.playing #game #cheat-open{background:#3d5066;border-color:#637e9a}
.cheats-modal[hidden]{display:none!important}
.cheats-modal{
  position:fixed;inset:0;z-index:2000;
  display:grid;place-items:center;
  padding:max(14px,env(safe-area-inset-top))
          max(12px,env(safe-area-inset-right))
          max(14px,env(safe-area-inset-bottom))
          max(12px,env(safe-area-inset-left));
  overflow-y:auto;overscroll-behavior:contain;
  background:rgba(2,7,17,.92);-webkit-overflow-scrolling:touch
}
.cheats-sheet{
  width:min(100%,620px);max-height:calc(100dvh - 28px);
  overflow-y:auto;overscroll-behavior:contain;
  padding:16px;border:1px solid #5a718d;border-radius:16px;
  background:#141e30;color:#eff5ff;
  box-shadow:0 12px 35px rgba(0,0,0,.5)
}
.cheats-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 10px}
.cheats-heading h2{font-size:1.12rem;line-height:1.35;margin:0}
.cheats-heading p{font-size:.75rem;color:#b9cbe1;margin:3px 0}
.cheats-heading button{padding:8px 13px;min-height:37px;touch-action:manipulation}
.cheats-note{font-size:.78rem;line-height:1.55;color:#c5d5e9;margin:0 0 13px}
.cheats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.cheats-grid label{min-width:0;font-size:.82rem;color:#e2ebf7}
.cheats-grid select{
  width:100%;min-width:0;min-height:41px;padding:8px 9px;
  background:#273953;border:1px solid #61779a;border-radius:8px;
  color:white;font-size:.9rem;touch-action:manipulation
}
.cheats-grid .cheats-check{display:flex;align-items:center;gap:9px;
  font-size:.82rem;line-height:1.4;padding:9px;
  border:1px solid #425771;border-radius:9px;background:#202c40}
.cheats-grid .cheats-check input{width:20px;height:20px;flex:0 0 auto;accent-color:#61aaee}
#cheat-feedback{display:block;margin:12px 0 8px;min-height:22px;
  color:#bcd8f5;font-size:.78rem;line-height:1.4}
.cheats-actions{display:flex;gap:10px;justify-content:flex-end}
.cheats-actions button{min-height:40px;padding:9px 14px;touch-action:manipulation}
#cheat-done{background:#365fa0}
#cheat-reset{background:#504050}
@media (orientation:portrait) and (max-width:390px){
 .cheats-sheet{padding:12px}
 .cheats-grid{gap:8px}
 .cheats-grid label{font-size:.75rem}
 .cheats-grid select{font-size:.82rem}
}
@media (orientation:landscape) and (max-height:650px){
 .cheats-modal{place-items:start center;padding-top:max(8px,env(safe-area-inset-top))}
 .cheats-sheet{max-height:calc(100dvh - 12px);padding:10px 14px}
 .cheats-note{margin-bottom:8px}
 .cheats-grid{gap:7px 12px}
 .cheats-grid select{min-height:32px;padding:4px 8px}
 #cheat-feedback{margin:7px 0}
}


/* v54: local-only ten-slot picker; uses the existing pause-sheet styling.
   This changes no SNES controller placement, gesture handlers, or game canvas size. */
.playing #game #save,.playing #game #load{background:#335e65;border-color:#5c8b95}
.playing #game #backup-open{background:#3d4d60;border-color:#62758e}
.save-slots-sheet{width:min(100%,600px)}
.save-slots-list{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:8px;max-height:min(54dvh,445px);min-height:90px;overflow-y:auto;
 padding:3px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch
}
.save-slot{
 display:flex;align-items:center;gap:9px;width:100%;min-width:0;
 text-align:left;padding:8px;min-height:78px;border-radius:10px;
 background:#202e43;border:1px solid #526781;touch-action:manipulation
}
.save-slot[aria-pressed="true"]{background:#30486b;border:2px solid #86b8ff;padding:7px}
.save-slot:disabled{opacity:.5}
.save-slot-thumb{display:block;width:88px;height:66px;flex:0 0 88px;
 border-radius:5px;border:1px solid #455875;background:#0c1421;object-fit:contain}
.save-slot-empty{display:grid;place-items:center;color:#92a4be;font-size:.72rem}
.save-slot-meta{display:flex;flex-direction:column;gap:4px;min-width:0}
.save-slot-meta strong{font-size:.83rem}
.save-slot-meta span{font-size:.72rem;color:#b5c9e2;overflow-wrap:anywhere}
.save-slots-feedback{font-size:.78rem;min-height:25px;margin:8px 0;color:#c6ddf4}
.save-slots-actions{display:flex;justify-content:flex-end;gap:8px}
.save-slots-actions button{min-height:40px;touch-action:manipulation}
#save-slots-confirm{background:#33679e}
.backup-actions{display:grid;gap:12px;margin:12px 0}
.backup-file-label{display:flex;align-items:center;justify-content:center;
 cursor:pointer;min-height:48px;touch-action:manipulation;background:#335b7b}
.backup-file-label input{display:none}
#backup-export{min-height:48px;background:#3b6150}
#backup-feedback{font-size:.82rem;margin-top:12px;min-height:22px}
@media (orientation:portrait) and (max-width:540px){
 .save-slots-list{grid-template-columns:1fr;max-height:min(51dvh,430px)}
 .save-slot{min-height:70px}
}
@media (orientation:landscape) and (max-height:650px){
 .save-slots-sheet,.backup-sheet{max-height:calc(100dvh - 12px)}
 .save-slots-list{max-height:min(45dvh,275px)}
 .playing #game .playbar{grid-template-rows:repeat(5,minmax(0,auto))}
}


/* v56: one physically reparented speed button. Portrait: above Start.
   Landscape: above the directional pad, never over the game picture.
   Existing SNES bits and all controller positions stay unchanged. */
.playing #game .start-speed-stack{display:block;position:relative;min-width:0}
.playing #game .start-speed-stack>.playbar-key{display:block;width:100%;height:100%}
.playing #game .dpad{position:relative}
.playing #game .speed-portrait-anchor{
  position:absolute;bottom:calc(100% + 5px);left:50%;
  transform:translateX(-50%);width:max-content;z-index:5;
  display:flex;justify-content:center;align-items:center
}
.playing #game .speed-landscape-anchor{display:none}
.playing #game #speed-toggle{
  display:block;width:76px;max-width:100%;
  min-height:27px;height:27px;padding:3px 8px;
  background:#365f75;border:1px solid #81a4b8;border-radius:8px;
  color:#fff;font-weight:750;font-size:11px;line-height:1.15;
  touch-action:manipulation;white-space:nowrap;user-select:none;
  -webkit-user-select:none;
}
.playing #game #speed-toggle[data-speed="2"],
.playing #game #speed-toggle[data-speed="3"]{
  background:#8a531e;border-color:#d5a252
}
.speed-update-sheet{width:min(100%,450px)}
#speed-update-description{font-size:.9rem;line-height:1.55;white-space:normal}
#speed-update-description .update-line{display:block;margin:7px 0}
#speed-update-description .update-footnote{display:block;margin-top:9px;font-size:.78rem;opacity:.8}
#speed-update-close{background:#335f9d;min-height:44px}

@media (orientation:portrait){
  /* Reserve a finger-height slot, so speed button never overlaps D-pad. */
  .playing #game .playbar{margin:clamp(37px,4.6dvh,44px) auto 0}
  .playing #game .screen{
    max-height:min(calc(100dvh - 455px),calc(100vw * 478 / 512))
  }
}
@media (orientation:landscape) and (max-height:650px){
  .playing #game .speed-portrait-anchor{display:none}
  .playing #game .speed-landscape-anchor{
    display:flex;position:absolute;
    bottom:calc(100% + 10px);left:50%;transform:translateX(-50%);
    z-index:6;width:76px;justify-content:center;align-items:center;
  }
  .playing #game .start-speed-stack>.playbar-key{min-height:28px;height:auto}
  .playing #game #speed-toggle{width:76px;min-height:28px;height:28px;font-size:11px;padding:2px 6px}
  .playing #game .playbar{margin:0}
}

/* v59: installation status lives in setup only; never overlays the game. */
.offline-status{
  margin:7px auto 12px;padding:8px 10px;
  max-width:640px;background:#1b2c3d;border:1px solid #365268;
  border-radius:9px;color:#cde7ee;font-size:.76rem;
  line-height:1.5;display:flex;align-items:center;justify-content:center;
  flex-wrap:wrap;gap:8px;text-align:center
}
.offline-status button{
  background:#355d86;color:#fff;border:1px solid #6f90b0;
  border-radius:8px;font:inherit;padding:6px 10px;min-height:30px
}

/* v60: update controls remain within setup, never over the SNES controls. */
#offline-update-apply{background:#387151;border-color:#83b99a}
#offline-check{background:#25465d;border-color:#617f92}

/* v64: compact launcher, safe automatic update gate. */
#setup.launch-ready #offline-status{order:-1;margin:0 auto 4px;width:100%;max-width:450px}
.offline-preparing #start{opacity:.5;pointer-events:none}
@media (orientation:landscape) and (max-height:550px){body:not(.playing) #setup{grid-column:1/-1;width:100%}body:not(.playing) #setup.launch-ready .launch-cover img{width:auto;max-width:100%;max-height:55dvh}}
