/*
  Mobile gameplay composition
  ---------------------------
  This layer is intentionally loaded after theme.css. It replaces the short
  landscape cabinet with a dense three-part game surface:

    last-shot rail / table / live kit rail

  The artwork stays loud, but mobile type uses proportional ink, strokes and
  shadows so labels remain legible at real phone pixels.
*/

/* Coarse-pointer browsers should treat the game as an application surface,
   not a zoomable document. Dedicated scroll roots opt back into their one
   intended axis; controls keep Safari's fast-tap behavior.

   Never put touch-action: none on a container: iOS WebKit intersects
   touch-action across the whole ancestor chain, so it vetoes the pan-y/pan-x
   opt-ins of scrollers inside it (chalk case, modal cards). Zoom is already
   blocked by the viewport meta, the gesturestart handlers, and the
   double-tap consumer in game.js. */
@media (pointer: coarse) {
  html,
  body {
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  .cabinet,
  .modal-backdrop,
  .rotate-overlay {
    touch-action: manipulation;
  }

  /* The UI is an app surface: long-presses and stray drags must not select
     display text or raise the copy callout. Real text entry opts back in. */
  html {
    -webkit-tap-highlight-color: transparent;
  }

  body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  input,
  textarea,
  [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
  }

  .modal-card,
  .chalk-case,
  .kit-meters {
    touch-action: pan-y;
  }

  .shop-stock,
  .bj-cards {
    touch-action: pan-x;
  }

  button,
  input,
  label,
  select,
  textarea,
  a,
  [role="button"],
  [contenteditable="true"] {
    touch-action: manipulation;
  }

  #game-canvas {
    touch-action: none;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  :root {
    --mobile-hud-height: clamp(44px, 12dvh, 54px);
    --mobile-left-rail: clamp(82px, 10.5vw, 102px);
    --mobile-kit-rail: clamp(62px, 8vw, 78px);
    --mobile-game-gap: clamp(6px, 0.85vw, 8px);
    /* 47-48px on the iPhone 16 / 16 Pro, reaching 52px on Plus/Pro Max. */
    --mobile-kit-size: clamp(44px, 12dvh, 52px);
  }

  html,
  body {
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  body {
    display: grid;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    place-items: stretch;
  }

  button,
  [role="button"],
  input,
  label,
  select,
  textarea,
  a,
  [contenteditable="true"] {
    touch-action: manipulation;
  }

  #game-canvas {
    touch-action: none;
  }

  .cabinet {
    display: grid;
    grid-template-rows: var(--mobile-hud-height) minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding:
      max(4px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    overflow: hidden;
  }

  /* Compact top strip. Audio and help remain reachable without taking a row. */
  .masthead {
    position: fixed;
    z-index: 60;
    top: max(5px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    display: block;
    width: auto;
    min-height: 0;
    padding: 0;
    overflow: visible;
  }

  .masthead::after,
  .brand-lockup,
  .header-actions > .mix-controls {
    display: none;
  }

  .header-actions {
    display: flex;
    gap: 5px;
  }

  .icon-button,
  .sound-button {
    display: flex;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-width: 3px;
    box-shadow: 3px 3px 0 #000;
    transform: none;
  }

  .icon-button:active,
  .sound-button:active {
    box-shadow: 1px 1px 0 #000;
    transform: translate(2px, 2px);
  }

  .sound-button > span:last-child {
    display: none;
  }

  .settings-panel {
    position: fixed;
    top: max(52px, calc(env(safe-area-inset-top) + 48px));
    right: max(8px, env(safe-area-inset-right));
    width: min(330px, calc(100vw - 16px));
    max-height: calc(100dvh - 62px - env(safe-area-inset-bottom));
    padding: 8px;
    overflow-y: auto;
    border-width: 3px;
    box-shadow: 6px 7px 0 var(--pink), 9px 10px 0 #000;
    touch-action: pan-y;
    transform: none;
  }

  .settings-panel__header {
    margin-bottom: 4px;
    padding-bottom: 5px;
    border-bottom-width: 3px;
  }

  .settings-panel__header strong {
    font-size: 23px;
  }

  #settings-close {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    border-width: 2px;
    font-size: 21px;
  }

  .setting-row {
    gap: 9px;
    padding: 5px 1px;
  }

  .setting-copy strong {
    font-size: 13px;
  }

  .setting-copy span {
    font-size: 9px;
  }

  .setting-toggle {
    min-width: 98px;
    height: 31px;
    border-width: 2px;
    box-shadow: 3px 3px 0 #000;
    font-size: 9px;
  }

  .aim-line-swatches {
    gap: 5px;
  }

  .aim-line-swatches button {
    width: 22px;
    height: 22px;
    border-width: 2px;
  }

  .settings-panel .mix-controls {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    padding: 4px 6px;
    border-width: 2px;
    box-shadow: 3px 3px 0 #000;
  }

  .settings-panel .mix-controls label {
    font-size: 8px;
  }

  .cabinet-switch {
    grid-template-columns: 56px;
  }

  .cabinet-switch > span {
    width: 56px;
    height: 26px;
    border-width: 2px;
  }

  .cabinet-switch > span i {
    width: 16px;
    height: 16px;
    border-width: 1.5px;
  }

  .cabinet-switch input:checked + span i {
    left: 33px;
  }

  .settings-note {
    margin-top: 4px;
    padding: 5px 7px;
    font-size: 8px;
  }

  .run-board {
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(104px, 0.82fr) minmax(206px, 1.55fr) minmax(88px, 0.7fr);
    width: auto;
    height: var(--mobile-hud-height);
    min-height: 0;
    margin: 0 88px 0 0;
    overflow: hidden;
    /* Below the table stage (z 2): the turn banner straddles the frame and
       must not sit behind this strip's pink drop shadow. */
    z-index: 1;
    border-width: 3px;
    box-shadow: 3px 3px 0 var(--pink);
    transform: none;
  }

  .blind-plaque {
    min-width: 0;
    padding: 4px 8px;
  }

  .blind-plaque::after,
  .blind-plaque small {
    display: none;
  }

  .blind-plaque span {
    max-width: 100%;
    margin: 0;
    padding: 1px 4px;
    overflow: hidden;
    font-size: 7px;
    line-height: 1.15;
    text-overflow: ellipsis;
    transform: none;
    white-space: nowrap;
  }

  .blind-plaque strong {
    display: block;
    max-width: 100%;
    margin: 2px 0 0;
    padding: 1px 2px 2px;
    overflow: hidden;
    font-size: clamp(11px, 3.4dvh, 15px);
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    text-shadow: none;
    -webkit-text-stroke: 0;
    transform: none;
    white-space: nowrap;
  }

  .score-cluster {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    justify-content: stretch;
    column-gap: clamp(5px, 1.2vw, 12px);
    min-width: 0;
    padding: 3px 9px;
    isolation: isolate;
    overflow: hidden;
  }

  .score-cluster::before {
    position: relative;
    z-index: 2;
    width: auto;
    height: auto;
    align-self: center;
    content: "/";
    color: #000;
    background: none;
    font-family: var(--display);
    font-size: clamp(18px, 5.4dvh, 25px);
    font-style: italic;
    font-weight: 950;
    line-height: 1;
    transform: none;
  }

  .score-readout,
  .target-readout {
    display: grid;
    min-width: 0;
    align-content: center;
    justify-items: center;
    gap: 0;
    overflow: visible;
    padding-inline: 3px;
    position: relative;
    z-index: 2;
  }

  .score-readout {
    justify-items: end;
  }

  .target-readout {
    justify-items: start;
  }

  .score-readout span,
  .target-readout span {
    overflow: hidden;
    max-width: 100%;
    font-size: 7px;
    line-height: 1;
    letter-spacing: 0.1em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .score-readout strong,
  .target-readout strong {
    display: block;
    min-width: 1.35em;
    max-width: calc(100% - 4px);
    padding: 1px 4px 2px;
    overflow: visible;
    font-size: clamp(18px, 5.4dvh, 25px);
    line-height: 1.08;
    letter-spacing: -0.035em;
    text-align: center;
    text-overflow: clip;
    -webkit-text-stroke: 0;
    white-space: nowrap;
  }

  .score-readout strong {
    text-shadow: 1px 1px 0 #fff;
  }

  .target-readout strong {
    text-shadow: none;
  }

  .progress-track {
    z-index: 0;
    inset: 0;
    height: auto;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--acid);
    box-shadow: none;
  }

  .progress-track > div {
    height: 100%;
    background:
      repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 0 4px, transparent 4px 12px),
      var(--pink);
    box-shadow: none;
  }

  .progress-track i {
    top: 0;
    bottom: 0;
    width: 10px;
    height: auto;
    border-radius: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.88), transparent);
    box-shadow: none;
  }

  .shots-plaque {
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, 0.7vw, 7px);
    padding: 3px 6px;
  }

  .misses-copy {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 4px;
    overflow: visible;
  }

  .misses-copy span {
    max-width: 34px;
    color: #fff;
    font-size: 7px;
    line-height: 0.9;
    letter-spacing: 0.08em;
  }

  .misses-copy strong {
    display: block;
    min-width: 1.1em;
    padding: 1px 3px 2px;
    overflow: visible;
    color: var(--acid);
    font-size: clamp(19px, 5.8dvh, 27px);
    line-height: 1.08;
    -webkit-text-stroke: 0.7px #000;
    text-shadow: 1px 1px 0 var(--pink), 2px 2px 0 #000;
    transform: none;
  }

  .shot-pips {
    flex: 0 0 auto;
    gap: 3px;
    margin: 0;
  }

  .shot-pips i {
    width: 9px;
    height: 9px;
    border-width: 1.5px;
    box-shadow: 1px 1px 0 #000;
  }

  .shot-pips i.is-spent {
    box-shadow: none;
  }

  .shot-pips i.is-spent::after {
    inset: 2px 1px;
  }

  /*
    The play stack becomes transparent to grid layout, allowing its two
    children to occupy the table and kit columns directly.
  */
  .game-layout {
    grid-row: 2;
    display: grid;
    /* The table is height-limited on modern wide iPhones. Give that exact
       aspect-ratio track to the table and let the left instrument absorb the
       otherwise-empty strip. The cabinet's outer safe-area padding remains
       the notch boundary. */
    grid-template-columns:
      minmax(var(--mobile-left-rail), 1fr)
      minmax(
        0,
        min(
          calc(
            (
                100dvh
                - var(--mobile-hud-height)
                - 6px
                - max(4px, env(safe-area-inset-top))
                - max(6px, env(safe-area-inset-bottom))
              ) * 1.846154
          ),
          calc(
            100%
            - var(--mobile-left-rail)
            - var(--mobile-kit-rail)
            - (2 * var(--mobile-game-gap))
          )
        )
      )
      var(--mobile-kit-rail);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--mobile-game-gap);
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    align-items: stretch;
  }

  .play-stack {
    display: contents;
  }

  /* Left instrument: last result, chips, multiplier, total and bankroll. */
  .side-panel--left {
    grid-column: 1;
    grid-row: 1;
    z-index: 4;
    display: flex;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 5px 4px;
    overflow: hidden;
    border-width: 3px;
    background:
      repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 11px),
      var(--acid);
    box-shadow: 3px 4px 0 #000;
    transform: none;
  }

  .side-panel--left .panel-heading {
    flex: 0 0 auto;
    gap: 4px;
    margin: 0 1px 5px;
    font-size: 8px;
    line-height: 1;
    letter-spacing: 0.08em;
    transform: none;
  }

  .side-panel--left .panel-heading i {
    height: 2px;
  }

  .side-panel--left .shot-card {
    display: grid;
    flex: 0 0 auto;
    min-height: 0;
    padding: 7px 3px 6px;
    align-content: center;
    overflow: visible;
    border-width: 3px;
    box-shadow: 3px 3px 0 var(--pink);
    text-align: center;
    transform: none;
  }

  .shot-card__overline {
    max-width: 100%;
    padding: 1px 2px;
    overflow: hidden;
    font-size: 6px;
    line-height: 1.1;
    letter-spacing: 0.05em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .side-panel--left .shot-card > strong {
    min-height: 0;
    margin: 7px 0 6px;
    overflow-wrap: anywhere;
    font-size: clamp(11px, 3.3dvh, 15px);
    line-height: 0.9;
    letter-spacing: -0.025em;
    -webkit-text-stroke: 0;
    text-shadow: 1px 1px 0 #000;
    transform: none;
  }

  .score-equation {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 0;
    align-items: center;
    justify-items: stretch;
    width: 100%;
    overflow: visible;
    font-size: 7px;
    line-height: 1;
  }

  .score-equation span {
    display: flex;
    min-width: 0;
    min-height: 24px;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    padding: 0 2px 1px;
    overflow: visible;
  }

  .score-equation span b,
  .score-equation span:last-child b {
    display: inline-block;
    min-width: 1em;
    padding: 1px 1px 2px;
    overflow: visible;
    font-size: clamp(17px, 5dvh, 23px);
    line-height: 1.08;
    -webkit-text-stroke: 0;
    text-shadow: none;
  }

  .score-equation span:last-child b {
    color: var(--pink);
    -webkit-text-stroke: 0.6px #000;
    text-shadow: 1px 1px 0 #000;
  }

  .score-equation em {
    display: grid;
    min-height: 13px;
    padding: 0;
    place-items: center;
    font-size: 12px;
    line-height: 1;
  }

  .side-panel--left .shot-card.has-long-equation .score-equation {
    gap: 0;
  }

  .side-panel--left .shot-card.has-long-equation .score-equation span,
  .side-panel--left .shot-card.has-long-equation .score-equation span b {
    padding-inline: 0;
  }

  .side-panel--left .shot-card.has-long-equation .score-equation span b {
    font-size: clamp(13px, 3.8dvh, 18px);
    letter-spacing: -0.08em;
  }

  .score-equation span b.is-long-number,
  .score-equation span:last-child b.is-long-number {
    font-size: clamp(14px, 4.2dvh, 19px);
    letter-spacing: -0.065em;
  }

  .shot-total {
    display: block;
    width: calc(100% - 4px);
    max-width: none;
    margin-right: auto;
    margin-left: auto;
    margin-top: 6px;
    padding: 2px 5px 3px;
    overflow: visible;
    font-size: clamp(16px, 4.8dvh, 22px);
    line-height: 1.1;
    letter-spacing: -0.03em;
    text-overflow: clip;
    -webkit-text-stroke: 0;
    text-shadow: none;
    transform: none;
    white-space: nowrap;
  }

  .shot-total.is-long-value {
    padding-inline: 2px;
    font-size: clamp(12px, 3.6dvh, 17px);
    letter-spacing: -0.075em;
  }

  .side-panel--left .run-meter {
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    justify-items: center;
    row-gap: 1px;
    margin: 6px 0 0;
    padding: 4px 3px 3px;
    border-width: 3px;
    box-shadow: 3px 3px 0 #000;
    font-size: 7px;
    line-height: 1.1;
    text-align: center;
  }

  .side-panel--left .run-meter strong {
    grid-column: 1;
    grid-row: auto;
    font-size: clamp(20px, 6.5dvh, 30px);
    line-height: 0.95;
  }

  .side-panel--left .run-meter[data-tier="blazing"] .run-meter__label {
    justify-self: center;
  }

  .side-panel--left .run-meter small {
    display: none;
  }

  .side-panel--left .cash-dock {
    flex: 0 0 auto;
    gap: 2px;
    margin-top: auto;
    padding: 5px 3px 3px;
    overflow: visible;
    border-top-width: 2px;
    transform: none;
  }

  .side-panel--left .cash-dock > span {
    font-size: 6px;
    letter-spacing: 0.1em;
  }

  .side-panel--left .cash-dock strong,
  .side-panel--left .cash-dock strong.is-long {
    display: flex;
    width: calc(100% - 4px);
    max-width: none;
    margin-inline: auto;
    padding: 2px 4px 3px;
    overflow: visible;
    align-items: baseline;
    justify-content: center;
    gap: 0.12em;
    color: var(--pink);
    font-size: clamp(23px, 6.25dvh, 29px);
    line-height: 1.08;
    letter-spacing: -0.04em;
    text-overflow: clip;
    -webkit-text-stroke: 0.7px #000;
    text-shadow: 1px 1px 0 var(--cobalt), 2px 2px 0 #000;
    white-space: nowrap;
  }

  .side-panel--left .cash-dock strong.is-long {
    font-size: clamp(15px, 4.3dvh, 20px);
    letter-spacing: -0.075em;
  }

  /* Table consumes every pixel left after the two information rails. */
  .table-slot {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    place-items: center;
    container-type: size;
  }

  .table-slot .table-stage {
    width: min(100cqw, calc(100cqh * 1.846154));
    max-width: 100%;
    margin: 0;
    border-width: 4px;
    box-shadow:
      0 0 0 2px var(--pink),
      5px 6px 0 #000,
      -3px -3px 0 var(--acid);
    transform: none;
  }

  .table-slot .marquee-lights {
    inset: -2px;
    border-width: 2px;
  }

  .aim-hint {
    bottom: 8px;
    gap: 5px;
    max-width: calc(100% - 20px);
    padding: 4px 7px;
    overflow: hidden;
    border-width: 2px;
    font-size: clamp(7px, 1.8dvh, 9px);
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    box-shadow: 2px 2px 0 #000;
    transform: translateX(-50%);
    white-space: nowrap;
  }

  .aim-hint.is-hidden {
    transform: translate(-50%, 6px);
  }

  .mouse-glyph {
    flex: 0 0 auto;
    border-width: 1px;
  }

  .power-rack {
    right: 12px;
    bottom: 8px;
    left: 12px;
    gap: 5px;
    font-size: 6px;
    letter-spacing: 0.08em;
  }

  .power-rack > div {
    height: 7px;
    border-width: 1.5px;
  }

  .ultra-console {
    --ultra-helper-rest-shadow: 2px 2px 0 #000;
    --ultra-helper-attention-shadow: 0 0 0 2px var(--acid), 4px 5px 0 var(--pink), 6px 7px 0 #000;
    bottom: 7px;
    width: max-content;
    max-width: calc(100% - 10px);
    gap: 5px;
    padding: 3px 4px 3px 6px;
    border-width: 1.5px;
    box-shadow: var(--ultra-helper-rest-shadow);
    transform: translateX(-50%);
  }

  .ultra-lock-label {
    font-size: 6px;
  }

  #ultra-power-value {
    font-size: 11px;
  }

  #ultra-angle-value {
    min-width: 33px;
    font-size: 9px;
  }

  .ultra-cancel {
    width: 22px;
    height: 22px;
    border-width: 1.5px;
    box-shadow: 1.5px 1.5px 0 #000;
    font-size: 13px;
  }

  .ultra-console > small {
    padding-left: 5px;
    font-size: 6px;
  }

  /* Screen-print type effects scaled as a system, never desktop ink on tiny type. */
  .callout {
    width: 94%;
    font-size: clamp(34px, 7vw, 60px);
    line-height: 0.84;
    letter-spacing: -0.045em;
    -webkit-text-stroke: 1.5px #000;
    text-shadow: 2px 2px 0 var(--pink), 4px 4px 0 #000;
    transform: translate(-50%, -50%) scale(0.65);
  }

  .callout.is-live {
    animation: mobile-callout-pop 1.25s cubic-bezier(0.15, 0.9, 0.2, 1) forwards;
  }

  .last-chance {
    width: min(92%, 620px);
    transform: translate(-50%, -50%) scale(0.45);
  }

  .last-chance span,
  .last-chance small {
    padding: 2px 6px;
    border-width: 2px;
    font-size: clamp(7px, 1.9dvh, 10px);
    letter-spacing: 0.1em;
    box-shadow: 2px 2px 0 #000;
    transform: none;
  }

  .last-chance span {
    margin-bottom: 5px;
  }

  .last-chance strong {
    font-size: clamp(42px, 8vw, 70px);
    line-height: 0.78;
    letter-spacing: -0.045em;
    -webkit-text-stroke: 1.7px #000;
    text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 #000;
    transform: none;
  }

  .last-chance small {
    margin-top: 5px;
  }

  .last-chance.is-live {
    animation: mobile-last-chance 2.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .table-stage.is-last-chance::after {
    border-width: 6px;
    background: repeating-linear-gradient(135deg, var(--pink) 0 7px, #000 7px 14px) border-box;
  }

  /* Straddle the top frame so the sticker never sits on the middle pocket. */
  .turn-banner {
    top: -9px;
    padding: 3px 10px;
    border-width: 2px;
    font-size: 10px;
    box-shadow: 2px 2px 0 #000;
  }

  /* Right instrument: vertically scrollable 44-52px power-ups and run stats. */
  .kit-dock {
    grid-column: 3;
    grid-row: 1;
    z-index: 8;
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 4px;
    overflow: hidden;
    border-width: 3px;
    background:
      linear-gradient(165deg, rgba(255, 255, 255, 0.22), transparent 32%),
      repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 12px),
      var(--pink);
    box-shadow: 3px 4px 0 #000;
    transform: none;
  }

  .kit-dock::before {
    display: none;
  }

  .kit-dock__heading {
    display: block;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .kit-dock__heading .panel-heading,
  .kit-dock__heading p {
    display: none;
  }

  .kit-dock__stamp {
    display: grid;
    width: 100%;
    min-height: 44px;
    padding: 2px 1px;
    overflow: hidden;
    border-width: 2px;
    place-items: center;
    font-size: 8px;
    line-height: 1;
    letter-spacing: 0.08em;
    text-align: center;
    text-overflow: ellipsis;
    transform: none;
    white-space: nowrap;
    appearance: none;
    touch-action: manipulation;
  }

  .kit-dock .chalk-case {
    display: flex;
    min-width: 0;
    min-height: var(--mobile-kit-size);
    flex: 1 1 auto;
    flex-direction: column;
    align-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 7px;
    padding: 3px 3px 6px 1px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--acid) rgba(0, 0, 0, 0.28);
    scrollbar-width: thin;
    /* The desktop tray is horizontal (pan-x, theme.css); this column must
       out-rank that or vertical touch pans are refused. */
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .kit-dock .chalk-case::-webkit-scrollbar {
    width: 4px;
  }

  .kit-dock .chalk-case::-webkit-scrollbar-thumb {
    background: var(--acid);
    border: 1px solid #000;
  }

  .kit-dock .chalk-mini,
  .kit-dock .chalk-mini:nth-child(even) {
    flex: 0 0 var(--mobile-kit-size);
    width: var(--mobile-kit-size);
    min-width: var(--mobile-kit-size);
    height: var(--mobile-kit-size);
    min-height: var(--mobile-kit-size);
    padding: 3px;
    overflow: visible;
    border-width: 3px;
    box-shadow: 3px 3px 0 #000;
    cursor: pointer;
    transform: none;
  }

  .kit-dock .chalk-mini:active {
    box-shadow: 1px 1px 0 #000;
    transform: translate(2px, 2px);
  }

  .kit-dock .chalk-mini:focus-visible {
    z-index: 2;
    outline: 2px solid #fff;
    outline-offset: 1px;
    transform: none;
  }

  .kit-dock .chalk-mini .chalk-level {
    right: -3px;
    bottom: -3px;
    padding: 2px 3px;
    border-width: 1.5px;
    font-size: 7px;
    text-shadow: none;
    transform: none;
  }

  /* Tap opens the dedicated detail sheet; the desktop hover card stays inert. */
  .kit-dock .chalk-mini .chalk-mini__tooltip {
    display: none !important;
  }

  .kit-dock .chalk-case .empty-chalk {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 90px;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 5px 3px;
    border-width: 2px;
    text-align: center;
    transform: none;
  }

  .kit-dock .chalk-case .empty-chalk > span {
    width: 26px;
    height: 26px;
    border-width: 2px;
    font-size: 15px;
    box-shadow: 2px 2px 0 #000;
  }

  .kit-dock .chalk-case .empty-chalk p {
    display: block;
    margin: 0;
    overflow: visible;
    font-size: 7px;
    line-height: 1.08;
    text-overflow: clip;
    white-space: normal;
  }

  .kit-dock .kit-meters {
    display: flex;
    min-width: 0;
    max-height: 48px;
    flex: 0 0 auto;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 3px;
    margin: 0;
    overflow: auto;
    scrollbar-width: none;
  }

  .kit-dock .kit-meters:empty {
    display: none;
  }

  .kit-dock .kit-meter {
    max-width: 100%;
    padding: 2px 1px;
    overflow: hidden;
    border-width: 1.5px;
    font-size: 6px;
    line-height: 1;
    letter-spacing: 0;
    text-align: center;
    text-overflow: ellipsis;
    box-shadow: 1px 1px 0 #000;
    transform: none;
    white-space: nowrap;
  }

  .kit-dock .run-stat {
    position: static;
    inset: auto;
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 38px;
    flex: 0 0 auto;
    align-content: center;
    justify-items: center;
    gap: 1px;
    padding: 3px 3px 4px;
    overflow: visible;
    border-width: 2px;
    box-shadow: 2px 2px 0 #000;
    text-align: center;
    transform: none;
  }

  .kit-dock .run-stat span {
    max-width: 100%;
    overflow: hidden;
    font-size: 6px;
    line-height: 1;
    letter-spacing: 0.07em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kit-dock .run-stat strong {
    display: block;
    width: calc(100% - 4px);
    max-width: none;
    padding: 1px 3px 2px;
    overflow: visible;
    font-size: clamp(13px, 3.7dvh, 18px);
    line-height: 1.08;
    letter-spacing: -0.035em;
    text-align: center;
    text-overflow: clip;
    -webkit-text-stroke: 0.5px #000;
    text-shadow: 1px 1px 0 #000;
    transform: none;
    white-space: nowrap;
  }

  .kit-dock .cash-chip {
    display: none;
  }

  .footer-line {
    display: none;
  }

  @keyframes mobile-callout-pop {
    0% { opacity: 0; transform: translate(-50%, -38%) scale(0.5); }
    16% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    35%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1.04); }
  }

  @keyframes mobile-last-chance {
    0% { opacity: 0; filter: blur(5px); transform: translate(-50%, -50%) scale(0.42); }
    12% { opacity: 1; filter: blur(0); transform: translate(-50%, -50%) scale(1.07); }
    24%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1.04); }
  }

}

/* Extra-short browser chrome or embedded landscape surfaces: retain all three
   gameplay instruments, but trade ornament and labels for table height. */
@media (max-height: 340px) and (orientation: landscape) {
  :root {
    --mobile-hud-height: 38px;
    --mobile-left-rail: clamp(76px, 10vw, 92px);
    --mobile-kit-rail: clamp(58px, 7.5vw, 72px);
    --mobile-kit-size: 44px;
  }

  .cabinet {
    gap: 4px;
  }

  .run-board {
    margin-right: 80px;
  }

  .icon-button,
  .sound-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .side-panel--left .run-meter {
    padding: 2px 5px;
  }

  .side-panel--left .run-meter em {
    display: none;
  }

  .kit-dock__heading {
    display: none;
  }

  .kit-dock .run-stat {
    min-height: 28px;
  }
}

/* Portrait short screens already receive the dedicated rotate prompt. Keep
   touch gestures deterministic underneath it if browser UI changes height. */
@media (max-height: 600px) and (orientation: portrait) {
  html,
  body {
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  #game-canvas {
    touch-action: none;
  }
}
