/* Keep a six-card hand wide enough to recognise without covering combat resources. */
/* The ordinary danger track adds a full row above the hand. Lift its HUD stack
   together so card faces clear the fixed turn controls. */
@media (max-width:650px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"]:has(.story-danger-track308) #playerHud #resources>#storyResourcePocket19,
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"]:has(.story-danger-track308) #playerHud #resources #threatInfo {bottom:290px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"]:has(.story-danger-track308) #storyFuel17 {bottom:232px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"]:has(.story-danger-track308) #game>#handSection {bottom:94px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"]:has(.story-danger-track308) #game #fieldActions .fire-source {bottom:361px!important}
}

/* The final tutorial panel is modal; keep its return control above the fixed HUD. */
@media (max-width:650px) {
  body[data-story="true"][data-tutorial-four="true"] #tutorialFourCue4[data-final-clue="true"]:not([hidden]) {
    z-index:240!important;
  }
}
@media (max-width: 650px) {
  /* Keep the settled response receipt in the gap between resources and hand. */
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #responseTracker23[data-tutorial="false"] {
    top: auto!important;
    bottom: 204px!important;
    max-height: 36px!important;
    padding: 3px 6px!important;
    overflow: hidden!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #responseTracker23 .response23-entry {
    flex-direction: row!important;
    flex-wrap: nowrap!important;
    align-items: center!important;
    justify-content: space-between!important;
    gap: 4px!important;
    font-size: 12px!important;
    line-height: 16px!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #responseTracker23 .response23-entry>span {
    min-width: 0!important;
    overflow: hidden!important;
    text-overflow: ellipsis!important;
    white-space: nowrap!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #responseTracker23 .response23-entry>strong {
    flex: none!important;
    font-size: 12px!important;
    line-height: 16px!important;
    white-space: nowrap!important;
  }
  /* A lifted hand face can paint across the fixed turn control. Keep the full
     End Turn button above that visual layer while its own card target stays put. */
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>.controls{z-index:180!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>.controls .turn-actions #endButton{z-index:180!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game:has(#hand>.ability.shared-ability-card15:is(:hover,:focus-visible,.selected)){z-index:160!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>#handSection:has(#hand>.ability.shared-ability-card15:is(:hover,:focus-visible,.selected)){z-index:170!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>#handSection {
    left: 14px!important;
    right: 14px!important;
    bottom: 90px!important;
    width: auto!important;
    height: 138px!important;
    min-height: 138px!important;
    max-height: 138px!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>#handSection #hand>.ability:not(:is(:hover,:focus-visible,.selected))::after {
    font-size: 9px!important;
    line-height: 11px!important;
    overflow-wrap: normal!important;
    word-break: normal!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>#handSection #hand>.ability:not(:is(:hover,:focus-visible,.selected)) {
    transform: translateY(var(--held-drop, 0px)) rotate(calc(var(--held-angle, 0deg) * .55))!important;
    transform-origin: 50% 100%!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #playerHud #resources>#storyResourcePocket19 {
    position: fixed!important;
    left: 8px!important;
    right: 86px!important;
    top: auto!important;
    bottom: 254px!important;
    width: auto!important;
    height: 58px!important;
    display: grid!important;
    grid-template-columns: repeat(4,minmax(0,1fr))!important;
    gap: 2px!important;
    padding: 2px!important;
    box-sizing: border-box!important;
    z-index: 70!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #playerHud #resources>#storyResourcePocket19>* {
    min-width: 0!important;
    width: auto!important;
    height: 50px!important;
    min-height: 0!important;
    max-height: 50px!important;
    padding: 1px!important;
    box-sizing: border-box!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #playerHud #resources>#storyResourcePocket19 .food-upkeep26 {
    font-size: 9px!important;
    line-height: 10px!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources #threatInfo {
    position: fixed!important;
    left: auto!important;
    right: 8px!important;
    top: auto!important;
    bottom: 254px!important;
    width: 72px!important;
    height: 58px!important;
    max-height: 58px!important;
  }
}

@media (max-width:650px) and (min-height:760px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase]:not(:has(.story-danger-track308)) #storyFuel17 {
    top: auto!important;
    bottom: 322px!important;
  }
}

/* Selection owns the centre phone slot; Undo returns when selection clears. */
@media (max-width:650px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"]:has(#cancelButton:not([hidden])) #game>.controls .turn-actions #undoButton51{display:none!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>.controls .turn-actions :is(#inspectButton,#cancelButton):not([hidden]){position:fixed!important;top:auto!important;bottom:8px!important;right:auto!important;width:44px!important;min-width:44px!important;max-width:44px!important;height:50px!important;min-height:50px!important;max-height:50px!important;padding:2px!important;font-size:19px!important;line-height:1!important;z-index:220!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>.controls .turn-actions #inspectButton:not([hidden]){left:calc(50vw - 46px)!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game>.controls .turn-actions #cancelButton:not([hidden]){left:calc(50vw + 2px)!important}
}

/* Place Leave beside Undo and End turn, clear of the Quest banner and hand. */
@media (max-width: 650px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"] #game>.controls .turn-actions :is(#retreatButton,#extractButton) {
    position: fixed!important;
    top: auto!important;
    right: auto!important;
    bottom: 8px!important;
    left: 8px!important;
    transform: none!important;
    min-width: 0!important;
    width: 126px!important;
    max-width: 126px!important;
    min-height: 50px!important;
    height: 50px!important;
    max-height: 50px!important;
    font-size: 15px!important;
    z-index: 210!important;
  }
}

/* Move the deck counts below the party cards on very narrow screens. */
@media (max-width: 340px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36 {
    position: fixed!important;
    left: 8px!important;
    top: auto!important;
    bottom: 312px!important;
    display: flex!important;
    gap: 3px!important;
    min-width: 0!important;
    width: max-content!important;
    z-index: 75!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36>span {
    font-size: 10px!important;
    line-height: 13px!important;
    padding: 1px 3px!important;
  }
}

/* The Forest notice sits in the 18px gap between pot and resource bar. */
@media (max-width: 650px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game #enemyEventNotice {
    position: fixed!important;
    top: calc(100dvh - 330px)!important;
    bottom: auto!important;
    left: calc(100vw - 188px)!important;
    right: auto!important;
    width: 100px!important;
    max-width: 100px!important;
    height: 18px!important;
    min-height: 18px!important;
    max-height: 18px!important;
    padding: 0 2px!important;
    overflow: hidden!important;
    white-space: nowrap!important;
    text-overflow: ellipsis!important;
    font: 12px/16px Georgia,serif!important;
    z-index: 75!important;
  }
}
@media (max-width: 340px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"] #game #enemyEventNotice {
    left: calc(100vw - 153px)!important;
    width: 68px!important;
    max-width: 68px!important;
    font-size: 11px!important;
  }
}
body[data-story="true"]:has(#formationPanel:not([hidden])) #playerHud{visibility:hidden!important}
body[data-story="true"]:has(#formationPanel:not([hidden])) #playerHud #resources>#storyResourcePocket19{visibility:hidden!important}

/* During the first Fight lesson, keep both combat targets clear of the hand. */
@media (max-width: 650px) and (max-height: 760px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="true"] #game > :is(.formation,.encounter) {
    top: 230px!important;
    height: 145px!important;
    min-height: 0!important;
  }
  body[data-story="true"][data-tutorial-four="true"][data-phase="battle"] #game > .controls {
    pointer-events: none!important;
  }
  body[data-story="true"][data-tutorial-four="true"][data-phase="battle"] #game > .controls button {
    pointer-events: auto!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #playerHud #resources > #storyResourcePocket19 {
    visibility: visible!important;
    pointer-events: auto!important;
    inset: 230px 3px auto auto!important;
    width: 47px!important;
    height: 145px!important;
    min-height: 145px!important;
    max-height: 145px!important;
    grid-template-columns: minmax(0,1fr)!important;
    grid-template-rows: repeat(4,minmax(0,1fr))!important;
    gap: 0!important;
    padding: 2px!important;
    border-width: 3px!important;
    border-image-width: 3px!important;
    box-sizing: border-box!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #playerHud #resources > #storyResourcePocket19 > :is(.mini-resource,.coin-purse) {
    height: 33px!important;
    min-height: 33px!important;
    max-height: 33px!important;
    flex-direction: row!important;
    gap: 1px!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #playerHud #resources > #storyResourcePocket19 .mini-resource > small,
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #playerHud #resources > #storyResourcePocket19 .coin-caption,
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #playerHud #resources > #storyResourcePocket19 .food-upkeep26 {
    display: none!important;
  }
  body[data-story="true"][data-tutorial-four="true"] #storyResourcePocket19 .mini-resource>span,
  body[data-story="true"][data-tutorial-four="true"] #storyResourcePocket19 .coin-count {
    font-size: 13px!important;
    line-height: 16px!important;
  }
  body[data-story="true"][data-tutorial-four="true"] #storyResourcePocket19 .icon {
    width: 13px!important;
    height: 13px!important;
  }
}

@media (max-width: 650px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="true"] #game #fieldActions .fire-source:has(.fire-gather:disabled) {
    visibility: hidden!important;
    pointer-events: none!important;
  }
}

/* On short phones, deck controls belong in the open header rail, clear of the compressed hero XP and action state. */
@media (max-width: 650px) and (max-height: 760px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck,
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #enemyDeck {
    position: fixed!important;
    top: 91px!important;
    bottom: auto!important;
    width: 29px!important;
    height: 32px!important;
    min-width: 29px!important;
    min-height: 32px!important;
    z-index: 191!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck {left: 8px!important;right:auto!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #enemyDeck {left:auto!important;right:8px!important;top:48px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .class-sigil {display:none!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36 {
    position: fixed!important;
    top: 124px!important;
    bottom: auto!important;
    left: 42px!important;
    width: max-content!important;
    min-width: 0!important;
    display: flex!important;
    flex-direction: row!important;
    gap: 2px!important;
    z-index: 192!important;
  }
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36>span {font-size:10px!important;padding:1px 2px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36 .icon {width:10px!important;height:10px!important}
}
@media (max-width: 340px) and (max-height: 760px) {
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36>span {font-size:9px!important;padding:1px!important;gap:1px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game #playerDeck .deck-counters36 {left:8px!important}
  body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-tutorial-four="false"] #game>.formation .section-line h2 {visibility:hidden!important}
}

@media (max-width:340px) and (max-height:760px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.formation :is(#front,#middle,#rear)>.hero>.hybrid-unit-name {padding-inline:4px!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.hybrid-unit-name {height:22px!important;min-height:22px!important;max-height:22px!important;padding-inline:4px!important;white-space:nowrap!important;font-size:13px!important;line-height:15px!important}
}
@media (max-width:340px) and (max-height:760px) {
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero>.hero-class-name {display:none!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero .hero-body>.hp {position:absolute!important;inset:auto auto 31px 3px!important;z-index:5!important;display:flex!important;align-items:center!important;width:max-content!important;height:16px!important;padding:0 2px!important;margin:0!important;font:700 13px/16px system-ui!important;background:#15251fec!important;white-space:nowrap!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero .hero-body>.stats {position:absolute!important;inset:auto 3px 31px auto!important;z-index:5!important;display:flex!important;flex-wrap:nowrap!important;align-items:center!important;width:max-content!important;height:16px!important;padding:0 2px!important;margin:0!important;font:12px/16px system-ui!important;gap:2px!important;background:#15251fec!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero .hero-body>.stats .icon {width:11px!important;height:11px!important;min-width:11px!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero .hero-body>.health-track {position:absolute!important;inset:auto 3px 25px 3px!important;z-index:5!important;width:auto!important;height:4px!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.hp {position:absolute!important;inset:auto auto 29px 3px!important;z-index:5!important;display:flex!important;align-items:center!important;width:max-content!important;height:16px!important;padding:0 2px!important;margin:0!important;font:700 13px/16px system-ui!important;background:#281f1ced!important;white-space:nowrap!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.knowledge-combat-stats {position:absolute!important;inset:auto 3px 29px auto!important;z-index:5!important;display:flex!important;align-items:center!important;width:max-content!important;height:16px!important;padding:0 2px!important;margin:0!important;font:12px/16px system-ui!important;gap:1px!important;background:#281f1ced!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.knowledge-combat-stats .icon {width:11px!important;height:11px!important;min-width:11px!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.enemy-signature {position:absolute!important;inset:38px 3px auto auto!important;z-index:5!important;width:max-content!important;max-width:76px!important;padding:0 2px!important;font:10px/13px system-ui!important;background:#281f1ced!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.intent {position:absolute!important;inset:auto 3px -5px 3px!important;z-index:5!important;width:auto!important;height:30px!important;padding:0!important;margin:0!important;background:#281f1ced!important;text-align:center!important;display:grid!important;grid-template-rows:minmax(0,1fr) 10px!important;overflow:hidden!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.intent>span {display:block!important;width:auto!important;height:auto!important;min-height:0!important;white-space:normal!important;font:9px/10px system-ui,sans-serif!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.intent .icon {display:inline-block!important;width:10px!important;height:10px!important;vertical-align:middle!important}
 body[data-story="true"] #game>.encounter #enemies>.enemy>.enemy-copy>.enemy-food-raid140 {top:31px!important}
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>.health-track {position:absolute!important;inset:auto 3px 25px 3px!important;z-index:5!important;width:auto!important;height:4px!important}
}
@media (max-width:340px) and (max-height:760px) {
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game .hero .hero-body>:is(.hp,.stats,.health-track),
 body[data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>.encounter #enemies>.enemy>.enemy-copy>:is(.hp,.knowledge-combat-stats,.enemy-signature,.intent,.health-track) {grid-area:1/1/-1/-1!important}
}

/* A paged phone hand needs its controls outside the resource and Threat strip. */
@media (max-width:650px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>#handSection .hand-paging:not([hidden]) {
  position:fixed!important;inset:max(318px,calc(100dvh - 358px)) auto auto 8px!important;z-index:205!important;pointer-events:auto!important;
  width:max-content!important;height:24px!important;padding:1px 3px!important;border:1px solid #9d916e!important;border-radius:5px!important;background:#23312ef2!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>#handSection .hand-paging:not([hidden])::before {content:"CARDS";position:absolute;left:1px;top:-15px;color:#f1e1b9;font:700 10px/13px system-ui,sans-serif;letter-spacing:.08em;text-shadow:0 1px 2px #000}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase] #game>#handSection .hand-paging:not([hidden]) button {pointer-events:auto!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase]:has(#hand>.ability.selected) #game>#handSection .hand-paging {visibility:hidden!important;pointer-events:none!important}
}

/* Three distinct bottom hit areas on narrow phones. */
@media (max-width:340px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"] #game>.controls .turn-actions :is(#retreatButton,#extractButton,#undoButton51,#endButton) {
  position:fixed!important;top:auto!important;bottom:8px!important;right:auto!important;
  width:calc((100vw - 32px)/3)!important;min-width:0!important;max-width:none!important;
  height:50px!important;min-height:50px!important;max-height:50px!important;
  padding:3px!important;font-size:14px!important;line-height:17px!important;z-index:210!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"] #game>.controls .turn-actions :is(#retreatButton,#extractButton){left:8px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"] #game>.controls .turn-actions #undoButton51{left:calc(16px + (100vw - 32px)/3)!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"] #game>.controls .turn-actions #endButton{left:auto!important;right:8px!important}
 /* Keep the now-available way home at the right edge of the phone action row. */
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #extractButton{left:auto!important;right:8px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #endButton{left:8px!important;right:auto!important}
}

@media (max-width:650px) {
 #formationPanel>.overlay-card{width:100%!important;min-width:0!important;max-width:100%!important;max-height:calc(100dvh - 20px)!important;overflow:hidden!important;box-sizing:border-box!important}
 #formationPanel #campFormation{width:100%!important;min-width:0!important;display:flex!important;flex-direction:column!important;align-items:center!important;gap:4px!important}
 #formationPanel #campFormation>p{margin:0!important;writing-mode:horizontal-tb!important;transform:none!important;text-align:center!important}
 #formationPanel #campFormation>.hero-row{width:100%!important;max-width:100%!important;height:100px!important;min-height:100px!important;flex:none!important;justify-content:center!important;gap:8px!important}
 #formationPanel #campFormation>.hero-row>.formation-choice{height:100px!important;max-width:108px!important;flex:1 1 0!important}
}

/* Narrow 300px battles use the empty right gutter for resources and the pot. */
@media (max-width:340px) and (max-height:760px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source {
  position:fixed!important;left:auto!important;right:3px!important;top:116px!important;bottom:auto!important;width:47px!important;height:43px!important;min-height:0!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source>.fire-gather {
  height:27px!important;min-height:27px!important;max-height:27px!important;padding:0!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source .gather-caption {font-size:0!important;line-height:1!important;white-space:nowrap!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source .gather-caption :is(.icon,b) {font-size:12px!important;width:14px!important;height:14px!important;line-height:14px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source>.pot-stock68 {
  left:0!important;bottom:0!important;width:100%!important;height:15px!important;min-width:0!important;transform:none!important;justify-content:center!important;padding:0!important;border-radius:0 0 4px 4px!important;font-size:10px!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source>.pot-stock68 .icon {width:12px!important;height:12px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #game #fieldActions .fire-source>.pot-disruption142 {top:-20px!important;font-size:10px!important;padding:2px 4px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources>#storyResourcePocket19 {
  left:auto!important;right:3px!important;top:160px!important;bottom:auto!important;width:47px!important;height:84px!important;grid-template-columns:1fr!important;grid-template-rows:repeat(4,19px)!important;gap:1px!important;padding:2px!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources>#storyResourcePocket19>* {
  display:flex!important;align-items:center!important;justify-content:center!important;flex-direction:row!important;gap:1px!important;height:19px!important;min-height:19px!important;max-height:19px!important;padding:0!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #storyResourcePocket19 :is(.mini-resource>small,.food-upkeep26,.coin-caption,.mana-track) {display:none!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources>#storyResourcePocket19 #moraleInfo>small,
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources>#storyResourcePocket19 #foodCounter .food-upkeep26 {display:none!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #storyResourcePocket19 :is(.mini-resource>span,.coin-purse) {display:flex!important;align-items:center!important;justify-content:center!important;gap:1px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #storyResourcePocket19 :is(.icon,.purse-icon) {width:13px!important;height:13px!important;min-width:13px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #storyResourcePocket19 :is(.mini-resource b,.coin-count) {font:700 12px/15px system-ui!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #playerHud #resources #threatInfo {
  left:auto!important;right:3px!important;top:245px!important;bottom:auto!important;width:47px!important;height:23px!important;min-height:23px!important;max-height:23px!important;padding:1px!important;
 }
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #threatInfo :is(.threat-column,.threat-bonus,.threat-next,.threat-meter15,.threat-value>span) {display:none!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #threatInfo .threat-value {display:flex!important;align-items:center!important;justify-content:center!important;gap:2px!important;font:700 12px/16px system-ui!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-tutorial-four="false"] #threatInfo .threat-value .icon {width:13px!important;height:13px!important}
}

/* A completed Quest makes the route home the primary bottom-right action. */
body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #extractButton {
 position:fixed!important;top:auto!important;left:auto!important;right:8px!important;bottom:8px!important;width:150px!important;min-width:150px!important;max-width:150px!important;height:52px!important;min-height:52px!important;max-height:52px!important;font-size:16px!important;z-index:211!important;
}
body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #endButton {
 position:fixed!important;top:auto!important;left:auto!important;right:8px!important;bottom:68px!important;width:150px!important;min-width:150px!important;max-width:150px!important;height:44px!important;min-height:44px!important;max-height:44px!important;font-size:16px!important;z-index:190!important;
}
@media (max-width:650px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #extractButton {left:auto!important;right:8px!important;bottom:8px!important;width:150px!important;min-width:0!important;max-width:150px!important;height:50px!important;min-height:50px!important;max-height:50px!important;font-size:15px!important}
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions #endButton {left:8px!important;right:auto!important;bottom:8px!important;width:126px!important;min-width:0!important;max-width:126px!important;height:50px!important;min-height:50px!important;max-height:50px!important;font-size:16px!important}
}
@media (max-width:374px) {
 body[data-story="true"][data-style="hybrid"][data-progression="xp"][data-view="expedition"][data-phase="battle"][data-cycle-phase="night"][data-hand-fan24="true"][data-primary-return="true"] #game>.controls .turn-actions :is(#extractButton,#endButton) {width:calc((100vw - 32px)/3)!important;max-width:none!important;min-width:0!important;font-size:14px!important;line-height:16px!important}
}
