/* 2D presentation layer. Simulation uses percent-based positions in game.js. */
:root {
  --ink: #eef7ff;
  --muted: #8ea7bb;
  --panel: rgba(9, 17, 30, 0.93);
  --line: rgba(120, 198, 231, 0.25);
  --blue: #56d9ff;
  --gold: #ffd37a;
  --red: #ff6677;
}
body {
  background:
    radial-gradient(circle at 15% 10%, #18334a 0, transparent 27rem),
    radial-gradient(circle at 88% 92%, #111f36 0, transparent 31rem), #050a11;
}
#app {
  width: min(1240px, 97vw);
  height: min(780px, 94vh);
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 12px;
}
#arena {
  isolation: isolate;
  border-radius: 14px;
  border: 1px solid #5bb8d655;
  background-color: #0a1722;
  background-image:
    linear-gradient(90deg, rgba(130, 199, 214, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(130, 199, 214, 0.045) 1px, transparent 1px),
    radial-gradient(ellipse at 52% 46%, #183346 0, #0a1722 68%);
  background-size:
    42px 42px,
    42px 42px,
    100% 100%;
  box-shadow:
    0 22px 70px #000b,
    inset 0 0 0 1px #a1e8ff12;
}
#arena::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 2.4%;
  border: 1px solid #a8ebf51e;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 49.7%, #b7f3ff0d 50%, transparent 50.3%),
    linear-gradient(transparent 49.7%, #b7f3ff0d 50%, transparent 50.3%);
}
#arena::after {
  display: none;
}
#reactorDeck,
#reactorDeck * {
  position: absolute;
  pointer-events: none;
}
#reactorDeck {
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.deck-frame {
  background: linear-gradient(180deg, #22384a, #101e2b 45%, #07121d);
  border: 1px solid #83c9da3b;
  box-shadow:
    inset 0 1px #d1fcff1a,
    0 0 12px #00121c;
}
.frame-north,
.frame-south {
  left: 7%;
  right: 7%;
  height: 7%;
}
.frame-north {
  top: -2%;
  border-radius: 0 0 18px 18px;
}
.frame-south {
  bottom: -2%;
  border-radius: 18px 18px 0 0;
}
.frame-west,
.frame-east {
  top: 18%;
  bottom: 18%;
  width: 5.8%;
}
.frame-west {
  left: -1%;
  border-radius: 0 16px 16px 0;
}
.frame-east {
  right: -1%;
  border-radius: 16px 0 0 16px;
}
.service-rail {
  height: 3%;
  width: 20%;
  border-block: 1px solid #79bec844;
  background: repeating-linear-gradient(
    90deg,
    #152a37 0 19px,
    #254353 20px 23px
  );
  opacity: 0.8;
}
.rail-a {
  top: 12%;
  left: 10%;
  transform: rotate(-8deg);
}
.rail-b {
  bottom: 12%;
  right: 9%;
  transform: rotate(-8deg);
}
.rail-c {
  top: 51%;
  right: -5%;
  width: 19%;
  transform: rotate(90deg);
}
.coolant-line {
  height: 1.5%;
  border-radius: 999px;
  background: #50d9ef;
  box-shadow: 0 0 11px #39cde88f;
  opacity: 0.66;
}
.coolant-a {
  width: 19%;
  left: 1%;
  top: 27%;
  transform: rotate(31deg);
}
.coolant-b {
  width: 18%;
  right: 2%;
  bottom: 26%;
  transform: rotate(31deg);
}
.deck-console {
  width: 8%;
  height: 12%;
  border: 1px dashed #79c6d75a;
  border-radius: 50%;
  background: radial-gradient(ellipse, #1a314080, #07121d33 70%);
  box-shadow: inset 0 0 18px #63d9e012;
  padding: 1.3%;
  display: flex;
  gap: 10%;
  align-items: start;
  opacity: 0.66;
}
.console-a {
  left: 4%;
  bottom: 8%;
  transform: rotate(-12deg);
}
.console-b {
  right: 4%;
  top: 8%;
  transform: rotate(168deg);
}
.deck-console::after {
  content: "FLOOR I/O";
  inset: auto 0 13%;
  text-align: center;
  color: #91dce8;
  font: 700 7px/1 monospace;
  letter-spacing: 0.09em;
}
.deck-console i {
  position: relative !important;
  display: block;
  width: 23%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #69e5ff;
  box-shadow: 0 0 6px #69e5ff;
}
.deck-console i:nth-child(2) {
  background: #ffca62;
  box-shadow: 0 0 6px #ffca62;
}
.deck-console i:nth-child(3) {
  background: #ff586c;
  box-shadow: 0 0 6px #ff586c;
}
.reactor-bay {
  width: 19%;
  aspect-ratio: 1;
  right: 5%;
  bottom: 6%;
  opacity: 0.62;
}
.reactor-ring {
  border-radius: 50%;
  border: 2px solid #68dced;
  box-shadow:
    0 0 12px #4ed4e46e,
    inset 0 0 12px #4ed4e449;
}
.ring-outer {
  inset: 3%;
  border-style: dashed;
  animation: reactor-turn 16s linear infinite;
}
.ring-inner {
  inset: 21%;
  border-color: #bedfff;
  animation: reactor-turn 9s linear infinite reverse;
}
.reactor-core {
  inset: 37%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #e7ffff 0 8%,
    #5ee6ff 20%,
    #226b95 55%,
    transparent 70%
  );
  box-shadow: 0 0 20px 8px #48d9fd73;
}
.reactor-bay span {
  inset: auto 0 5%;
  text-align: center;
  color: #b8f6ff;
  font: 700 clamp(8px, 1vw, 12px)/1 monospace;
  letter-spacing: 0.18em;
}
.reactor-bay::after {
  content: "UNDERDECK";
  inset: 47% -15% auto;
  text-align: center;
  color: #c9f8ff;
  font: 700 7px/1 monospace;
  letter-spacing: 0.1em;
}
@keyframes reactor-turn {
  to {
    rotate: 1turn;
  }
}
.hazard-stripe {
  width: 14%;
  height: 2.7%;
  opacity: 0.48;
  background: repeating-linear-gradient(
    135deg,
    #f2b74f 0 7px,
    #5f471c 7px 14px
  );
}
.stripe-a {
  left: 11%;
  top: 8%;
  transform: rotate(23deg);
}
.stripe-b {
  right: 21%;
  bottom: 9%;
  transform: rotate(-33deg);
}
#hud {
  z-index: 5;
  left: 18px;
  right: 18px;
  top: 15px;
}
.label {
  color: #93aabd;
  font-size: 10px;
  letter-spacing: 0.13em;
}
.bar {
  width: clamp(136px, 21vw, 236px);
  height: 9px;
  border-radius: 3px;
  background: #050b11;
  border-color: #8ed7e133;
  box-shadow: inset 0 1px 3px #000;
}
#hpFill {
  background: linear-gradient(90deg, #c83550, #ff7784 70%, #ffd1ae);
}
#xpFill {
  background: linear-gradient(90deg, #247fb3, #51d5f3 70%, #d7ffff);
}
#wave {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px;
  text-shadow: 0 0 18px #61d6ed6e;
}
.entity {
  z-index: 3;
  transition:
    left 0.055s linear,
    top 0.055s linear;
}
#hero {
  width: 40px;
  height: 48px;
  filter: drop-shadow(0 0 8px #3ce4ff);
}
#hero::before {
  content: "";
  position: absolute;
  inset: 10px -9px -8px;
  border-radius: 50%;
  background: radial-gradient(ellipse, #38d9ff50, transparent 65%);
  z-index: -1;
}
#hero .head {
  left: 10px;
  top: 1px;
  width: 21px;
  height: 18px;
  border: 2px solid #bdf7ff;
  border-radius: 7px 7px 5px 5px;
  background: linear-gradient(135deg, #5bd2ec, #1a4e73 43%, #092740);
  box-shadow: inset 0 -4px #0d3655;
}
#hero .visor {
  left: 3px;
  top: 5px;
  width: 12px;
  height: 5px;
  border-radius: 1px;
  background: #d6ffff;
  box-shadow: 0 0 7px #61eaff;
}
#hero .body {
  left: 7px;
  top: 19px;
  width: 27px;
  height: 23px;
  border: 2px solid #a9edfb;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(
    90deg,
    #23648b 0 43%,
    #49b8d1 44% 52%,
    #16466a 53%
  );
}
#hero .arm {
  right: -4px;
  top: 24px;
  width: 18px;
  height: 7px;
  border: 1px solid #b5f9ff;
  border-radius: 2px;
  background: #396f91;
  transform: rotate(-13deg);
  box-shadow: 7px 0 #9df5ff;
}
.hero-leg {
  top: 40px;
  width: 8px;
  height: 9px;
  background: #175578;
  border: 1px solid #8de5f5;
}
.monster {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 8px #ed415f99);
}
.monster .body {
  inset: 7px 5px 3px;
  border: 2px solid #ff7585;
  border-radius: 48% 52% 42% 45%;
  background: linear-gradient(145deg, #c83657, #50162d);
}
.monster .eye {
  top: 13px;
  background: #fff2a4;
  box-shadow: 0 0 4px #fff3ad;
}
.monster .horn {
  background: #f06178;
}
.monster.stalker {
  filter: drop-shadow(0 0 8px #bc69ff);
}
.monster.stalker .body {
  background: linear-gradient(140deg, #9e53ce, #311950);
  border-color: #e0a7ff;
}
.monster.spitter {
  filter: drop-shadow(0 0 9px #92ed72);
}
.monster.spitter .body {
  background: linear-gradient(140deg, #5eb751, #17472f);
  border-color: #c4ff8f;
}
.monster.brute {
  filter: drop-shadow(0 0 12px #ffac4e);
}
.monster.brute .body {
  background: linear-gradient(145deg, #d77b37, #65321e);
  border-color: #ffd070;
}
.monster.boss {
  filter: drop-shadow(0 0 18px #ffc04e);
}
.monster.boss .body {
  background: linear-gradient(145deg, #c84d69, #532038);
  border-color: #ffe59a;
}
.mhp {
  background: #080d13;
  border: 1px solid #ffffff33;
  box-shadow: 0 1px 2px #000;
}
.mhp i {
  background: #ff6478;
}
.shot {
  width: 8px;
  height: 8px;
  z-index: 4;
  background: #f0ffff;
  box-shadow:
    0 0 3px 2px #fff,
    0 0 15px 5px #36d8ff;
}
.float {
  z-index: 6;
  text-shadow:
    0 2px 3px #000,
    0 0 8px currentColor;
}
.world-marker {
  z-index: 2;
}
/* ── Телеграф опасной зоны ───────────────────────────────────────────────
   Зона живёт ровно `--hazard-delay` — переменную ставит `createHazard`
   (`game.js:746`) из своего аргумента задержки: 0.8 с — кислота плевуна
   (`game.js:1033`), 0.9 с и 0.72 с во второй фазе — удар волны босса
   (`game.js:1046`). CSS ЧИТАЕТ эту переменную и берёт её длительностью
   анимации; своего времени не хардкодит, поэтому зона с любой новой
   задержкой получает телеграф автоматически и без правки стилей.

   Связь односторонняя. Урон считает `updateHazards` (`game.js:760`) по
   `remaining` симуляции; анимация — только отражение этого числа и ни на
   один бит боя не влияет. Отсюда и правило: менять здесь время нельзя,
   его источник — аргумент `d` в `createHazard`.

   Что видит игрок:
   1) появление — тусклое янтарное кольцо фиксированного радиуса (сам круг
      поражения, он не растёт и не сжимается: граница честная всё время);
   2) внутри кольца от центра к краю растёт «фитиль» — заливка, чей радиус
      идёт линейно по времени. Зазор между её краем и кольцом и есть ответ
      на «сколько осталось»: сомкнулись — сейчас рванёт;
   3) последние ~12 % времени кольцо белеет и раздувает свечение — момент
      детонации читается иначе, чем момент появления, и виден боковым
      зрением, когда игрок смотрит на своего персонажа.
   Двойной контраст (светлая заливка + тёмный ободок `0 0 0 2px`) держит
   читаемость и на тёмной сетке арены, и на светлых декалях палубы. */
.hazard-marker {
  border-color: #ffbd67;
  box-shadow:
    0 0 0 2px #0b0400b3,
    0 0 18px #ff6c5077;
  animation: hazard-alarm var(--hazard-delay, 0.8s) linear forwards;
}
.hazard-marker::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #ff8b3cc9 0 56%,
    #ffd694e0 78%,
    #fff3d6 100%
  );
  box-shadow: inset 0 0 0 2px #2a0d00a8;
  scale: 0.06;
  animation: hazard-fuse var(--hazard-delay, 0.8s) linear forwards;
}
/* «!» из `index.html` — поверх фитиля: позиционированный ::before рисуется
   выше нерасположенного грид-элемента ::after и иначе его перекроет. */
.hazard-marker::after {
  position: relative;
  z-index: 1;
  text-shadow:
    0 1px 2px #351100,
    0 0 6px #2a0d00;
}
@keyframes hazard-fuse {
  from {
    scale: 0.06;
    opacity: 0.75;
  }
  to {
    scale: 1;
    opacity: 1;
  }
}
@keyframes hazard-alarm {
  0% {
    border-color: #ffbd67;
    box-shadow:
      0 0 0 2px #0b0400b3,
      0 0 10px #ff6c5055;
  }
  70% {
    border-color: #ff9a4d;
    box-shadow:
      0 0 0 2px #0b0400b3,
      0 0 18px #ff6c5099;
  }
  88% {
    border-color: #fff0cf;
    box-shadow:
      0 0 0 2px #0b0400cc,
      0 0 28px 4px #ffb46eaa;
  }
  100% {
    border-color: #ffffff;
    box-shadow:
      0 0 0 3px #0b0400cc,
      0 0 44px 12px #fff0c8;
  }
}
/* Пауза не должна врать. Симуляция на паузе стоит, а таймлайн CSS — нет:
   без этого игрок вернулся бы из меню к «уже сомкнувшемуся» фитилю, имея
   на деле полсекунды форы. Любой видимый оверлей внутри арены = бой не
   идёт, значит отсчёт замирает вместе с ним. */
#arena:has(.overlay:not(.hidden)) .hazard-marker,
#arena:has(.overlay:not(.hidden)) .hazard-marker::before {
  animation-play-state: paused;
}
/* Пониженная анимация (галка «Уменьшить движение» и системный
   `prefers-reduced-motion`): непрерывного движения не остаётся — отсчёт
   квантуется в четыре статичных состояния, `jump-none` даёт первым пустой
   круг, последним — сомкнувшийся. Полностью статичная зона ответила бы
   «здесь опасно», но не «сколько осталось», а это ровно та информация,
   ради которой телеграф и делается, — поэтому деградация дискретная,
   а не выключение. */
.reduced-motion .hazard-marker,
.reduced-motion .hazard-marker::before {
  animation-timing-function: steps(4, jump-none);
}
@media (prefers-reduced-motion: reduce) {
  .hazard-marker,
  .hazard-marker::before {
    animation-timing-function: steps(4, jump-none);
  }
}
.relay-marker {
  border-color: #5ee8ff;
  box-shadow:
    inset 0 0 20px #49d5f63d,
    0 0 15px #49d5f64b;
}
.cache-marker {
  box-shadow:
    inset 0 0 16px #f7b94066,
    0 0 14px #ffc65b50;
}
#tip {
  z-index: 5;
  bottom: 12px;
  padding: 5px 9px;
  border: 1px solid #9bdded28;
  border-radius: 3px;
  background: #07111aa8;
  font-size: 11px;
}
/* ── Подсказка первой встречи с опасной зоной ────────────────────────────
   Та же строка `#tip`, что и обычная справка по управлению, — не оверлей и
   не модальное окно: игрок в этот момент в бою, и отнимать у него кадр
   нельзя. Элемент не интерактивен, в порядок табуляции не входит, фокус и
   навигацию геймпадом не трогает; `aria-live="polite"` (`index.html`)
   проговаривает текст, ничего не перехватывая.
   Живёт подсказка `hintSeconds` секунд СИМУЛЯЦИИ и гаснет сама
   (`updateHazardHint`, `game.js`): на паузе и в магазине она замирает
   вместе с боем. Янтарная палитра — та же, что у самой зоны
   (`.hazard-marker`), чтобы текст и круг читались как одно событие. */
#tip.tip-alert {
  color: #ffe3bd;
  border-color: #ffbd6799;
  background: #2a1102e0;
  box-shadow: 0 0 16px #ff6c5044;
  font-size: 12.5px;
  /* Строка длиннее справки по управлению: на узком экране она обязана
     переноситься, а не уезжать за край арены. */
  white-space: normal;
  max-width: min(92%, 620px);
  text-align: center;
  animation: tip-alert-in 0.22s ease-out;
}
@keyframes tip-alert-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
/* Пониженная анимация: появление гасится, сама подсказка — нет. Она несёт
   текст, а не движение, поэтому выключается ровно въезд снизу. */
.reduced-motion #tip.tip-alert {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  #tip.tip-alert {
    animation: none;
  }
}
#sidebar {
  border-radius: 14px;
  padding: 18px;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(150deg, #142536, #09131f 55%);
  border-color: #5bb8d655;
  box-shadow: 0 22px 70px #000a;
}
h1 {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  font-size: 19px;
}
h1 span {
  color: #60e7ff;
  text-shadow: 0 0 14px #40d8f777;
}
#weapon {
  position: relative;
  padding: 13px;
  overflow: hidden;
  border-radius: 8px;
  border-color: #59d9f666;
  background: linear-gradient(125deg, #20516c99, #0d1e2f);
}
#weapon::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  right: -30px;
  bottom: -40px;
  rotate: 36deg;
  border: 1px solid #8eefff88;
  box-shadow: 0 0 15px #44d7ee88;
}
.weapon-name {
  color: #d2faff;
}
#stats {
  gap: 0;
  border-top: 1px solid #9eeaff1c;
}
.stat {
  padding: 7px 3px;
  border-bottom: 1px solid #9eeaff1c;
  font-size: 12px;
}
.stat b {
  color: #e8faff;
  font-family: ui-monospace, monospace;
}
.sidebar-actions {
  margin-top: auto;
  grid-template-columns: 1fr 1fr;
}
button {
  border-radius: 6px;
  background: linear-gradient(135deg, #8ff2ff, #42b9dd);
  box-shadow:
    inset 0 1px #fff8,
    0 3px 0 #175977;
}
button:hover {
  filter: brightness(1.08);
}
button:active {
  box-shadow: inset 0 2px 4px #07394d;
}
.secondary {
  background: #223949;
  color: #d9f6ff;
  box-shadow: inset 0 0 0 1px #a7eaff4a;
}
.overlay {
  z-index: 20;
  background: #02060cce;
  backdrop-filter: blur(7px);
}
.modal {
  width: min(680px, 92%);
  border-radius: 12px;
  border-color: #71ddec73;
  background: linear-gradient(145deg, #172c3f, #09131f 70%);
  box-shadow:
    0 20px 90px #000,
    inset 0 1px #d9ffff18;
}
.modal h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* Экспорт телеметрии: обычная <textarea>, а не clipboard-API — в iframe и без
   https запись в буфер может быть недоступна, а выделяемый текст работает всегда. */
.telemetry-hint {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.telemetry-output {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #061020;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  resize: vertical;
}
.telemetry-output:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
#telemetryStatus {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}
#objectiveChoices button,
#schoolChoices button {
  background: #122b3b;
  border-color: #4f8797;
  box-shadow: none;
}
#objectiveChoices .selected {
  border-color: #84edff;
  background: #174b61;
}
#weaponInventory {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 4px;
  text-align: left;
}
.weapon-slot {
  min-height: 62px;
  padding: 8px;
  border: 1px solid #82e7f044;
  border-radius: 6px;
  background: #0a1724;
}
.weapon-slot.active {
  border-color: #70ecff;
  box-shadow: inset 0 0 16px #43dff326;
}
#weaponInventory > h3,
#weaponInventory > .shop-help {
  grid-column: 1 / -1;
  margin: 0;
}
#weaponInventory > h3 {
  font-size: 13px;
  color: #d7fbff;
}
.shop-help {
  color: var(--muted);
  font-size: 11px;
}
.weapon-slot h3 {
  margin: 0 0 4px;
  font-size: 11px;
  color: #caf9ff;
}
.weapon-slot h4 {
  margin: 0 0 4px;
  color: #caf9ff;
  font-size: 11px;
  line-height: 1.25;
}
.weapon-slot p {
  min-height: 0;
  margin: 0;
  font-size: 10px;
}
.weapon-slot button {
  margin-top: 5px;
  padding: 5px;
  width: 100%;
  font-size: 10px;
  box-shadow: none;
}
.weapon-actions {
  display: grid;
  gap: 4px;
  margin-top: 7px;
}
.weapon-actions button {
  margin: 0;
}
#shopItems {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.item {
  padding: 11px;
  border-radius: 7px;
  background: linear-gradient(145deg, #102536, #0b1722);
  border-color: #83e5ed2b;
}
.item.weapon-item {
  border-color: #b58aff85;
  background: linear-gradient(145deg, #241c42, #101629);
}
.item.owned-weapon {
  opacity: 0.72;
}
.item h3 {
  color: #ddfaff;
}
.item button {
  border-radius: 4px;
  box-shadow: none;
}
@media (max-width: 860px) {
  #app {
    height: 96vh;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  #sidebar {
    padding: 11px 13px;
    display: grid;
    grid-template-columns: 1.15fr 1.3fr 1.3fr;
    align-items: center;
    gap: 9px 13px;
  }
  #sidebar h1 {
    display: none;
  }
  #weapon {
    grid-row: span 2;
  }
  #stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0 8px;
  }

  #sidebar {
    scrollbar-color: #52cde4 #09131f;
  }
  .sidebar-actions {
    margin: 0;
  }
  #dashText,
  #objectiveText,
  #schoolText {
    font-size: 9px;
  }
  .reactor-bay {
    width: 22%;
  }
}
@media (max-width: 560px) {
  body {
    overflow: auto;
  }
  #app {
    width: 100vw;
    height: 100dvh;
    gap: 0;
    grid-template-rows: minmax(0, 1fr) 174px;
  }
  #arena {
    border-radius: 0;
    border-inline: 0;
  }
  #sidebar {
    border-radius: 0;
    border-inline: 0;
    grid-template-columns: 1fr 1.25fr;
    overflow: auto;
  }
  #weapon {
    grid-row: span 2;
  }
  #stats {
    grid-template-columns: repeat(2, 1fr);
    font-size: 10px;
  }
  #hud {
    left: 12px;
    right: 12px;
    top: 10px;
  }
  .bar {
    width: 125px;
  }
  #tip {
    max-width: 86%;
    white-space: normal;
    text-align: center;
  }
  #wave {
    font-size: 25px;
  }
  #objectiveChoices,
  #schoolChoices {
    grid-template-columns: 1fr;
  }
  #shopItems {
    grid-template-columns: repeat(2, 1fr);
  }
  #weaponInventory {
    grid-template-columns: repeat(2, 1fr);
  }
  .modal {
    padding: 20px 14px;
  }
  .deck-console {
    width: 12%;
  }
  .reactor-bay {
    right: 2%;
    bottom: 2%;
    width: 25%;
  }
}
.reduced-motion .entity,
.reduced-motion .fill,
.reduced-motion button {
  transition: none !important;
}
.reduced-motion .float,
.reduced-motion .reactor-ring {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .reactor-ring {
    animation: none !important;
  }
}

/* Stat names grow with the build. Keep each value in its own usable cell. */
.stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px;
}

.stat span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.stat b {
  white-space: nowrap;
}

@media (max-width: 560px) and (orientation: portrait) {
  #app {
    grid-template-rows: minmax(0, 1fr) 205px;
  }

  #sidebar {
    overscroll-behavior: contain;
    scrollbar-color: #52cde4 #09131f;
  }

  .overlay {
    position: fixed;
    inset: 0;
  }

  #arena:has(.overlay:not(.hidden)) {
    z-index: 60;
    overflow: visible;
  }

  .modal {
    max-height: min(92dvh, 760px);
  }
}

/* A narrow landscape screen is a desktop-like combat view, not a stacked phone. */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 560px) {
  body {
    overflow: hidden;
  }

  #app {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    grid-template-columns: minmax(0, 1fr) minmax(232px, 31vw);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
  }

  #sidebar {
    min-height: 0;
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #52cde4 #09131f;
  }

  #sidebar h1 {
    display: none;
  }

  #weapon {
    grid-row: auto;
    padding: 9px;
  }

  #stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 9px;
  }

  .stat {
    min-width: 0;
    padding: 4px 1px;
    font-size: 10px;
  }

  #dashText,
  #objectiveText,
  #schoolText {
    font-size: 8px;
  }

  .sidebar-actions {
    flex: 0 0 auto;
    margin-top: 0;
  }

  .sidebar-actions button {
    padding: 8px 5px;
    font-size: 11px;
  }

  .overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
  }

  #arena:has(.overlay:not(.hidden)) {
    z-index: 60;
    overflow: visible;
  }

  .modal {
    width: min(680px, 94vw);
    max-height: 94dvh;
    padding: 16px;
  }

  .modal h2 {
    font-size: 23px;
  }

  #weaponInventory,
  #shopItems {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .item,
  .weapon-slot {
    min-width: 0;
    padding: 8px;
  }

  .item h3,
  .weapon-slot h3 {
    overflow-wrap: anywhere;
  }
}

/* Inventory headings span the grid; weapon cards share the offer typography. */
#weaponInventory > h3,
#weaponInventory > .shop-help {
  grid-column: 1 / -1;
  margin: 0;
}
#weaponInventory > .shop-help {
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 6px;
}
.weapon-slot h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #caf9ff;
  overflow-wrap: anywhere;
}
.weapon-slot.active {
  border-color: #73e4ef;
}
.weapon-actions {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}
.weapon-actions button {
  min-height: 32px;
  margin: 0;
}
#sidebar {
  min-height: 0;
  overflow-y: auto;
}

/* Long builds scroll instead of compressing the weapon summary. */
#sidebar > * {
  flex-shrink: 0;
}
#sidebar,
.modal {
  scrollbar-width: thin;
  scrollbar-color: #41677c #0b1722;
  color-scheme: dark;
}
.sidebar-actions {
  position: sticky;
  bottom: -1px;
  background: #0b1722;
  padding: 8px 0 2px;
  z-index: 2;
}

/* Position interpolation belongs to the simulation, not layout transitions. */
.entity { transition: none; }

/* Hundreds of independently blurred layers dominate low-end GPU paint time. */
.monster, .monster.stalker, .monster.spitter, .monster.brute, .monster.boss { filter: none; }
.shot { box-shadow: none; }

#battleView { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:2; }
.canvas-combat .monster, .canvas-combat .shot { display:none; }

/* Реролл витрины: отдельная строка между товарами и выходом в волну. Кнопка
   штатная <button> внутри #shopOverlay — поэтому она автоматически попадает в
   menuControls() (game.js), то есть проходима табом и крестовиной геймпада без
   отдельной ветки навигации. Заблокированную кнопку обход пропускает сам. */
#shopRerollRow {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 0 14px;
}
#shopReroll {
  width: min(320px, 100%);
  padding: 9px 12px;
  font-size: 12px;
  margin: 0;
}
#shopRerollHint {
  margin: 0;
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}
