:is(a, button)[data-wp-return="main"] {
  box-sizing: border-box !important;
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  height: 51px !important;
  min-height: 51px !important;
  max-height: 51px !important;
  display: grid !important;
  grid-template-columns: 16px 28px !important;
  place-items: center !important;
  gap: 4px !important;
  padding: 4px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: linear-gradient(180deg, #fff8d8, #ffba58) !important;
  color: #4a2918 !important;
  box-shadow: 0 7px 0 #9d5626, 0 12px 20px rgb(86 45 20 / 22%) !important;
  font-size: 22px !important;
  font-weight: 950 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  overflow: hidden !important;
}

:is(a, button)[data-wp-return="main"] > img {
  width: 28px !important;
  height: 28px !important;
  object-fit: contain !important;
}

:is(button, a)[data-wp-return="stage"],
:is(button, a)[data-wp-return="battle"] {
  box-sizing: border-box !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: #f8fafc !important;
  color: #1676c9 !important;
  box-shadow: none !important;
  font-size: 24px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  overflow: hidden !important;
}

:is(a, button)[data-wp-return].hidden,
:is(a, button)[data-wp-return][hidden] {
  display: none !important;
}

[data-wp-logical-stage-canvas] [hidden] {
  display: none !important;
}

:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid) {
  display: flex !important;
  grid-template-columns: none !important;
  grid-auto-columns: unset !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding-inline: max(24px, calc((100% - 264px) / 2)) !important;
  scroll-snap-type: x mandatory !important;
  scroll-behavior: smooth;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  touch-action: none !important;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  min-height: 198px !important;
}

:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid).wp-stage-dragging {
  cursor: grabbing;
}

:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid)::-webkit-scrollbar {
  display: none;
}

:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid).hidden {
  display: none !important;
}

:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid) > :is(.stage-card, .mission-card, .region-card, .route-card, .day-card, .zone-card, .expedition-card, .zone-node, button) {
  box-sizing: border-box !important;
  flex: 0 0 264px !important;
  width: 264px !important;
  min-width: 264px !important;
  max-width: 264px !important;
  height: 190px !important;
  min-height: 190px !important;
  max-height: 190px !important;
  scroll-snap-align: center !important;
  scroll-snap-stop: normal !important;
  overflow: hidden;
}

/* Locked native buttons must not swallow a swipe before it reaches the rail. */
:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid) > :is(
  .stage-card,
  .mission-card,
  .region-card,
  button
):is(.locked, .is-locked, :disabled, [aria-disabled="true"]) {
  pointer-events: none !important;
}

/* Wrapped locked cards must also leave the rail as the gesture target. */
:is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid, .route-rail, .day-rail, .zone-row, .expedition-rail, .world-map-grid) :is(
  .stage-card,
  .mission-card,
  .region-card,
  .route-card,
  .day-card,
  .zone-card,
  .expedition-card,
  .zone-node
):is(.locked, .is-locked, :disabled, [aria-disabled="true"]) {
  pointer-events: none !important;
}

.standard-main-start {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: #ffd45f;
  color: #231a10;
  font-weight: 900;
}

.wp-standard-stage-panel {
  position: fixed;
  inset: 0 0 56px;
  z-index: 40;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  background: #17243a;
}

.wp-stage-art-shell {
  --wp-stage-scrim: linear-gradient(rgb(9 18 32 / 78%), rgb(23 36 58 / 86%));
  background-color: #17243a !important;
  background-image: var(--wp-stage-scrim), var(--wp-stage-art) !important;
  background-position: center, center !important;
  background-size: cover, cover !important;
  background-repeat: no-repeat !important;
}

.wp-stage-art-shell :is(
  .wp-standard-stage-heading,
  .stage-head,
  .stage-heading,
  .stage-screen-head,
  .stage-shell-head,
  .stage-header,
  .stage-panel-head,
  .stage-select-head
) {
  position: relative;
  z-index: 1;
  background: rgb(13 27 45 / 82%);
  border-radius: 8px;
}

.wp-stage-art-shell :is(
  .wp-standard-stage-heading,
  .stage-head,
  .stage-heading,
  .stage-screen-head,
  .stage-shell-head,
  .stage-header,
  .stage-panel-head,
  .stage-select-head
) :is(h1, h2, h3, strong, span, small, em) {
  color: #f8fafc !important;
  line-height: 1.5 !important;
  text-shadow: 0 1px 2px rgb(0 0 0 / 55%);
}

/* Keep localized glyphs inside the fixed Stage heading track even when a
   game uses the standard logical Canvas without the artwork-shell class. */
[data-wp-logical-stage-canvas] :is(
  .wp-standard-stage-heading,
  .stage-head,
  .stage-heading,
  .stage-screen-head,
  .stage-shell-head,
  .stage-header,
  .stage-panel-head,
  .stage-select-head
) :is(h1, h2, h3, strong, span, small, em) {
  line-height: 1.5 !important;
}

.wp-stage-art-shell .menu-copy {
  padding: 8px 10px;
  background: rgb(255 255 255 / 84%);
  border-radius: 8px;
}

body[data-wp-game-id="animal-hero-trials"] .wp-stage-art-shell .stage-card {
  grid-template-rows: 56px 30px 66px;
  gap: 4px;
}

body[data-wp-game-id="animal-hero-trials"] .wp-stage-art-shell .stage-card img {
  min-height: 0;
}

body[data-wp-game-id="animal-hero-trials"] .wp-stage-art-shell .stage-card :is(strong, span) {
  overflow: hidden;
  white-space: normal;
  text-overflow: clip;
}

body[data-wp-game-id="animal-hero-trials"] .wp-stage-art-shell .stage-card strong {
  font-size: 14px;
  line-height: 1.08;
}

body[data-wp-game-id="animal-hero-trials"] .wp-stage-art-shell .stage-card span {
  min-height: 0;
  font-size: 11px;
  line-height: 1.18;
}

.wp-standard-stage-panel:has(> header + :is(.stage-select, .mission-list) + button) {
  grid-template-rows: 52px minmax(0, 1fr) 52px;
}

.wp-standard-stage-panel > :is(.stage-select, .mission-list) {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.wp-standard-stage-panel :is(.stage-grid, .stage-rail, .mission-grid, .mission-rail, .region-rail, .level-grid) {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.wp-standard-stage-panel.hidden,
.wp-standard-stage-reserve.hidden {
  display: none !important;
}

.wp-standard-stage-heading {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: #f8fafc;
}

.wp-standard-stage-heading :is(h1, h2, h3, strong, span) {
  min-width: 0;
  margin: 0;
  color: inherit;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgb(0 0 0 / 35%);
}

.wp-standard-stage-heading::after {
  content: "";
}

.wp-standard-stage-heading button {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  color: #1676c9;
  font-size: 24px;
  font-weight: 900;
}

.wp-standard-stage-reserve {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  pointer-events: none;
  background: #17243a;
}

body.wp-standard-stage-page,
body.wp-stage-select-active {
  overflow: hidden !important;
}

body.wp-standard-stage-page :is(.topbar, .game-page-info, .wp-tutorial-button, .sound-toggle, .weightplay-version-badge),
body.wp-stage-select-active :is(.topbar, .game-page-info, .wp-tutorial-button, .sound-toggle, .weightplay-version-badge) {
  display: none !important;
}

body.wp-stage-select-active [data-wp-logical-stage-canvas] {
  position: fixed !important;
  z-index: 40 !important;
  top: var(--wp-stage-canvas-top, 4px) !important;
  right: auto !important;
  bottom: auto !important;
  left: var(--wp-stage-canvas-left, 4px) !important;
  box-sizing: border-box !important;
  width: 390px !important;
  min-width: 390px !important;
  max-width: 390px !important;
  height: 788px !important;
  min-height: 788px !important;
  max-height: 788px !important;
  margin: 0 !important;
  overflow: hidden !important;
  transform: scale(var(--wp-stage-canvas-scale, 1)) !important;
  transform-origin: top left !important;
}

body.wp-stage-select-active [data-wp-logical-stage-canvas] :is(
  .ad-reserve,
  .stage-ad,
  .stage-ad-reserve,
  #stageAdReserve
) {
  display: none !important;
}

.wp-stage-physical-reserve {
  display: none;
}

.wp-stage-physical-reserve[data-wp-stage-reserve-active] {
  position: fixed;
  z-index: 39;
  top: var(--wp-stage-reserve-top, calc(100dvh - 60px));
  left: var(--wp-stage-canvas-left, 4px);
  display: block;
  width: var(--wp-stage-canvas-rendered-width, calc(100vw - 8px));
  height: 56px;
  min-height: 56px;
  pointer-events: none;
  background: #17243a;
  border-top: 1px solid rgb(255 255 255 / 12%);
}

/* Legacy short-viewport media queries must not reflow a scaled logical Stage. */
body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .stage-workspace {
  grid-template-columns: none !important;
  grid-template-rows: 54px 190px minmax(0, 1fr) 52px !important;
  gap: 8px !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] :is(.stage-profile, .day-rail, .upgrade-panel, #startBtn) {
  grid-column: auto !important;
  grid-row: auto !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .stage-profile {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .stage-profile > div {
  width: auto !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .day-rail {
  width: 100% !important;
  height: 190px !important;
  min-height: 190px !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .upgrade-panel small {
  display: block !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .upgrade-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body[data-wp-game-id="animal-cafe-rush"] [data-wp-logical-stage-canvas] .upgrade-card {
  height: 82px !important;
  min-height: 82px !important;
  max-height: 82px !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas]:has(> .stage-canvas) {
  grid-template-rows: minmax(0, 1fr) !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .stage-canvas {
  grid-template-columns: none !important;
  grid-template-rows: 44px 106px minmax(0, 1fr) !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .stage-header {
  grid-column: auto !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .planner {
  display: grid !important;
  grid-template-columns: 76px minmax(0, 1fr) !important;
  align-self: auto !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .planner > img {
  width: 76px !important;
  height: 76px !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .planner-body {
  grid-template-rows: auto 52px auto !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .gadget-choice {
  width: 46px !important;
  height: 46px !important;
  padding: 4px !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .economy-btn {
  min-height: 42px !important;
  padding: 4px 7px !important;
  font-size: 10px !important;
}

body[data-wp-game-id="animal-moonlight-heist"] [data-wp-logical-stage-canvas] .mission-rail {
  padding-block: 12px !important;
}

body[data-wp-game-id="animal-gearpack-expedition"] [data-wp-logical-stage-canvas]:has(> .stage-canvas) {
  grid-template-rows: minmax(0, 1fr) !important;
}

body[data-wp-game-id="animal-gearpack-expedition"] [data-wp-logical-stage-canvas] .stage-canvas {
  grid-template-columns: none !important;
  grid-template-rows: 52px 96px minmax(0, 1fr) !important;
}

body[data-wp-game-id="animal-gearpack-expedition"] [data-wp-logical-stage-canvas] :is(.stage-header, .loadout-preview, .region-rail) {
  grid-column: auto !important;
  grid-row: auto !important;
}

body[data-wp-game-id="animal-gearpack-expedition"] [data-wp-logical-stage-canvas] .loadout-preview {
  grid-template-columns: 76px minmax(0, 1fr) !important;
  height: auto !important;
}

body[data-wp-game-id="animal-gearpack-expedition"] [data-wp-logical-stage-canvas] .region-rail {
  width: 100% !important;
  padding-block: 8px !important;
}

body[data-wp-game-id="animal-relic-hunters"] [data-wp-logical-stage-canvas] {
  grid-template-columns: none !important;
  grid-template-rows: 54px 198px minmax(0, 1fr) !important;
  gap: 8px !important;
}

body[data-wp-game-id="animal-relic-hunters"] [data-wp-logical-stage-canvas] :is(.stage-panel-head, .expedition-rail, .stage-config-mount) {
  grid-column: auto !important;
  grid-row: auto !important;
}

body[data-wp-game-id="animal-relic-hunters"] [data-wp-logical-stage-canvas] .expedition-rail {
  width: 100% !important;
  height: 198px !important;
  min-height: 198px !important;
  max-height: 198px !important;
}

body[data-wp-game-id="animal-rune-tactics"] [data-wp-logical-stage-canvas] .mission-list {
  grid-template-rows: 44px 198px !important;
}

body[data-wp-game-id="animal-rune-tactics"] [data-wp-logical-stage-canvas] .mission-grid {
  width: 100% !important;
  height: 198px !important;
  min-height: 198px !important;
  max-height: 198px !important;
}

body[data-wp-game-id="animal-rune-tactics"] [data-wp-logical-stage-canvas] .mission-card {
  height: 190px !important;
  min-height: 190px !important;
  max-height: 190px !important;
}

body[data-wp-game-id="animal-rune-tactics"] [data-wp-logical-stage-canvas] .rune-stage-view[data-rune-stage-view="missions"] {
  grid-template-columns: none !important;
  grid-template-rows: minmax(0, 1fr) 52px !important;
}

body[data-wp-game-id="animal-rune-tactics"] [data-wp-logical-stage-canvas] .rune-stage-view > #startBtn {
  width: 100% !important;
  height: 52px !important;
  min-height: 52px !important;
  max-height: 52px !important;
  align-self: auto !important;
}

body[data-wp-game-id="beast-deck"] [data-wp-logical-stage-canvas] .beast-stage-view[data-stage-view="missions"] .stage-select {
  grid-template-rows: 58px 190px minmax(52px, 1fr) !important;
}

body[data-wp-game-id="beast-deck"] [data-wp-logical-stage-canvas] .stage-select-head {
  display: grid !important;
  grid-template-rows: 21px 27px !important;
  align-content: center !important;
  align-items: center !important;
  gap: 0 !important;
  padding: 5px 8px !important;
}

body[data-wp-game-id="beast-deck"] [data-wp-logical-stage-canvas] .stage-select-head :is(strong, small) {
  min-width: 0;
  line-height: 1.3 !important;
}

body[data-wp-game-id="beast-deck"] [data-wp-logical-stage-canvas] #stagePanel :is(.stage-grid, .stage-card) {
  height: 190px !important;
  min-height: 190px !important;
  max-height: 190px !important;
}

.wonder-main {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 52px 44px;
  gap: 8px;
  padding: 8px;
  background: #101827;
}

.wonder-main.hidden {
  display: none !important;
}

.wonder-main header {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 116px;
  align-items: center;
  gap: 8px;
  justify-self: center;
  width: min(374px, 100%);
  text-align: center;
}

.wonder-main .home-link {
  width: 58px;
  min-height: 44px;
  display: grid;
  grid-template-columns: 16px 28px;
  place-items: center;
  gap: 4px;
  color: #172033;
  background: #fff;
  text-decoration: none;
}

.wonder-main .home-link img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.wonder-main header label {
  display: grid;
  font-size: 10px;
}

.wonder-main header select {
  width: 116px;
  height: 36px;
}

.wonder-main-cover {
  justify-self: center;
  width: 100%;
  max-width: 374px;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

#wonderMainStart {
  justify-self: center;
  width: min(374px, 100%);
  max-width: 374px;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
}

body.wonder-stage-select #wonderStageBack {
  position: absolute;
  z-index: 90;
  top: 8px;
  left: 8px;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  padding: 0;
  font-size: 24px !important;
  line-height: 1 !important;
  font-weight: 900;
}

body.wonder-stage-select .wonder-language-picker,
body.wonder-stage-select .game-page-info,
body.wonder-stage-select .wp-tutorial-button,
body.wonder-stage-select .sound-toggle,
body.wonder-stage-select .weightplay-version-badge,
body.wonder-stage-select .version-badge {
  display: none !important;
}

body.wonder-stage-select :is(.campaign-summary, .beast-guide) {
  display: none !important;
}

body.wonder-stage-select #game {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.wonder-stage-select #overlay {
  inset: 0 !important;
  width: 390px !important;
  height: calc(390px * 16 / 9) !important;
  gap: 12px;
  padding: 12px 24px 96px;
}

body.wonder-stage-select #menuContent {
  width: 342px;
  max-height: 448px;
}

body.wonder-stage-select #menuTabs {
  grid-template-columns: repeat(5, 66px);
  justify-content: center;
}

body.wonder-stage-select #menuTabs button {
  width: 66px;
  min-width: 66px;
  max-width: 66px;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  font-size: 11px;
}

body.wonder-stage-select #menuTabs :is(img, .tab-gear) {
  width: 46px;
  height: 46px;
}

body.wonder-stage-select #levelGrid > button {
  width: 264px !important;
  min-width: 264px !important;
  max-width: 264px !important;
  flex-basis: 264px !important;
  height: 190px !important;
  min-height: 190px !important;
  max-height: 190px !important;
}

body.wonder-stage-select #battleAdReserve {
  position: fixed !important;
  z-index: 70;
  left: 50% !important;
  right: auto !important;
  bottom: 0 !important;
  display: block !important;
  width: calc(390px * var(--wonder-shell-scale, 1)) !important;
  height: 56px !important;
  transform: translateX(-50%);
  pointer-events: none !important;
}
