
/* =========================================================
   ARCVEL V39 — RESPONSIVE MOBILE LAYOUT
   Mobile-only layout repair. Desktop styles/game logic untouched.
   ========================================================= */
@media (max-width: 768px) {
  html, body {
    width: 100%;
    min-width: 0;
    overflow-x: hidden !important;
  }
  #gameShell {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: max(4px, env(safe-area-inset-top)) 6px calc(190px + env(safe-area-inset-bottom)) !important;
    margin: 0 auto !important;
    display: block !important;
  }
  #gameShell > header {
    display: grid !important;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 5px !important;
    min-height: 0 !important;
    padding: 6px 7px !important;
    margin: 0 0 5px !important;
    box-sizing: border-box !important;
  }
  #gameShell .headerBrand {
    min-width: 0 !important;
    width: auto !important;
    min-height: 38px !important;
    padding: 2px !important;
    gap: 5px !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
  }
  #gameShell .headerBrand .backHome {
    position: static !important;
    transform: none !important;
    flex: 0 0 auto !important;
    min-height: 28px !important;
    padding: 5px 6px !important;
    font-size: 8px !important;
  }
  #gameShell .headerBrand .gameHeroLogo {
    display: none !important;
  }
  #gameShell .headerBrand > div {
    display: block !important;
    min-width: 0 !important;
    text-align: left !important;
  }
  #gameShell .headerBrand .arcvelBrandName {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.05 !important;
    letter-spacing: .5px !important;
    white-space: nowrap !important;
  }
  #gameShell .headerBrand small {
    display: block !important;
    font-size: 6px !important;
    line-height: 1.1 !important;
    letter-spacing: .6px !important;
    white-space: nowrap !important;
  }
  #gameShell .topActions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
  }
  #gameShell .topActions button,
  #gameShell .topActions .volumeControl {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    width: 100% !important;
    height: 27px !important;
    min-height: 27px !important;
    padding: 3px 2px !important;
    margin: 0 !important;
    font-size: clamp(6px, 1.8vw, 8px) !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  #gameShell .topActions .volumeControl {
    gap: 2px !important;
  }
  #gameShell .topActions .volumeControl input[type="range"] {
    width: clamp(18px, 6vw, 30px) !important;
    min-width: 0 !important;
    height: 10px !important;
    margin: 0 !important;
  }
  #gameShell .topActions button kbd {
    display: none !important;
  }

  #gameShell .hud {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(86px, .9fr) minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    align-items: center !important;
    gap: 5px !important;
    margin: 0 0 5px !important;
    padding: 7px 7px !important;
    box-sizing: border-box !important;
  }
  #gameShell .hud > div {
    min-width: 0 !important;
    grid-column: auto !important;
    order: initial !important;
    padding: 0 !important;
    text-align: left !important;
  }
  #gameShell .hud > div:nth-child(2) {
    text-align: center !important;
    align-items: center !important;
    gap: 3px !important;
  }
  #gameShell .hud span,
  #gameShell .hud small {
    display: block !important;
    margin: 0 0 3px !important;
    font-size: clamp(7px, 2vw, 9px) !important;
    line-height: 1.1 !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
  }
  #gameShell .hud > div:nth-child(2) > span {
    font-size: clamp(6px, 1.7vw, 8px) !important;
    white-space: normal !important;
  }
  #gameShell .hud b,
  #gameShell .hud b#heroStats {
    display: inline-block !important;
    font-size: clamp(9px, 2.6vw, 12px) !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }
  #gameShell .bar {
    height: 12px !important;
    width: 100% !important;
    margin-top: 3px !important;
    box-sizing: border-box !important;
  }
  #gameShell #shieldStatus {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    margin: 2px 0 0 !important;
    padding: 4px 5px !important;
    min-width: 0 !important;
    font-size: 7px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }
  #gameShell #shieldStatus b,
  #gameShell #shieldStatus span {
    font-size: 7px !important;
  }

  #gameShell main {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    min-width: 0 !important;
  }
  #gameShell canvas#game {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: contain !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    border-width: 2px !important;
  }
  #gameShell .under {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 5px !important;
    margin: 5px 0 0 !important;
    padding: 6px 7px !important;
    box-sizing: border-box !important;
  }
  #gameShell .mission {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
  #gameShell .mission b {
    display: block !important;
    font-size: clamp(7px, 2vw, 9px) !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere !important;
  }
  #gameShell .mission span {
    display: block !important;
    font-size: clamp(6px, 1.7vw, 8px) !important;
    line-height: 1.15 !important;
    margin-top: 2px !important;
  }
  #gameShell .skillHints {
    display: flex !important;
    flex: 0 1 auto !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 3px !important;
    min-width: 0 !important;
  }
  #gameShell .skillHints span {
    padding: 5px 4px !important;
    font-size: clamp(5px, 1.45vw, 7px) !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  .mobileControls {
    position: fixed !important;
    left: max(6px, env(safe-area-inset-left)) !important;
    right: max(6px, env(safe-area-inset-right)) !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    min-height: 0 !important;
    z-index: 35 !important;
    box-sizing: border-box !important;
  }
}

/* Portrait: compact, stacked game UI; controls live in their own bottom dock. */
@media (max-width: 768px) and (orientation: portrait) {
  #gameShell {
    padding-bottom: calc(178px + env(safe-area-inset-bottom)) !important;
  }
  #gameShell > header {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  #gameShell .headerBrand {
    justify-content: center !important;
    min-height: 30px !important;
  }
  #gameShell .headerBrand .backHome {
    position: absolute !important;
    left: 5px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
  }
  #gameShell .headerBrand > div {
    text-align: center !important;
  }
  #gameShell .topActions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  #gameShell .hud {
    grid-template-columns: minmax(0, 1fr) minmax(92px, .9fr) minmax(0, 1fr) !important;
  }
  #gameShell .under {
    flex-wrap: wrap !important;
  }
  .mobileControls {
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    padding: 7px 9px !important;
    gap: 8px !important;
  }
  .joystickWrap {
    flex-basis: clamp(88px, 27vw, 112px) !important;
    width: clamp(88px, 27vw, 112px) !important;
  }
  .joystickBase {
    width: clamp(78px, 24vw, 100px) !important;
    height: clamp(78px, 24vw, 100px) !important;
  }
  .actionDiamond {
    grid-template-columns: repeat(3, clamp(42px, 13vw, 50px)) !important;
    grid-template-rows: repeat(3, clamp(36px, 11vw, 44px)) !important;
    gap: 4px !important;
  }
  .mobileControls .actionDiamond button {
    min-height: 0 !important;
    height: 100% !important;
    font-size: 16px !important;
  }
  .mobileControls .actionDiamond button small {
    font-size: 6px !important;
  }
}

/* Landscape phones: reclaim vertical space and keep the full playfield visible. */
@media (max-width: 960px) and (max-height: 600px) and (orientation: landscape) {
  html, body {
    height: 100% !important;
    overflow: hidden !important;
  }
  #gameShell {
    height: 100dvh !important;
    min-height: 0 !important;
    padding: max(2px, env(safe-area-inset-top)) 6px 0 !important;
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    gap: 3px !important;
    overflow: hidden !important;
  }
  #gameShell > header {
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr) !important;
    min-height: 32px !important;
    margin: 0 !important;
    padding: 3px 5px !important;
  }
  #gameShell .headerBrand {
    min-height: 26px !important;
  }
  #gameShell .headerBrand .arcvelBrandName {
    font-size: 10px !important;
  }
  #gameShell .headerBrand small {
    font-size: 5px !important;
  }
  #gameShell .headerBrand .backHome {
    min-height: 22px !important;
    font-size: 7px !important;
    padding: 3px 4px !important;
  }
  #gameShell .topActions {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 3px !important;
  }
  #gameShell .topActions button,
  #gameShell .topActions .volumeControl {
    height: 22px !important;
    min-height: 22px !important;
    padding: 2px 1px !important;
    font-size: clamp(5px, 1.15vw, 7px) !important;
  }
  #gameShell .topActions .volumeControl input[type="range"] {
    width: 18px !important;
  }
  #gameShell main {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 2px !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  #gameShell .hud {
    grid-row: 1 !important;
    grid-template-columns: minmax(0, 1fr) minmax(95px, .75fr) minmax(0, 1fr) !important;
    padding: 3px 6px !important;
    margin: 0 !important;
    gap: 5px !important;
  }
  #gameShell .hud span,
  #gameShell .hud small {
    font-size: 7px !important;
    margin-bottom: 1px !important;
  }
  #gameShell .hud > div:nth-child(2) > span {
    font-size: 6px !important;
  }
  #gameShell .hud b,
  #gameShell .hud b#heroStats {
    font-size: 9px !important;
  }
  #gameShell .bar {
    height: 8px !important;
    margin-top: 1px !important;
  }
  #gameShell #shieldStatus {
    padding: 2px 4px !important;
    margin-top: 1px !important;
  }
  #gameShell #shieldStatus b,
  #gameShell #shieldStatus span {
    font-size: 6px !important;
  }
  #gameShell canvas#game {
    grid-row: 2 !important;
    align-self: center !important;
    justify-self: center !important;
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 112px) !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: contain !important;
  }
  #gameShell .under {
    display: none !important;
  }
  .mobileControls {
    left: 8px !important;
    right: 8px !important;
    bottom: max(4px, env(safe-area-inset-bottom)) !important;
    padding: 4px 8px !important;
    gap: 8px !important;
    border-radius: 10px !important;
    min-height: 0 !important;
    background: rgba(8, 15, 42, .92) !important;
  }
  .joystickWrap {
    flex: 0 0 72px !important;
    width: 72px !important;
  }
  .joystickBase {
    width: 62px !important;
    height: 62px !important;
  }
  .stickLabel {
    display: none !important;
  }
  .actionDiamond {
    grid-template-columns: repeat(3, 34px) !important;
    grid-template-rows: repeat(3, 27px) !important;
    gap: 3px !important;
  }
  .mobileControls .actionDiamond button {
    height: 100% !important;
    min-height: 0 !important;
    font-size: 12px !important;
    padding: 0 !important;
    border-radius: 5px !important;
  }
  .mobileControls .actionDiamond button small {
    font-size: 5px !important;
    line-height: 1 !important;
  }
}
