/* Touch play (game/touch-controls.js): the whole screen is the controller.
   Left side = a stick drawn only while a thumb is down; right side = JUMP
   (the button marks it; the whole side works) plus a FIRE / SPIN button.
   The game picture loses its frame and padding and takes all the room the
   screen gives it: full width upright, full height sideways. */
.touch-layer { display: none; }
.uses-touch.is-playing .touch-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.touch-art { display: none; }
.uses-touch.is-playing .touch-art { position: fixed; inset: 0; z-index: 12; display: block; pointer-events: none; }
.stick-base {
  position: absolute;
  left: -60px;
  top: -60px;
  width: 120px;
  height: 120px;
  display: none;
  box-sizing: border-box;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.stick-base.is-on { display: grid; place-items: center; }
.stick-knob { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 214, 92, 0.6); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
.touch-hint {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translateX(-50%);
  max-width: 92%;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(8, 24, 40, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.touch-button {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: 16px;
  display: grid;
  place-items: center;
  width: 100px;
  height: 100px;
  padding: 0;
  box-sizing: border-box;
  border: 3px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.2), 0 6px 16px rgba(0, 0, 0, 0.28);
  -webkit-tap-highlight-color: transparent;
}
.jump-button { background: rgba(255, 214, 92, 0.85); color: #2a1d00; pointer-events: none; }
.fire-button { right: calc(max(16px, env(safe-area-inset-right)) + 112px); bottom: 40px; width: 78px; height: 78px; background: rgba(255, 138, 61, 0.88); color: #2a0f00; font-size: 14px; pointer-events: none; }
.fire-button.is-idle { display: none; }
.touch-button.is-down { transform: scale(0.93); filter: brightness(1.12); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.28); }
.touch-art.was-used .touch-hint { display: none; }
/* Watching a replay: the run plays itself, so no stick, buttons, hint or finger layer. */
.uses-touch.is-playing.is-watching .touch-layer,
.uses-touch.is-playing.is-watching .touch-art { display: none; }

/* The picture: no frame, no padding, no rounded corners. The shell sits
   above the touch layer only so the map's Menu button stays tappable. */
.container.uses-touch.is-playing { padding: 0; background: #000; }
.uses-touch.is-playing .game-shell { z-index: 11; border-radius: 0; pointer-events: none; }
.uses-touch.is-playing canvas { border: 0; border-radius: 0; box-shadow: none; }
.uses-touch.is-playing .hud-menu-button { pointer-events: auto; }
.uses-touch .overlay-actions .btn { min-height: 48px; min-width: 160px; font-size: 1.05rem; }

/* Upright: picture across the top, the score strip under it, and the empty
   space below is where the thumbs go. */
@media (orientation: portrait) {
  .container.uses-touch.is-playing { align-items: flex-start; }
  .uses-touch.is-playing .hud { position: static; display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto; gap: 4px; max-width: none; margin: 6px 6px 0; }
  .uses-touch.is-playing .hud .stat { min-width: 0; padding: 5px 5px; }
  .uses-touch.is-playing .hud .stat span { font-size: 10px; letter-spacing: 0; }
  .uses-touch.is-playing .hud .stat strong { font-size: 15px; }
  .uses-touch.is-playing .hud-menu-button { padding: 0 8px; }
  .uses-touch.is-playing .stat-mute { display: none !important; }
  /* A replay's name gets its own full-width row under the score line, so it
     never squeezes the numbers or pushes Pause onto a row of its own. */
  .uses-touch.is-playing .stat-replay { grid-column: 1 / -1; order: 1; display: flex; align-items: baseline; gap: 8px; }
  .uses-touch.is-playing .stat-replay strong { flex: 1 1 auto; min-width: 0; max-width: none; }
}

/* Sideways: the picture fills the height; a small score line sits on it. */
@media (orientation: landscape) {
  .uses-touch.is-playing .hud { top: 4px; left: 4px; gap: 3px; }
  .uses-touch.is-playing .hud .stat { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 6px; border-radius: 5px; }
  .uses-touch.is-playing .hud .stat span { font-size: 9px; letter-spacing: 0; }
  .uses-touch.is-playing .hud .stat strong { font-size: 13px; }
  .uses-touch.is-playing .hud-menu-button { min-height: 28px; padding: 0 10px; font-size: 11px; }
}

/* What the thumbs can do right now (touch-controls.js setMode): off during
   cards, banners, a death, a stage clear and the pause card; the map keeps
   the stick and GO only; a chest pick needs no buttons at all. */
.touch-art > * { transition: opacity 0.18s ease; }
.touch-art[data-mode="off"] > :not(.touch-deck),
.touch-art[data-mode="chest"] > :not(.touch-deck),
.touch-art[data-mode="map"] .fire-button,
.touch-art[data-mode="map"] .touch-hint { opacity: 0 !important; visibility: hidden; transition: opacity 0.18s ease, visibility 0s linear 0.18s; }
.touch-hint { top: calc(var(--pic-top, 0px) + 54px); }

/* The move ring: a quiet mark where the left thumb goes, gone while a thumb steers. */
.touch-pad {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: 18px;
  width: 104px;
  height: 104px;
  box-sizing: border-box;
  border: 3px dashed rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 18px;
  pointer-events: none;
}
.touch-pad.is-hidden { opacity: 0; }
.touch-art.was-used .touch-pad { opacity: 0.45; }
.touch-art.was-used .touch-pad.is-hidden { opacity: 0; }
.touch-deck { display: none; }

/* Sideways with a gutter beside the picture: the buttons stand in it, one
   column, JUMP low for the thumb and FIRE above it; nothing covers the game. */
.touch-art.fit-gutter .touch-button {
  --size: min(96px, calc(var(--gap-right) - 16px));
  right: calc((var(--gap-right) - var(--size)) / 2);
  width: var(--size);
  height: var(--size);
  opacity: 1;
}
.touch-art.fit-gutter .jump-button { bottom: max(16px, env(safe-area-inset-bottom)); }
.touch-art.fit-gutter .fire-button {
  --size: min(76px, calc(var(--gap-right) - 22px));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + min(96px, calc(var(--gap-right) - 16px)) + 16px);
}
/* Over the picture the ring would sit on the hero: it shows only in a gutter or on the deck. */
.touch-art:not(.fit-deck):not(.fit-left-gutter) .touch-pad { display: none; }
.touch-art.fit-left-gutter .touch-pad { left: calc((var(--gap-left) - 92px) / 2); width: 92px; height: 92px; }
.touch-art:not(.fit-gutter):not(.fit-deck) .touch-button { opacity: 0.62; }
.touch-art:not(.fit-gutter):not(.fit-deck) .fire-button { bottom: 24px; right: calc(max(16px, env(safe-area-inset-right)) + 112px); }

/* Upright: the space under the picture and its score line is a controller deck. */
.touch-art.fit-deck .touch-deck {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--deck-top) + 8px);
  bottom: 0;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.05), transparent 60%),
    linear-gradient(#141c2b, #0b101a);
  border-top: 2px solid rgba(255, 255, 255, 0.08);
}
.touch-art.fit-deck .touch-pad {
  width: 132px;
  height: 132px;
  left: calc(25% - 66px);
  bottom: auto;
  top: calc(var(--deck-top) + var(--deck-h) * 0.56 - 66px);
  font-size: 22px;
  padding: 0 16px;
}
.touch-art.fit-deck .jump-button {
  width: 112px;
  height: 112px;
  right: calc(22% - 56px);
  bottom: auto;
  top: calc(var(--deck-top) + var(--deck-h) * 0.56 - 30px);
}
.touch-art.fit-deck .fire-button {
  width: 80px;
  height: 80px;
  right: calc(22% + 50px);
  bottom: auto;
  top: calc(var(--deck-top) + var(--deck-h) * 0.56 - 100px);
}
.touch-art.fit-deck .touch-hint { bottom: auto; top: calc(var(--deck-top) + 26px); }
