/* Phones and tablets: on-screen controls, landscape-first layouts for short screens, and the rotate prompt. */

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* one pixel of page to scroll on touch screens (pullGuard.mjs: an app that refreshes on a pull from the top of the
   page never sees the top); the game itself stays put */
html.pull-guard { overflow-y: auto; scrollbar-width: none; }
html.pull-guard::-webkit-scrollbar { display: none; }
html.pull-guard body { height: calc(100% + 1px); }
html.pull-guard #game-shell { position: fixed; left: 0; top: 0; }

/* --- Lying sideways on a screen that stays upright (screenTurn.mjs) ------------------------------------------------
   Some apps open the game in a browser locked to portrait. The shell is then rotated a quarter turn to fill the
   portrait screen as a landscape one (the player turns the phone to meet it). --turn-w/--turn-h are the screen's
   height and width in px. Everything inside measures the shell, so the landscape layouts apply as usual. */
html[data-turn] #game-shell { position: fixed; left: 0; top: 0; width: var(--turn-w); height: var(--turn-h); transform-origin: 0 0; }
html[data-turn="90"] #game-shell { transform: translateX(var(--turn-h)) rotate(90deg); }
html[data-turn="-90"] #game-shell { transform: translateY(var(--turn-w)) rotate(-90deg); }
/* the notch and the home bar are on the ends of the phone, which are now the game's left and right */
html[data-turn="90"] { --safe-l: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-bottom, 0px); --safe-b: env(safe-area-inset-left, 0px); }
html[data-turn="-90"] { --safe-l: env(safe-area-inset-bottom, 0px); --safe-r: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-right, 0px); }

html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { -webkit-user-select: none; -webkit-touch-callout: none; }
input { -webkit-user-select: text; user-select: text; }
button, input { touch-action: manipulation; }

/* --- On-screen controls (created by TouchControls, visible only in the arena) --- */
.touch-controls { display: none; }
.touch-controls.active { display: block; position: absolute; inset: 0; z-index: 12; pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; --s: var(--ts, 1); }
@container app (min-height: 560px) { .touch-controls.active { --s: calc(1.18 * var(--ts, 1)); } }

.touch-btn { position: absolute; display: grid; place-items: center; align-content: center; gap: 1px; width: calc(var(--size) * var(--s)); height: calc(var(--size) * var(--s)); border-radius: 50%; border: 1.5px solid rgba(222, 204, 160, .5); background: radial-gradient(circle at 50% 36%, rgba(52, 49, 40, .6), rgba(15, 16, 12, .68)); color: #f1e8d0; box-shadow: 0 2px 10px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .08); overflow: hidden; transition: background .08s ease; }
.touch-btn svg { width: calc(var(--size) * var(--s) * .42); height: calc(var(--size) * var(--s) * .42); fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.touch-btn span { font-size: 7px; font-weight: 900; letter-spacing: .14em; opacity: .82; }
.touch-btn.pressed { background: radial-gradient(circle at 50% 40%, rgba(200, 164, 95, .55), rgba(70, 55, 30, .72)); }

/* Only the face compresses; the captured touch target never changes size. */
.touch-face { position:absolute; inset:0; display:grid; place-items:center; align-content:center; gap:1px; border-radius:inherit; transition:transform .07s ease; pointer-events:none; }
.touch-btn.pressed .touch-face { transform:scale(.95); }
.touch-status:empty { display:none; }
.touch-status { font:800 6px/1 system-ui; letter-spacing:.02em; color:#dbc38c; }

/* right thumb: an arc of actions around Attack */
.touch-attack { --size: 80px; right: calc(var(--safe-r) + 28px * var(--s)); bottom: calc(var(--safe-b) + 28px * var(--s)); border-color: rgba(233, 130, 90, .75); }
.touch-attack svg { width: calc(var(--size) * var(--s) * .38); height: calc(var(--size) * var(--s) * .38); }
.touch-guard { --size: 64px; right: calc(var(--safe-r) + 152px * var(--s)); bottom: calc(var(--safe-b) + 36px * var(--s)); color: #a6e6f3; border-color: rgba(102, 201, 221, .62); }
.touch-dash { --size: 54px; right: calc(var(--safe-r) + 138px * var(--s)); bottom: calc(var(--safe-b) + 104px * var(--s)); color: #a6e6f3; }
.touch-spell { --size: 54px; right: calc(var(--safe-r) + 88px * var(--s)); bottom: calc(var(--safe-b) + 147px * var(--s)); color: #ffb277; border-color: rgba(233, 130, 67, .62); }
.touch-spell.coreflagration { color: #ff9852; border-color: rgba(255, 152, 82, .62); }
.touch-spell.frost { color: #a6e2ff; border-color: rgba(120, 200, 240, .62); }
.touch-spell.gale { color: #e6eee3; border-color: rgba(220, 232, 216, .6); }
.touch-spell.steel { color: #dfe6ee; border-color: rgba(214, 224, 236, .6); }
.touch-jump { --size: 58px; right: calc(var(--safe-r) + 21px * var(--s)); bottom: calc(var(--safe-b) + 154px * var(--s)); }
.touch-guard.drained { opacity: .5; }

/* left thumb: sprint toggle above the stick */
.touch-sprint { --size: 50px; left: calc(var(--safe-l) + 26px * var(--s)); bottom: calc(var(--safe-b) + 190px * var(--s)); color: #efd48a; }
.touch-sprint.on { background: radial-gradient(circle, rgba(230, 196, 106, .5), rgba(80, 64, 28, .72)); border-color: #e6c46a; }
.touch-sprint.sprinting { box-shadow: 0 0 14px rgba(230, 196, 106, .6); }

.touch-pause, .touch-scores { --size: 38px; top: 8px; }
.touch-pause { left: calc(var(--safe-l) + 10px); }
.touch-scores { left: calc(var(--safe-l) + 54px); }
.touch-pause span, .touch-scores span { display: none; }
.touch-pause svg, .touch-scores svg { width: calc(var(--size) * var(--s) * .5); height: calc(var(--size) * var(--s) * .5); stroke-width: 2.6; }
/* Practice-only: directly below the Pause and Scores icons, out of the combat arc. */
.touch-practiceTools {
  --size: 44px;
  top: calc(var(--safe-t) + 56px);
  left: calc(var(--safe-l) + 10px);
  color: #f2d48f;
  border-color: rgba(236, 201, 127, .84);
  background: radial-gradient(circle at 50% 32%, rgba(113, 73, 39, .86), rgba(53, 27, 22, .91));
}
.touch-practiceTools svg { width: calc(22px * var(--s)); height: calc(22px * var(--s)); }
.touch-practiceTools span { font-size: 6px; letter-spacing: .04em; }
.touch-practiceTools[hidden] { display: none !important; }
/* Touch users get a direct shortcut; desktop's established menu route is unchanged. */
.touch-ui #pause-practice { display: none !important; }

/* Ballista mount & deploy touch controls */
.touch-interact { --size: 58px; right: calc(var(--safe-r) + 204px * var(--s)); bottom: calc(var(--safe-b) + 96px * var(--s)); color: #ffdf77; border-color: rgba(255, 223, 119, .7); }
.touch-deploy { --size: 58px; right: calc(var(--safe-r) + 196px * var(--s)); bottom: calc(var(--safe-b) + 164px * var(--s)); color: #a8e063; border-color: rgba(168, 224, 99, .7); }
.touch-siegeView { --size: 58px; right: calc(var(--safe-r) + 122px * var(--s)); bottom: calc(var(--safe-b) + 174px * var(--s)); }
/* The on-foot VIEW toggle keeps its familiar control, with a persistent visual state. */
.touch-siegeView.on { border-color: #e6c46a; background: radial-gradient(circle, rgba(230,196,106,.35), rgba(55,48,31,.82)); box-shadow: inset 0 0 0 1px rgba(240,212,142,.35), 0 2px 10px #0008; }
.touch-btn[hidden] { display: none; }
.touch-mounted :is(.touch-guard, .touch-dash, .touch-spell, .touch-jump, .touch-sprint, .touch-crouch, .touch-gauntlet, .touch-ultimate) { display: none; }

.touch-cooldown { position: absolute; inset: 0; background: rgba(8, 9, 7, .66); transform: translateY(calc((1 - var(--cooldown, 0)) * 100%)); pointer-events: none; }
.touch-timer { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 900; color: #f3ead2; text-shadow: 0 1px 3px #000; pointer-events: none; }
.touch-btn.cooling svg, .touch-btn.cooling span { opacity: .4; }

/* fixed lower-left movement ring: only its thumb knob moves; no layout snap during fullscreen/resize */
.touch-stick { --stick-size:112px;position: absolute; left: calc(var(--safe-l) + 118px); top: calc(100% - var(--safe-b) - 110px); width: var(--stick-size); height: var(--stick-size); margin: calc(var(--stick-size) * -.5) 0 0 calc(var(--stick-size) * -.5); border-radius: 50%; border: 1.5px solid rgba(222, 204, 160, .38); background: radial-gradient(circle, rgba(20, 21, 17, .16), rgba(20, 21, 17, .4)); opacity: .5; pointer-events: auto; touch-action: none; transition: opacity .12s ease; }
.touch-stick.held { opacity: 1; }
.touch-stick.sprint { border-color: #e6c46a; box-shadow: 0 0 16px rgba(230, 196, 106, .4); }
/* One continuous front/rear charge cavity, extended only during Beat to
   the Punch's authoritative reverse window. Travels with edited joystick. */
.touch-stick-shell .touch-cavity-reverse { display:none; }
.touch-stick.reverse-charge-available .touch-stick-shell { height:calc(100% + 100px); }
.touch-stick.reverse-charge-available .touch-cavity-normal { display:none; }
.touch-stick.reverse-charge-available .touch-cavity-reverse { display:block; }
.touch-stick.reverse-charge-available .touch-motion-guide::after {
 content:'↓';position:absolute;left:50%;top:calc(100% + 96px);
 transform:translateX(-50%);font:800 20px/1 system-ui;pointer-events:none;
 color:var(--motion-tint);opacity:.7;text-shadow:0 0 5px #141511;
}
.touch-stick.reverse-charge-available.motion-active .touch-motion-guide::after { opacity:1; }
/* Never invent an additional gauge: server pressure shades the same charge
   channel's arrows/edge, regardless of forward/reverse direction. */
.touch-controls.touch-ram .touch-stick.motion-active .touch-stick-shell path {
 opacity:calc(.4 + var(--drive-pressure, 1) * .6);
}
.touch-controls.touch-ram .touch-motion-guide.active .touch-motion-well svg {
 opacity:calc(.32 + var(--drive-pressure, 1) * .68);
}
.touch-controls.touch-ram .touch-motion-guide[data-charge-direction="-1"]::after {
 opacity:1;text-shadow:0 0 9px #e6c46a;
}


.touch-stick-knob { position: absolute; left: 50%; top: 50%; width: calc(var(--stick-size) * .447); height: calc(var(--stick-size) * .447); margin: calc(var(--stick-size) * -.2235) 0 0 calc(var(--stick-size) * -.2235); border-radius: 50%; border: 1px solid rgba(240, 230, 205, .6); background: radial-gradient(circle at 45% 38%, rgba(240, 230, 205, .55), rgba(140, 128, 100, .45)); }

/* One outline joins the circle and its forward channel. The guide inside it
   carries no second frame across the joystick. Input geometry is unchanged. */
.touch-stick-shell { display:none;position:absolute;left:0;top:-50px;width:100%;height:calc(100% + 50px);overflow:visible;pointer-events:none; }
.touch-stick-shell path { fill:#14151150;stroke:#decca060;stroke-width:1.5; }
.touch-controls:not(.touch-mounted):not(.inspection-flight) .touch-stick,
.touch-controls.touch-ram .touch-stick { border-color:transparent;background:none; }
.touch-controls:not(.touch-mounted):not(.inspection-flight) .touch-stick-shell,
.touch-controls.touch-ram .touch-stick-shell { display:block; }
.touch-stick:is(.sprint,.motion-active) .touch-stick-shell path { stroke:#e6c46a;filter:drop-shadow(0 0 5px #e6c46a55); }

/* Sprint/Charge is the joystick's own broad upper channel, not a second
   floating control. Its lower edge overlaps the ring; no oval foot/connector. */
.touch-motion-guide {
  --motion-tint: #ecd18a;
  --motion-push: 0;
  position: absolute;
  left: 50%;
  bottom: calc(100% - 20px);
  width: calc(var(--stick-size) * .536);
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 2;
}
.touch-motion-guide::before,
.touch-motion-guide::after { content: none; }
.touch-motion-label {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  font: 800 9px/1.2 var(--font-script, system-ui);
  letter-spacing: .085em;
  white-space: nowrap;
  text-align: center;
  color: var(--motion-tint);
  text-shadow: 0 1px 3px #15130f, 0 0 5px #15130f;
  opacity: 0;
  transition: opacity .14s ease;
}
.touch-motion-well {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 60px;
  height: 70px;
  overflow: hidden;
  border-radius: 15px 15px 0 0;
  border:0; background:none; box-shadow:none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
/* A single pressure/charge indication. No sliding yellow detent. */
.touch-motion-well::after { content:none; }
.touch-motion-well svg {
  position: absolute;
  top: 49px;
  left: calc(50% - 10px);
  width: 20px;
  height: 13px;
  fill: none;
  stroke: var(--motion-tint);
  stroke-width: 2.35;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: .08;
}
.touch-motion-guide.active .touch-motion-well {
  border-color: color-mix(in srgb, var(--motion-tint) 75%, transparent);
  background:none; box-shadow:none;
}
.touch-motion-guide.active .touch-motion-label { opacity: 1; }
/* Preview is deliberately distinct from confirmed authoritative Sprint/Charge. */
.touch-motion-guide.approaching:not(.active) .touch-motion-well {
  border-color:transparent;background:none;
}
.touch-motion-guide.approaching:not(.active) .touch-motion-well svg { opacity:.52; }
.touch-motion-guide.approaching:not(.active) .touch-motion-label { opacity:.7; }
.touch-motion-guide.approaching:not(.active) .touch-motion-label::after { content:'PUSH ↑'; }
.touch-motion-guide.active .touch-motion-well svg {
  opacity: 1;
  animation: touch-motion-rise 1.05s linear infinite;
}
.touch-motion-guide.active .touch-motion-well svg:nth-child(2) { animation-delay: -.35s; }
.touch-motion-guide.active .touch-motion-well svg:nth-child(3) { animation-delay: -.7s; }
.touch-motion-guide[data-motion="charging"] { --motion-tint: #f0ae76; }
.touch-motion-guide[data-motion="charging"] svg { animation-duration: .8s; }
.touch-motion-guide.active[data-motion="charging"] .touch-motion-well svg:nth-child(2) { animation-delay: -.267s; }
.touch-motion-guide.active[data-motion="charging"] .touch-motion-well svg:nth-child(3) { animation-delay: -.533s; }
.touch-stick.motion-active { opacity: 1; }
@keyframes touch-motion-rise {
  0% { transform: translateY(11px); opacity: 0; }
  25% { opacity: .95; }
  72% { opacity: .95; }
  100% { transform: translateY(-68px); opacity: 0; }
}
/* Flight and every unrelated mounted machine use different motion semantics. */
.touch-mounted:not(.touch-ram) .touch-motion-guide,
.touch-controls.inspection-flight .touch-motion-guide,
.touch-controls.touch-flight .touch-motion-guide { display: none; }
@media (prefers-reduced-motion: reduce) {
  .touch-motion-guide.active .touch-motion-well svg { animation: none; opacity: .9; }
  .touch-motion-well svg:nth-child(1) { top: 9px; }
  .touch-motion-well svg:nth-child(2) { top: 29px; }
  .touch-motion-well svg:nth-child(3) { top: 49px; }
}


/* the touch HUD moves health and stamina to the top, clear of both thumbs; the buttons show their own cooldowns */
.touch-ui .bottom-hud { top: calc(var(--safe-t) + 9px); bottom: auto; left: calc(var(--safe-l) + 104px); right: auto; display: block; }
.touch-ui .health-block { width: 150px; }
.touch-ui .health-label { font-size: 13px; margin-bottom: 3px; }
.touch-ui .health-track { height: 10px; }
.touch-ui .guard-track { height: 7px; }
.touch-ui .guard-block { position: static; transform: none; width: 150px; margin-top: 6px; }
.touch-ui .guard-block span { font-size: 10px; letter-spacing: .12em; }
.touch-ui .abilities { display: none; }
/* Touch: remain horizontally centered, immediately above the actual
   subtitle lane. The shared HUD measurement raises it when dialogue wraps;
   neither the thumb controls nor the crosshair need to move. */
.touch-ui .status-flash {
  top: auto; left: 50%;
  bottom: var(--status-caption-bottom, calc(var(--safe-b, 0px) + 68px));
  width: max-content; max-width: min(320px, 66cqw); padding: 4px 9px;
  font-size: 10px; line-height: 1.2; letter-spacing: .035em;
}
.touch-ui .match-info { top: 10px; }
.touch-ui .duel-score { top:39px; padding:3px 9px; gap:8px; }
.touch-ui .hud-status-stack { top: calc(var(--safe-t) + 8px); left: calc(var(--safe-l) + 266px); right: calc(var(--safe-r) + 12px); width: auto; transform: none; gap: 4px; }
.touch-ui .breakthrough-hud { width: min(310px, 100%); }
@container app (max-width: 540px) {
  .touch-ui .hud-status-stack { top: calc(var(--safe-t) + 86px); left: calc(var(--safe-l) + 12px); }
}
.touch-btn.denied { border-color:#f1aa7e; box-shadow:0 0 0 2px #d28b5b99,0 2px 10px #0006; }
.touch-ui .kill-feed { top: 10px; right: calc(var(--safe-r) + 14px); width: min(260px, 34cqw); font-size: 10px; }
.touch-ui .hud.pointer-locked .practice-tools { display: none; }
.touch-ui .pointer-hint { top: 62%; padding: 12px 16px; font-size: 11px; }

/* How to Play shows the controls for the device in hand */
.touch-controls-grid { display: none; }
.touch-ui .touch-controls-grid { display: grid; grid-template-columns: 96px 1fr; }
.touch-ui .key-controls-grid { display: none; }

/* --- Short landscape screens (phones on their side) ------------------------------------------------------ */
@container app (max-height: 500px) {
  :where(#game-shell) > * { --banner-width: min(290px, 42cqw); --hem: 24px; }
  .manual-inner { --banner-width: min(360px, 50cqw); }
  .menu-screen::after, .side-screen::after, .lobby-screen::after { top: 5px; height: 7px; }
  .banner-panel { top: 8px; max-height: calc(100% - 8px); padding: 18px 18px calc(var(--hem) + 14px); }
  .banner-panel::before { inset: 6px 6px calc(var(--hem) + 6px); }
  .game-brand .crest { display: none; }
  .game-brand { margin-bottom: 10px; }
  .game-brand h1 { font-size: 25px; }
  .banner-panel .eyebrow { margin-bottom: 3px; font-size: 11px; }
  .banner-panel .game-input { height: 36px; }
  .name-block { margin-bottom: 4px; }
  .command-rail { gap: 5px; }
  .menu-command { min-height: 38px; padding: 6px 28px 7px; }
  .menu-command small { display: none; }
  .menu-command span { font-size: 16px; }
  .quiet-command { min-height: 36px; }
  .command-pair .menu-command { min-height: 36px; padding: 6px 16px 7px; }
  .command-pair .menu-command::before { left: 8px; }
  .command-pair .menu-command span { font-size: clamp(10px, 1.6cqw, 13px); white-space: normal; text-wrap: balance; }
  .banner-panel .error-copy { min-height: 0; }
  .side-screen .banner-panel h2, .lobby-screen h2 { font-size: 22px; margin-bottom: 6px; }
  .back-button { margin-bottom: 8px; }
  .banner-panel .panel-copy { display: none; }
  .banner-panel .mode-choice { min-height: 46px; margin-bottom: 6px; }
  .banner-panel .private-divider { margin: 8px 0 6px; }
  #solo-name, #private-name { margin: 4px 0 6px; }
  .banner-panel .controls-grid { gap: 4px 12px; padding: 8px 0; }
  .banner-panel .rules-copy { font-size: 11.5px; }
  .lobby-player { min-height: 32px; }
  .rooms-inner { --banner-width: min(340px, 48cqw); }
  .room-list { max-height: 30cqh; }
  .room-row { padding: 6px 10px; }
  .seek-banner { top: 50px; padding: 6px 8px 6px 12px; gap: 8px; }
  .seek-copy strong { font-size: 13px; }
  .wide-button { min-height: 40px; }
  .turn-hint { display: none; }

  .end-screen { align-content: start; overflow-y: auto; padding: 14px 0; overscroll-behavior: contain; touch-action: pan-y; }
  .end-medallion { display: none !important; }
  .end-screen h2 { font-size: 28px; margin: 0 0 8px; }
  .final-scoreboard { margin: 6px 0 10px; }
  .final-row { min-height: 32px; }

  .pause-card { padding: 16px 20px; }
  .pause-card h2 { font-size: 24px; margin: 0; }
  .pause-card p { margin: 6px 0 12px; }
}

/* --- Portrait on a phone or tablet: ask for landscape, offer to lie the game sideways when the app will not turn,
   and let the player carry on upright anyway. The shell's own shape decides, so a sideways game never asks. --- */
.rotate-prompt { display: none; }
@media (hover: none) and (pointer: coarse) {
  @container app (orientation: portrait) {
    body:not(.portrait-ok) .rotate-prompt { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 28px; text-align: center; background: radial-gradient(circle at 50% 38%, rgba(104, 87, 56, .3), rgba(14, 15, 12, .97) 65%), #11130f; }
  }
}
/* standing upright for a moment to type a name: no prompt over the keyboard */
html.turn-typing .rotate-prompt { display: none !important; }
.rotate-card { max-width: 320px; }
.rotate-card h2 { margin: 18px 0 10px; font-size: 26px; }
.rotate-card p { margin: 0 0 22px; color: rgba(235, 228, 212, .7); font-size: 13px; line-height: 1.55; }
.rotate-card .back-button { margin: 0; padding: 10px 14px; border: 1px solid rgba(218, 201, 163, .3); }
.rotate-card .rotate-sideways { display: block; width: 100%; margin: 0 0 12px; text-align: center; }
.rotate-card .rotate-note { margin: -4px 0 18px; font-size: 11.5px; }

/* after lying the game down: which way to turn the phone, and a flip for when it is the other way round */
.turn-toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); z-index: 90; display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100cqw - 32px)); padding: 10px 12px 10px 16px; transform: translateX(-50%); border: 1px solid rgba(201, 156, 82, .55); background: rgba(20, 17, 14, .92); color: var(--heraldry-cream, #eadcb6); font: 700 11px/1.35 var(--font-script, system-ui); letter-spacing: .08em; pointer-events: auto; }
.turn-toast button { flex: none; padding: 8px 12px; border: 1px solid rgba(201, 156, 82, .6); background: rgba(52, 42, 30, .9); color: inherit; font: inherit; letter-spacing: .12em; }
.rotate-phone { width: 40px; height: 66px; margin: 0 auto; border: 2px solid var(--gold); border-radius: 7px; position: relative; animation: rotate-phone 2.4s ease-in-out infinite; }
.rotate-phone i { position: absolute; left: 50%; bottom: 5px; width: 8px; height: 2px; margin-left: -4px; background: var(--gold); border-radius: 1px; }
@keyframes rotate-phone {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; transform: rotate(-90deg); }
}
/* the gauntlet: while the spell cools the spell button is the fist's (steel and brass), the spell's own mark small in
   its corner and its cooldown still counting; dimmed while the sword has the hand */
.touch-spell.fist { color: #eadfc4; border-color: rgba(214, 190, 140, .78); }
.touch-spell.fist.fist-held { opacity: .62; }
.touch-badge { position: absolute; right: 7%; top: 7%; width: 34%; height: 34%; display: grid; place-items: center; border-radius: 50%; background: rgba(15, 16, 12, .8); color: #ffb277; opacity: .9; }
.touch-badge:empty { display: none; }
.touch-badge svg { width: 70% !important; height: 70% !important; stroke-width: 2.4; }
.touch-spell.coreflagration .touch-badge { color: #ff9852; }
.touch-spell.frost .touch-badge { color: #a6e2ff; }
.touch-spell.gale .touch-badge { color: #cfeed2; }
.touch-spell.steel .touch-badge { color: #dfe6ee; }

/* Gale Garner gesture indicator overlay */
.touch-gale-indicator {
  position: absolute;
  right: calc(var(--safe-r) + 88px * var(--s));
  bottom: calc(var(--safe-b) + 147px * var(--s));
  width: calc(54px * var(--s));
  height: calc(54px * var(--s));
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.touch-gale-indicator.active {
  opacity: 1;
}
.chivalry-prepared .touch-gale-indicator {
  display: none !important;
}

/* Compact capsule indicators above (Burst) and below (Sustained) */
.touch-gale-capsule {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(16, 18, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  font: 800 8px/1 var(--font-script, sans-serif);
  letter-spacing: 0.12em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 0.45;
  transition: opacity 0.12s ease, transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.touch-gale-capsule.touch-gale-burst {
  bottom: calc(100% + 8px);
}
.touch-gale-capsule.touch-gale-sustained {
  top: calc(100% + 8px);
}
.touch-gale-capsule svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.touch-gale-capsule.selected {
  opacity: 1 !important;
  border-color: #ffffff;
  background: rgba(8, 10, 12, 0.98);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.7);
  transform: translateX(-50%) scale(1.08);
}

@keyframes chevrons-up {
  0% { transform: translateY(2px); opacity: 0.4; }
  50% { opacity: 1; }
  100% { transform: translateY(-2px); opacity: 0.4; }
}
@keyframes chevrons-down {
  0% { transform: translateY(-2px); opacity: 0.4; }
  50% { opacity: 1; }
  100% { transform: translateY(2px); opacity: 0.4; }
}
.gale-chevrons-up {
  animation: chevrons-up 0.8s infinite linear;
}
.gale-chevrons-down {
  animation: chevrons-down 0.8s infinite linear;
}

/* Legible mode label placed just to the left of the Gale button */
.touch-gale-label {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(14, 16, 18, 0.88);
  border: 1px solid rgba(220, 232, 216, 0.4);
  color: #e6eee3;
  font: 700 9px/1.2 var(--font-script, sans-serif);
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  opacity: 0.9;
}
/* the gauntlet's own button: only when asked for in the settings, left of the spell */
.touch-gauntlet { --size: 46px; display: none !important; right: calc(var(--safe-r) + 206px * var(--s)); bottom: calc(var(--safe-b) + 150px * var(--s)); color: #eadfc4; border-color: rgba(214, 190, 140, .62); }
.touch-controls.gauntlet-on .touch-gauntlet { display: grid !important; }
/* Crouch sits inward of the joystick, away from its forward Sprint/Charge
   extension. The flight rail occupies this space only while Crouch is hidden. */
.touch-crouch { --size: 50px; left: calc(var(--safe-l) + 190px * var(--s)); bottom: calc(var(--safe-b) + 187px * var(--s)); color: #e6dcc2; border-color: rgba(222, 204, 160, .62); overflow: visible; }
.touch-crouch::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
.touch-crouch svg { stroke-width: 2.5; }
.touch-crouch.on { color: #fff6de; background: radial-gradient(circle at 50% 40%, rgba(214, 196, 150, .55), rgba(64, 58, 42, .78)); border-color: #ecd9a4; box-shadow: inset 0 0 0 2px rgba(236, 217, 164, .3); }
.touch-crouch.crouched { box-shadow: inset 0 0 0 2px rgba(236, 217, 164, .3), 0 0 14px rgba(236, 217, 164, .55); }

/* the ultimate: top of the right thumb's arc, above Jump; its shade drains as prowess fills, full it glows */
.touch-ultimate { --size: 50px; right: calc(var(--safe-r) + 24px * var(--s)); bottom: calc(var(--safe-b) + 222px * var(--s)); color: #e2c27a; border-color: rgba(226, 194, 122, .55); background: radial-gradient(circle at 50% 120%, rgba(226, 120, 40, calc(var(--prowess-fraction, 0) * 0.45)), rgba(18, 20, 16, 0.95)); transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out; }
.touch-ultimate.prowess-draining { border-color: #ff9d42 !important; box-shadow: 0 0 14px rgba(255, 140, 50, 0.65), inset 0 0 10px rgba(255, 120, 30, 0.35) !important; animation: prowess-fluid-drain 0.4s ease-in-out infinite alternate; }
.touch-ultimate.practice-refill { animation: prowess-practice-refill 0.5s ease-out; }
@keyframes prowess-fluid-drain { 0% { filter: brightness(1) drop-shadow(0 0 2px rgba(255, 140, 50, 0.4)); } 100% { filter: brightness(1.2) drop-shadow(0 0 6px rgba(255, 140, 50, 0.75)); } }
@keyframes prowess-practice-refill { 0% { box-shadow: 0 0 22px rgba(255, 200, 80, 0.9), inset 0 0 14px rgba(255, 200, 80, 0.6); border-color: #ffe082; } 100% { box-shadow: 0 0 14px rgba(226, 194, 122, .55); border-color: #e2c27a; } }
@media (prefers-reduced-motion: reduce) { .touch-ultimate.prowess-draining, .touch-ultimate.practice-refill { animation: none; } }
.touch-ultimate::after { content: ""; position: absolute; inset: 0; background: rgba(8, 9, 7, .66); transform: translateY(calc(var(--charge, 0) * -100%)); pointer-events: none; }
.touch-ultimate.charging svg, .touch-ultimate.charging span { opacity: .55; }
.touch-ultimate.ready { border-color: #e2c27a; box-shadow: 0 0 14px rgba(226, 194, 122, .55); }
.touch-ultimate.ready::after, .touch-ultimate.active::after { display: none; }
.touch-ultimate.active { --ring: #f0a36a; --beat: .8s; color: #f0a36a; border-color: rgba(201, 106, 58, .8); animation: touch-ultimate-active var(--beat) ease-in-out infinite; }
/* while it runs: what is left of it as a ring round the button, its edge beating; a Vortex takes on what it has been
   steered to (the blade: hot white, quick; the fire: deep orange, slow), as the desktop tile does */
.touch-ultimate.active::before {
  content: ""; position: absolute; inset: 0; padding: 3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 0deg, var(--ring) calc(var(--left, 0) * 360deg), rgba(255, 255, 255, .08) 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.touch-ultimate.active[data-emphasis="blade"] { --ring: #ffe9c6; --beat: .42s; color: #fff1d6; border-color: #e9d2aa; }
.touch-ultimate.active[data-emphasis="fire"] { --ring: #ff5a1e; --beat: 1.15s; color: #ff8a4a; border-color: #d2481a; }
@keyframes touch-ultimate-active { 0%, 100% { box-shadow: 0 0 9px color-mix(in srgb, var(--ring) 40%, transparent); } 50% { box-shadow: 0 0 18px color-mix(in srgb, var(--ring) 70%, transparent); } }
@media (prefers-reduced-motion: reduce) { .touch-ultimate.active { animation: none; box-shadow: 0 0 14px color-mix(in srgb, var(--ring) 55%, transparent); } }

/* the Practice Yard: the button works though its real cooldown shows; a small brass infinity says so */
.touch-btn.practice::before { content: "\221E"; position: absolute; left: 12%; top: 8%; z-index: 3; width: 34%; height: 34%; display: grid; place-items: center; border-radius: 50%; font: 900 11px/1 system-ui, sans-serif; color: #2a1c10; background: linear-gradient(180deg, #e7c47c, #b8893f); pointer-events: none; }
.touch-btn.practice svg, .touch-btn.practice span { opacity: .85 !important; }

/* A short phone keeps the objective clear of the right thumb's action arc. */
@container app (max-width: 700px) and (max-height: 420px) {
  .touch-ui .hud-status-stack { right: calc(var(--safe-r) + 80px); }
  .touch-ui .breakthrough-hud { padding: 5px 7px; gap: 2px; }
  .touch-ui .bt-phase, .touch-ui .bt-footer { display: none; }
  .touch-ui .bt-main { gap: 4px; }
  .touch-ui .bt-obj-name { font-size: 11px; }
  .touch-ui .bt-state-pill { font-size: 8px; letter-spacing: 0; }
}

.touch-siegeWeapon { --size: 62px; right: calc(var(--safe-r) + 48px * var(--s)); bottom: calc(var(--safe-b) + 174px * var(--s)); color: #a8e2e9; }
.touch-mounted.touch-ram .touch-sprint { display: none; }
/* Joystick channel is the sprint/charge gesture; retain FAST in inspection flight. */
.touch-controls:not(.inspection-flight) .touch-sprint { display: none !important; }

.touch-siegeSkill.skill-active { border-color:#ffd875;box-shadow:0 0 12px #eed39b88; }

.touch-siegeSkill { --size: 62px; right: calc(var(--safe-r) + 278px * var(--s)); bottom: calc(var(--safe-b) + 96px * var(--s)); color: #eed39b; border-color: #bca06c; }

/* Fight-and-Flight mobile layout */
.touch-ui .flight-hud { width: min(290px, 100%); }
.touch-ui .flight-hud-strip { padding: 2px 6px; }
.touch-ui .flight-metric label { font-size: 7px; }
.touch-ui .flight-metric b { font-size: 11px; }
.touch-ui .flight-bar-wrap progress { width: 36px; height: 5px; }

/* Flight layout positions come from touchLayout.mjs, including mirroring and
   saved edits. One visual family, with fixed targets around pressed metal faces. */
.touch-flightRise, .touch-flightLower, .touch-flight-rail { display:none; }
.touch-controls.touch-flight { --s:var(--ts,1); }
.touch-mounted.touch-flight :is(.touch-guard,.touch-dash,.touch-jump,.touch-ultimate),
.touch-mounted.mounted-steel-available .touch-spell { display:grid; }
.touch-controls.touch-flight .touch-btn { min-width:44px; min-height:44px; }
.touch-controls.touch-flight .touch-btn span { white-space:nowrap; }
/* Wider attack targets are paired low-profile metal plates, not enlarged
   circular buttons that overlap Jump or crowd the safe-area edge. */
.touch-controls.touch-flight :is(.touch-attack,.touch-siegeWeapon) {
  border-radius:15px;
  border-width:2px;
  background:linear-gradient(150deg,rgba(71,75,73,.85),rgba(22,29,30,.94));
}
.touch-controls.touch-flight :is(.touch-attack,.touch-siegeWeapon) .touch-face { gap:2px; }
.touch-controls.touch-flight .touch-siegeWeapon.pressed { border-color:#b4f2f6;box-shadow:0 0 10px #a7dfe277; }
.touch-controls.touch-flight .touch-dash.flight-spinning { border-color:#eac47c;box-shadow:0 0 12px #ecbd6499;animation:flight-spool-pulse .28s ease-in-out infinite alternate; }
@keyframes flight-spool-pulse {from { filter:brightness(.92); } to {filter:brightness(1.18);}}
@media(prefers-reduced-motion:reduce){.touch-controls.touch-flight .touch-dash.flight-spinning{animation:none;}}

.touch-controls.touch-flight .touch-jump.pressed { border-color:#ffe4aa;box-shadow:0 0 11px #dfc18b66; }

.touch-controls.touch-flight .touch-siegeSkill span { font-size:7px;letter-spacing:.03em; }
.touch-controls.touch-flight .touch-interact { color:#e3b3a6; }
.touch-controls.touch-flight .touch-guard.airborne-forbidden,
.touch-controls.touch-flight .touch-dash:is(.flight-grounded,.flight-no-prowess,.flight-no-rotor) { opacity:.48; }
.touch-controls.touch-flight .touch-dash.flight-dash-active { border-color:#eae0af;box-shadow:0 0 9px #b9c9b970; }
.touch-controls.touch-flight :is(.touch-ultimate,.touch-dash).valkyrie-prep { border-color:#f5a17a;box-shadow:0 0 10px #bf623666; }
.touch-controls.touch-flight .touch-stick { opacity:1; border-color:#c6ae73aa; background:radial-gradient(circle,#26303555,#162126a8); }
.touch-controls.touch-flight .touch-stick::before {
  content:'';position:absolute;z-index:-1;inset:-6px -45px -6px -6px;border:1px solid #b99f6399;border-radius:58px 18px 18px 58px;
  background:linear-gradient(150deg,#414a4dbb,#131e24b8);box-shadow:inset 0 1px #eee0b433,0 2px 7px #0005;pointer-events:none;
}
.touch-controls.touch-flight .touch-stick.motion-mirrored::before { inset:-6px -6px -6px -45px; border-radius:18px 58px 58px 18px; }
.touch-controls.touch-flight .touch-motion-guide { display:none; }
.touch-controls.touch-flight .touch-flight-rail {
  position:absolute;left:calc(100% + 2px);top:0;width:40px;height:100%;
  display:flex;flex-direction:column;align-items:center;justify-content:space-between;
  box-sizing:border-box;padding:7px 0;border-radius:12px;touch-action:none;pointer-events:auto;
  color:#e9d7ad;background:linear-gradient(90deg,#0c171b88,#333d40cc,#0c171b88);z-index:18;
}
.touch-stick.motion-mirrored .touch-flight-rail { left:auto;right:calc(100% + 2px); }
.touch-flight-rail-arrow { font:800 17px/1 system-ui;opacity:.7;pointer-events:none; }
.touch-flight-rail-thumb { position:absolute;top:50%;left:4px;right:4px;height:28px;transform:translateY(-50%);border-radius:6px;pointer-events:none;border:1px solid #e0c98c;background:linear-gradient(160deg,#b69c63,#555440 60%,#353d3b);box-shadow:inset 0 1px #f4e1ac9c,0 2px 4px #000a; }
.touch-flight-rail[data-intent="rise"] { color:#fff1bd; }
.touch-flight-rail[data-intent="lower"] { color:#b9dce6; }
@container app (max-height:340px) { .touch-controls.touch-flight { --s:calc(.88 * var(--ts,1)); } }
/* Dagaz is ink projected across REAL Flight controls, not another button.
   SVG is full-layer and pointer transparent; every waypoint follows the
   player-edited Jump / Chivalry / Dash / Ascension rectangles. */
.touch-valkyrie-stencil {
  --ritual-progress:0;
  position:absolute;inset:0;width:100%;height:100%;box-sizing:border-box;
  z-index:22;pointer-events:none;touch-action:none;
  opacity:calc(.26 + var(--ritual-progress) * .74);
  transition:opacity .1s linear;
}
.touch-valkyrie-stencil[hidden] {display:none !important;}
.touch-valkyrie-stencil.unready {opacity:.13;}
.touch-valkyrie-stencil.unready.drawing {opacity:calc(.31 + var(--ritual-progress) * .69);}
.touch-valkyrie-ink {
  fill:none;stroke:#fff3bc;stroke-width:5.5;
  stroke-linecap:round;stroke-linejoin:round;
  stroke-dasharray:0 1;stroke-dashoffset:0;
  filter:drop-shadow(0 0 5px #ffbd6b) drop-shadow(0 0 2px #ffe3a3);
  pointer-events:none;
}
.touch-valkyrie-status {
  position:absolute;min-width:140px;max-width:230px;box-sizing:border-box;
  padding:4px 7px;border:1px solid #e1c78488;border-radius:4px;
  background:rgba(15,20,21,.83);color:#ffe7ac;
  text-align:center;font:800 10px/1.2 system-ui;
  letter-spacing:.04em;text-shadow:0 1px 2px #000;pointer-events:none;
}
.touch-valkyrie-stencil:not(.drawing) .touch-valkyrie-status {opacity:.85;}
.touch-valkyrie-stencil.drawing .touch-valkyrie-status {opacity:1;}

.touch-valkyrie-stencil.preview {opacity:.5;}
.touch-valkyrie-stencil svg {display:block;width:100%;height:100%;pointer-events:none;overflow:hidden;}
.touch-valkyrie-ghost {
  fill:none;stroke:#ffe4a5;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:5 6;
  filter:drop-shadow(0 0 3px rgba(252,194,103,.6));
}
.touch-valkyrie-stencil.unready .touch-valkyrie-ghost {stroke-dasharray:2 8;}
.touch-valkyrie-segment {
  fill:none;stroke:#ffe8b4;stroke-width:2;
  stroke-opacity:.05;stroke-linejoin:round;stroke-linecap:round;
  filter:drop-shadow(0 0 4px rgba(255,220,150,.65));
}
.touch-valkyrie-glyph {
  font:bold 22px/1 serif;fill:#f9d895;
  opacity:calc(.25 + var(--ritual-progress) * .65);
  text-anchor:middle;filter:drop-shadow(0 0 3px #d2a751);
}
.touch-valkyrie-stencil.drawing .touch-valkyrie-ghost {stroke-dasharray:none;stroke:#f2d29b;}
.touch-valkyrie-stencil.complete .touch-valkyrie-segment {filter:drop-shadow(0 0 9px #ffe3a3);}
.touch-valkyrie-stencil.complete {opacity:1;}

@media(prefers-reduced-motion:reduce){
  .touch-valkyrie-stencil{transition:none;filter:none;}
}


/* Custom opacity support */
.touch-controls {
  opacity: var(--touch-opacity, 1);
}

/* Touch Layout Editor overlay & toolbar */
/* Editor selection never depends on arena pointer-lock/touch focus. A late
   focus-lost event must not hide controls while someone drags a layout item. */
.touch-controls.touch-layout-editing {
  display:block !important;position:absolute;inset:0;z-index:59;
  pointer-events:auto;touch-action:none;
  /* Reuse the live --s from .active and the same game-shell container rules.
     Overriding it here used to change physical target size on editor open. */
}
@container app (min-height:560px) {
  .touch-controls.touch-layout-editing:not(.touch-flight) {
    --s:calc(1.18 * var(--ts,1)); /* match the live on-foot/siege HUD */
  }
}
.touch-controls.touch-layout-detached {position:absolute !important;inset:0 !important;z-index:59 !important;}
/* The layout editor owns the screen: no Arena Menu, Settings modal or
   background Practice tools card can obscure its first-frame preview. */
body.touch-layout-editor-open #pause-menu,
body.touch-layout-editor-open #settings,
body.touch-layout-editor-open #practice-overlay {
  visibility:hidden !important;pointer-events:none !important;
}
.touch-layout-editor {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: rgba(10, 12, 10, 0.4);
}
.tle-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 96vw);
  background: rgba(24, 20, 16, 0.94);
  border: 1px solid rgba(222, 204, 160, 0.6);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  color: #f1e8d0;
  font: 700 11px/1.3 var(--font-script, system-ui);
}
.tle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tle-header strong {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #ffd580;
}
.tle-mode-toggles {
  display: flex;
  gap: 4px;
}
.tle-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 10px;
}
.tle-controls label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tle-controls input[type="range"] {
  width: 70px;
}
.tle-btn {
  padding: 4px 8px;
  background: rgba(50, 42, 32, 0.85);
  border: 1px solid rgba(222, 204, 160, 0.45);
  color: #f1e8d0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.08em;
}
.tle-btn.active, .tle-btn.primary {
  background: rgba(180, 140, 70, 0.9);
  color: #1a140c;
  font-weight: 900;
  border-color: #ffd580;
}
.tle-selected-name { color:#f4d58c;font:800 10px system-ui;letter-spacing:.04em; }
.tle-mode-toggles { display:flex; flex-wrap:wrap;gap:4px;justify-content:flex-end; }
.tle-dimension[hidden] { display:none !important; }
.tle-controls input[type="range"] {accent-color:#dbb763;}
.tle-btn:focus-visible{outline:2px solid #ffe2a0;outline-offset:2px;}
@container app (max-height:385px){
 .tle-bar {top:3px;gap:3px;padding:4px 8px;max-width:98vw;}
 .tle-header strong{font-size:10px;}
 .tle-controls{gap:5px;}
 .tle-btn {padding:3px 6px;font-size:8px;}
 .tle-hint {bottom:3px;font-size:8px;padding:2px 7px;}
}
.tle-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 12, 10, 0.85);
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid rgba(222, 204, 160, 0.3);
  font: 10px var(--font-script, system-ui);
  color: #ebdcc0;
  pointer-events: none;
}
.touch-controls.touch-layout-editing .touch-btn,
.touch-controls.touch-layout-editing .touch-stick {
  outline: 1.5px dashed rgba(255, 215, 128, 0.65);
  cursor: grab;
}
.touch-controls.touch-layout-editing .tle-selected {
  outline: 2px solid #ffd580 !important;
  box-shadow: 0 0 12px #ffd580aa !important;
}

/* Deliberate mobile volley: separate from simultaneous finger gestures. */
.touch-siegeBoth { --size: 62px; right: calc(var(--safe-r) + 203px * var(--s)); bottom: calc(var(--safe-b) + 96px * var(--s)); color: #f3d4ac; border-color: #e6ad77; }

/* Bi-Bye-llista only. All coordinates are owned by the dedicated touch
   preset; these selectors provide color hierarchy without altering other rigs. */
.touch-controls.touch-ballista .touch-attack { color:#a5eaff; border-color:#77cde7; }
.touch-controls.touch-ballista .touch-siegeSkill { color:#e8d5ab; border-color:#c6ae83; }
.touch-controls.touch-ballista .touch-deploy { color:#e0cfac; border-color:#b8a06f; }
.touch-controls.touch-ballista .touch-siegeWeapon { color:#d1e4e8; }
.touch-controls.touch-ballista .touch-siegeBoth { color:#ead9bb; border-color:#dfb780; }
.touch-controls.touch-ballista .touch-siegeSkill span { letter-spacing:.015em; font-size:7px; }
.touch-controls.touch-ballista .touch-deploy span { letter-spacing:0; font-size:6.5px; }
.touch-controls.touch-ballista .touch-btn[aria-disabled="true"] { opacity:.55; }

/* Mounted Sheathe in Steel */
.touch-controls.touch-mounted:not(.touch-flight).mounted-steel-available .touch-spell {
  display: grid;
  border-color: rgba(182, 214, 240, 0.72);
  color: #dfe9f5;
  box-shadow: inset 0 1px #ffffff30, 0 3px 12px #0009;
}
.touch-controls.touch-mounted:not(.touch-flight).mounted-steel-available .touch-spell {
  --size: 62px;
  right: calc(var(--safe-r) + 48px * var(--s));
  bottom: calc(var(--safe-b) + 96px * var(--s));
}
/* Ballista Steel is a third, low-priority target on the firing row; it no
   longer occludes BOTH. Custom user placements still win as inline styles. */
.touch-controls.touch-mounted.touch-ballista:not(.touch-flight).mounted-steel-available .touch-spell {
  --size:54px;
  right:calc(var(--safe-r) + 176px * var(--s));
  bottom:calc(var(--safe-b) + 22px * var(--s));
}
.touch-controls .touch-spell.steel-ward-active {
  border-color: #79c0ff !important;
  box-shadow: inset 0 1px #ffffff40, 0 0 14px rgba(110, 184, 255, 0.75) !important;
  animation: touch-steel-pulse 1.8s infinite ease-in-out;
}
@keyframes touch-steel-pulse {
  0%, 100% { box-shadow: inset 0 1px #ffffff40, 0 0 8px rgba(110, 184, 255, 0.5); }
  50% { box-shadow: inset 0 1px #ffffff60, 0 0 18px rgba(130, 205, 255, 0.85); }
}
@media (prefers-reduced-motion: reduce) {
  .touch-controls .touch-spell.steel-ward-active {
    animation: none;
  }
}

.touch-controls .touch-btn[hidden] { display:none !important; }

/* Reserve the auxiliary controls even on short phones. Six flight metrics form
   two rows only when the space between health and View cannot fit one strip. */
@container app (max-width:700px) {
 .touch-ui .hud.ballista-mounted .hud-status-stack { left:calc(var(--safe-l) + 266px); right:calc(var(--safe-r) + 116px); }
 .touch-ui .ballista-hud { box-sizing:border-box;padding:4px 6px;gap:2px; }
 .touch-ui .ballista-hud strong { font-size:8px;letter-spacing:.02em; }
 .touch-ui .ballista-hud span { font-size:10px;line-height:1.15; }
 .touch-ui .ballista-hud small { display:none; }
 .touch-ui .hud.flight-mounted .flight-hud-strip { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:3px 5px; }
 .touch-ui .hud.flight-mounted .match-info { font-size:7px; letter-spacing:.06em; }
}
@container app (max-width:540px) {
 .touch-ui .hud.ballista-mounted .hud-status-stack { top:calc(var(--safe-t) + 85px); left:calc(var(--safe-l) + 180px); right:calc(var(--safe-r) + 116px); }
}
.touch-ui:has(.touch-flight .motion-mirrored) .bottom-hud { left:calc(var(--safe-l) + 120px); }

/* Inform the player when the browser cannot retain touch edits after reload. */
.tle-storage-warning { color:#f0bf7a; font:800 9px/1.3 system-ui,sans-serif;
  letter-spacing:.04em; text-shadow:0 1px 2px #000; }
.tle-storage-warning[hidden] { display:none !important; }

/* The mounted visibility reset hides on-foot Jump/Crouch. The ram reuses
   these actions for distinct RAISE and LOWER hydraulic buttons. */
.touch-mounted.touch-ram :is(.touch-jump,.touch-crouch,.touch-spell):not([hidden]) {display:grid}
.touch-mounted.touch-ram :is(.touch-jump,.touch-crouch) .touch-face span {
 font-size:6px;letter-spacing:.025em;max-width:94%;overflow-wrap:anywhere;
 text-align:center;line-height:1.15
}

/* Compact mobile feedback belongs to the thumb-side lower-left margin,
   not in the central sightline or over the subtitles. */
.touch-ui .status-flash {
  left:calc(var(--safe-l,0px) + 12px);
  bottom:calc(var(--safe-b,0px) + 8px);
  width:max-content;max-width:min(235px,31cqw);
  padding:4px 8px;text-align:left;font-size:9px;
  transform:translateY(5px);
}
.touch-ui .status-flash.show {transform:translateY(0);}
.touch-ui .hud.ballista-mounted:not(.flight-mounted) .ballista-hud {display:none !important;}

/* During defeat, only navigation remains clickable: no phantom attacks. */
.touch-controls.dead-navigation .touch-btn:not(.touch-pause):not(.touch-practiceTools),
.touch-controls.dead-navigation .touch-stick,
.touch-controls.dead-navigation .touch-motion-guide {display:none!important;}
.touch-controls.dead-navigation .touch-pause,
.touch-controls.dead-navigation .touch-practiceTools:not([hidden]) {display:grid!important;}
