/* SimCity — touch screens (mobile pass, 2026-10-14). Last in the 14.7 sheet
   order, linked by every page. A finger wants about 44 CSS px; the SNES art
   keeps its whole-number scale, so a target grows by a gap and an invisible
   hit margin (::after) round its art, not by stretching the picture. The
   gestures on the map are play/pointer.js (touch-gesture.js). */

/* The browser's own gestures never fight the game's: no pull-to-refresh, no
   double-tap zoom, no selection or callout on a long press. The canvas is
   already touch-action: none (band.css); the band, the board and the
   fold-outs swallow a stray pinch too. Scrolling windows keep pan-y. */
@media (pointer: coarse) {
  html:has(> body.play-page),
  html.title-page {
    overscroll-behavior: none;
  }
  body.play-page,
  html.title-page body {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
  :is(input, textarea, select) {
    -webkit-user-select: auto;
    user-select: auto;
  }
  .play-page :is(.hud.play-hud, .palette, .foldout) {
    touch-action: none;
  }

  /* the band's eight window buttons: the 16 px cells at 2 CSS px a pixel
     (32 px), 9 px apart, each reaching 4.5 px past its art (41 × 41) */
  .play-page .hud-buttons {
    --win-px: 2px;
    gap: 9px;
  }
  .play-page .hud-buttons button,
  .play-page .palette :is(.tool, .gift-tile),
  .play-page .foldout button {
    position: relative;
  }
  .play-page .hud-buttons button::after {
    content: "";
    position: absolute;
    inset: -5px;
  }

  /* the tool board: 36 px tiles 7 px apart, each reaching 4 px out (44 px) */
  .play-page .tool-board {
    gap: min(7px, calc((100vw - 304px) / 7));
  }
  .play-page .palette :is(.tool, .gift-tile)::after {
    content: "";
    position: absolute;
    inset: -4px;
  }

  /* the fold-outs' tiles at 2 CSS px a pixel (48 px), wrapping on a phone */
  .play-page .foldout {
    --ipx: 2px;
    max-width: calc(100vw - 12px);
  }
  .play-page .fold-tiles {
    flex-wrap: wrap;
  }

  /* every window's close key, the map's overlay keys, the graphs' range and
     legend, the settings' fields: a finger's size */
  :is(.play-page, .title-page) button[id$="-close"]:not(#budget-close) {
    min-width: 44px;
    min-height: 44px;
  }
  .play-page .map-icons button {
    min-width: 40px;
    min-height: 40px;
  }
  .play-page :is(.graph-range, .graph-legend) button {
    min-height: 40px;
  }
  .settings-body :is(select, input, button) {
    min-height: 32px;
  }
  /* the evaluation's OK (6 art px tall at a phone's scale) reaches past its
     art into the frame's empty bottom margin */
  .eval-ok::after {
    content: "";
    position: absolute;
    inset: -14px -10px -10px;
  }
}

/* Portrait phone: the window buttons get the band's third row to themselves
   (8 × 32 + 7 × 9 = 319 px); the numbers and the RCI pill stay above. */
@media (pointer: coarse) and (max-width: 599px) {
  .play-page .hud-buttons {
    grid-column: 1 / -1;
    grid-row: 3;
    flex-wrap: nowrap;
  }
}

/* Landscape phone: the board is one row of 16 tiles 2 px apart (38 × 44 px
   targets), so the map keeps the height. */
@media (pointer: coarse) and (max-height: 500px) and (min-width: 600px) {
  .play-page .tool-board {
    grid-template-columns: repeat(16, auto);
    column-gap: 2px;
    row-gap: 0;
  }
  .play-page .palette :is(.tool, .gift-tile)::after {
    inset: -4px -1px;
  }
}

/* A phone with the CRT on: the band and the board step in past the rounded
   mask (crt-pass.js crtCornerInset is 16-20 px at phone sizes, not the
   desktop's 33-64), without the desktop's 50 px. */
@media (max-width: 899px) {
  html[data-crt="on"] .hud.play-hud {
    top: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }
  html[data-crt="on"] .palette {
    bottom: 14px;
  }
}

/* A short or narrow screen: a window taller than the screen scrolls inside
   itself, so its title bar and close key stay on the glass. */
@media (max-height: 560px), (max-width: 480px) {
  .map-window,
  .query-panel,
  .feed-panel,
  .graph-panel {
    max-height: calc((100dvh - 12px) / var(--menu-scale, 1));
    overflow-y: auto;
    touch-action: pan-y;
  }
}

/* The title's MAP SELECT board (panels-title.css places its keys on the
   art): the keys and the digit arrows reach past their art — up arrows
   upwards, down arrows downwards, away from each other — and the bar's
   MENU and MUSIC keys grow to a finger's height. */
@media (pointer: coarse) {
  #title.map-select :is(.ms-key, .ms-tri)::after {
    content: "";
    position: absolute;
    inset: -8px -3px;
  }
  #title.map-select :is(#map-up-h, #map-up-t, #map-up)::after {
    inset: -14px -1px -2px;
  }
  #title.map-select :is(#map-down-h, #map-down-t, #map-down)::after {
    inset: -2px -1px -14px;
  }
  html.title-page .map-btn {
    min-height: 40px;
  }
  /* The naming board: its keys touch each other on the art (23 px on a
     360 px phone), so a finger types with the phone's own keyboard. A tap
     on the LCD focuses an invisible field over it (naming.js); 16 px text
     so iOS does not zoom the page on focus. The level and Yes/No buttons
     reach up and down into the panel's empty rows. */
  .naming .naming-input {
    display: block;
    position: absolute;
    z-index: 1;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    font-size: 16px;
    outline: none;
  }
  .naming .naming-input[hidden] { display: none; }
  .naming :is(.nl, .nc)::after {
    content: "";
    position: absolute;
    inset: -8px 0;
  }
}
