/* Phone support shared by every page (pairs with public/shared/mobile.js): no zoom gestures,
   no text selection outside text fields, no sideways overflow, safe-area insets, 44 px taps
   on touch screens. Link it before the page's own stylesheet. */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --tap: 44px;
}

html, body {
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

* {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="url"],
input[type="tel"], input[type="password"], input[type="number"], textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

canvas { touch-action: none; }

@media (pointer: coarse) {
  button, select, summary, [role="button"], input[type="search"], input[type="url"], input[type="text"],
  input[type="button"], input[type="submit"], input[type="checkbox"], input[type="radio"] {
    min-height: var(--tap);
  }
  button, [role="button"], input[type="button"], input[type="submit"] { min-width: var(--tap); }
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
}

[hidden] { display: none !important; }

/* ---- /create/ phone layer (M1.1–M1.6): Menu sheet, close buttons, movement pad ---- */
/* M1.1: the shared phone layer (with ../shared/mobile.js). Every page links it after
   its own stylesheet. No page zoom, no text selection outside text fields, no
   overscroll, safe-area insets, 44 px tap targets on touch screens, the Menu button
   and bottom sheet under 700 px, close buttons, the on-screen movement pad. */
html { touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overscroll-behavior: none; }
*, *::before, *::after { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
input:not([type="range"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]), textarea, [contenteditable] {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
canvas { touch-action: none; }
.m-closed { display: none !important; }

/* Close button (panels, hints, errors, help) */
.m-close { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; padding: 0 6px;
  margin-left: 6px; background: rgba(10, 8, 24, .6) !important; border: 1px solid rgba(140, 120, 255, .4) !important; border-radius: 6px;
  color: #c9c3ff !important; font: 18px/1 system-ui, sans-serif; cursor: pointer; pointer-events: auto; }
.m-close:active { color: #22e6ff !important; border-color: #22e6ff !important; }

/* Touch screens: every control is at least 44 x 44 CSS px */
@media (pointer: coarse) {
  button, summary, select, [role="button"], input[type="checkbox"], input[type="radio"], input[type="color"], .m-close { min-height: 44px; min-width: 44px; }
  input[type="range"] { min-height: 44px; }
  input[type="number"], input[type="text"] { min-height: 44px; font-size: 16px; } /* 16 px: iOS does not zoom into the field; 44 px (H10.1) */
  summary { display: flex; align-items: center; }
}

/* Menu button + bottom sheet (phone) */
.m-menu-btn { display: none; }
.m-sheet-head { display: none; }
@media (max-width: 699px) {
  .m-menu-btn { display: inline-flex; align-items: center; justify-content: center; position: fixed; z-index: 45;
    top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: 48px; height: 48px;
    background: rgba(10, 8, 24, .82); color: #22e6ff; border: 1px solid #22e6ff; border-radius: 10px; font: 22px/1 system-ui, sans-serif;
    box-shadow: 0 0 14px rgba(34, 230, 255, .25); cursor: pointer; }
  .m-menu-btn[aria-expanded="true"] { color: #b44cff; border-color: #b44cff; }
  .m-sheet { position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: auto !important; max-width: none !important; max-height: 72vh !important; overflow-y: auto !important; overscroll-behavior: contain;
    z-index: 50 !important; box-sizing: border-box; padding: 0 calc(10px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)) !important;
    background: rgba(10, 8, 24, .96) !important; border: 1px solid rgba(140, 120, 255, .4) !important; border-bottom: 0 !important;
    border-radius: 14px 14px 0 0 !important; box-shadow: 0 -8px 30px rgba(0, 0, 0, .6);
    transform: translateY(105%); visibility: hidden; transition: transform .18s ease-out, visibility 0s linear .18s; }
  .m-sheet[data-open] { transform: none; visibility: visible; transition: transform .18s ease-out; }
  .m-sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1;
    margin: 0 -10px 4px; padding: 6px 10px; background: rgba(10, 8, 24, .98); border-bottom: 1px solid rgba(140, 120, 255, .25);
    color: #22e6ff; font: 600 13px system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
  .m-sheet-head .m-close { min-width: 44px; min-height: 44px; }
}

/* On-screen movement pad: a drag stick on the left, up/down and turn on the right */
.m-pad { display: none; }
@media (pointer: coarse) { .m-pad { display: block; } }
.m-pad.m-force { display: block; }
@media all {
  .m-pad { position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); height: 0; z-index: 20; pointer-events: none; }
  .m-pad[hidden], .m-pad.m-off { display: none !important; }
  .m-stick { position: absolute; bottom: 0; left: calc(14px + env(safe-area-inset-left)); width: 116px; height: 116px; border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 230, 255, .10), rgba(180, 76, 255, .10)); border: 1px solid rgba(34, 230, 255, .45);
    opacity: .7; pointer-events: auto; touch-action: none; }
  .m-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
    background: rgba(34, 230, 255, .35); border: 1px solid #22e6ff; box-shadow: 0 0 10px rgba(34, 230, 255, .4); pointer-events: none; }
  .m-pad-buttons { position: absolute; bottom: 0; right: calc(14px + env(safe-area-inset-right)); display: grid; grid-template-columns: 52px 52px;
    grid-template-areas: "up up" "tl tr" "dn dn"; gap: 6px; pointer-events: auto; opacity: .7; }
  .m-pad-btn { width: 100%; min-height: 44px; height: 44px; padding: 0; border-radius: 10px; touch-action: none;
    background: rgba(10, 8, 24, .55); border: 1px solid rgba(180, 76, 255, .55); color: #e6e0ff; font: 600 15px system-ui, sans-serif; }
  .m-pad-btn.on { background: rgba(34, 230, 255, .3); border-color: #22e6ff; color: #fff; }
  .m-pad-buttons.m-has-extra { grid-template-areas: "up up" "tl tr" "dn dn" "zi zo"; }
  .m-zoomIn { grid-area: zi; } .m-zoomOut { grid-area: zo; }
  .m-up { grid-area: up; } .m-turnLeft { grid-area: tl; } .m-turnRight { grid-area: tr; } .m-down { grid-area: dn; }
}

/* H7.1: the hold tip, one box beside the finger (shared/mobile.js installHoldTips) */
.m-tip { position: fixed; z-index: 90; box-sizing: border-box; max-width: min(280px, calc(100vw - 16px)); padding: 8px 10px;
  background: rgba(10, 8, 24, .96); border: 1px solid rgba(34, 230, 255, .6); border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .6);
  color: #e6e0ff; font: 14px/1.35 system-ui, sans-serif; pointer-events: none; white-space: normal; overflow-wrap: anywhere; }
.m-tip[hidden] { display: none; }

/* H7.2: number fields by finger: − and + steppers, and a horizontal drag on the label scrubs */
.m-step { display: none; }
@media (pointer: coarse) {
  .m-step { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 44px; margin: 0 2px;
    padding: 0; background: rgba(34, 230, 255, .08); color: #22e6ff; border: 1px solid rgba(34, 230, 255, .45); border-radius: 8px;
    font: 600 20px/1 system-ui, sans-serif; touch-action: manipulation; vertical-align: middle; }
  .m-step:active { background: rgba(34, 230, 255, .25); }
  label.m-scrub { touch-action: pan-y; cursor: ew-resize; -webkit-user-select: none; user-select: none; }
}
/* the sheet lifted above the on-screen keyboard follows it without the slide-in delay */
.m-sheet.m-kbd { transition: none; }
