/* Multiverse touch overlay — built and driven by input.js (MvInput).
   JS sets positions in px and the size scale --mv-s: the thumb arcs depend on the viewport
   and the safe areas. Colours follow the dimension through --mv-fg / --mv-accent / --mv-bg
   (set on :root by the HUD). Same visual language as the valley's #touch controls: thin
   rings, translucent fills, small mono labels. */
#mv-touch {
  --mv-s: 1;
  --mv-tc-fg: var(--mv-fg, #e8e6f0);
  --mv-tc-ac: var(--mv-accent, #f2b35b);
  --mv-tc-ink: var(--mv-bg, #14110a);
  /* Flat tints for engines without color-mix() (Safari < 16.2); themed ones follow below. */
  --mv-tc-ring: rgba(232, 230, 240, 0.38);
  --mv-tc-ring-dim: rgba(232, 230, 240, 0.3);
  --mv-tc-ring-hi: rgba(232, 230, 240, 0.6);
  --mv-tc-fill: rgba(8, 9, 15, 0.42);
  --mv-tc-fill-soft: rgba(8, 9, 15, 0.15);
  --mv-tc-knob: rgba(232, 230, 240, 0.28);
  --mv-tc-knob-hi: rgba(232, 230, 240, 0.45);
  --mv-tc-ac-ring: rgba(242, 179, 91, 0.85);
  --mv-tc-ac-fill: rgba(40, 26, 8, 0.45);
  --mv-tc-ac-down: rgba(242, 179, 91, 0.55);
  --mv-tc-ac-glow: rgba(242, 179, 91, 0.25);
  --mv-tc-shade: rgba(0, 0, 0, 0.8);
  --mv-tc-veil: rgba(4, 5, 9, 0.66);
  position: fixed; inset: 0; z-index: 8; display: none; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  font-family: var(--mono, 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace); color: var(--mv-tc-fg);
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  #mv-touch {
    --mv-tc-ring: color-mix(in srgb, var(--mv-tc-fg) 38%, transparent);
    --mv-tc-ring-dim: color-mix(in srgb, var(--mv-tc-fg) 30%, transparent);
    --mv-tc-ring-hi: color-mix(in srgb, var(--mv-tc-fg) 60%, transparent);
    --mv-tc-fill: color-mix(in srgb, var(--mv-bg, #08090f) 44%, transparent);
    --mv-tc-fill-soft: color-mix(in srgb, var(--mv-bg, #08090f) 16%, transparent);
    --mv-tc-knob: color-mix(in srgb, var(--mv-tc-fg) 28%, transparent);
    --mv-tc-knob-hi: color-mix(in srgb, var(--mv-tc-fg) 45%, transparent);
    --mv-tc-ac-ring: color-mix(in srgb, var(--mv-tc-ac) 85%, transparent);
    --mv-tc-ac-fill: color-mix(in srgb, color-mix(in srgb, var(--mv-tc-ac) 22%, var(--mv-bg, #08090f)) 48%, transparent);
    --mv-tc-ac-down: color-mix(in srgb, var(--mv-tc-ac) 55%, transparent);
    --mv-tc-ac-glow: color-mix(in srgb, var(--mv-tc-ac) 25%, transparent);
    /* Halo and cooldown veil are made of the world's own ground, so labels (in --mv-fg) keep
       their contrast in dark and in pale dimensions alike. */
    --mv-tc-shade: color-mix(in srgb, var(--mv-bg, #000) 80%, transparent);
    --mv-tc-veil: color-mix(in srgb, var(--mv-bg, #04050a) 72%, transparent);
  }
}
#mv-touch.mv-tc-on { display: block; }
#mv-touch * { box-sizing: border-box; }
/* A pad or a mouse took over on a touch device: keep the controls, out of the way. */
#mv-touch > * { transition: opacity 0.25s; }
#mv-touch.mv-tc-dim > * { opacity: 0.35; }
#mv-touch .mv-tc-off { display: none !important; }

/* ---- sticks ---- */
#mv-touch .mv-tc-stick { position: absolute; left: -400px; top: -400px; width: calc(136px * var(--mv-s)); height: calc(136px * var(--mv-s)); transform: translate(-50%, -50%); pointer-events: none; }
#mv-touch .mv-tc-ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--mv-tc-ring-dim); background: radial-gradient(circle, var(--mv-tc-fill-soft), var(--mv-tc-fill)); }
#mv-touch .mv-tc-move .mv-tc-ring::before { content: ''; position: absolute; left: 50%; top: 8px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 8px solid var(--mv-tc-ring); border-top: 0; }
#mv-touch .mv-tc-knob { position: absolute; left: 50%; top: 50%; width: calc(54px * var(--mv-s)); height: calc(54px * var(--mv-s)); border-radius: 50%; background: var(--mv-tc-knob); border: 1.5px solid var(--mv-tc-ring-hi); transform: translate(-50%, -50%); }
#mv-touch .mv-tc-stick.mv-tc-active .mv-tc-knob { background: var(--mv-tc-knob-hi); }

/* Floating aim stick ('pointer' dimensions): drag to aim, release past the dashed circle to fire. */
#mv-touch .mv-tc-aim { display: none; }
#mv-touch .mv-tc-aim.mv-tc-active { display: block; }
#mv-touch .mv-tc-aim .mv-tc-ring::after { content: ''; position: absolute; left: 50%; top: 50%; width: 35%; height: 35%; border-radius: 50%; border: 1px dashed var(--mv-tc-ring-dim); transform: translate(-50%, -50%); }
#mv-touch .mv-tc-aim.mv-tc-armed .mv-tc-ring { border-color: var(--mv-tc-ac-ring); box-shadow: 0 0 0 3px var(--mv-tc-ac-glow), inset 0 0 14px var(--mv-tc-ac-glow); }
#mv-touch .mv-tc-aim.mv-tc-armed .mv-tc-knob { background: var(--mv-tc-ac-down); border-color: var(--mv-tc-ac); }
/* The thumb hides the knob: a beam past the ring shows where the shot will go. */
#mv-touch .mv-tc-beam { position: absolute; left: 50%; top: 50%; width: calc(150px * var(--mv-s)); height: 2px; margin-top: -1px; opacity: 0; transform-origin: 0 50%;
  background: linear-gradient(90deg, transparent 0, transparent 24%, var(--mv-tc-ac) 46%, var(--mv-tc-ac) 78%, transparent 100%); }
#mv-touch .mv-tc-aim.mv-tc-armed .mv-tc-beam { opacity: 0.9; }

/* ---- buttons ---- */
#mv-touch .mv-tc-btn { --mv-d: 64; --mv-fs: 9; --mv-cd: 0; position: absolute; left: -400px; top: -400px; width: calc(var(--mv-d) * var(--mv-s) * 1px); height: calc(var(--mv-d) * var(--mv-s) * 1px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 50%;
  background: var(--mv-tc-fill); border: 1.5px solid var(--mv-tc-ring); color: var(--mv-tc-fg); text-shadow: 0 1px 2px var(--mv-tc-shade);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); transform: translate(-50%, -50%); }
#mv-touch .mv-tc-btn > * { position: relative; z-index: 1; pointer-events: none; }
#mv-touch .mv-tc-btn i { font-style: normal; font-size: calc(var(--mv-d) * var(--mv-s) * 0.33px); line-height: 1; }
#mv-touch .mv-tc-btn span { font-size: calc(var(--mv-fs) * var(--mv-s) * var(--mv-ts, 1) * 1px); font-weight: 600; letter-spacing: 0.08em; margin-right: -0.08em; line-height: 1.12; text-align: center; white-space: pre; }
#mv-touch .mv-tc-btn.mv-tc-two i { font-size: calc(var(--mv-d) * var(--mv-s) * 0.25px); }
#mv-touch .mv-tc-big { --mv-d: 84; }
#mv-touch .mv-tc-fire2 { --mv-d: 68; }
#mv-touch .mv-tc-fire { border-color: var(--mv-tc-ac-ring); color: var(--mv-tc-ac); background: var(--mv-tc-ac-fill); }
#mv-touch .mv-tc-btn.mv-tc-down { background: var(--mv-tc-ac-down); border-color: var(--mv-tc-ac); color: var(--mv-tc-ink); text-shadow: none; transform: translate(-50%, -50%) scale(0.95); }
/* Latched toggle (ALT with altToggle) */
#mv-touch .mv-tc-btn.mv-tc-lit { border-color: var(--mv-tc-ac); color: var(--mv-tc-ac); box-shadow: 0 0 0 3px var(--mv-tc-ac-glow), inset 0 0 12px var(--mv-tc-ac-glow); }
#mv-touch .mv-tc-btn.mv-tc-lit.mv-tc-down { color: var(--mv-tc-ink); }

/* Cooldown: --mv-cd runs 1 (just used) → 0 (ready). A veiled wedge drains clockwise behind a
   clock hand while an accent arc on the rim fills in after it. */
#mv-touch .mv-tc-btn::before, #mv-touch .mv-tc-btn::after { content: ''; position: absolute; inset: -1.5px; border-radius: 50%; pointer-events: none; opacity: 0; }
#mv-touch .mv-tc-btn::after { --mv-a: calc((1 - var(--mv-cd)) * 360deg);
  background: conic-gradient(transparent calc(var(--mv-a) - 2deg), var(--mv-tc-ring-hi) calc(var(--mv-a) - 2deg), var(--mv-tc-ring-hi) var(--mv-a), var(--mv-tc-veil) var(--mv-a), var(--mv-tc-veil) 358deg, var(--mv-tc-ring-hi) 358deg); }
#mv-touch .mv-tc-btn::before { background: conic-gradient(var(--mv-tc-ac) calc((1 - var(--mv-cd)) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px)); mask: radial-gradient(closest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px)); }
#mv-touch .mv-tc-btn.mv-tc-cooling::before, #mv-touch .mv-tc-btn.mv-tc-cooling::after { opacity: 1; }
#mv-touch .mv-tc-btn.mv-tc-cooling { border-color: var(--mv-tc-ring-dim); }
#mv-touch .mv-tc-btn.mv-tc-cooling i, #mv-touch .mv-tc-btn.mv-tc-cooling span { opacity: 0.6; }
#mv-touch .mv-tc-btn.mv-tc-ready { animation: mv-tc-ready 0.45s ease-out; }
@keyframes mv-tc-ready { 0% { box-shadow: 0 0 0 0 var(--mv-tc-ac); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* Charges badge on the rim, top-right */
#mv-touch .mv-tc-btn b { position: absolute; z-index: 2; right: 0; top: 0; display: none; min-width: calc(19px * var(--mv-s)); height: calc(19px * var(--mv-s)); padding: 0 calc(4px * var(--mv-s)); border-radius: calc(10px * var(--mv-s));
  font-size: calc(10px * var(--mv-s)); font-weight: 600; line-height: calc(19px * var(--mv-s)); text-align: center; text-shadow: none; color: var(--mv-tc-ink); background: var(--mv-tc-ac); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
#mv-touch .mv-tc-big b { right: calc(3px * var(--mv-s)); top: calc(3px * var(--mv-s)); }
#mv-touch .mv-tc-btn b.mv-tc-show { display: block; }
#mv-touch .mv-tc-btn.mv-tc-empty { border-style: dashed; }
#mv-touch .mv-tc-btn.mv-tc-empty i, #mv-touch .mv-tc-btn.mv-tc-empty span { opacity: 0.4; }
#mv-touch .mv-tc-btn.mv-tc-empty b { background: var(--mv-tc-fg); opacity: 0.75; }

/* ---- pause pill, aim hint ---- */
#mv-touch .mv-tc-pause { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); min-width: 58px; height: 30px; padding: 0 8px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--mv-tc-ring); border-radius: 3px; background: var(--mv-tc-fill); color: var(--mv-tc-fg); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; white-space: nowrap; }
#mv-touch .mv-tc-pause::before { content: ''; position: absolute; inset: -10px -14px -16px -14px; } /* fat-finger margin */
#mv-touch .mv-tc-pause.mv-tc-down { background: var(--mv-tc-ac-down); border-color: var(--mv-tc-ac); color: var(--mv-tc-ink); }
#mv-touch .mv-tc-hint { position: absolute; left: -400px; top: -400px; display: none; align-items: center; gap: 9px; transform: translate(-100%, -100%); pointer-events: none; white-space: pre; text-align: right;
  font-size: 9px; font-weight: 600; letter-spacing: 0.16em; line-height: 1.5; color: var(--mv-tc-fg); text-shadow: 0 1px 2px var(--mv-tc-shade); opacity: 0.8; }
#mv-touch.mv-tc-pointer .mv-tc-hint { display: flex; }
#mv-touch .mv-tc-hint.mv-tc-done { opacity: 0; }
#mv-touch .mv-tc-hint::after { content: ''; flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed var(--mv-tc-ring-hi);
  background: radial-gradient(circle at 68% 32%, var(--mv-tc-ac) 0, var(--mv-tc-ac) 4px, transparent 5px); }

/* ---- phones held sideways (input.js adds .mv-tc-compact below 480 px of height) ----
   Smaller, see-through controls hugging the bottom corners keep the playfield visible; labels
   stay a touch larger than the discs' scale so they remain readable. */
#mv-touch.mv-tc-compact { --mv-ts: 1.12; }
#mv-touch.mv-tc-compact:not(.mv-tc-dim) .mv-tc-btn:not(.mv-tc-down), #mv-touch.mv-tc-compact:not(.mv-tc-dim) .mv-tc-move { opacity: 0.8; }
#mv-touch.mv-tc-compact .mv-tc-btn { backdrop-filter: none; -webkit-backdrop-filter: none; border-width: 1.25px; }
#mv-touch.mv-tc-compact .mv-tc-btn b { min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; font-size: 9.5px; line-height: 16px; }
#mv-touch.mv-tc-compact .mv-tc-big b { right: 1px; top: 1px; }
#mv-touch.mv-tc-compact .mv-tc-pause { left: max(12px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); min-width: 50px; height: 26px; }
#mv-touch.mv-tc-compact .mv-tc-hint { font-size: 8px; gap: 6px; letter-spacing: 0.12em; opacity: 0.7; }
#mv-touch.mv-tc-compact .mv-tc-hint::after { width: 20px; height: 20px; }
