/* SHARDSTORM UI. Dark sci-fi glass, teal and violet accents, warm orange credits.
   Layout: desktop = canvas left + 300px sidebar, command strip under the canvas;
   compact (narrow or portrait) = top HUD, canvas, command strip, bottom drawer;
   phones held sideways = canvas, command column, side drawer.
   The command strip (#cmd) holds the ability bar and the touch Place / Cancel buttons. It is a
   grid track of its own, reserved for the whole run, so nothing it holds can cover the map. */

:root {
  --bg: #060913;
  --bg-2: #0a1020;
  --panel: rgba(12, 18, 36, 0.82);
  --panel-solid: #0d1328;
  --card: linear-gradient(180deg, rgba(36, 50, 94, 0.5), rgba(15, 21, 44, 0.72));
  --card-hi: linear-gradient(180deg, rgba(46, 64, 118, 0.62), rgba(20, 28, 58, 0.8));
  --line: rgba(140, 200, 255, 0.13);
  --line-2: rgba(140, 220, 255, 0.26);
  --line-3: rgba(140, 230, 255, 0.42);
  --text: #eaf2ff;
  --text-2: #a8b7d6;
  --text-3: #6d7ca0;
  --teal: #3ef0d8;
  --teal-d: #14b3ad;
  --violet: #9b7bff;
  --violet-d: #6a4bff;
  --pink: #ff6ec7;
  --credit: #ffb547;
  --credit-d: #e2650f;
  --danger: #ff4d6a;
  --ok: #47f09a;
  --warn: #ffd23d;
  --gold: #ffd76a;
  --dt-kinetic: #c9d4e6;
  --dt-blast: #ff9f43;
  --dt-thermal: #ff5e5e;
  --dt-cryo: #7fdcff;
  --dt-energy: #c58bff;
  --dt-void: #ff5fd2;
  --r-xl: 20px;
  --r-lg: 16px;
  --r: 12px;
  --r-sm: 8px;
  --font: 'Chakra Petch', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --hud-h: 62px;
  --side-w: 300px;
  --cmd-h: 72px;
  --ab: 54px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  --glow-teal: 0 0 0 1px rgba(62, 240, 216, 0.45), 0 0 22px rgba(62, 240, 216, 0.28);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-touch-callout: none;
  /* No browser double-tap or pinch zoom anywhere (iPad Safari ignores user-scalable=no):
     pan-x pan-y leaves only scrolling, and it is intersected down the tree, so no descendant
     can bring page zoom back. Panels still scroll by touch. The playfield canvas (.view) sets
     touch-action: none and runs its own pinch zoom on pointer events. */
  touch-action: pan-x pan-y;
}
button, a, input, select, label, [role="button"] { touch-action: manipulation; }
body { background: radial-gradient(120% 90% at 50% 0%, #0f1733 0%, var(--bg) 60%); }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled, button[aria-disabled='true'] { cursor: default; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
canvas { display: block; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font: 600 10px/1 var(--font); letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  border-radius: 5px;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; }
.glyph { width: 0.74em; height: 1em; flex: none; vertical-align: -0.12em; filter: drop-shadow(0 0 3px rgba(255, 170, 60, 0.45)); }
.glyph--lg { width: 17px; height: 23px; }
.cr { display: inline-flex; align-items: center; gap: 0.28em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; margin: 0 7px; vertical-align: middle; }
.muted { color: var(--text-3); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(140, 200, 255, 0.18); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 220, 255, 0.32); background-clip: padding-box; border: 2px solid transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(140, 200, 255, 0.22) transparent; }

[data-layout='compact'] .only-wide { display: none !important; }
[data-layout='wide'] .only-compact { display: none !important; }
.is-touch .tile__key, .is-touch .up__key, .is-touch .tp__kbd, .is-touch .ab__key { display: none !important; }

/* ============================================================== app shell */

.app { position: fixed; inset: 0; overflow: hidden; }

.game {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'hud panel' 'stage panel' 'cmd panel';
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: #05070f;
}

.stage { grid-area: stage; position: relative; overflow: hidden; background: #070b16; }
.view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* ============================================================== buttons */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 44px; padding: 0 20px;
  border-radius: var(--r);
  font-weight: 600; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.14s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s, background 0.18s, color 0.18s, filter 0.18s;
  white-space: nowrap;
}
.btn .ico { width: 20px; height: 20px; }
.btn:hover { border-color: rgba(62, 240, 216, 0.6); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 8px 22px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(62, 240, 216, 0.2), 0 0 18px rgba(62, 240, 216, 0.18); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.985); transition-duration: 0.05s; }
.btn:disabled { opacity: 0.45; transform: none; box-shadow: none; }
.btn--primary {
  color: #041317;
  background: linear-gradient(100deg, #7ffff0 0%, var(--teal) 30%, #57b8ff 70%, var(--violet) 100%);
  border-color: rgba(190, 255, 250, 0.7);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 -2px 0 rgba(0, 0, 0, 0.12) inset, 0 8px 24px rgba(62, 240, 216, 0.28), 0 2px 8px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn--primary:hover { filter: brightness(1.08) saturate(1.05); border-color: #d6fffb; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 10px 30px rgba(62, 240, 216, 0.42), 0 2px 8px rgba(0, 0, 0, 0.4); }
.btn--glass { background: rgba(18, 26, 52, 0.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn--ghost { background: rgba(255, 255, 255, 0.03); border-color: var(--line); box-shadow: none; }
.btn--quiet { color: var(--text-2); }
.btn--credit { color: #2a1400; background: linear-gradient(100deg, #ffe0a3, var(--credit) 45%, #ff8a3d); border-color: rgba(255, 220, 160, 0.7); }
.btn--credit:hover { border-color: #fff0cf; box-shadow: 0 8px 22px rgba(255, 170, 60, 0.35); }
.btn--credit:disabled { filter: grayscale(0.6); }
.btn--sm { height: 34px; padding: 0 12px; font-size: 12px; gap: 7px; border-radius: 10px; }
.btn--sm .ico { width: 16px; height: 16px; }
.btn--lg { height: 52px; font-size: 16px; padding: 0 24px; }
.btn--xl { height: 62px; font-size: 19px; padding: 0 30px; border-radius: 14px; letter-spacing: 0.1em; }
.btn--xl .ico { width: 24px; height: 24px; }
.btn.is-armed { background: linear-gradient(100deg, #ff8a9b, var(--danger)); color: #22030a; border-color: #ffc2cc; }
.btn__stack { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.btn__sub { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: none; opacity: 0.72; margin-top: 3px; }
.btn--back { height: 38px; padding: 0 14px 0 10px; font-size: 13px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.icon-btn:hover { color: var(--text); background: rgba(62, 240, 216, 0.1); border-color: rgba(62, 240, 216, 0.45); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn--sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn--sm .ico { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--chip, var(--text-2));
  background: color-mix(in srgb, var(--chip, #9fb0cf) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip, #9fb0cf) 42%, transparent);
  white-space: nowrap;
}
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: #06111a; background: var(--teal);
}
.tag--teal { background: var(--teal); }
.tag--blue { background: #6fb6ff; }
.tag--orange { background: #ffab4c; }
.tag--red { background: #ff5e78; color: #1e0208; }
.tag--titan { background: linear-gradient(90deg, #ff5e78, #ff9a4c); color: #1e0208; }
.tag--phantom { background: rgba(190, 170, 255, 0.2); color: #d9ccff; border: 1px solid rgba(190, 170, 255, 0.45); }

/* ============================================================== HUD */

.hud {
  grid-area: hud;
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  height: calc(var(--hud-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 14px;
  background: linear-gradient(180deg, rgba(16, 24, 48, 0.96), rgba(10, 15, 32, 0.96));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.hud::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(62, 240, 216, 0.55) 20%, rgba(155, 123, 255, 0.55) 80%, transparent);
  opacity: 0.7;
}
.hud__stats { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud__titan-slot { flex: 1; min-width: 0; }
.hud__controls { display: flex; align-items: center; gap: 8px; flex: none; }

.stat {
  display: flex; align-items: center; gap: 9px;
  height: 44px; padding: 0 14px 0 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  min-width: 0;
}
.stat__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none; }
.stat__icon .ico { width: 20px; height: 20px; }
.stat__body { display: flex; flex-direction: column; min-width: 0; }
.stat__v { font-size: 20px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; white-space: nowrap; }
.stat__l { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-top: 3px; white-space: nowrap; }
.stat--lives .stat__icon { color: #ff7a8e; background: rgba(255, 77, 106, 0.12); }
.stat__art { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55)); pointer-events: none; user-select: none; }
.stat--lives .stat__icon:has(.stat__art) { background: radial-gradient(circle at 50% 55%, rgba(80, 220, 255, 0.2), rgba(80, 220, 255, 0) 70%); }
.stat--lives.low .stat__art { animation: lowPulse 1s ease-in-out infinite; }
.stat--lives.low .stat__v { color: var(--danger); animation: lowPulse 1s ease-in-out infinite; }
.stat--lives.low { border-color: rgba(255, 77, 106, 0.5); }
.stat--lives.hit { animation: hit 0.45s var(--ease); }
.stat--cash .stat__icon { background: rgba(255, 181, 71, 0.12); }
.stat--cash .stat__v { color: #ffd08a; text-shadow: 0 0 14px rgba(255, 170, 60, 0.35); }
.stat--cash.gain { animation: gain 0.6s var(--ease); }
.stat--wave .stat__icon { color: var(--teal); background: rgba(62, 240, 216, 0.1); }
.stat__best { margin-left: 7px; padding-left: 7px; border-left: 1px solid var(--line-2); color: var(--text-3); }
@keyframes lowPulse { 50% { opacity: 0.55; } }
@keyframes hit { 0% { transform: translateX(0); } 20% { transform: translateX(-4px); background: rgba(255, 77, 106, 0.25); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } 100% { transform: none; } }
@keyframes gain { 0% { box-shadow: 0 0 0 0 rgba(255, 181, 71, 0.6); } 100% { box-shadow: 0 0 0 10px rgba(255, 181, 71, 0); } }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.seg__btn {
  height: 34px; min-width: 38px; padding: 0 9px;
  border-radius: 8px;
  font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
  color: var(--text-3);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg__btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.seg__btn.is-on { color: #041317; background: linear-gradient(180deg, #8ffff2, var(--teal)); box-shadow: 0 0 14px rgba(62, 240, 216, 0.35); }

.hud-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 12px;
  border-radius: 11px;
  font-weight: 600; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.hud-btn:hover { color: var(--text); border-color: var(--line-3); background: rgba(255, 255, 255, 0.08); }
.hud-btn:active { transform: scale(0.96); }
.hud-btn--icon { width: 40px; padding: 0; justify-content: center; }
.hud-btn--auto.is-on { color: var(--teal); border-color: rgba(62, 240, 216, 0.55); background: rgba(62, 240, 216, 0.1); }
.hud-btn--auto.is-on .ico { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.wave-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 18px 0 12px;
  border-radius: 13px;
  color: #041317;
  background: linear-gradient(100deg, #8dfff2, var(--teal) 40%, #4fc3ff);
  border: 1px solid rgba(200, 255, 250, 0.75);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 6px 20px rgba(62, 240, 216, 0.3);
  transition: transform 0.14s var(--ease), filter 0.15s, box-shadow 0.2s, background 0.2s;
  min-width: 178px;
  overflow: hidden;
}
.wave-btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sheen 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.wave-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 10px 28px rgba(62, 240, 216, 0.45); }
.wave-btn:active { transform: translateY(1px) scale(0.98); }
.wave-btn__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(4, 19, 23, 0.14); }
.wave-btn__icon .ico { width: 18px; height: 18px; }
.wave-btn__text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.wave-btn__main { font-weight: 700; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.wave-btn__sub { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; margin-top: 2px; }
.wave-btn[data-mode='early'] { background: linear-gradient(100deg, #d8c9ff, var(--violet) 50%, #ff8fd6); border-color: rgba(230, 215, 255, 0.8); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 6px 20px rgba(155, 123, 255, 0.35); color: #13052b; }
.wave-btn[data-mode='busy'], .wave-btn[data-mode='over'] { background: rgba(255, 255, 255, 0.05); color: var(--text-3); border-color: var(--line); box-shadow: none; filter: none; transform: none; }
.wave-btn[data-mode='busy']::after, .wave-btn[data-mode='over']::after { display: none; }
.wave-btn[data-mode='busy'] .wave-btn__icon { background: rgba(255, 255, 255, 0.05); }
.wave-btn.is-titan { background: linear-gradient(100deg, #ffb07a, #ff5e78 55%, #d94bff); border-color: #ffd0c2; color: #22030a; box-shadow: 0 6px 24px rgba(255, 80, 110, 0.45); animation: titanPulse 1.6s ease-in-out infinite; }
@keyframes titanPulse { 50% { box-shadow: 0 6px 34px rgba(255, 80, 110, 0.75); } }

/* ============================================================== panel (sidebar / drawer) */

.panel {
  grid-area: panel;
  position: relative; z-index: 4;
  display: flex; flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(14, 20, 42, 0.98), rgba(9, 13, 28, 0.98));
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.35);
}
.panel::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -1px; width: 1px;
  background: linear-gradient(180deg, rgba(62, 240, 216, 0.5), rgba(155, 123, 255, 0.4) 50%, transparent);
  pointer-events: none;
}
.panel__body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 14px 12px calc(16px + env(safe-area-inset-bottom)); }
.panel__title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 2px 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-2);
}
.panel__hint { font-size: 10px; font-weight: 500; letter-spacing: 0.08em; color: var(--text-3); text-transform: none; }
.is-touch .panel__hint { display: none; }

.shop__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 108px; padding: 9px 4px 8px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.2s, background 0.2s;
}
.tile__art {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, rgba(120, 200, 255, 0.2), rgba(120, 200, 255, 0) 70%);
  transition: transform 0.2s var(--spring), filter 0.2s;
}
.tile__name { font-size: 11.5px; font-weight: 600; line-height: 1.12; text-align: center; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.24em; padding: 0 2px; }
.tile__price { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: #ffcf85; font-variant-numeric: tabular-nums; }
.tile__key { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; font-size: 9.5px; }
.tile:hover { transform: translateY(-2px); background: var(--card-hi); border-color: rgba(62, 240, 216, 0.5); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 16px rgba(62, 240, 216, 0.15); }
.tile:hover .tile__art { transform: scale(1.08); }
.tile:active { transform: translateY(0) scale(0.97); }
.tile.is-active { border-color: var(--teal); background: linear-gradient(180deg, rgba(62, 240, 216, 0.2), rgba(15, 21, 44, 0.8)); box-shadow: var(--glow-teal); }
.tile.is-poor .tile__price { color: var(--danger); }
.tile.is-poor .tile__art { filter: saturate(0.35) brightness(0.72); }
.tile.is-poor .tile__name { color: var(--text-2); }
.tile.is-capped { opacity: 0.55; }
.tile.is-capped .tile__price::after { content: 'Max'; margin-left: 4px; font-size: 10px; color: var(--text-3); letter-spacing: 0.1em; text-transform: uppercase; }
.nudge { animation: nudge 0.4s var(--ease); }
@keyframes nudge { 20% { transform: translateX(-4px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }

.hero-slot:not(:empty) { margin-top: 10px; }
.hero-tile {
  position: relative;
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px 9px 9px;
  border-radius: 13px;
  text-align: left;
  background: linear-gradient(100deg, rgba(255, 181, 71, 0.16), rgba(155, 123, 255, 0.12) 60%, rgba(15, 21, 44, 0.7));
  border: 1px solid rgba(255, 190, 110, 0.35);
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.2s;
}
.hero-tile:hover { transform: translateY(-1px); border-color: rgba(255, 210, 140, 0.75); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 181, 71, 0.2); }
.hero-tile.is-active, .hero-tile.is-selected { border-color: var(--credit); box-shadow: 0 0 0 1px var(--credit), 0 0 20px rgba(255, 181, 71, 0.3); }
.hero-tile.is-poor .hero-tile__price { color: var(--danger); }
.hero-tile__art { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); flex: none; }
.hero-tile__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hero-tile__role { font-size: 9.5px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--credit); }
.hero-tile__name { font-size: 15px; font-weight: 700; line-height: 1.15; }
.hero-tile__meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; margin-top: 1px; }
.hero-tile__price { display: inline-flex; align-items: center; gap: 4px; color: #ffcf85; }
.hero-tile__lvl { color: var(--text); }
.hero-tile__xp { display: block; height: 4px; margin-top: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hero-tile__xp i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(var(--fill, 0)); background: linear-gradient(90deg, var(--credit), #ffe7a8); transition: transform 0.4s var(--ease); }
.hero-tile .tile__key { top: 8px; right: 8px; }

.preview {
  margin-top: 12px; padding: 10px 11px 11px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}
.preview__head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.preview__label { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3); }
.preview__wave { font-size: 14px; font-weight: 700; }
.preview__tags { display: flex; gap: 5px; margin-left: auto; }
.preview__name { margin: -4px 0 9px; font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; }
.preview__name:empty { display: none; }
.preview__list { display: flex; flex-wrap: wrap; gap: 6px; }
.preview__empty { font-size: 12px; color: var(--text-3); }
.pv {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  height: 38px; padding: 0 9px 0 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.pv__n { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pv__n::before { content: 'x'; font-size: 10px; color: var(--text-3); margin-right: 1px; }
.pv--titan .pv__n::before { content: none; }
.pv__mods { position: absolute; top: -5px; left: -3px; display: flex; gap: 1px; }
.pv--titan { border-color: rgba(255, 94, 120, 0.55); background: rgba(255, 94, 120, 0.12); color: #ff9aac; padding-left: 8px; }
.pv__skull .ico { width: 20px; height: 20px; }
.pv--mini { height: 30px; padding: 0 7px 0 2px; }
.pv--mini .pv__n { font-size: 12px; }
.pv-more { align-self: center; font-size: 12px; color: var(--text-3); font-weight: 700; padding: 0 4px; flex: none; }
.pv-more:empty { display: none; }
.pv { cursor: default; }
.pv:focus-visible { outline-offset: 1px; }
.mod {
  display: inline-grid; place-items: center;
  width: 14px; height: 14px; border-radius: 4px;
  font: 700 9px/1 var(--font); font-style: normal;
  color: #0a0d1a; box-shadow: 0 0 0 1.5px #0a0d1a;
}
.mod--phantom { background: #cbb8ff; }
.mod--nanite { background: #6dffb0; }
.mod--plated { background: #ffd76a; }

/* ============================================================== selected tower panel */

.tp { display: flex; flex-direction: column; gap: 10px; animation: tpIn 0.22s var(--ease); }
@keyframes tpIn { from { opacity: 0; transform: translateX(10px); } }
.tp__head { display: flex; align-items: center; gap: 11px; }
.tp__art {
  display: grid; place-items: center; flex: none;
  width: 70px; height: 70px; border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(120, 220, 255, 0.24), rgba(10, 14, 30, 0.6) 72%);
  border: 1px solid var(--line-2);
  box-shadow: 0 0 20px rgba(62, 240, 216, 0.12) inset;
}
.tp__id { flex: 1; min-width: 0; }
.tp__name { font-size: 18px; font-weight: 700; line-height: 1.1; letter-spacing: 0.02em; }
.tp__sub { display: flex; align-items: center; flex-wrap: wrap; gap: 0; margin-top: 4px; font-size: 12px; color: var(--text-2); }
.tp__levels { font-weight: 700; color: var(--text); letter-spacing: 0.08em; margin-right: 8px; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); }
.tp__det { color: var(--teal); }
.tp__close { align-self: flex-start; }

.tp__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.kv { padding: 7px 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); min-width: 0; }
.kv__k { display: block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); }
.kv__v { display: block; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv__v--cr { color: #ffcf85; }

.tp__hero { padding: 10px; border-radius: 12px; background: rgba(255, 181, 71, 0.07); border: 1px solid rgba(255, 190, 110, 0.28); }
.tp__hero-top { display: flex; justify-content: space-between; align-items: baseline; }
.tp__lvl { font-size: 15px; font-weight: 700; color: #ffd08a; }
.tp__xp-text { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.xpbar { height: 7px; margin-top: 7px; border-radius: 6px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.xpbar i { display: block; height: 100%; transform-origin: left; transform: scaleX(var(--fill, 0)); background: linear-gradient(90deg, #ff9d3d, #ffe29a); box-shadow: 0 0 10px rgba(255, 181, 71, 0.6); transition: transform 0.4s var(--ease); }
.tp__hero-notes { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.hero-abil { display: flex; flex-direction: column; gap: 4px; }
.hero-abil li { display: flex; align-items: center; gap: 8px; opacity: 0.5; }
.hero-abil li.on { opacity: 1; }
.hero-abil__lvl { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); color: var(--credit); }

.tp__target { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
.tp__label { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3); margin-right: auto; }
.tp__mode { min-width: 70px; text-align: center; font-size: 14px; font-weight: 700; color: var(--teal); letter-spacing: 0.04em; }
.tp__kbd { margin-left: 2px; }
.tp__extra { display: flex; gap: 6px; flex-wrap: wrap; }
.tp__extra .btn { flex: 1; }
.tp__aim.is-active { color: #041317; background: linear-gradient(100deg, #8dfff2, var(--teal)); border-color: #d6fffb; }
.tp__vault-amt { margin-left: auto; font-size: 14px; letter-spacing: 0.02em; }

.tp__paths { display: flex; flex-direction: column; gap: 7px; }
.up {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; padding: 9px 11px 9px 14px;
  text-align: left;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform 0.15s var(--ease), border-color 0.16s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
.up::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--path); opacity: 0.85; box-shadow: 0 0 10px var(--path); }
.up__top { display: flex; align-items: center; gap: 8px; }
.up__path { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--path); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { display: inline-flex; gap: 5px; padding-right: 2px; }
.pip { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); border: 1.5px solid rgba(255, 255, 255, 0.24); background: rgba(0, 0, 0, 0.25); transition: background 0.25s, box-shadow 0.25s, border-color 0.25s; }
.pip.on { background: var(--path); border-color: var(--path); box-shadow: 0 0 7px var(--path); }
.pip.next { border-color: var(--path); animation: pipNext 1.3s ease-in-out infinite; }
@keyframes pipNext { 50% { box-shadow: 0 0 8px var(--path); background: color-mix(in srgb, var(--path) 30%, transparent); } }
.up__key { min-width: 16px; height: 16px; font-size: 10px; }
.up__name { font-size: 14.5px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.up__desc { font-size: 12px; line-height: 1.3; color: var(--text-2); }
.up__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; min-height: 22px; }
.up__state { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-3); min-width: 0; }
.up__state .ico { width: 13px; height: 13px; }
.up__state span:not(.up__tier) { white-space: normal; }
.up__tier { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.up__price { font-size: 16px; font-weight: 700; color: #ffcf85; }
.up[data-state='available']:hover { transform: translateY(-1px); border-color: var(--path); background: var(--card-hi); box-shadow: 0 0 0 1px color-mix(in srgb, var(--path) 60%, transparent) inset, 0 8px 22px rgba(0, 0, 0, 0.4), 0 0 20px color-mix(in srgb, var(--path) 22%, transparent); }
.up[data-state='available']:active { transform: scale(0.985); }
.up[data-state='available'] .up__price { padding: 2px 9px; border-radius: 8px; background: rgba(255, 181, 71, 0.12); border: 1px solid rgba(255, 181, 71, 0.4); }
.up[data-state='unaffordable'] .up__price { color: var(--danger); }
.up[data-state='unaffordable'] { cursor: not-allowed; }
.up[data-state='locked'] { opacity: 0.55; cursor: not-allowed; background: rgba(255, 255, 255, 0.02); }
.up[data-state='locked'] .up__name, .up[data-state='locked'] .up__desc { color: var(--text-3); }
.up[data-state='maxed'] { cursor: default; background: linear-gradient(100deg, color-mix(in srgb, var(--path) 16%, transparent), rgba(15, 21, 44, 0.8)); border-color: color-mix(in srgb, var(--path) 45%, transparent); }
.up[data-state='maxed'] .up__state { color: var(--gold); }
.up.bought { animation: bought 0.55s var(--ease); }
@keyframes bought { 0% { box-shadow: 0 0 0 0 var(--path); } 40% { box-shadow: 0 0 0 3px var(--path), 0 0 30px var(--path); } 100% { box-shadow: 0 0 0 0 transparent; } }

.tp__foot { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.btn--sell {
  width: 100%; height: 44px; justify-content: flex-start; padding: 0 14px;
  color: #ffb3bf;
  background: rgba(255, 77, 106, 0.08);
  border-color: rgba(255, 77, 106, 0.4);
  box-shadow: none;
}
.btn--sell:hover { border-color: rgba(255, 120, 140, 0.85); background: rgba(255, 77, 106, 0.16); box-shadow: 0 0 18px rgba(255, 77, 106, 0.2); }
.btn-sell__val { margin-left: auto; font-size: 15px; color: #ffd08a; letter-spacing: 0.02em; }
.btn--sell.is-undo { color: #9ffff2; background: rgba(62, 240, 216, 0.08); border-color: rgba(62, 240, 216, 0.45); }
.btn--sell.is-undo:hover { background: rgba(62, 240, 216, 0.16); box-shadow: 0 0 18px rgba(62, 240, 216, 0.2); border-color: var(--teal); }
.btn--sell.is-armed { color: #fff; background: linear-gradient(100deg, #ff6d86, #e22b4c); border-color: #ffc2cc; animation: armed 0.8s ease-in-out infinite; }
@keyframes armed { 50% { box-shadow: 0 0 22px rgba(255, 77, 106, 0.6); } }
.tp__foot-note { font-size: 11px; color: var(--text-3); text-align: center; }

/* ============================================================== overlay: titan, banners, toasts, abilities */

/* Top-center stack in the overlay: Titan bar, aim hint, coach and toasts, in one column that
   keeps clear of the Fit map corner (--stack-side), so none of them can cover another control. */
.topstack {
  position: absolute; top: 10px; left: var(--stack-side, 128px); right: var(--stack-side, 128px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.titan {
  position: relative;
  width: min(560px, 100%);
  padding: 8px 12px 10px;
  border-radius: 14px;
  background: rgba(20, 8, 20, 0.72);
  border: 1px solid rgba(255, 94, 120, 0.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 60, 90, 0.18);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: titanIn 0.5s var(--ease);
}
@keyframes titanIn { from { opacity: 0; transform: translateY(-14px); } }
.titan__label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.titan__tag { font-size: 10px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: #ff8fa2; }
.titan__name { font-size: 16px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.titan__bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.5); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.1); }
.titan__hp { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--fill, 1)); background: linear-gradient(90deg, #ff2e55, #ff7a45 70%, #ffc06a); transition: transform 0.2s linear; }
.titan__hp::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(0, 0, 0, 0.22) 18px 20px); }
.titan__shield { position: absolute; left: 0; right: 0; top: 0; height: 5px; transform-origin: left; transform: scaleX(var(--fill, 0)); background: linear-gradient(90deg, #7fe6ff, #d5f7ff); box-shadow: 0 0 8px #7fe6ff; transition: transform 0.2s linear; }
.titan__shield-ico { position: absolute; right: 8px; top: 4px; width: 26px; height: 26px; pointer-events: none; animation: titanIn 0.3s var(--ease); }
.titan__shield-ico[hidden] { display: none; }
.titan__shield-art { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 6px rgba(127, 230, 255, 0.7)); }
.titan__num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-shadow: 0 1px 2px #000, 0 0 4px #000; font-variant-numeric: tabular-nums; }

.banners { position: absolute; left: 0; right: 0; top: 30%; display: grid; place-items: center; pointer-events: none; }
.banner { grid-area: 1 / 1; text-align: center; animation: bannerIn 0.5s var(--spring) both; }
.banner.out { animation: bannerOut 0.3s ease-in both; }
.banner__title {
  font-size: clamp(30px, 4.4vw, 56px); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1;
  background: linear-gradient(180deg, #ffffff 20%, #a8fff4 60%, var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(62, 240, 216, 0.55)) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.6));
}
.banner__sub { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 16px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text); text-shadow: 0 2px 6px #000; }
.banner--clear .banner__title { font-size: clamp(22px, 3vw, 36px); background: linear-gradient(180deg, #ffffff, #d7ccff 60%, var(--violet)); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 14px rgba(155, 123, 255, 0.55)) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.6)); }
.banner--clear .banner__sub { color: #ffd08a; }
.banner--titan { width: 100%; padding: 18px 0 16px; background: linear-gradient(90deg, transparent, rgba(60, 4, 20, 0.85) 20%, rgba(60, 4, 20, 0.85) 80%, transparent); border-top: 1px solid rgba(255, 94, 120, 0.5); border-bottom: 1px solid rgba(255, 94, 120, 0.5); }
.banner--titan .banner__title { background: linear-gradient(180deg, #fff 10%, #ffb0bd 50%, #ff3d63); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 20px rgba(255, 60, 90, 0.8)) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.7)); }
.banner--titan .banner__sub { color: #ffb0bd; }
.banner--win .banner__title { background: linear-gradient(180deg, #fff 10%, #ffe7a8 50%, var(--credit)); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 20px rgba(255, 181, 71, 0.7)) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.7)); }
.banner--still { animation: none; }
@keyframes bannerIn { from { opacity: 0; transform: scale(1.35); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes bannerOut { to { opacity: 0; transform: translateY(-14px) scale(0.96); } }

.toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: 100%; }
.toasts:empty { display: none; }
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 100%;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(10, 14, 30, 0.9);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s var(--ease);
}
.toast::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); flex: none; }
.toast--bad { border-color: rgba(255, 77, 106, 0.5); }
.toast--bad::before { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.toast--good::before { background: var(--credit); box-shadow: 0 0 8px var(--credit); }
.toast--tip { border-radius: 14px; max-width: min(520px, 100%); white-space: normal; text-align: left; line-height: 1.35; border-color: rgba(62, 240, 216, 0.35); }
.toast--tip::before { background: var(--credit); box-shadow: 0 0 8px var(--credit); }
.toast__n { font-size: 11px; color: var(--text-3); }
.toast__n:empty { display: none; }
.toast.out { animation: toastOut 0.25s ease-in forwards; }
.toast.bump { animation: bump 0.25s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes bump { 40% { transform: scale(1.06); } }

/* ---- command strip: ability bar + touch Place / Cancel ---------------------------------- */
.cmd {
  grid-area: cmd;
  position: relative; z-index: 3;
  display: none;
  align-items: center; gap: 12px;
  min-width: 0;
  height: calc(var(--cmd-h) + env(safe-area-inset-bottom));
  padding: 0 12px env(safe-area-inset-bottom);
  background: linear-gradient(180deg, rgba(12, 18, 38, 0.97), rgba(8, 12, 26, 0.98));
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
}
.in-game .cmd { display: flex; }
.cmd::before {
  content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(62, 240, 216, 0.4) 25%, rgba(155, 123, 255, 0.4) 75%, transparent);
  opacity: 0.6;
}
.abilities {
  flex: 1 1 auto; min-width: 0; align-self: stretch;
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-x;
}
.abilities::-webkit-scrollbar { display: none; }
/* centered while it fits, scrollable from the first button once it does not */
.abilities > .ab:first-child { margin-left: auto; }
.abilities > .ab:last-child { margin-right: auto; }
.cmd__empty {
  position: absolute; inset: 0 0 env(safe-area-inset-bottom);
  display: none; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-3); pointer-events: none;
}
.cmd:not(.has-abilities):not(.is-placing) .cmd__empty { display: flex; }
.cmd__empty-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 1px dashed rgba(140, 200, 255, 0.25); color: rgba(255, 226, 138, 0.55); }
.cmd__empty-ico .ico { width: 16px; height: 16px; }
.cmd__empty-text { display: flex; flex-direction: column; line-height: 1.2; }
.cmd__empty-text b { font-size: 11px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-2); }
.cmd__empty-text span { font-size: 12px; }
.ab {
  position: relative;
  flex: none;
  display: grid; place-items: center;
  width: var(--ab); height: var(--ab);
  border-radius: 15px;
  background: rgba(12, 18, 38, 0.85);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.14s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.ab canvas { position: relative; }
.ab__sweep { position: absolute; inset: 0; background: conic-gradient(rgba(3, 6, 16, 0.78) calc(var(--cd, 0) * 360deg), transparent 0); pointer-events: none; }
.ab__glyph { position: absolute; left: 6px; bottom: 3px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px #000; }
.ab__glyph:empty { display: none; }
.ab__glyph--svg { left: 4px; bottom: 4px; width: 17px; height: 17px; padding: 2px; border-radius: 6px; background: rgba(8, 10, 22, 0.78); color: #ffe28a; box-shadow: 0 0 0 1px rgba(255, 226, 138, 0.35); }
.ab__glyph--svg .ico { display: block; width: 13px; height: 13px; stroke-width: 2.2; }
.ab__key { position: absolute; top: 4px; left: 4px; min-width: 15px; height: 15px; font-size: 9.5px; background: rgba(0, 0, 0, 0.55); }
.ab__count { position: absolute; bottom: 3px; right: 5px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px #000; }
.ab__cd { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px #000; pointer-events: none; font-variant-numeric: tabular-nums; }
.ab__cd:empty { display: none; }
.ab.is-ready { border-color: rgba(62, 240, 216, 0.7); animation: abReady 1.6s ease-in-out infinite; }
.ab.is-ready:hover { border-color: var(--teal); background: rgba(20, 34, 60, 0.95); }
.ab.is-ready:active { transform: scale(0.94); }
.ab[aria-disabled='true'] { cursor: default; }
.ab.is-waiting { border-color: rgba(62, 240, 216, 0.35); }
@keyframes abReady { 50% { box-shadow: 0 0 0 1px rgba(62, 240, 216, 0.35), 0 0 14px rgba(62, 240, 216, 0.45); } }
.cmd .ab { overflow: visible; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.ab__sweep { border-radius: inherit; }

.ghost-tag {
  position: absolute; left: 0; top: 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: rgba(8, 12, 26, 0.88);
  border: 1px solid var(--line-2);
  color: #ffcf85;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform;
}
.ghost-tag__why { color: #ff9aac; font-weight: 600; }
.ghost-tag__why:empty { display: none; }
.ghost-tag.is-bad { border-color: rgba(255, 77, 106, 0.6); }

/* Zoom: back to the whole map (the top stack keeps out of this corner) */
.view-ctl { position: absolute; top: 10px; right: 10px; z-index: 2; pointer-events: auto; animation: toastIn 0.2s var(--ease); }
.view-ctl[hidden] { display: none; }
.view-ctl__fit {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px 0 10px; border-radius: 11px;
  font-weight: 600; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text);
  background: rgba(10, 15, 32, 0.82);
  border: 1px solid var(--line-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.view-ctl__fit .ico { width: 18px; height: 18px; color: var(--teal); }
.view-ctl__fit:hover { border-color: rgba(62, 240, 216, 0.55); background: rgba(16, 26, 48, 0.9); }
.view-ctl__fit:active { transform: scale(0.95); }

.aim-hint {
  position: relative; max-width: 100%;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 18px;
  font-size: 13px; font-weight: 600;
  color: var(--teal);
  background: rgba(8, 12, 26, 0.88);
  border: 1px solid rgba(62, 240, 216, 0.5);
  box-shadow: var(--shadow);
}

.touch-place { flex: none; display: flex; align-items: center; gap: 10px; animation: toastIn 0.2s var(--ease); }
.touch-place .btn { height: 52px; padding: 0 18px; }
.touch-place__ok { min-width: 170px; }
.touch-place__label { display: inline-flex; align-items: center; gap: 8px; }
.touch-place__ok .cr { font-size: 15px; }
.touch-place__ok:disabled { opacity: 0.5; filter: grayscale(0.6); }
.cmd:not(.has-abilities) .touch-place { margin: 0 auto; }

.fps {
  position: absolute; bottom: 8px; left: 8px;
  display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 360px;
  padding: 5px 9px; border-radius: 8px;
  font: 600 11px/1.3 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color: #bfffe0;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.fps b { color: var(--ok); }

.leak-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 140px 20px rgba(255, 30, 70, 0.55); }
.leak-flash.on { animation: leak 0.6s ease-out; }
@keyframes leak { 0% { opacity: 1; } 100% { opacity: 0; } }

.tip {
  position: fixed; left: 0; top: 0; z-index: 30;
  width: 250px; padding: 11px 13px 12px;
  border-radius: 13px;
  background: rgba(10, 15, 32, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: tipIn 0.14s var(--ease);
}
@keyframes tipIn { from { opacity: 0; } }
.tip__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tip__name { font-size: 15px; font-weight: 700; }
.tip__blurb { margin-top: 4px; font-size: 12.5px; color: var(--text-2); line-height: 1.35; }
.tip__facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tip__fact { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--text-2); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.tip__fact--det { color: var(--teal); border-color: rgba(62, 240, 216, 0.4); }
.tip__price { margin-top: 9px; font-size: 15px; font-weight: 700; color: #ffcf85; }
.tip__sub { margin-top: 2px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-3); }
.tip__sub--ok { color: var(--teal); }
.tip { max-width: calc(100vw - 16px); }

/* ============================================================== screens */

.screens { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.screens.is-open { pointer-events: auto; }
.screens.is-modal { background: rgba(3, 5, 12, 0.56); backdrop-filter: blur(7px) saturate(0.8); -webkit-backdrop-filter: blur(7px) saturate(0.8); animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.sky { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.screens.is-menu .sky { display: block; }
.screens__layer { position: absolute; inset: 0; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  overflow-y: auto; overflow-x: hidden;
  opacity: 0; transform: translateY(14px);
  transition: opacity 0.24s ease, transform 0.32s var(--ease);
}
.screen.in { opacity: 1; transform: none; }
.screen.out { opacity: 0; transform: translateY(-10px); pointer-events: none; transition-duration: 0.18s; }
.screen--full:not(.screen--title) { background: linear-gradient(180deg, rgba(4, 6, 14, 0.5), rgba(4, 6, 14, 0.8)); }
/* Centered with auto margins, not justify-content: when a modal is taller than the screen
   (phones held sideways) it then scrolls from its top instead of losing it above the fold. */
.screen--modal.screen--pause, .screen--modal.screen--gameover { align-items: center; }
.screen--pause > .modal, .screen--gameover > .modal { margin: auto 0; flex: none; }
.screen--modal.screen--settings, .screen--modal.screen--codex { background: rgba(5, 8, 18, 0.82); }

.screen__head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  width: 100%; max-width: 1200px; margin: 0 auto 18px;
}
.screen__head > :first-child { justify-self: start; }
.screen__titles { text-align: center; }
.screen__title { font-size: clamp(22px, 3vw, 32px); font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.screen__sub { margin-top: 4px; font-size: 13.5px; color: var(--text-2); }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-2); margin: 0 0 10px; }
.section-title .ico { width: 16px; height: 16px; color: var(--teal); }
.section-sub { margin: -4px 0 12px; font-size: 13px; color: var(--text-3); }
.empty { padding: 40px; text-align: center; color: var(--text-3); }

/* ---- title */
.screen--title { padding: 0; }
.title {
  position: relative; min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(22px, 5vh, 46px);
  padding: 40px 20px 70px;
}
.title__brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.title__logo { max-width: min(760px, 88vw); max-height: 34vh; object-fit: contain; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6)); }
.emblem { width: 74px; height: 78px; margin-bottom: 8px; filter: drop-shadow(0 0 18px rgba(62, 240, 216, 0.6)); animation: float 5s ease-in-out infinite; }
.emblem svg { width: 100%; height: 100%; overflow: visible; }
@keyframes float { 50% { transform: translateY(-8px) rotate(2deg); } }
.wordmark {
  display: flex; gap: 0.02em;
  font-size: clamp(46px, 10vw, 128px); font-weight: 700; line-height: 0.95; letter-spacing: 0.05em;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 0 30px rgba(62, 240, 216, 0.28));
}
.wordmark__a { background: linear-gradient(180deg, #ffffff 15%, #b3fff6 55%, var(--teal) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark__b { background: linear-gradient(180deg, #ffffff 10%, #d7c9ff 50%, var(--violet) 80%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.title__tag { margin-top: 14px; font-size: clamp(13px, 1.7vw, 17px); font-weight: 500; letter-spacing: 0.34em; text-transform: uppercase; color: var(--text-2); text-shadow: 0 2px 10px #000; }
.menu { display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: min(380px, 100%); }
.menu__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu__row .btn { padding: 0 8px; font-size: 13px; gap: 7px; }
.menu__row .btn .ico { width: 17px; height: 17px; }
.title__foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 22px max(14px, env(safe-area-inset-bottom)); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.title__foot .ico { width: 14px; height: 14px; color: var(--credit); vertical-align: -2px; }
.title__foot span:first-child { display: inline-flex; align-items: center; gap: 6px; }

/* ---- map select */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; width: 100%; max-width: 1200px; margin: 6px auto 0; }
.map-card {
  display: flex; flex-direction: column;
  text-align: left;
  border-radius: 18px;
  background: rgba(14, 20, 42, 0.78);
  border: 1px solid var(--line-2);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.25s;
}
.map-card:hover { transform: translateY(-4px); border-color: rgba(62, 240, 216, 0.65); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(62, 240, 216, 0.2); }
.map-card:active { transform: translateY(-1px) scale(0.99); }
.map-card__art { position: relative; display: block; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; background: #111a30; }
.map-card__art canvas { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s var(--ease); }
.map-card:hover .map-card__art canvas { transform: scale(1.04); }
.map-card__art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8, 12, 26, 0.75)); pointer-events: none; }
.map-card__body { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 15px; }
.map-card__name { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
.map-card__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase; }
.map-card__meta .tag { height: 18px; padding: 0 7px; font-size: 10px; }
.map-card__best { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.map-card__best-l { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3); margin-right: 2px; }
.best-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px 0 6px; border-radius: 7px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--text-3); }
.best-chip__k { font-size: 10px; opacity: 0.8; }
.best-chip.has { color: var(--text); border-color: rgba(62, 240, 216, 0.35); }
.best-chip.has .best-chip__k { color: var(--teal); }

/* ---- difficulty + commander */
.setup { width: 100%; max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 22px; align-items: start; }
.setup__main { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.map-strip { position: sticky; top: 0; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.map-strip__art { position: relative; display: block; width: 100%; aspect-ratio: 3 / 2; background: #111a30; overflow: hidden; }
.map-strip__art canvas { width: 100%; height: 100%; object-fit: cover; }
.map-strip__body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; }
.map-strip__name { font-size: 24px; font-weight: 700; letter-spacing: 0.04em; }
.map-strip__desc { margin-top: 4px; font-size: 13.5px; color: var(--text-2); }
.map-strip__change { align-self: flex-start; margin-top: 12px; }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.diff-card {
  --acc: var(--teal);
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 16px 14px;
  text-align: left;
  border-radius: 16px;
  background: rgba(14, 20, 42, 0.8);
  border: 1px solid var(--line-2);
  transition: transform 0.18s var(--ease), border-color 0.2s, box-shadow 0.25s, background 0.2s;
  overflow: hidden;
}
.diff-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--acc); opacity: 0.8; }
.diff-card--pilot { --acc: #6fb6ff; }
.diff-card--veteran { --acc: #ffab4c; }
.diff-card--nightmare { --acc: #ff5e78; }
.diff-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--acc) 70%, transparent); }
.diff-card[aria-checked='true'] { border-color: var(--acc); background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 16%, transparent), rgba(14, 20, 42, 0.9)); box-shadow: 0 0 0 1px var(--acc), 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 28px color-mix(in srgb, var(--acc) 25%, transparent); }
.diff-card[aria-checked='true']::after { content: ''; position: absolute; top: 14px; right: 14px; width: 20px; height: 20px; border-radius: 50%; background: var(--acc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23061018' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat; }
.diff-card__name { font-size: 20px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--acc); }
.diff-card__blurb { font-size: 13px; color: var(--text-2); min-height: 2.7em; padding-right: 24px; }
.diff-card__stats { display: flex; gap: 8px; }
.dstat { display: flex; flex-direction: column; gap: 3px; flex: 1; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); min-width: 0; }
.dstat__top { display: flex; align-items: center; gap: 6px; }
.dstat__i { display: grid; place-items: center; color: #ff7a8e; }
.dstat__i .ico { width: 16px; height: 16px; }
.dstat__art { width: 20px; height: 20px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.dstat__v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dstat__k { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diff-card__best { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.diff-card__best .ico { width: 13px; height: 13px; color: var(--credit); }
.setup__section { }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.hero-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  text-align: left;
  border-radius: 15px;
  background: rgba(14, 20, 42, 0.8);
  border: 1px solid var(--line-2);
  transition: transform 0.18s var(--ease), border-color 0.2s, box-shadow 0.25s;
}
.hero-card:hover { transform: translateY(-2px); border-color: rgba(255, 200, 120, 0.6); }
.hero-card[aria-checked='true'] { border-color: var(--credit); background: linear-gradient(180deg, rgba(255, 181, 71, 0.14), rgba(14, 20, 42, 0.9)); box-shadow: 0 0 0 1px var(--credit), 0 0 24px rgba(255, 181, 71, 0.22); }
.hero-card__art { display: grid; place-items: center; width: 60px; height: 60px; flex: none; border-radius: 14px; background: rgba(0, 0, 0, 0.3); }
.hero-card__art--none { color: var(--text-3); }
.hero-card__art--none .ico { width: 26px; height: 26px; }
.hero-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-card__name { font-size: 16px; font-weight: 700; }
.hero-card__blurb { font-size: 12px; color: var(--text-2); line-height: 1.3; }
.hero-card__price { font-size: 13px; font-weight: 700; color: #ffcf85; margin-top: 2px; }
/* The Start button stays on screen however tall the setup gets (laptops, iPad landscape): a
   full-bleed bar stuck to the bottom edge, its content aligned with the 1200 px layout. */
.screen--difficulty { --screen-px: 22px; padding-bottom: 0; }
.setup__foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap;
  flex: none;
  margin: 18px calc(-1 * var(--screen-px)) 0;
  padding: 14px max(var(--screen-px), calc((100% - 1200px) / 2 + var(--screen-px))) max(14px, env(safe-area-inset-bottom));
  background: rgba(6, 9, 20, 0.9);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.35);
}
.setup__note { display: inline-flex; align-items: center; gap: 7px; margin-right: auto; font-size: 13px; color: var(--text-3); }
.setup__note .ico { width: 16px; height: 16px; color: var(--credit); }
.setup__start { min-width: 260px; }

/* ---- modals: pause, game over */
.modal {
  position: relative;
  width: min(440px, 100%);
  padding: 28px 28px 24px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(180deg, rgba(22, 30, 60, 0.94), rgba(10, 14, 30, 0.96));
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 60px rgba(62, 240, 216, 0.08);
}
.modal::before { content: ''; position: absolute; left: 24px; right: 24px; top: -1px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--teal), var(--violet), transparent); }
.modal__title { font-size: 30px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; }
.modal__sub { margin-top: 6px; font-size: 13px; color: var(--text-2); letter-spacing: 0.04em; }
.modal__menu { margin: 22px auto 0; width: 100%; }
.modal__menu .btn { width: 100%; justify-content: flex-start; padding-left: 20px; }
.modal__note { margin-top: 16px; font-size: 12px; color: var(--text-3); }

.modal--over { width: min(560px, 100%); padding-top: 30px; }
.modal--over::before { background: linear-gradient(90deg, transparent, #ff5e78, #ffab4c, transparent); }
.over__kicker { font-size: 14px; font-weight: 700; letter-spacing: 0.4em; text-transform: uppercase; color: #ff7a8e; text-shadow: 0 0 16px rgba(255, 77, 106, 0.6); }
.over__wave { display: flex; flex-direction: column; align-items: center; margin-top: 14px; line-height: 1; }
.over__wave-l { font-size: 13px; font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-3); }
.over__wave-n {
  font-size: clamp(76px, 14vw, 120px); font-weight: 700; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 20%, #b3fff6 60%, var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(62, 240, 216, 0.45));
  animation: waveNum 0.7s var(--spring) 0.1s both;
}
@keyframes waveNum { from { opacity: 0; transform: scale(0.6); } }
.record-banner {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 10px auto 0; padding: 7px 18px;
  border-radius: 999px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase;
  color: #2b1600;
  background: linear-gradient(100deg, #fff1c2, var(--gold) 40%, var(--credit));
  box-shadow: 0 0 30px rgba(255, 200, 90, 0.5);
  position: relative; overflow: hidden;
  animation: recIn 0.6s var(--spring) 0.4s both;
}
.record-banner .ico { width: 16px; height: 16px; }
.record-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%); animation: sheen 2.4s ease-in-out infinite; }
@keyframes recIn { from { opacity: 0; transform: scale(0.5); } }
.over__best { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.over__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.over__stat { padding: 10px 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.over__stat dt { font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.over__stat dd { margin-top: 3px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.over__menu { flex-direction: row; width: 100%; margin-top: 22px; gap: 10px; }
.over__menu .btn { flex: 1; padding: 0 10px; }

/* ---- settings */
.settings { width: 100%; max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.set-group { padding: 16px 18px 8px; border-radius: 18px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.set-group .section-title + .set-row { border-top: 0; }
.set-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-row__label { font-size: 15px; font-weight: 600; }
.set-row__sub { font-size: 12px; color: var(--text-3); }
.switch { position: relative; width: 50px; height: 28px; flex: none; border-radius: 999px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-2); transition: background 0.2s, border-color 0.2s, box-shadow 0.2s; }
.switch__knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #c7d3ea; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); transition: transform 0.22s var(--spring), background 0.2s; }
.switch[aria-checked='true'] { background: linear-gradient(90deg, var(--teal-d), var(--teal)); border-color: #b8fff6; box-shadow: 0 0 14px rgba(62, 240, 216, 0.35); }
.switch[aria-checked='true'] .switch__knob { transform: translateX(22px); background: #fff; }
.range { display: flex; align-items: center; gap: 12px; flex: 0 1 280px; }
.range input { flex: 1; min-width: 0; height: 28px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
.range input::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--teal) var(--v, 50%), rgba(255, 255, 255, 0.1) var(--v, 50%)); }
.range input::-moz-range-track { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); }
.range input::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--teal); }
.range input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); box-shadow: 0 0 10px rgba(62, 240, 216, 0.6); }
.range input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); box-shadow: 0 0 10px rgba(62, 240, 216, 0.6); }
.range__out { width: 42px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.seg--set .seg__btn { min-width: 70px; }
.keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; padding-bottom: 8px; }
.keys__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.keys dt { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; flex: none; max-width: 58%; }
.keys dd { font-size: 12.5px; color: var(--text-2); text-align: right; }
.keys kbd { height: 20px; font-size: 10.5px; text-transform: none; }
.keys__sep { margin: 0 3px; font-size: 11px; color: var(--text-3); }
.keys__plus { margin: 0 1px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.is-touch .keys kbd { height: 24px; padding: 0 8px; font-size: 11.5px; }
.settings__foot { display: flex; justify-content: center; padding: 6px 0 12px; }
.settings__foot .btn { min-width: 220px; }

/* ---- records */
.records { width: 100%; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.records__table-wrap { border-radius: 18px; overflow-x: auto; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.records__table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.records__table th, .records__table td { padding: 13px 16px; text-align: center; border-top: 1px solid var(--line); }
.records__table thead th { border-top: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3); background: rgba(0, 0, 0, 0.2); }
.records__table tbody th { text-align: left; }
.records__map { display: block; font-size: 15px; font-weight: 700; }
.records__mapd { display: block; font-size: 11px; color: var(--text-3); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500; }
.records__table td { font-size: 18px; font-weight: 700; color: var(--text-3); }
.records__table td.has { color: var(--text); }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.total { padding: 14px 16px; border-radius: 15px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.total__v { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; background: linear-gradient(180deg, #fff, #b3fff6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.total__k { display: block; margin-top: 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); }
.records__note { font-size: 12px; color: var(--text-3); text-align: center; }

/* ---- codex */
.tabs { display: flex; gap: 6px; width: 100%; max-width: 1200px; margin: 0 auto 16px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); overflow-x: auto; flex: none; }
.tab { flex: 1; min-width: max-content; height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 700; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); transition: background 0.15s, color 0.15s; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tab[aria-selected='true'] { color: #041317; background: linear-gradient(180deg, #8ffff2, var(--teal)); box-shadow: 0 0 16px rgba(62, 240, 216, 0.3); }
.codex { width: 100%; max-width: 1200px; margin: 0 auto; }
.codex__sec { margin: 22px 0 12px; }
.codex__sec:first-child { margin-top: 4px; }
.codex__foot { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; font-size: 13px; color: var(--text-2); }
.codex__foot .ico { color: var(--teal); margin-top: 1px; }
.ecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ecard { display: flex; gap: 12px; padding: 13px; border-radius: 16px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.ecard__art { display: grid; place-items: center; width: 72px; height: 72px; flex: none; border-radius: 14px; background: radial-gradient(circle at 50% 40%, rgba(120, 200, 255, 0.16), rgba(0, 0, 0, 0.3) 70%); }
.ecard--ship .ecard__art { width: 80px; height: 80px; }
.ecard__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ecard__name { font-size: 16px; font-weight: 700; }
.ecard__kind { margin-top: -4px; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.ecard__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.ecard__stats div { padding: 5px 7px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.ecard__stats dt { font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.ecard__stats dd { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ecard__imm { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ecard__imm-l { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-right: 2px; }
.ecard__imm-l--none { letter-spacing: 0.08em; text-transform: none; font-weight: 500; font-size: 12px; }
.ecard__kids { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.ecard__kids .ico { width: 14px; height: 14px; color: var(--teal); }
.ecard__kids--none { color: var(--text-3); }
.ecard__note { font-size: 12px; color: var(--text-3); }
.mods, .tcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mcard, .tcard { display: flex; gap: 12px; align-items: flex-start; padding: 13px; border-radius: 16px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.mcard__art { position: relative; display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: 12px; background: rgba(0, 0, 0, 0.3); }
.mcard__art .mod { position: absolute; top: -4px; left: -4px; width: 18px; height: 18px; font-size: 11px; }
.mcard__name, .tcard__name { font-size: 16px; font-weight: 700; }
.mcard__desc, .tcard__desc { margin-top: 3px; font-size: 12.5px; color: var(--text-2); }
.tcard { border-color: rgba(255, 94, 120, 0.35); background: linear-gradient(180deg, rgba(60, 10, 28, 0.5), rgba(14, 20, 42, 0.85)); }
.tcard__art { display: grid; place-items: center; width: 76px; height: 76px; flex: none; border-radius: 14px; background: radial-gradient(circle, rgba(255, 80, 110, 0.2), rgba(0, 0, 0, 0.35) 70%); }
.tcard__waves { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #ff8fa2; }
.mcard__first { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin-top: 2px; }
.ctow { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.ctow__list { position: sticky; top: 0; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 16px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); }
.ctow__item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; text-align: left; font-size: 13.5px; font-weight: 600; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.ctow__item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.ctow__item[aria-selected='true'] { color: var(--text); background: linear-gradient(90deg, rgba(62, 240, 216, 0.2), rgba(62, 240, 216, 0.02)); box-shadow: inset 2px 0 0 var(--teal); }
.ctow__detail { padding: 18px; border-radius: 18px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); min-width: 0; }
.ctow__head { display: flex; align-items: center; gap: 14px; }
.ctow__art { display: grid; place-items: center; width: 88px; height: 88px; flex: none; border-radius: 18px; background: radial-gradient(circle at 50% 40%, rgba(120, 220, 255, 0.22), rgba(0, 0, 0, 0.3) 70%); border: 1px solid var(--line-2); }
.ctow__name { font-size: 26px; font-weight: 700; letter-spacing: 0.04em; }
.ctow__blurb { margin-top: 3px; font-size: 14px; color: var(--text-2); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.fact { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: 11px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.fact__k { font-size: 9.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); }
.fact__v { display: flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 700; color: var(--text); }
.fact__v .cr { color: #ffcf85; }
.ctow__diff { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.ctow__diff-l { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); }
.seg--sm .seg__btn { height: 30px; font-size: 12px; padding: 0 12px; }
.cpaths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.cpath { display: flex; flex-direction: column; border-radius: 15px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-top: 3px solid var(--path); overflow: hidden; }
.cpath__name { display: flex; align-items: center; gap: 8px; padding: 11px 12px 8px; font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--path); }
.cpath__n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--path); color: #061018; font-size: 12px; }
.cpath__list { display: flex; flex-direction: column; }
.cup { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 9px 12px; border-top: 1px solid var(--line); }
.cup__tier { position: relative; display: grid; place-items: center; width: 22px; height: 22px; font-size: 11px; font-weight: 700; color: var(--path); margin-top: -1px; }
.cup__tier::before { content: ''; position: absolute; inset: 4px; border-radius: 3px; border: 1.5px solid color-mix(in srgb, var(--path) 60%, transparent); transform: rotate(45deg); }
.cup__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cup__name { font-size: 13.5px; font-weight: 700; }
.cup__desc { font-size: 12px; color: var(--text-2); line-height: 1.3; }
.cup__price { font-size: 13px; font-weight: 700; color: #ffcf85; padding-top: 1px; }
.cup:last-child .cup__tier::before { background: color-mix(in srgb, var(--path) 30%, transparent); border-color: var(--path); box-shadow: 0 0 8px color-mix(in srgb, var(--path) 50%, transparent); }
.cpath__total { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 9px 12px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.cpath__total .cr { font-size: 14px; color: #ffcf85; letter-spacing: 0.02em; }
.ctow__rule { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 12.5px; color: var(--text-3); }
.ctow__rule .ico { width: 16px; height: 16px; color: var(--teal); }
.dtypes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.dcard { padding: 15px 16px; border-radius: 16px; background: rgba(14, 20, 42, 0.8); border: 1px solid var(--line-2); border-left: 4px solid var(--chip); }
.dcard__name { font-size: 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chip); }
.dcard__blurb { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.dcard__imm { margin-top: 8px; font-size: 12.5px; }
.dcard__imm-l { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-right: 4px; }
.hcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.hcard { display: flex; gap: 14px; padding: 15px; border-radius: 16px; background: linear-gradient(180deg, rgba(255, 181, 71, 0.08), rgba(14, 20, 42, 0.85)); border: 1px solid rgba(255, 190, 110, 0.3); }
.hcard__art { display: grid; place-items: center; width: 84px; height: 84px; flex: none; border-radius: 16px; background: rgba(0, 0, 0, 0.3); }
.hcard__name { font-size: 18px; font-weight: 700; }
.hcard__price { margin-top: 2px; font-size: 14px; font-weight: 700; color: #ffcf85; }
.hcard__blurb { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.hcard__abil { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.hcard__abil li { display: flex; gap: 8px; align-items: baseline; }

/* ============================================================== boot, fatal, notice */

.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(90% 70% at 50% 40%, #111a38, #05070f 70%); transition: opacity 0.4s ease; }
.boot.done { opacity: 0; pointer-events: none; }
.boot__inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.boot__mark { width: 34px; height: 44px; background: linear-gradient(135deg, #b8fff5, var(--teal) 45%, var(--violet-d)); clip-path: polygon(50% 0, 100% 32%, 72% 100%, 50% 90%, 28% 100%, 0 32%); filter: drop-shadow(0 0 14px rgba(62, 240, 216, 0.7)); animation: float 2.4s ease-in-out infinite; }
.boot__name { font-size: 22px; font-weight: 700; letter-spacing: 0.4em; margin-right: -0.4em; background: linear-gradient(90deg, #fff, #b3fff6, #d7c9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.boot__bar { width: 200px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.boot__bar i { display: block; height: 100%; transform-origin: left; transform: scaleX(0.05); background: linear-gradient(90deg, var(--teal), var(--violet)); transition: transform 0.3s var(--ease); }
.boot__text { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-3); }

.fatal { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; gap: 12px; align-items: flex-start; max-width: min(520px, calc(100% - 32px)); padding: 14px 18px; border-radius: 14px; background: rgba(40, 8, 18, 0.95); border: 1px solid rgba(255, 94, 120, 0.6); box-shadow: var(--shadow); color: var(--text); }
.fatal .ico { color: var(--danger); width: 22px; height: 22px; }
.fatal b { display: block; font-size: 15px; }
.fatal span { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; }

.notice { position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translate(-50%, 20px); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: rgba(10, 14, 30, 0.94); border: 1px solid var(--line-2); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s var(--ease); max-width: calc(100% - 32px); text-align: center; }
.notice.on { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================== compact layout: top HUD + bottom drawer */

[data-layout='compact'] {
  --hud-h: 52px;
}
[data-layout='compact'] {
  --cmd-h: 62px;
  --ab: 48px;
}
[data-layout='compact'] .game {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'hud' 'stage' 'cmd' 'panel';
}
[data-layout='compact'] .hud { padding: env(safe-area-inset-top) 8px 0; gap: 6px; }
/* The drawer below owns the bottom safe area in compact portrait. */
[data-layout='compact'] .cmd { height: var(--cmd-h); padding: 0 10px; gap: 10px; }
[data-layout='compact'] .cmd__empty { inset: 0; }
[data-layout='compact'] .cmd.is-placing .abilities { display: none; }
[data-layout='compact'] .cmd.is-placing .touch-place { flex: 1; justify-content: center; }
[data-layout='compact'] .touch-place .btn { height: 48px; }
[data-layout='compact'] .touch-place__ok { flex: 0 1 240px; min-width: 0; }
[data-layout='compact'] .hud__stats { gap: 5px; flex: 1; }
[data-layout='compact'] .stat { height: 38px; padding: 0 8px 0 5px; gap: 5px; border-radius: 10px; }
[data-layout='compact'] .stat__icon { width: 22px; height: 22px; }
[data-layout='compact'] .stat__icon .ico { width: 16px; height: 16px; }
[data-layout='compact'] .stat__art { width: 24px; height: 24px; }
[data-layout='compact'] .view-ctl { top: 8px; right: 8px; }
[data-layout='compact'] .topstack { --stack-side: 56px; top: 8px; gap: 6px; }
[data-layout='compact'] .view-ctl__fit { height: 40px; width: 40px; padding: 0; justify-content: center; }
[data-layout='compact'] .view-ctl__fit span { display: none; }
[data-layout='compact'] .glyph--lg { width: 13px; height: 18px; }
[data-layout='compact'] .stat__v { font-size: 16px; }
[data-layout='compact'] .stat__l { display: none; }
[data-layout='compact'] .stat--wave .stat__l { display: block; font-size: 10px; letter-spacing: 0.08em; margin-top: 1px; }
[data-layout='compact'] .stat__best { display: none; }
.hud-btn--speed { min-width: 42px; justify-content: center; font-size: 14px; font-weight: 700; letter-spacing: 0.02em; text-transform: none; }
.hud-btn--speed.is-fast { color: #041317; background: linear-gradient(180deg, #8ffff2, var(--teal)); border-color: #b8fff6; }
[data-layout='compact'] .hud__titan-slot { display: none; }
[data-layout='compact'] .hud__controls { gap: 5px; }
[data-layout='compact'] .seg__btn { height: 30px; min-width: 30px; padding: 0 5px; font-size: 12px; }
[data-layout='compact'] .hud-btn { height: 40px; padding: 0 8px; }
[data-layout='compact'] .hud-btn--icon, [data-layout='compact'] .hud-btn--auto { width: 40px; padding: 0; justify-content: center; }
[data-layout='compact'] .hud-btn__label { display: none; }

[data-layout='compact'] .panel {
  border-left: 0;
  border-top: 1px solid var(--line-2);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  max-height: 46vh;
  padding-bottom: env(safe-area-inset-bottom);
}
[data-layout='compact'] .panel::before { top: -1px; bottom: auto; left: 20px; right: 20px; width: auto; height: 1px; background: linear-gradient(90deg, transparent, rgba(62, 240, 216, 0.6), rgba(155, 123, 255, 0.5), transparent); }
[data-layout='compact'] .panel[data-view='tower'] { max-height: 58vh; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; flex: none; }
.drawer-toggle { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; flex: none; color: var(--text-2); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); transition: transform 0.25s var(--ease); }
.drawer-closed .drawer-toggle { transform: rotate(180deg); }
/* next wave strip: tap for the full preview, hold an icon to read it */
.drawer-head__preview {
  flex: 1; min-width: 0; align-self: stretch;
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 4px; border-radius: 11px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.drawer-head__preview:hover, .drawer-head__preview[aria-expanded='true'] { background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.mini__list { flex: 1 1 auto; min-width: 0; display: flex; gap: 5px; padding-top: 6px; overflow: hidden; }
.mini__list .pv { flex: none; }
.pv__dot { position: absolute; top: -4px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 1.5px #0a0d1a; }
.pv--mini.pv--titan { padding: 0 8px 0 5px; }
.pv--mini .pv__skull .ico { width: 16px; height: 16px; }
.pv--mini .mod { width: 14px; height: 14px; font-size: 10px; }
.show-preview[data-layout='compact'] .preview { display: block; order: -1; margin: 2px 0 10px; }
[data-layout='compact'] .shop { display: flex; flex-direction: column; }
.wave-btn--compact { min-width: 0; height: 40px; padding: 0 14px 0 8px; gap: 7px; }
.wave-btn--compact .wave-btn__icon { width: 24px; height: 24px; }
.wave-btn--compact .wave-btn__main { font-size: 13px; }
[data-layout='compact'] .panel__body { padding: 4px 10px 12px; }
.drawer-closed[data-layout='compact'] .panel__body { display: none; }
[data-layout='compact'] .panel__title { display: none; }
[data-layout='compact'] .shop__grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
[data-layout='compact'] .tile { min-height: 88px; padding: 6px 3px 6px; border-radius: 11px; }
[data-layout='compact'] .tile__art { width: 44px; height: 44px; }
[data-layout='compact'] .tile__name { font-size: 11px; }
[data-layout='compact'] .tile__price { font-size: 12px; }
[data-layout='compact'] .preview { display: none; }
[data-layout='compact'] .tp { gap: 8px; }
[data-layout='compact'] .tp__art { width: 56px; height: 56px; border-radius: 13px; }
[data-layout='compact'] .tp__paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
[data-layout='compact'] .abilities { gap: 7px; }
[data-layout='compact'] .ab { border-radius: 13px; }
[data-layout='compact'] .titan { padding: 6px 10px 8px; }
[data-layout='compact'] .titan__name { font-size: 13px; }
[data-layout='compact'] .banners { top: 26%; }
[data-layout='compact'] .toast { font-size: 12.5px; padding: 7px 12px 7px 10px; }

/* phone-size menus */
@media (max-width: 899px) {
  .screen { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .screen__head { grid-template-columns: auto 1fr auto; margin-bottom: 14px; }
  .screen__titles { text-align: left; }
  .screen__head-end { display: none; }
  .btn--back span { display: none; }
  .btn--back { width: 40px; padding: 0; }
  .setup { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .map-strip { position: static; flex-direction: row; }
  .map-strip__art { width: 42%; flex: none; aspect-ratio: auto; min-height: 120px; }
  .map-strip__body { padding: 10px 12px 12px; min-width: 0; }
  .map-strip__name { font-size: 18px; }
  .map-strip__desc, .map-strip__change { display: none; }
  .map-strip .map-card__best { flex-wrap: wrap; }
  .diff-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .diff-card { padding: 13px 12px 12px; }
  .diff-card__name { font-size: 17px; }
  .diff-card__stats { flex-direction: column; gap: 5px; }
  .screen--difficulty { --screen-px: 14px; }
  .setup__foot { justify-content: stretch; }
  .setup__start { width: 100%; min-width: 0; }
  .menu__row .btn { font-size: 12px; }
  .ctow { grid-template-columns: minmax(0, 1fr); }
  .ctow__list { position: static; flex-direction: row; overflow-x: auto; }
  .ctow__item { flex-direction: column; gap: 4px; min-width: 78px; font-size: 11px; text-align: center; }
  .cpaths { grid-template-columns: minmax(0, 1fr); }
  .ctow__detail { padding: 14px; }
  .ctow__name { font-size: 21px; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keys { grid-template-columns: minmax(0, 1fr); }
  .over__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { padding: 22px 18px 18px; }
  .ecards, .mods, .tcards, .dtypes, .hcards { grid-template-columns: minmax(0, 1fr); }
  .records__table th, .records__table td { padding: 10px 8px; }
  .records__table td { font-size: 16px; }
  .set-row { flex-wrap: wrap; }
  .range { flex-basis: 100%; }
}
@media (max-width: 420px) {
  .over__menu { flex-direction: column; }
  .over__menu .btn { flex: none; width: 100%; height: 48px; }
  .menu__row { grid-template-columns: 1fr; }
  .title__foot { font-size: 10px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .title { gap: 16px; padding-top: 20px; }
  .emblem { display: none; }
  .wordmark { font-size: clamp(40px, 8vw, 80px); }
  .btn--xl { height: 50px; }
  /* game over fits a landscape phone: the Retry, Maps and Title row stays on screen */
  .modal--over { padding-top: 16px; padding-bottom: 14px; }
  .over__wave { margin-top: 6px; }
  .over__wave-n { font-size: 56px; }
  .record-banner { margin-top: 6px; padding: 4px 14px; font-size: 12px; }
  .over__best { margin-top: 6px; }
  .over__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
  .over__stat { padding: 6px 8px; }
  .over__stat dd { font-size: 16px; }
  .over__menu { margin-top: 12px; }
}

/* ============================================================== motion preferences */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .wave-btn::after, .record-banner::after { display: none; }
}
.screen:focus, .screen:focus-visible { outline: none; }
.hero-abil__lvl .ico { width: 11px; height: 11px; vertical-align: -1px; }
.hero-next { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }

/* ============================================================== medium desktop widths */
@media (max-width: 1360px) {
  [data-layout='wide'] .hud { gap: 10px; }
  [data-layout='wide'] .hud-btn__label { display: none; }
  [data-layout='wide'] .hud-btn--auto { width: 40px; padding: 0; justify-content: center; }
  [data-layout='wide'] .wave-btn { min-width: 0; }
}
@media (max-width: 1180px) {
  [data-layout='wide'] { --side-w: 272px; }
  [data-layout='wide'] .stat { padding: 0 10px 0 8px; gap: 7px; }
  [data-layout='wide'] .stat--lives .stat__l, [data-layout='wide'] .stat--cash .stat__l { display: none; }
  [data-layout='wide'] .stat__best { display: none; }
  [data-layout='wide'] .wave-btn__sub { display: none; }
  [data-layout='wide'] .wave-btn { padding: 0 14px 0 9px; }
  [data-layout='wide'] .seg__btn { min-width: 32px; padding: 0 6px; }
  [data-layout='wide'] .tile { min-height: 100px; }
  [data-layout='wide'] .tile__art { width: 46px; height: 46px; }
}

/* ============================================================== phones in landscape: side drawer */
.is-short[data-layout='compact'] {
  --cmd-w: 64px;
}
.is-short[data-layout='compact'] .game {
  grid-template-columns: minmax(0, 1fr) var(--cmd-w) 236px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'hud hud panel' 'stage cmd panel';
}
.is-short[data-layout='compact'] .panel { max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--line-2); padding-bottom: 0; }
/* phones held sideways: the command strip is a column between the map and the drawer */
.is-short[data-layout='compact'] .cmd {
  flex-direction: column; height: auto; gap: 8px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  border-top: 0; border-left: 1px solid var(--line);
  box-shadow: -8px 0 20px rgba(0, 0, 0, 0.25);
}
.is-short[data-layout='compact'] .cmd::before { display: none; }
.is-short[data-layout='compact'] .abilities {
  flex-direction: column; width: 100%; padding: 4px 0;
  overflow-x: hidden; overflow-y: auto; touch-action: pan-y;
}
.is-short[data-layout='compact'] .abilities > .ab:first-child { margin: auto 0 0; }
.is-short[data-layout='compact'] .abilities > .ab:last-child { margin: 0 0 auto; }
.is-short[data-layout='compact'] .abilities > .ab:only-child { margin: auto 0; }
.is-short[data-layout='compact'] .cmd__empty-text { display: none; }
.is-short[data-layout='compact'] .cmd.is-placing .touch-place { flex-direction: column-reverse; justify-content: center; gap: 10px; width: 100%; padding: 0 6px; }
.is-short[data-layout='compact'] .touch-place .btn { width: 100%; height: auto; min-height: 48px; padding: 8px 0; flex-direction: column; gap: 3px; border-radius: 12px; }
.is-short[data-layout='compact'] .touch-place__ok { flex: 0 0 auto; min-height: 96px !important; }
.is-short[data-layout='compact'] .touch-place__word { display: none; }
.is-short[data-layout='compact'] .touch-place__label { flex-direction: column; gap: 0; }
.is-short[data-layout='compact'] .touch-place__ok .cr { font-size: 11px; letter-spacing: 0; }
.is-short[data-layout='compact'] .panel[data-view='tower'] { max-height: none; }
.is-short[data-layout='compact'] .drawer-toggle { display: none; }
.is-short[data-layout='compact'] .drawer-head { padding: 6px 8px 4px; }
.is-short[data-layout='compact'] .drawer-head__preview { display: none; }
.is-short[data-layout='compact'] .wave-btn--compact { width: 100%; justify-content: center; }
.is-short.drawer-closed[data-layout='compact'] .panel__body { display: block; }
.is-short[data-layout='compact'] .shop__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.is-short[data-layout='compact'] .tile { min-height: 86px; }
.is-short[data-layout='compact'] .tile__art { width: 38px; height: 38px; }
.is-short[data-layout='compact'] .tile__name { font-size: 11px; line-height: 1.1; }
.is-short[data-layout='compact'] .tp__paths { grid-template-columns: minmax(0, 1fr); }
.is-short[data-layout='compact'] .up__desc { display: none; }
.is-short[data-layout='compact'] .hud { padding-top: 0; height: var(--hud-h); }
/* no drawer-head strip in the side drawer, so the full preview stays in the list */
.is-short[data-layout='compact'] .preview { display: block; }

.coach {
  position: relative;
  display: inline-flex; align-items: center; gap: 10px;
  max-width: 100%;
  padding: 8px 16px 8px 8px; border-radius: 20px;
  font-size: 13.5px; font-weight: 600;
  background: rgba(8, 12, 26, 0.9);
  border: 1px solid rgba(155, 123, 255, 0.55);
  box-shadow: var(--shadow), 0 0 24px rgba(155, 123, 255, 0.2);
  pointer-events: none;
  animation: coachIn 0.5s var(--ease) both;
  transition: opacity 0.2s ease;
}
.coach.is-faded { opacity: 0.18; }
.coach__step { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; font-size: 12px; font-weight: 700; color: #13052b; background: linear-gradient(180deg, #e2d6ff, var(--violet)); }
@keyframes coachIn { from { opacity: 0; transform: translateY(-8px); } }
[data-layout='compact'] .coach { font-size: 12px; padding: 6px 12px 6px 6px; }
.pv--new { border-color: rgba(255, 210, 90, 0.55); background: rgba(255, 200, 80, 0.08); }
.pv__new { position: absolute; top: -7px; right: -5px; padding: 1px 4px; border-radius: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #2b1600; background: var(--gold); box-shadow: 0 0 0 1.5px #0a0d1a; }
.wave-btn__sub:empty { display: none; }

/* ============================================================== touch: targets and text sizes */
/* Every touch target is at least 40 px, and small labels stay readable (about 11 px). */
.is-touch .seg__btn { height: 40px; min-width: 42px; }
.is-touch .hud-btn { height: 40px; min-width: 40px; }
.is-touch .icon-btn { width: 42px; height: 42px; }
.is-touch .icon-btn--sm { width: 40px; height: 40px; }
.is-touch .btn--sm { height: 42px; }
.is-touch .btn--back { height: 44px; }
.is-touch .range input { height: 40px; }
.is-touch .range input::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }
.is-touch .range input::-moz-range-thumb { width: 22px; height: 22px; }
.is-touch .tab { height: 44px; }
.is-touch .seg--sm .seg__btn { height: 40px; }
.is-touch .kv__k { font-size: 11px; letter-spacing: 0.12em; }
.is-touch .up__path { font-size: 11px; letter-spacing: 0.14em; }
.is-touch .up__tier { font-size: 11px; }
.is-touch .mod { width: 16px; height: 16px; font-size: 10.5px; }
.is-touch .hero-tile__role { font-size: 10.5px; }
.is-touch .tp__label { font-size: 11px; }
.is-touch .hero-abil li { min-height: 28px; }
.is-touch .hero-abil__lvl { font-size: 11px; }
.is-touch .over__stat dt, .is-touch .ecard__stats dt, .is-touch .fact__k { font-size: 10.5px; }
.codex__diff .ctow__diff { margin: 0 0 14px; }
.ctow__diff-note { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); }
/* a bar with more abilities than fit scrolls; its edges fade to say so */
.abilities.is-scroll { padding: 0 16px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent); }
.is-short[data-layout='compact'] .abilities.is-scroll { padding: 14px 0; -webkit-mask-image: linear-gradient(180deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); mask-image: linear-gradient(180deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); }
.is-touch .switch { width: 64px; height: 40px; }
.is-touch .switch__knob { top: 3px; left: 3px; width: 32px; height: 32px; }
.is-touch .switch[aria-checked='true'] .switch__knob { transform: translateX(24px); }
.is-touch .stat__l, .is-touch .preview__label { font-size: 11px; }
.is-touch[data-layout='compact'] .stat--wave .stat__l { font-size: 11px; line-height: 1.1; }
.set-row:has(.switch) { flex-wrap: nowrap; }
[data-layout='compact'] .banners { top: 38%; }
.is-touch .keys { grid-template-columns: minmax(0, 1fr); }
.pv--mini.pv--titan .pv__n { display: none; }
.pv--mini.pv--titan { padding: 0 6px; }
