/* Colourful console-platformer: 1:1 / 4:3 playfield on phones, pads in a dock below. */
body.in-game .play-wrap:has(.console-shell) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
  /* Pad dock, not the wrap, reserves --host-safe-bottom so the 2.6rem host
     badge cannot cover Play / D-pad. Keep overflow hidden (no scroll steal). */
  padding-bottom: 0;
}
body.in-game .play-wrap:has(.console-shell) .game-mount {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: .35rem;
}
body.in-game .play-wrap:has(.console-shell) .online-side:empty { display: none; }
body.in-game .play-wrap:has(.console-shell) > .play-actions {
  flex-wrap: nowrap;
  flex: 0 0 auto;
  margin: .15rem 0 .1rem;
  gap: .3rem;
  padding: .1rem .15rem .2rem;
}
body.in-game .play-wrap:has(.console-shell) > .play-actions .btn {
  min-height: 2.4rem;
  padding-inline: .65rem;
  font-size: .9rem;
  flex: 0 1 auto;
  white-space: nowrap;
}

.console-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  gap: 0;
  position: relative;
}
.console-shell.is-full,
.console-shell:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #12081c;
  border-radius: 0;
  padding: .4rem .4rem max(.4rem, env(safe-area-inset-bottom, 0px));
}
.console-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(12,8,24,.55), rgba(12,8,24,0));
  padding-bottom: .35rem;
}
.console-hud .console-fs,
.console-hud button { pointer-events: auto; }
.console-hud > .btn[data-act="levels"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}
.console-hud-bar {
  display: flex;
  align-items: center;
  gap: .45rem .7rem;
  flex: 0 0 auto;
  padding: .2rem .35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  z-index: 3;
}
.console-hearts { display: flex; gap: .15rem; font-size: 1.15rem; letter-spacing: .02em; }
.console-heart { color: #ff4d6a; text-shadow: 0 1px 0 #1b1208; }
.console-heart.is-empty { color: #4a3040; opacity: .55; }
.console-coins { display: flex; align-items: center; gap: .25rem; color: #ffe566; }
.console-coins::before {
  content: "";
  width: .95rem; height: .95rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c0, #ffe24a 45%, #ff9c10);
  box-shadow: inset 0 0 0 1px #1b1208;
}
.console-lvl { margin-inline-start: auto; color: var(--ivory, #fff6d0); opacity: .9; font-size: .85rem; }
.console-fs {
  min-width: 2.4rem; min-height: 2.4rem;
  border-radius: .7rem;
  background: rgba(255,246,208,.12);
  border: 1px solid rgba(232,200,120,.45);
  color: #fff6d0;
  font-size: 1.05rem;
  cursor: pointer;
}
.console-status.game-status {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}
.console-scores { display: none; }

.console-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 14rem;
  min-width: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #12081c;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--line, #c9a227) 55%, transparent);
  touch-action: none;
}
.console-stage canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.console-play {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 5;
  min-width: 8.5rem;
  min-height: 3rem;
  padding: .4rem 1.4rem;
  font-size: 1.25rem;
  font-weight: 800;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe566, #f0b429);
  color: #1b1208;
  border: 2px solid #1b1208;
  box-shadow: 0 4px 0 #a06a10;
  cursor: pointer;
}
.console-play[hidden] { display: none !important; }

.console-rotate {
  display: none;
  text-align: center;
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--ivory, #fff6d0);
  opacity: .72;
  padding: .35rem .4rem .1rem;
  pointer-events: none;
}

.console-pad {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  pointer-events: none;
  position: relative;
  flex: 0 0 auto;
  z-index: 4;
  padding: .45rem .4rem max(.55rem, calc(env(safe-area-inset-bottom, 0px) + .3rem));
}
.console-pad-left, .console-pad-right {
  display: flex;
  gap: .55rem;
  pointer-events: auto;
}
.console-shell .btn.console-btn {
  min-width: 4.1rem;
  min-height: 4.1rem;
  font-size: 1.5rem;
  font-weight: 800;
  border-radius: 1.2rem;
  touch-action: manipulation;
  user-select: none;
  background: rgba(16, 12, 28, 0.82);
  border: 2px solid rgba(255, 246, 208, 0.55);
  color: #fff6d0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.console-shell .btn.console-jump,
.console-shell .btn.console-action {
  min-width: 4.5rem;
  min-height: 4.5rem;
  background: linear-gradient(180deg, #ffe566, #f0b429);
  color: #1b1208;
  border-color: #1b1208;
  box-shadow: 0 3px 0 #a06a10;
}
.console-ico {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}
.console-ico svg { display: block; }

/* Portrait: 1:1 playfield at the top, pads in a dock underneath (never over the canvas).
   Short 360×640 phones: do NOT force a 42vh stage — that plus header / play-actions /
   rotate hint used to overflow the hidden play-wrap, clipping the pad (and sometimes
   Play). Playwright then times out on bounding_box (0-move official/smoke FAILs). */
@media (orientation: portrait) {
  .console-shell .console-stage {
    /* flex-grow + aspect-ratio can oscillate and shift the pad dock
       (Playwright bounding_box 4s timeouts). Size a capped square instead. */
    flex: 0 1 auto;
    width: 100%;
    max-width: min(100%, 22.5rem, calc(100dvh - 18rem), 46vh);
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: min(22.5rem, calc(100dvh - 18rem), 46vh);
    min-height: 8rem;
    margin-inline: auto;
  }
  .console-shell.is-full .console-stage,
  .console-shell:fullscreen .console-stage {
    max-height: min(26rem, calc(100dvh - 10rem), 52vh);
  }
  .console-shell .console-pad {
    position: relative;
    flex: 0 0 auto;
    left: auto; right: auto; bottom: auto;
    align-items: center;
    min-height: 7rem;
    overflow: visible;
    padding: .45rem .5rem max(.55rem, calc(env(safe-area-inset-bottom, 0px) + var(--host-safe-bottom, 2.6rem)));
  }
  .console-rotate { display: block; }
  .console-shell .btn.console-btn { min-width: 4.25rem; min-height: 4.25rem; }
  .console-shell .btn.console-jump,
  .console-shell .btn.console-action { min-width: 4.6rem; min-height: 4.6rem; }
  .console-pad-left { margin-inline-end: auto; }
  .console-pad-right { margin-inline-start: auto; }
  body.in-game .play-wrap:has(.console-shell) .game-mount { padding: .2rem; }
}
@media (orientation: portrait) and (max-height: 700px) {
  .console-rotate { padding: .12rem .4rem 0; font-size: .62rem; }
  .console-shell .btn.console-btn { min-width: 3.8rem; min-height: 3.8rem; }
  .console-shell .btn.console-jump,
  .console-shell .btn.console-action { min-width: 4.1rem; min-height: 4.1rem; }
}

/* Landscape / wide: playfield fills the stage; pads sit at the left/right edges, not over the hero lane. */
@media (orientation: landscape) {
  .console-shell .console-stage {
    flex: 1 1 auto;
    aspect-ratio: auto;
    max-height: none;
    min-height: 12rem;
  }
  .console-shell .console-pad {
    position: absolute;
    left: 0; right: 0;
    bottom: max(0.45rem, calc(env(safe-area-inset-bottom, 0px) + 0.2rem));
    padding: 0 .45rem;
    flex: 0 0 auto;
    pointer-events: none;
  }
  .console-rotate { display: none !important; }
  .console-play { bottom: 1.1rem; }
}

@media (min-width: 900px) {
  .console-stage { min-height: 22rem; }
  .console-shell .btn.console-btn { min-width: 4.2rem; min-height: 4rem; }
}

.cat-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin: .7rem 0 .2rem;
  flex-wrap: wrap;
}

/* 3.3.0: down button (top-down / swim / fly / climb), goal counter, ability chips, retry */
.console-shell .btn.console-down { min-width: 3.4rem; min-height: 3.4rem; font-size: 1.2rem; align-self: flex-end; }
.console-goal { color: #ff9ad0; font-size: .95rem; text-shadow: 0 1px 0 #1b1208; }
.console-goal:empty { display: none; }
.console-chips { display: flex; gap: .3rem; padding: 0 .4rem; pointer-events: none; }
.console-chips:empty { display: none; }
.console-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.45rem; height: 1.45rem; padding: 0 .3rem; border-radius: .5rem;
  background: rgba(16,12,28,.7); border: 1px solid rgba(255,246,208,.45);
  color: #ffe566; font-size: .85rem; font-weight: 800;
}
.console-retry {
  position: absolute; left: 50%; top: 62%; transform: translateX(-50%); z-index: 7;
  min-width: 9rem; min-height: 3rem; padding: .4rem 1.1rem; border-radius: 1rem;
  background: linear-gradient(180deg, #ffe566, #f0b429); color: #1b1208; border: 2px solid #1b1208;
  font-weight: 800; font-size: 1.05rem; cursor: pointer; box-shadow: 0 3px 0 #a06a10;
}
.console-retry[hidden] { display: none; }
@media (max-width: 480px) {
  .console-shell .btn.console-down { min-width: 3rem; min-height: 3rem; }
  .console-pad-left { flex-wrap: nowrap; }
}
.console-pad.has-down { gap: .35rem; }
.console-pad.has-down .console-pad-left, .console-pad.has-down .console-pad-right { gap: .35rem; }
.console-shell .console-pad.has-down .btn.console-btn { min-width: 3.15rem; min-height: 3.5rem; font-size: 1.3rem; border-radius: 1rem; }
.console-shell .console-pad.has-down .btn.console-jump, .console-shell .console-pad.has-down .btn.console-action { min-width: 3.7rem; min-height: 3.9rem; }
.console-shell .console-pad.has-down .btn.console-down { align-self: center; min-height: 3.5rem; }
