/* Fix65: R57 general section/layout rules override the older R42 fixed adventure.
   Scope these higher-specificity rules to active R42 play only. Other tabs,
   coach/admin pages, and classic non-active adventure modes are unaffected. */
@media screen and (max-width:900px) and (orientation:portrait),
       screen and (orientation:landscape) and (max-height:560px) and (max-width:1100px) {
  body.r57-app-mode.r42AdventureMode {
    height:100dvh!important;
    overflow:hidden!important;
    overscroll-behavior:none!important;
  }
  body.r57-app-mode.r42AdventureMode #app {
    display:block!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    width:100vw!important;
    max-width:100vw!important;
    overflow:hidden!important;
  }
  body.r57-app-mode.r42AdventureMode #app > header.top {
    visibility:hidden!important;
    pointer-events:none!important;
  }
  body.r57-app-mode.r42AdventureMode #app > section#game.r42AdventurePage {
    display:flex!important;
    position:fixed!important;
    inset:0!important;
    top:0!important;
    right:0!important;
    bottom:0!important;
    left:0!important;
    flex-direction:column!important;
    box-sizing:border-box!important;
    width:100vw!important;
    max-width:100vw!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
    overscroll-behavior:none!important;
    scrollbar-gutter:auto!important;
    touch-action:manipulation!important;
    z-index:950!important;
  }
  body.r57-app-mode.r42AdventureMode #app > #game.r42AdventurePage > .head {
    box-sizing:border-box!important;
    flex:0 0 54px!important;
    width:100%!important;
    height:54px!important;
    min-height:54px!important;
    max-height:54px!important;
    margin:0!important;
    padding:5px 10px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:8px!important;
    overflow:hidden!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage > .head h2 {
    margin:0!important;
    font-size:clamp(14px,4vw,18px)!important;
    line-height:1.1!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage > .head small {
    display:none!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage > .head button {
    min-height:40px!important;
    padding:5px 12px!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage > .gamewrap {
    display:block!important;
    box-sizing:border-box!important;
    flex:1 1 0!important;
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage.v19Embedded #v19EmbeddedGameHost,
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage.v19Embedded #v19EmbeddedGameFrame {
    display:block!important;
    box-sizing:border-box!important;
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }
}
/* The original Canvas is an intentional fallback if the embedded game is absent.
   Keep it usable without clipping the canvas on short/wide screens. */
@media screen and (max-width:900px) and (orientation:portrait),
       screen and (orientation:landscape) and (max-height:560px) and (max-width:1100px) {
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage:not(.v19Embedded) > .gamewrap {
    display:flex!important;
    flex-direction:column!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage:not(.v19Embedded) #v17OriginalShell {
    display:none!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage:not(.v19Embedded) .classicGameBox {
    box-sizing:border-box!important;
    flex:1 1 0!important;
    height:auto!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    overflow:hidden!important;
  }
  body.r57-app-mode.r42AdventureMode #game.r42AdventurePage:not(.v19Embedded) .classicGameBox .gamecanvas {
    box-sizing:border-box!important;
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    object-fit:contain!important;
  }
}

@media screen and (orientation:landscape) and (max-height:560px) and (max-width:1100px) {
  body.r57-app-mode.r42AdventureMode #app > #game.r42AdventurePage > .head {
    flex-basis:43px!important;
    height:43px!important;
    min-height:43px!important;
    max-height:43px!important;
    padding:3px 10px!important;
  }
  body.r57-app-mode.r42AdventureMode #app > #game.r42AdventurePage > .head button {
    min-height:35px!important;
    padding:4px 10px!important;
  }
}
