/* ============================================================================
   Two Sides — style.css  (SPEC §9 лэйаут, §11 палитра, §13 анимации, §15 адаптив)
   Чистый CSS, без сети/шрифтов/CDN. Пиксель-арт ретро в бренд-палитре ShieldSafe.
   ========================================================================== */

:root {
  /* §11 — бренд-палитра ShieldSafe */
  --bg-deep:     #0b1120;
  --bg-panel:    #0f172a;
  --bg-panel-2:  #111c33;
  --cyan:        #06b6d4;
  --cyan-bright: #22d3ee;
  --indigo:      #6366f1;
  --indigo-lite: #a5b4fc;
  --red:         #f43f5e;
  --red-bright:  #fb7185;
  --amber:       #f59e0b;
  --amber-lite:  #fcd34d;
  --green:       #22c55e;
  --outline:     #04141f;
  --text:        #e2f2f7;
  --text-dim:    #7c9bb0;

  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;

  --radius: 6px;
  --turn: 180ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Пиксель-арт: без сглаживания при апскейле */
.px,
img.px {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  display: block;
}

/* ── Корень игры ─────────────────────────────────────────────────────────── */
.game-root {
  position: relative;
  z-index: 1;                 /* над фоном-сеткой (body::before, z-index:0) */
  width: 100%;
  max-width: 720px;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;    /* фон-сетка вынесена на body::before — во всю ширину экрана */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Фон-сетка + радиальное свечение + дрейф — на ВСЮ ширину вьюпорта (за столом).
   position:fixed → выпадает из flex-потока body (не становится flex-элементом),
   центрирование .game-root не нарушается. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 50% -8%, rgba(34, 211, 238, 0.10), transparent 60%),
    url("assets/bg-grid.png") repeat,
    var(--bg-deep);
  background-size: auto, 96px 96px, auto;
  animation: grid-drift 24s linear infinite;
}

/* ── Экраны ──────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  width: 100%;
  padding: 18px;
  /* min-height:0 + overflow-y:auto — защита от обрезки на коротких портретах:
     если контент (особенно с баннером IDS) выше вьюпорта, экран скроллится,
     а sticky-кнопка «Защитить» остаётся доступной. На десктопе/высоких экранах
     контент влезает (арена flex:1 поглощает слабину) — скролл не появляется. */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.screen.is-active { display: flex; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* ── Текст / ретро-заголовки ─────────────────────────────────────────────── */
.t-blue { color: var(--cyan-bright); }
.t-red  { color: var(--red-bright); }
.muted  { color: var(--text-dim); }

.stat-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Кнопки ──────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  color: var(--bg-deep);
  background: linear-gradient(180deg, var(--cyan-bright), var(--cyan));
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  padding: 13px 26px;
  cursor: pointer;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.4), 0 6px 18px rgba(6, 182, 212, 0.28);
  transition: transform var(--turn) ease, box-shadow var(--turn) ease, filter var(--turn) ease, opacity var(--turn) ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover  { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 0 0 1px var(--cyan-bright), 0 10px 26px rgba(6, 182, 212, 0.42); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--cyan-bright); outline-offset: 2px; }

.btn-ghost {
  background: transparent;
  color: var(--cyan-bright);
  border: 2px solid var(--cyan);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(6, 182, 212, 0.12); box-shadow: none; }

.btn-resolve { width: auto; align-self: center; margin-top: 4px; }

/* ── Кнопка mute (глобально) ─────────────────────────────────────────────── */
.mute-btn {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 30;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: rgba(15, 23, 42, 0.8);
  color: var(--cyan-bright);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--turn) ease, background var(--turn) ease;
}
.mute-btn:hover { transform: scale(1.08); background: rgba(6, 182, 212, 0.18); }
.mute-btn:active { transform: scale(0.92); }
.mute-btn .mute-off { display: none; }
.mute-btn.is-muted { color: var(--text-dim); border-color: var(--text-dim); }
.mute-btn.is-muted .mute-on  { display: none; }
.mute-btn.is-muted .mute-off { display: inline; font-size: 22px; line-height: 1; }

/* ════════════════ МЕНЮ ════════════════ */
#screen-menu { align-items: center; text-align: center; }
.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 460px;
  /* margin:auto центрирует по вертикали при наличии места, но при переполнении
     схлопывается в 0 — контент не обрезается сверху и доступен скроллом. */
  margin: auto;
  animation: float-in 520ms ease both;
}
@keyframes float-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.menu-logo {
  width: 84px; height: 84px;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.6));
  animation: logo-bob 3.4s ease-in-out infinite;
}
@keyframes logo-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.menu-title {
  width: min(360px, 78vw);
  height: auto;
  filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.35)) drop-shadow(0 0 12px rgba(34, 211, 238, 0.35));
}
/* Текстовый дубль тайтла — скрыт визуально (есть спрайт), доступен скринридеру */
.menu-title-text {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden;
}

.menu-sub {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  margin: 2px 0 6px;
}
.menu-tag {
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 0 0;
  line-height: 1.5;
}
.menu-foot {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.powered {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan-bright);
  opacity: 0.85;
}
.powered img { filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.6)); }
.menu-copy { color: var(--text-dim); text-decoration: none; }
.menu-copy:hover { color: var(--cyan-bright); }

/* Возврат на лендинг: игра открывается ПЕРЕХОДОМ в той же вкладке
   (landing: window.location.href='/game/'), поэтому обратной дороги, кроме
   кнопки «назад» браузера, не было. Ссылка ведёт на лендинг нужного языка. */
.back-link {
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: 14px;
  transition: color var(--turn) ease, border-color var(--turn) ease, background var(--turn) ease;
}
.back-link:hover { color: var(--cyan-bright); border-color: var(--cyan); background: rgba(6, 182, 212, 0.12); }

/* ════════════════ БОЙ ════════════════ */
#screen-battle { gap: 12px; padding: 16px 16px 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* Место под ДВЕ плавающие кнопки в правом верхнем углу (звук + язык),
     иначе «Ход X/Y» уезжает под кружок EN. Кластер кнопок занимает ~104px от края. */
  padding-right: 112px;
}
.topbar-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.badge-ss { filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.7)); flex: none; }
.level-name { font-size: 14px; font-weight: 700; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { font-size: 13px; letter-spacing: 1px; color: var(--text); }
#turn-cur { color: var(--cyan-bright); font-weight: 700; }

/* Статус-бар */
.statusbar {
  background: linear-gradient(180deg, rgba(17, 28, 51, 0.92), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: var(--radius);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.stat-row { display: flex; align-items: center; gap: 10px; }
.hp-row { width: 100%; }
.hp-bar {
  flex: 1;
  height: 14px;
  background: #081020;
  border: 2px solid var(--outline);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.12);
}
.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-bright));
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.55);
  transition: width 420ms cubic-bezier(.2,.7,.2,1), background 300ms ease;
}
.hp-fill.is-warn { background: linear-gradient(90deg, var(--amber), var(--amber-lite)); box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
.hp-fill.is-crit { background: linear-gradient(90deg, var(--red), var(--red-bright)); box-shadow: 0 0 10px rgba(244, 63, 94, 0.55); }
.stat-val { font-size: 13px; font-weight: 700; min-width: 30px; text-align: right; }

.meta-row { justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; }
.rep-block, .kc-block { display: flex; align-items: center; gap: 8px; }
.rep-stars { font-size: 14px; color: var(--amber-lite); letter-spacing: 2px; text-shadow: 0 0 6px rgba(252, 211, 77, 0.4); }

/* Kill-chain точки */
.kc-dots { display: inline-flex; gap: 5px; }
.kc-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #0c1830;
  border: 2px solid #233152;
  transition: background var(--turn) ease, box-shadow var(--turn) ease, border-color var(--turn) ease, transform var(--turn) ease;
}
.kc-dot.lit {
  background: var(--red);
  border-color: var(--red-bright);
  box-shadow: 0 0 9px rgba(244, 63, 94, 0.8);
}
.kc-dot.just-lit { animation: dot-pop 420ms ease; }
@keyframes dot-pop { 0% { transform: scale(0.4); } 55% { transform: scale(1.55); } 100% { transform: scale(1); } }
.kc-stage { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--amber-lite); }
.kc-stage.danger { color: var(--red-bright); }

/* Баннер IDS */
.ids-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.16), rgba(99, 102, 241, 0.12));
  border: 1px solid var(--cyan);
  border-left: 4px solid var(--cyan-bright);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--cyan-bright);
  font-weight: 700;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.2);
  animation: banner-drop 320ms cubic-bezier(.2,.8,.2,1) both;
}
.ids-banner[hidden] { display: none; }
@keyframes banner-drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* ── Арена ───────────────────────────────────────────────────────────────── */
.arena {
  position: relative;
  flex: 1;
  min-height: 168px;
  display: grid;
  grid-template-columns: 1fr minmax(80px, 1.4fr) 1fr;
  align-items: center;
  justify-items: center;
  background:
    radial-gradient(120px 80px at 22% 60%, rgba(6, 182, 212, 0.16), transparent 70%),
    radial-gradient(120px 80px at 78% 60%, rgba(244, 63, 94, 0.16), transparent 70%);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 10px;
  overflow: hidden;
  padding: 8px;
}
.arena.shake { animation: shake 360ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.side { display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 2; }
.side-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; }

.server-img {
  width: 88px; height: 88px;
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.45));
}
.server-img.win-pulse { animation: win-pulse 900ms ease-in-out infinite; }
@keyframes win-pulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.45)); transform: scale(1); }
  50%      { filter: drop-shadow(0 0 24px rgba(34, 211, 238, 0.9));  transform: scale(1.06); }
}
.hacker-img {
  width: 88px; height: 88px;
  filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.4));
}
.hacker-img.lunge { animation: lunge 360ms ease; }
@keyframes lunge { 0% { transform: none; } 40% { transform: translateX(-10px) scale(1.06); } 100% { transform: none; } }

.lane { position: relative; width: 100%; height: 100%; z-index: 3; pointer-events: none; }

/* Летящий снаряд-атака */
.attack-fly {
  position: absolute;
  top: 50%;
  width: 52px; height: 52px;
  margin-top: -26px;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.7));
}
.attack-fly[hidden] { display: none; }
.attack-fly.fly {
  animation: fly-in 360ms cubic-bezier(.45,.05,.55,.95) forwards;
}
@keyframes fly-in {
  from { right: -10%; opacity: 0; transform: scale(0.7) rotate(-8deg); }
  20%  { opacity: 1; }
  to   { right: 86%; opacity: 1; transform: scale(1.05) rotate(8deg); }
}

/* Вспышка над сервером (блок/удар) */
.fx-server {
  position: absolute;
  top: 50%; left: 4%;
  width: 56px; height: 56px;
  margin-top: -28px;
}
.fx-server[hidden] { display: none; }
.fx-server.burst { animation: fx-burst 480ms ease forwards; }
@keyframes fx-burst {
  0%   { opacity: 0; transform: scale(0.3); }
  35%  { opacity: 1; transform: scale(1.25); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* Плавающая подпись (BLOCK / -20 HP) */
.float-msg {
  position: absolute;
  left: 8%;
  top: 18%;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 2px 0 var(--outline);
  white-space: nowrap;
}
.float-msg[hidden] { display: none; }
.float-msg.block { color: var(--cyan-bright); }
.float-msg.hit   { color: var(--red-bright); }
.float-msg.show  { animation: float-up 760ms ease forwards; }
@keyframes float-up {
  0%   { opacity: 0; transform: translateY(6px) scale(0.8); }
  20%  { opacity: 1; transform: translateY(0) scale(1.1); }
  80%  { opacity: 1; transform: translateY(-16px) scale(1); }
  100% { opacity: 0; transform: translateY(-26px) scale(1); }
}

/* ── Контролы ────────────────────────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 11px; }
.budget-row { display: flex; align-items: center; gap: 8px; }
.budget-pips { display: inline-flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.bpip {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: #0c1830;
  border: 2px solid #1c2b4a;
  transition: background var(--turn) ease, box-shadow var(--turn) ease;
}
.bpip.on {
  background: linear-gradient(180deg, var(--amber-lite), var(--amber));
  border-color: var(--amber);
  box-shadow: 0 0 7px rgba(245, 158, 11, 0.55);
}

/* Рука карт */
.hand {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 8px;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border: 2px solid #21304f;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--mono);
  color: var(--text);
  min-height: 92px;
  transition: transform var(--turn) ease, border-color var(--turn) ease, box-shadow var(--turn) ease, opacity var(--turn) ease, background var(--turn) ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.card:hover { transform: translateY(-3px); border-color: var(--cyan); box-shadow: 0 6px 16px rgba(6, 182, 212, 0.2); }
.card:focus-visible { outline: 2px solid var(--cyan-bright); outline-offset: 2px; }
.card .card-icon { width: 40px; height: 40px; image-rendering: pixelated; }
.card .card-name { font-size: 12px; font-weight: 700; letter-spacing: 0.3px; text-align: center; line-height: 1.1; }
.card .card-cost {
  font-size: 11px;
  color: var(--amber-lite);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.card .card-cost b { color: var(--amber-lite); font-weight: 800; }

.card.is-ids { border-color: rgba(34, 211, 238, 0.4); }
.card.is-ids .card-icon { filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.6)); }

/* Поставленная карта */
.card.placed {
  border-color: var(--cyan-bright);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.18), rgba(6, 182, 212, 0.08));
  box-shadow: 0 0 0 1px var(--cyan-bright), 0 0 16px rgba(34, 211, 238, 0.35);
  transform: translateY(-2px);
}
/* Бейдж «поставлено» — язык-нейтральный (✓), чтобы не ломать i18n RU/EN.
   Текстовую подпись (если нужна) рисует game.js. */
.card.placed::after {
  content: "✓";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.5px;
  background: var(--cyan-bright);
  color: var(--bg-deep);
  font-weight: 900;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  animation: placed-pop 260ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes placed-pop { 0% { transform: translateX(-50%) scale(0.2); } 60% { transform: translateX(-50%) scale(1.25); } 100% { transform: translateX(-50%) scale(1); } }
.card.just-pick { animation: card-pick 240ms ease; }
@keyframes card-pick { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: translateY(-2px) scale(1); } }

/* Недоступна (не хватает бюджета) */
.card.disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.card.disabled:hover { transform: none; border-color: #21304f; box-shadow: none; }

/* Tooltip-подсказка (desktop hover) */
.card .card-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max(160px, 100%);
  max-width: 220px;
  background: #07101f;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--turn) ease, transform var(--turn) ease;
  z-index: 12;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}
.card:hover .card-tip { opacity: 1; transform: translateX(-50%) translateY(0); }

.card-help {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  text-align: center;
  margin: 0;
  min-height: 2.6em;
}
.card-help b { color: var(--cyan-bright); }

/* ════════════════ РЕЗУЛЬТАТ ════════════════ */
#screen-result { align-items: center; text-align: center; }
.result-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 480px;
  margin: auto; /* см. .menu-inner — центр + безопасный скролл при переполнении */
  animation: float-in 460ms ease both;
}
.result-art {
  width: 96px; height: 96px;
}
.result-art.win  { filter: drop-shadow(0 0 18px rgba(34, 211, 238, 0.8)); animation: win-pulse 1.1s ease-in-out infinite; }
.result-art.lose { filter: drop-shadow(0 0 16px rgba(244, 63, 94, 0.7)); }

.result-title {
  font-size: 26px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0;
}
.result-title.win  { color: var(--cyan-bright); text-shadow: 0 0 18px rgba(34, 211, 238, 0.6); }
.result-title.lose { color: var(--red-bright);  text-shadow: 0 0 18px rgba(244, 63, 94, 0.55); }
.result-subtitle { font-size: 14px; color: var(--amber-lite); margin: -6px 0 0; letter-spacing: 1px; text-transform: uppercase; }

.result-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  margin: 6px 0;
  padding: 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
}
.sum-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sum-num { font-size: 22px; font-weight: 800; }
.sum-lbl { font-size: 9.5px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-dim); text-align: center; line-height: 1.2; }

.result-pitch {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin: 2px 0 4px;
}
.result-pitch b { color: var(--cyan-bright); }
.result-foot { margin-top: 6px; }

/* ════════════════ АДАПТИВ (мобила-портрет) ════════════════ */
@media (max-width: 560px) {
  /* Экран боя целиком вписывается в высоту вьюпорта и скроллится ВНУТРИ себя
     (а не документ). Без этого .game-root разрастался выше экрана, скроллился
     документ, и sticky-кнопка «Защитить» пиналась к низу off-screen .screen —
     то есть уезжала за нижний край. Теперь скроллер = .screen → sticky работает. */
  .game-root { height: 100vh; height: 100dvh; }

  .screen { padding: 12px 12px; }
  #screen-battle { gap: 8px; padding: 10px 12px 12px; }

  /* Шапка: клиренс под звук+язык чуть меньше (кнопки на мобиле поджаты). */
  .topbar { padding-right: 104px; }
  .topbar-right { white-space: nowrap; }

  .statusbar { padding: 8px 10px; gap: 6px; }
  /* Плавающие кнопки звука/языка (absolute, правый верхний угол) на мобиле
     накрывают ПЕРВУЮ строку статус-бара: значение HP оказывалось прямо под
     кружком ♪ и было нечитаемо (проверено на 390px и 360px). Резервируем справа
     полосу под кластер кнопок — тем же приёмом, что уже применён к .topbar. */
  .hp-row { padding-right: 86px; }
  .meta-row { flex-direction: column; align-items: flex-start; gap: 6px; }

  .threat-row { gap: 8px; }

  .arena { min-height: 120px; grid-template-columns: 1fr 1fr 1fr; }
  .server-img, .hacker-img { width: 62px; height: 62px; }

  .controls { gap: 8px; }

  /* Рука 2×2 */
  .hand { grid-template-columns: repeat(2, 1fr); gap: 7px; padding-bottom: 4px; }
  .card { min-height: 76px; padding: 8px 6px 7px; }
  .card .card-icon { width: 34px; height: 34px; }
  .card-help { min-height: 2em; font-size: 11.5px; }

  /* Кнопка «Защитить» — липкая панель действия у низа вьюпорта: ВСЕГДА видна,
     пока карты скроллятся выше. Бэкдроп ::before гасит карты под верхним краем,
     сам фон-градиент кнопки закрывает область под текстом. padding-bottom с
     safe-area — фон доходит до самого низа, текст остаётся над home-indicator. */
  .btn-resolve {
    width: 100%;
    align-self: stretch;
    position: sticky;
    bottom: 0;
    z-index: 30;
    margin-top: 2px;
    padding-top: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .btn-resolve::before {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -16px;
    height: 18px;
    width: 100vw;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(11, 17, 32, 0), var(--bg-deep));
  }

  /* На узких экранах tip может вылезать — подавляем hover-tip (есть card-help) */
  .card .card-tip { display: none; }

  .menu-title { width: min(320px, 84vw); }
  .result-title { font-size: 22px; }
  .result-summary { grid-template-columns: repeat(2, 1fr); }
  .sum-num { font-size: 20px; }
}

@media (max-width: 360px) {
  .card .card-name { font-size: 11px; }
  .topbar { padding-right: 98px; }
  .arena { min-height: 106px; }
  .server-img, .hacker-img { width: 56px; height: 56px; }
  .card { min-height: 72px; }
  .card .card-icon { width: 32px; height: 32px; }
}

/* ════════════════ Reduced motion (§13) ════════════════ */
@media (prefers-reduced-motion: reduce) {
  .arena.shake { animation: none; }
  .hacker-img.lunge { animation: none; }
  .attack-fly.fly { animation: fly-fade 200ms ease forwards; }
  @keyframes fly-fade { from { opacity: 0; right: 40%; } to { opacity: 1; right: 60%; } }
  .menu-logo, .server-img.win-pulse, .result-art.win { animation: none; }
  .float-msg.show { animation: float-fade 600ms ease forwards; }
  @keyframes float-fade { 0% { opacity: 0; } 20%,80% { opacity: 1; } 100% { opacity: 0; } }
  .kc-dot.just-lit, .card.just-pick { animation: none; }
  * { scroll-behavior: auto; }
}

/* ════════════════════════════════════════════════════════════════════════════
   JUICE LAYER  (динамика/«сочность» поверх MVP — без правок .js/.html)
   Все классы/DOM-id ниже совпадают дословно с контрактом PRESENTATION.
   Элементы создаёт game.js; CSS устойчив к их отсутствию (no-op без DOM).
   ════════════════════════════════════════════════════════════════════════════ */

/* ── 1. CRT-оверлей + дрейф сетки + неон ──────────────────────────────────── */
/* Лёгкий дрейф фоновой сетки (parallax) — оживляет статичный фон.
   Радиальная подсветка (1-й слой) держится на месте, плывёт только grid.
   Анимация применена к body::before (фон-сетка во всю ширину экрана). */
@keyframes grid-drift {
  from { background-position: 50% -10%, 0 0,      0 0; }
  to   { background-position: 50% -10%, 96px 96px, 0 0; }
}

/* Полноэкранный CRT-слой: scanlines + vignette + опц. flicker.
   pointer-events:none — клики проходят сквозь. game.js вставляет .crt-overlay. */
.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  mix-blend-mode: multiply;
}
.crt-overlay::before {           /* scanlines */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(0, 0, 0, 0)    0px,
    rgba(0, 0, 0, 0)    2px,
    rgba(2, 8, 16, 0.20) 3px
  );
  background-size: 100% 3px;
  opacity: 0.55;
}
.crt-overlay::after {            /* vignette + лёгкий cyan-bloom по краям */
  content: "";
  position: absolute;
  inset: 0;
  box-shadow:
    inset 0 0 120px 10px rgba(0, 0, 0, 0.55),
    inset 0 0 30px 0 rgba(34, 211, 238, 0.05);
  mix-blend-mode: normal;
}
.crt-overlay.flicker { animation: crt-flicker 5.5s steps(1) infinite; }
@keyframes crt-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.86; }
  98% { opacity: 1; }
  99% { opacity: 0.92; }
}

/* Неон-glow усиление статичных надписей (дёшево, оживляет) */
.level-name   { text-shadow: 0 0 8px rgba(34, 211, 238, 0.35); }
.side-label.t-blue { text-shadow: 0 0 8px rgba(34, 211, 238, 0.5); }
.side-label.t-red  { text-shadow: 0 0 8px rgba(244, 63, 94, 0.5); }

/* ── 2. Раздача карт (stagger) + screen-flash ─────────────────────────────── */
/* game.js ставит inline style="animation-delay:Nms" на каждую карту. */
.card.deal-in { animation: deal-in 340ms cubic-bezier(.2, .85, .25, 1) both; }
@keyframes deal-in {
  0%   { opacity: 0; transform: translateY(22px) scale(0.88) rotate(-3deg); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* Полноэкранная цветная вспышка по событию (удар/блок/крит). */
.screen-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 55;
  mix-blend-mode: screen;
}
.screen-flash.flash-hit   { background: radial-gradient(circle at 28% 52%, rgba(244, 63, 94, 0.65), transparent 68%); }
.screen-flash.flash-block { background: radial-gradient(circle at 28% 52%, rgba(34, 211, 238, 0.60), transparent 68%); }
.screen-flash.flash-crit  { background: radial-gradient(circle at 50% 50%, rgba(252, 211, 77, 0.75), rgba(244, 63, 94, 0.45) 55%, transparent 78%); }
.screen-flash.fx-flash    { animation: screen-flash 380ms ease forwards; }
.screen-flash.fx-flash.flash-crit { animation: screen-flash-crit 520ms ease forwards; }
@keyframes screen-flash      { 0% { opacity: 0; } 12% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes screen-flash-crit { 0% { opacity: 0; } 8% { opacity: 0.9; } 30% { opacity: 0.4; } 45% { opacity: 0.8; } 100% { opacity: 0; } }

/* ── 3. Частицы (спарки/осколки) + усиленный шейк на крите ─────────────────── */
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}
/* game.js задаёт inline CSS-переменные: --dx --dy --r --dur (разлёт+вращение). */
.particle {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 2px;
  will-change: transform, opacity;
  pointer-events: none;
}
.particle.particle-fly {
  animation: particle-fly var(--dur, 600ms) cubic-bezier(.18, .6, .3, 1) forwards;
}
@keyframes particle-fly {
  from { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  to   { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.25) rotate(var(--r, 180deg)); opacity: 0; }
}
.p-spark { width: 4px; height: 4px; border-radius: 50%; }
.p-shard { width: 7px; height: 3px; border-radius: 1px; }
.p-cyan  { background: var(--cyan-bright); box-shadow: 0 0 7px rgba(34, 211, 238, 0.9); }
.p-red   { background: var(--red-bright);  box-shadow: 0 0 7px rgba(244, 63, 94, 0.9); }
.p-amber { background: var(--amber-lite);  box-shadow: 0 0 7px rgba(245, 158, 11, 0.9); }

/* Крит — более жёсткий шейк арены (с микро-поворотом). */
.arena.shake-hard { animation: shake-hard 460ms cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake-hard {
  10%, 90% { transform: translate(-5px, 1px) rotate(-0.6deg); }
  20%, 80% { transform: translate(7px, -2px) rotate(0.6deg); }
  30%, 50%, 70% { transform: translate(-9px, 2px) rotate(-0.8deg); }
  40%, 60% { transform: translate(9px, -1px) rotate(0.8deg); }
}

/* ── 4. Заряд хакера / телеграф угрозы / charge-meter / фаза kill-chain / hp-ghost ─ */
.side { position: relative; }   /* якорь для абсолютных тэллов/мэтров */

.hacker-img.charge { animation: hacker-charge 820ms ease-in-out; transform-origin: 70% 60%; }
@keyframes hacker-charge {
  0%   { transform: none;                        filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.4)); }
  35%  { transform: translateX(5px) scale(1.05); filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.85)); }
  70%  { transform: translateX(7px) scale(1.04); filter: drop-shadow(0 0 22px rgba(244, 63, 94, 0.9)); }
  100% { transform: none;                        filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.4)); }
}

/* Телеграф вектора (намёк, не спойлер): цветной чип у хакера. */
.threat-tell {
  position: absolute;
  top: -8px; right: 2px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; letter-spacing: 0.5px;
  border: 2px solid var(--outline);
  border-radius: 10px;
  opacity: 0; transform: scale(0.5);
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 7;
  white-space: nowrap;
}
.threat-tell.show { opacity: 1; transform: scale(1); animation: tell-pulse 1.1s ease-in-out infinite; }
@keyframes tell-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.tt-network { background: var(--amber);  color: #1b1205; box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
.tt-web     { background: var(--red);    color: #fff;    box-shadow: 0 0 12px rgba(244, 63, 94, 0.6); }
.tt-auth    { background: var(--indigo); color: #fff;    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6); }

/* Индикатор «заряда» атаки под хакером. */
.charge-meter {
  width: 64px; height: 6px;
  margin-top: 2px;
  background: #0c1830;
  border: 2px solid var(--outline);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.18);
}
.charge-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--amber), var(--red));
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.55);
  transition: width 520ms cubic-bezier(.2, .7, .2, 1), background 300ms ease;
}
/* Стадия kill-chain (если game.js не задаёт inline width — fallback по классу). */
.charge-fill.stage-0 { width: 8%; }
.charge-fill.stage-1 { width: 30%; }
.charge-fill.stage-2 { width: 55%; }
.charge-fill.stage-3 { width: 80%; background: linear-gradient(90deg, var(--amber), var(--red-bright)); }
.charge-fill.stage-4 { width: 100%; background: linear-gradient(90deg, var(--red), var(--red-bright)); box-shadow: 0 0 12px rgba(244, 63, 94, 0.7); }

/* Текущая стадия kill-chain — пульсирующая точка. */
.kc-dot.active-phase {
  box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.45), 0 0 10px rgba(245, 158, 11, 0.7);
  animation: phase-pulse 1.2s ease-in-out infinite;
}
@keyframes phase-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.28); } }

/* «Призрак» HP — красный след за основным баром, показывает только что снятый урон. */
.hp-bar  { position: relative; }
.hp-fill { position: relative; z-index: 2; }
.hp-ghost {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 100%;
  z-index: 1;
  background: linear-gradient(90deg, var(--red), var(--red-bright));
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.5);
  opacity: 0.6;
  transition: width 680ms cubic-bezier(.4, 0, .2, 1) 240ms;
}

/* ── 5. Боевой лог / комбо-баннер / отчёт результата ──────────────────────── */
.battle-log {
  background: linear-gradient(180deg, rgba(7, 16, 31, 0.92), rgba(11, 17, 32, 0.92));
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 70px;
  overflow: hidden;
}
.log-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: log-in 240ms ease both;
}
@keyframes log-in { from { opacity: 0; transform: translateX(-7px); } to { opacity: 1; transform: none; } }
.log-line.is-info  { color: var(--text-dim); }
.log-line.is-block { color: var(--cyan-bright); }
.log-line.is-hit   { color: var(--red-bright); }
.log-line.is-crit  { color: var(--amber-lite); font-weight: 700; text-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }
.log-caret {
  display: inline-block;
  width: 7px;
  color: var(--cyan-bright);
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* Комбо/стрик-баннер — выезжает в центр арены при серии блоков. */
.combo-banner {
  position: absolute;
  left: 50%; top: 30%;
  transform: translate(-50%, -50%) scale(0.5);
  padding: 7px 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--amber-lite), var(--amber));
  color: #1b1205;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 2px solid var(--outline);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 45;
  white-space: nowrap;
}
.combo-banner.show { animation: combo-pop 950ms cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes combo-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-5deg); }
  22%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18) rotate(3deg); }
  68%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -86%) scale(0.95); }
}

/* Отчёт на экране результата (построчно, ранг, итоговый счёт со счётчиком). */
.result-report {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
}
.report-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 0;
  border-bottom: 1px dashed rgba(99, 102, 241, 0.12);
  animation: log-in 340ms ease both;
}
.report-line:last-child { border-bottom: 0; }
.report-line b { color: var(--text); font-weight: 800; }
.report-line .t-blue { color: var(--cyan-bright); }
.report-line .t-red  { color: var(--red-bright); }

.rank-badge {
  width: 58px; height: 58px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; font-weight: 900;
  border: 3px solid var(--outline);
  background: radial-gradient(circle at 35% 30%, var(--cyan-bright), var(--cyan));
  color: var(--bg-deep);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.6);
  animation: badge-in 560ms cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes badge-in {
  0%   { opacity: 0; transform: scale(0.3) rotate(-14deg); }
  60%  { transform: scale(1.16) rotate(4deg); }
  100% { opacity: 1; transform: none; }
}
.rank-badge.rank-s { background: radial-gradient(circle at 35% 30%, var(--amber-lite), var(--amber)); box-shadow: 0 0 22px rgba(245, 158, 11, 0.75); }
.rank-badge.rank-a { background: radial-gradient(circle at 35% 30%, var(--cyan-bright), var(--cyan)); box-shadow: 0 0 20px rgba(34, 211, 238, 0.7); }
.rank-badge.rank-b { background: radial-gradient(circle at 35% 30%, var(--indigo-lite), var(--indigo)); box-shadow: 0 0 20px rgba(99, 102, 241, 0.7); color: #fff; }
.rank-badge.rank-c { background: radial-gradient(circle at 35% 30%, var(--red-bright), var(--red)); box-shadow: 0 0 20px rgba(244, 63, 94, 0.7); color: #fff; }

.sum-score { font-variant-numeric: tabular-nums; }
.sum-score.count-up { animation: count-pop 320ms ease; }
@keyframes count-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28); color: var(--cyan-bright); }
  100% { transform: scale(1); }
}

/* ── 6. Адаптив (≤560) + тач-таргеты + reduced-motion для новых анимаций ───── */
@media (max-width: 560px) {
  /* Тач-таргет mute ≥44px (SPEC §15). */
  .mute-btn { width: 44px; height: 44px; font-size: 20px; }

  .battle-log { max-height: 56px; font-size: 11px; padding: 6px 9px; }
  .combo-banner { font-size: 13px; padding: 6px 14px; }
  .charge-meter { width: 52px; }
  .threat-tell { font-size: 10px; min-width: 18px; height: 18px; }
  .result-report { padding: 10px 12px; }
  .report-line { font-size: 12px; }
  .rank-badge { width: 50px; height: 50px; font-size: 23px; }
  .crt-overlay::before { opacity: 0.42; }   /* мягче на мелком экране */
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .crt-overlay.flicker { animation: none; }
  .card.deal-in { animation: none; }
  .card.placed::after { animation: none; }
  .arena.shake-hard { animation: none; }
  .hacker-img.charge { animation: none; }
  .kc-dot.active-phase { animation: none; }
  .threat-tell.show { animation: none; }
  .combo-banner.show { animation: combo-fade 700ms ease forwards; }
  @keyframes combo-fade { 0% { opacity: 0; } 20%, 75% { opacity: 1; } 100% { opacity: 0; } }
  .rank-badge { animation: none; }
  .sum-score.count-up { animation: none; }
  .log-line, .report-line { animation: none; }
  /* Частицы — без разлёта, только короткое затухание. */
  .particle.particle-fly { animation: particle-fade 260ms ease forwards; }
  @keyframes particle-fade { from { opacity: 1; } to { opacity: 0; } }
  .screen-flash.fx-flash, .screen-flash.fx-flash.flash-crit { animation: screen-flash-soft 300ms ease forwards; }
  @keyframes screen-flash-soft { 0% { opacity: 0; } 25% { opacity: 0.4; } 100% { opacity: 0; } }
}
