/* ===== ЖАХ · пиксель / инди-крафт (по дизайн-макетам pixel-*) =====
   Эры на body[data-era="0|1|2"]: крафт-бумага → плотный жёлтый → ночной уровень.
   Шрифт Press Start 2P вшит в css/font.css. */

/* ===== Токены эр ===== */
body { color-scheme: light; }
body[data-era="0"] {
  --ink: #33291F; --paper: #F2E6C9; --card: #FBF3DD; --muted: #6E6250;
  --accent: #3E63C4; --accent-ink: #FBF3DD;
  --amber: #B97700; --amber-fill: #F4A50E;
  --danger: #C23B2E; --ok: #3E7C3A; --filter: #7A4FBF;
  --edge: var(--ink);
  --check-dot: rgba(51, 41, 31, 0.05);
  --pp: 12px; --cardpad: 9px 10px; --cardgap: 10px;
}
body[data-era="1"] {
  --ink: #3A2B18; --paper: #EBD5A0; --card: #F6E9C3; --muted: #6F5B36;
  --accent: #B25E00; --accent-ink: #F6E9C3;
  --amber: #8F5A00; --amber-fill: #E8930C;
  --danger: #A93122; --ok: #4A7C2E; --filter: #7A4FBF;
  --edge: var(--ink);
  --check-dot: rgba(58, 43, 24, 0.07);
  --pp: 9px; --cardpad: 7px 9px; --cardgap: 8px;
}
body[data-era="2"] { /* «ночной уровень»: глубокий синий, не чёрный */
  --ink: #EDEAF7; --paper: #1F2440; --card: #2A3054; --muted: #A9ACCB;
  --accent: #F4A50E; --accent-ink: #1F2440;
  --amber: #FFCB5C; --amber-fill: #F4A50E;
  --danger: #FF7B6B; --ok: #6FDB9B; --filter: #A585F0;
  --edge: #0F1226;
  --check-dot: rgba(237, 234, 247, 0.035);
  --pp: 10px; --cardpad: 8px 10px; --cardgap: 8px;
  color-scheme: dark;
}

/* ===== База ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background-color: #F2E6C9; } /* фолбэк против вспышки до отрисовки слоя фона */
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
  /* игра, а не документ: текст не выделяется (кроме полей ввода) */
  user-select: none;
  -webkit-user-select: none;
}
/* Фон-узор вынесен в отдельный слой: так его можно тонировать per-рынок
   (hue-rotate) не задевая цвета контента. Меняется на КАЖДОМ рынке. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-color: var(--paper);
  background-image: repeating-conic-gradient(var(--check-dot) 0% 25%, transparent 0% 50%);
  background-size: 8px 8px;
  transition: filter .5s ease;
}
body[data-market="2"]::after { filter: hue-rotate(40deg); }
body[data-market="3"]::after { filter: hue-rotate(85deg); }
body[data-market="4"]::after { filter: hue-rotate(130deg); }
body[data-market="5"]::after { filter: hue-rotate(175deg); }
body[data-market="6"]::after { filter: hue-rotate(215deg); }
body[data-market="7"]::after { filter: hue-rotate(260deg); }
body[data-market="8"]::after { filter: hue-rotate(310deg); }
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
/* убираем браузерную синюю подсветку тапа на мобильных (свой :active-фидбек есть) */
button, a, label, input, select, [tabindex], [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); } a:hover { color: var(--ink); }
svg { display: block; }

/* ===== Скроллбары: пиксель-арт, цвета эры, без закруглений =====
   ВАЖНО: стандартный scrollbar-color в Chromium отключает ::-webkit-scrollbar,
   поэтому применяем его только в Firefox через @supports. */
@supports (-moz-appearance: none) {
  * { scrollbar-color: var(--edge) var(--paper); }
}
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track {
  background-color: var(--paper);
  background-image: repeating-conic-gradient(var(--check-dot) 0% 25%, transparent 0% 50%);
  background-size: 8px 8px;
  border: 2px solid var(--edge);
  border-radius: 0;
}
::-webkit-scrollbar-thumb {
  background: var(--edge);
  border: 2px solid var(--paper);
  border-radius: 0;
  box-shadow: inset 2px 2px 0 color-mix(in srgb, var(--paper) 35%, var(--edge));
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-thumb:active { background: var(--amber-fill); }
::-webkit-scrollbar-corner { background: var(--paper); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

.pxfont { font-family: 'Press Start 2P', monospace; }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* ===== Стартовый экран ===== */
#startScreen {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--paper);
  background-image: repeating-conic-gradient(var(--check-dot) 0% 25%, transparent 0% 50%);
  background-size: 8px 8px;
}
.startInner { text-align: center; padding: 40px 16px 24px; max-width: 430px; width: 100%; box-sizing: border-box; }
.startMark { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 18px; color: var(--ink); }
.startMark span { width: 36px; height: 28px; display: block; }
.startMark span.boltMark { width: 22px; }
.startInner h1 { font-family: 'Press Start 2P', monospace; font-size: 58px; color: var(--ink); line-height: 1;
  text-shadow: 4px 4px 0 var(--amber-fill); }
.startChars { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin-top: 22px; min-height: 76px; }
.slogan { margin: 20px 0 28px; color: var(--muted); font: 700 12.5px/1.7 ui-monospace, Menlo, Consolas, monospace; }
#startBtn { background: var(--accent); color: var(--accent-ink); font-family: 'Press Start 2P', monospace;
  font-size: 13px; padding: 18px 34px; min-height: 58px; border: 4px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink); display: block; margin: 0 auto 14px; white-space: nowrap; }
#startBtn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
/* Десктоп: звук и настройки в ряд; «Сначала» — отдельной строкой при продолжении */
.startGhosts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  width: min(100%, 360px); margin: 0 auto;
}
.startGhosts .ghost { width: 100%; min-width: 0; white-space: normal; line-height: 1.35; }
#startResetBtn { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .startInner { padding: 20px 12px 14px; }
  .startMark { margin-bottom: 12px; }
  .startInner h1 { font-size: 44px; }
  .slogan { margin: 12px 0 16px; font-size: 11px; line-height: 1.55; }
  #startBtn { font-size: 11px; padding: 14px 18px; min-height: 50px; margin-bottom: 10px; }
  .startGhosts { gap: 8px; width: 100%; }
  .startGhosts .ghost { min-height: 40px; padding: 8px 6px; font-size: 7px; }
  .startChars { margin-top: 12px; min-height: 56px; gap: 10px; }
}

/* ===== Каркас ===== */
#app {
  display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  position: relative;
  /* Рамка-«девайс» по всему периметру, как в дизайне (.device: 4px solid #191612)
     и как на десктопе (min-width:900px тоже ставит эту рамку).
     overflow:hidden — как .device в макете: контент не вылезает за рамку. */
  border: 4px solid #191612;
  overflow: hidden;
  /* Без viewport-fit=cover вьюпорт РАВЕН safe-area, поэтому 100dvh уже не заходит
     под системные полосы — нижний бордер всегда виден. 100vh — фолбэк для старых. */
  height: 100vh;
  height: 100dvh;
}

/* ===== Тикер ===== */
#top { flex: none; }
#ticker {
  min-height: 42px; width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px;
  background: var(--card); border-bottom: 3px solid var(--edge); text-align: left;
  font: 700 11px/1.5 ui-monospace, Menlo, Consolas, monospace;
  white-space: nowrap; overflow: hidden; cursor: pointer;
}
#tickerText { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; }
.tickerMsg { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tickerMsg.marquee { text-overflow: clip; }
.tickerMsg.marquee > span { display: inline-block; animation: marquee 9s linear infinite; padding-right: 60px; }
@keyframes marquee { 0%, 12% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
.tickerTag { flex: none; font-family: 'Press Start 2P', monospace; font-size: 7px; padding: 4px 6px 3px;
  background: var(--ink); color: var(--paper); }
.tickerTag.urgent { background: var(--danger); color: #fff; }
.tickerTag.filterT { background: var(--filter); color: #fff; }
.tickerTag.markets { background: var(--amber-fill); color: #33291F; }
.tickerTag.science { background: var(--accent); color: var(--accent-ink); }
.tickerTag.flash { animation: tagFlash 0.9s steps(2) 3; }
@keyframes tagFlash { 50% { filter: brightness(1.6); } }
.tickerIn { animation: tickerIn 0.25s steps(3); }
@keyframes tickerIn { from { opacity: 0; transform: translateY(8px); } }
.journalBtn { flex: none; width: 30px; height: 30px; padding: 6px; color: var(--ink); position: relative; }
.journalBtn.dot::after { content: ''; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px;
  background: var(--accent); border: 1px solid var(--ink); }
.journalBtn::after { content: ''; position: absolute; inset: -7px; }

/* ===== Цифры ===== */
#numbers { flex: none; text-align: center; padding: 16px var(--pp) 8px; }
#attBig {
  font-family: 'Press Start 2P', monospace; font-size: 26px; line-height: 1.2; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
body[data-era="1"] #attBig { font-size: 28px; }
body[data-era="2"] #attBig { color: var(--amber); text-shadow: 0 0 14px rgba(244, 165, 14, 0.45); }
body[data-era="2"] #attBig { animation: attGlitch 7s steps(1) infinite; }
@keyframes attGlitch {
  0%, 96.5%, 100% { transform: none; filter: none; }
  97% { transform: translateX(-2px) skewX(-4deg); filter: hue-rotate(30deg); }
  97.5% { transform: translateX(2px); filter: none; }
}
#attBig .coin { width: 22px; height: 22px; flex: none; }
#attBig .unit { display: none; }
#attBig.longNum { font-size: 17px; }
#vnsRow { margin-top: 8px; font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--muted);
  display: flex; justify-content: center; align-items: center; gap: 10px; white-space: nowrap; min-height: 17px; }
.buffChip { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: #33291F;
  background: var(--amber-fill); border: 2px solid var(--edge); padding: 3px 6px 2px; }
#metaRow { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: var(--card); border: 3px solid var(--edge); padding: 5px 9px;
  font-family: 'Press Start 2P', monospace; font-size: 8px;
}
.chip::before { content: ''; position: absolute; inset: -8px; }
.chipLabel { color: var(--muted); font-size: 7px; }
.chipBar { display: inline-flex; gap: 2px; }
.chipBar i { width: 7px; height: 9px; background: var(--check-dot); border: 1px solid var(--ink); }
.chipBar i.on { background: var(--accent); }
body[data-era="2"] .chipBar i { border-color: var(--muted); }
body[data-era="2"] .chipBar i.on { background: var(--amber-fill); }
.chip.bad { border-color: var(--danger); color: var(--danger); }
.chip.bad .chipBar i.on { background: var(--danger); }
.chip .ico { width: 12px; height: 12px; }
.chip.bad .ico { color: var(--danger); }
.chipHint { color: var(--amber); font-size: 7px; }

/* ===== Рейд Фильтра ===== */
#raidBar {
  /* z-index выше .questOverlay (140): рейд, начатый до открытия диалога, обязан
     оставаться доступным для тапов — иначе отбиться нельзя (находка 23) */
  position: relative; z-index: 145;
  margin: 10px var(--pp) 0; background: var(--card); border: 3px solid var(--filter);
  padding: 8px 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  font: 700 11px/1.4 ui-monospace, monospace; text-align: left;
}
#raidBar.strike { animation: raidBlink 1s steps(2) infinite; }
@keyframes raidBlink { 50% { box-shadow: 0 0 0 3px var(--filter); } }
.raidFace { flex: none; width: 34px; height: 30px; color: var(--filter); }
.raidFace .pxChar { width: 100% !important; height: 100% !important; }
#raidText { flex: 1; min-width: 0; }
#raidText b { color: var(--filter); font-family: 'Press Start 2P', monospace; font-size: 8px; }
body[data-era="2"] #raidText b { color: #C9B3FF; }
#raidText small { display: block; color: var(--muted); font-size: 10px; }
.raidTimer { width: 100%; height: 8px; border: 2px solid var(--ink); background: var(--paper); }
.raidTimer i { display: block; height: 100%; background: var(--filter); width: calc(var(--val, 1) * 100%); }
#fightBtn {
  position: relative; flex: 1 1 100%; min-height: 56px; overflow: hidden;
  background: var(--filter); color: #fff; border: 3px solid var(--edge);
  font-family: 'Press Start 2P', monospace; font-size: 10px;
  box-shadow: 0 5px 0 var(--edge);
}
#fightBtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.fightFill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--val, 0) * 100%);
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.3) 0 6px, rgba(255,255,255,.18) 6px 12px); }
#fightBtn > span, #fightBtn > b { position: relative; }

/* ===== Кнопка ЖАХ ===== */
#blastZone { position: relative; flex: none; padding: 14px 20px 22px; }
#blastBtn {
  width: 100%; min-height: 104px; background: var(--accent); color: var(--accent-ink);
  font-family: 'Press Start 2P', monospace; font-size: 34px; letter-spacing: .1em; text-indent: .1em;
  border: 4px solid var(--edge); box-shadow: 0 8px 0 var(--edge);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; position: relative;
}
/* Стадии раскала — СТРОГО пиксельные средства (игра пиксельная): плоские вспышки
   грани/фона через steps() без сглаживания. Единственное «мягкое» — внешнее
   свечение (drop-shadow), оно задаётся из JS через --glow (см. .heating выше).
   Стадия 3 — дрожащая красная грань; стадия 4 — грань + вспышки фона + тряска. */
#blastBtn[data-blaze="3"] { animation: blazeEdge 0.22s steps(2) infinite; }
@keyframes blazeEdge { 50% { border-color: #ff5a3c; } }
#blastBtn[data-blaze="4"] { animation: blazeFlare 0.16s steps(2) infinite; }
@keyframes blazeFlare { 50% { border-color: #ff6a44; background: #cc1326; } }
body.blazeShake { animation: blazeShake 0.13s steps(2) infinite; }
@keyframes blazeShake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px); }
  50% { transform: translate(-1px, 1px); } 75% { transform: translate(1px, 1px); } }
/* Стадия 4 — полноэкранные красные вспышки (плоский цвет, steps — пиксельно),
   поверх игрового поля, но под модалками/тостами (z-index 90). */
body.blazeMax::before { content: ''; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: #ff2a17; opacity: 0; animation: blazeFlash 0.28s steps(2) infinite; }
@keyframes blazeFlash { 50% { opacity: 0.14; } }
body[data-era="2"] #blastBtn { box-shadow: 0 8px 0 var(--edge), 0 0 30px rgba(244, 165, 14, 0.35); }
#blastBtn::before { content: ''; position: absolute; left: 6px; top: 6px; right: 6px; height: 8px; background: rgba(255,255,255,.28); }
#blastBtn::after { content: ''; position: absolute; left: 6px; bottom: 6px; right: 6px; height: 6px; background: rgba(0,0,0,.15); }
#blastBtn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--edge); }
#blastBtn.hot { filter: brightness(1.12) saturate(1.15); }
#blastBtn.hot::before { background: rgba(255,255,255,.45); }
/* Раскал: поверхность калится к красному (--heat 0..1), красное свечение
   хаотично пульсирует (--glow, обновляется каждый кадр из JS). */
#blastBtn.heating {
  /* пик — глубокий бордово-насыщенно-красный (не оранжевый) */
  background: color-mix(in srgb, var(--accent), #b3061f calc(var(--heat, 0) * 100%));
  border-color: color-mix(in srgb, var(--edge), #7a0316 calc(var(--heat, 0) * 70%));
  filter: brightness(calc(1 + var(--heat, 0) * 0.14)) saturate(calc(1 + var(--heat, 0) * 0.45))
    drop-shadow(0 0 calc(var(--glow, 0) * 26px) rgba(215, 18, 38, calc(var(--glow, 0) * 0.95)))
    drop-shadow(0 0 calc(var(--glow, 0) * 11px) rgba(255, 66, 56, calc(var(--glow, 0) * 0.8)));
}
#blastBtn.heating::before { background: rgba(255, 180, 178, calc(0.28 + var(--heat, 0) * 0.5)); }
.floater { position: absolute; pointer-events: none; z-index: 6;
  font-family: 'Press Start 2P', monospace; font-size: 15px; color: var(--amber);
  text-shadow: 2px 2px 0 rgba(0,0,0,.2); opacity: 0; }
body[data-era="2"] .floater { color: var(--amber-fill); text-shadow: 0 0 10px rgba(244,165,14,.6); }
.floatUp { animation: floatUp 1s steps(8); }
@keyframes floatUp { 0% { opacity: 1; } 100% { opacity: 0; transform: translateY(-84px) scale(1.15); } }
.blastParticle { position: absolute; width: 22px; height: 17px; color: var(--accent-ink); pointer-events: none;
  z-index: 5; animation: partFly 0.6s steps(6) forwards; }
@keyframes partFly { to { opacity: 0; transform: translate(var(--dx, 24px), var(--dy, -44px)) rotate(var(--rot, 20deg)); } }

/* ===== Бафф-иконка (спавн над панелями, не над кнопкой — X3) ===== */
#buffIcon { position: absolute; z-index: 7; width: 56px; height: 64px; padding: 4px;
  background: var(--card); border: 3px solid var(--edge); box-shadow: 4px 4px 0 rgba(0,0,0,.3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  animation: buffHop 0.8s steps(2) infinite; }
@keyframes buffHop { 50% { transform: translateY(-3px); } }
#buffIcon .ico { width: 34px; height: 34px; color: var(--ink); }
#buffIcon .pxChar { transform-origin: center bottom; }
.buffTimer { display: flex; gap: 2px; }
.buffTimer i { width: 5px; height: 6px; background: var(--check-dot); border: 1px solid var(--ink); }
.buffTimer i.on { background: var(--amber-fill); }
#buffIcon.negative { border-style: dashed; border-color: var(--danger); animation: none; }
#buffIcon.negative::after { content: 'УВЕРНИСЬ'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace; font-size: 6px; color: var(--danger); white-space: nowrap; }

/* ===== Вкладки ===== */
#tabs { flex: none; display: flex; background: var(--card);
  border-top: 3px solid var(--edge); border-bottom: 3px solid var(--edge); }
.tab[data-tab="more"] { display: none; } /* ЕЩЁ — десктоп; на телефоне меню в бургере */
.tab { flex: 1; min-height: 46px; padding: 8px 2px; color: var(--muted); position: relative;
  font-family: 'Press Start 2P', monospace; font-size: 7px; border-right: 3px solid var(--edge); }
.tab:last-child { border-right: 0; }
.tab.active { background: var(--ink); color: var(--paper); }
body[data-era="2"] .tab.active { background: var(--amber-fill); color: #1F2440; }
.tab .badge { position: absolute; top: 3px; right: 6%; min-width: 16px; height: 16px; padding: 4px 4px 0;
  background: var(--danger); color: #fff; font-size: 8px; border: 2px solid var(--edge); }
.tab.dot::after { content: ''; position: absolute; top: 5px; right: 12%; width: 7px; height: 7px;
  background: var(--accent); border: 1px solid var(--ink); }
.tab.glow { animation: tabGlow 1s steps(2) 6; }
@keyframes tabGlow { 50% { background: var(--amber-fill); color: #33291F; } }
@media (max-width: 899px) {
  .tab[data-tab="dash"] { order: 1; }
  .tab[data-tab="sources"] { order: 2; }
  .tab[data-tab="upgrades"] { order: 3; }
  .tab[data-tab="data"] { order: 4; }
  .tab[data-tab="legacy"] { order: 5; }
  .tab { border-right: none; white-space: normal; line-height: 1.25; padding: 6px 3px; }
  .tab[data-tab="sources"],
  .tab[data-tab="upgrades"],
  .tab[data-tab="data"],
  .tab[data-tab="legacy"] { border-left: 3px solid var(--edge); }
  .dashGrid { grid-template-columns: 1fr; }
}

/* ===== Панели ===== */
#panels { flex: 1; min-height: 0; overflow-y: auto; padding: var(--pp) var(--pp) 20px; position: relative; }
.panel { display: none; }
.panel.active { display: block; }
.kindHead { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--muted);
  margin: 16px 2px 8px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
.kindHead:first-child { margin-top: 2px; }
.kindHead::after { content: ''; flex: 1; height: 3px;
  background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px); opacity: .5; }
.colHead { display: none; font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--ink); padding: 12px 2px 10px; }
.panelHead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 2px 2px 10px; font: 700 12px/1.5 ui-monospace, monospace; }
.panelHead b { font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--amber); }

/* ===== Карточки покупок ===== */
.buyCard { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 3px 10px;
  width: 100%; text-align: left; background: var(--card); border: 3px solid var(--edge);
  padding: var(--cardpad); margin-bottom: var(--cardgap); overflow: hidden; }
/* прогресс накопления к цене: дискретные пунктики по нижней кромке,
   заполняются по одному на каждые 10% (не «растягивающаяся» заливка) */
.bcPips { position: absolute; left: 6px; right: 6px; bottom: 0; display: flex; gap: 3px;
  pointer-events: none; }
.bcPips i { flex: 1; height: 4px; background: var(--check-dot); }
.bcPips i.on { background: var(--accent); }
body[data-era="2"] .bcPips i.on { background: var(--amber-fill); }
.buyCard.affordable .bcPips, .buyCard.locked .bcPips, .buyCard.owned .bcPips { display: none; }
.bcIcon { grid-row: 1 / span 3; width: 20px; height: 20px; margin-top: 2px; color: var(--ink); position: relative; }
body[data-era="2"] .bcIcon { color: var(--muted); }
.bcTop { grid-column: 2; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; position: relative; min-width: 0; }
.bcTitle { font-family: 'Press Start 2P', monospace; font-size: 9px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcCount { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--accent); flex: none; }
body[data-era="2"] .bcCount { color: var(--amber); }
.bcFlavor { grid-column: 2; font: 11.5px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.bcBottom { grid-column: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; position: relative; min-width: 0; }
.bcCost { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--amber);
  white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 5px; }
.bcCost .coin { width: 12px; height: 12px; }
.bcNote { font: 10.5px ui-monospace, monospace; color: var(--muted); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.buyCard.affordable { box-shadow: 4px 4px 0 rgba(0,0,0,.25); }
body[data-era="2"] .buyCard.affordable { box-shadow: 4px 4px 0 rgba(0,0,0,.5); }
/* ушко КУПИТЬ — внутри карточки, контент под него не попадает (паддинг у bcTop) */
.buyCard.affordable::after { content: 'КУПИТЬ'; position: absolute; top: 0; right: 0;
  font-family: 'Press Start 2P', monospace; font-size: 7px; padding: 4px 5px 3px;
  background: var(--accent); color: var(--accent-ink);
  border-left: 3px solid var(--edge); border-bottom: 3px solid var(--edge); }
.buyCard.affordable .bcTop { padding-right: 56px; }
/* нажатие — вжимание внутрь (scale), чтобы края не резались оверфлоу скролл-колонок */
.buyCard.affordable:active { transform: scale(0.985); box-shadow: 2px 2px 0 rgba(0,0,0,.25); }
.buyCard.locked { border-style: dashed; background: transparent; }
.buyCard.locked .bcTitle, .buyCard.locked .bcIcon { color: var(--muted); }
.bcLock { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font: 700 10.5px ui-monospace, monospace; white-space: nowrap; min-width: 0; overflow: hidden; }
.bcLock .ico { width: 13px; height: 13px; flex: none; }
.buyCard.owned { padding-top: 6px; padding-bottom: 6px; border-color: var(--ok); }
.buyCard.owned .bcIcon { grid-row: 1; color: var(--ok); }
.buyCard.owned .bcFlavor { display: none; }
.bcCheck { display: inline-flex; align-items: center; gap: 6px; color: var(--ok);
  font-family: 'Press Start 2P', monospace; font-size: 8px; }
.bcCheck .ico { width: 12px; height: 12px; }
.buyCard.dirty { border-left: 6px solid var(--danger); }
.dirtyMark { display: inline-flex; align-items: center; gap: 5px; color: var(--danger); font: 700 10.5px ui-monospace, monospace; }
.dirtyMark .ico { width: 14px; height: 13px; }
.buyCard.market { border-color: var(--amber-fill); background: color-mix(in srgb, var(--amber-fill) 10%, var(--card)); }
.buyCard.market .bcIcon { color: var(--amber); }
.buyCard.rebrand { border-color: var(--amber-fill); }
.buyCard.rebrand .bcIcon { color: var(--amber); }

.term { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border: 2px solid var(--muted); font: 700 10px ui-monospace, monospace; color: var(--muted);
  margin-left: 6px; vertical-align: middle; cursor: help; position: relative; }
.term::after { content: ''; position: absolute; inset: -8px; }
.apToggle { font-family: 'Press Start 2P', monospace; font-size: 7px; border: 2px solid var(--muted);
  color: var(--muted); padding: 3px 5px 2px; flex: none; position: relative; }
.apToggle::after { content: ''; position: absolute; inset: -8px; }
.apToggle.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ===== Меню («Ещё» и бургер) ===== */
.menuList { display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.menuBtn { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 14px;
  background: var(--card); border: 3px solid var(--edge); text-align: left;
  font-family: 'Press Start 2P', monospace; font-size: 10px; box-shadow: 0 4px 0 var(--edge); }
.menuBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.menuBtn .mIco { width: 20px; height: 20px; flex: none; color: var(--accent); }
body[data-era="2"] .menuBtn .mIco { color: var(--amber); }
.menuBtn b { margin-left: auto; color: var(--amber); font-size: 9px; }

/* ===== Статистика / ачивки (модалки, читаемый шрифт) ===== */
.statGrid { display: grid; grid-template-columns: 1fr auto; gap: 11px 16px; padding: 4px 2px;
  font: 700 13.5px/1.5 ui-monospace, monospace; }
.statGrid div:nth-child(odd) { color: var(--muted); }
.statGrid div:nth-child(even) { font-family: 'Press Start 2P', monospace; font-size: 11px; text-align: right; }
.achList { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
/* На десктопе модалка «Ачивки и награды» шире, а список ачивок — в 2 колонки. */
@media (min-width: 900px) {
  .modalBox.achModal { max-width: 720px; }
  .achModal .achList { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
}
.ach { display: grid; grid-template-columns: 16px 1fr; gap: 3px 10px; align-items: center;
  color: var(--muted); padding: 8px 10px; border: 2px dashed color-mix(in srgb, var(--muted) 50%, transparent); }
.ach .ico { width: 15px; height: 15px; grid-row: 1 / span 2; opacity: .35; }
.achName { font-family: 'Press Start 2P', monospace; font-size: 9px; line-height: 1.5; }
.achDesc { font: 700 12px/1.4 ui-monospace, monospace; grid-column: 2; }
.ach.done { color: var(--ink); border-style: solid; border-color: var(--amber-fill); background: var(--card); }
.ach.done .ico { color: var(--amber); opacity: 1; }
.softCta { padding: 12px 2px; font: 11.5px ui-monospace, monospace; }
.softCta a { color: var(--muted); }

/* ===== СВОДКА: дашборд =====
   Карточки обязаны ужиматься (min-width: 0), а значения — переноситься,
   иначе длинные числа выталкивают сетку за край панели под обрезку. */
.dashGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 2px; }
.dashCard { background: var(--card); border: 3px solid var(--edge); padding: 10px 12px; min-width: 0; }
.dashHead { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--muted);
  margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.dashHead::after { content: ''; flex: 1; height: 3px;
  background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px); opacity: .5; }
.dashRow { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 5px 0;
  font: 700 12px/1.4 ui-monospace, monospace; color: var(--muted); min-width: 0; }
.dashRow > span:first-child { flex: none; }
.dashRow b { margin-left: auto; font-family: 'Press Start 2P', monospace; font-size: 9px;
  color: var(--amber); text-align: right; min-width: 0; overflow-wrap: anywhere; line-height: 1.7; }
.dashRow .chipBar { margin-left: auto; flex: none; }
.dashRow .chipBar + b { margin-left: 8px; }
.chipBar.barDanger i.on { background: var(--danger); }

/* ===== Журнал-лента (десктоп) ===== */
#journalStrip { display: none; }

/* ===== Модалки ===== */
/* z-index 150: модалки должны перекрывать и стартовый экран (у него 100) */
.modal { position: fixed; inset: 0; background: rgba(20, 15, 8, 0.55); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
body[data-era="2"] .modal { background: rgba(5, 6, 18, 0.65); }
.modalBox { background: var(--card); color: var(--ink); border: 4px solid var(--edge);
  padding: 20px; max-width: 440px; width: 100%; max-height: 88dvh; overflow-y: auto;
  box-shadow: 8px 8px 0 rgba(0,0,0,.35);
  font: 12.5px/1.55 ui-monospace, Menlo, Consolas, monospace; }
.modalBox h2 { font-family: 'Press Start 2P', monospace; font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.modalBox p { margin-bottom: 10px; }
.modalBox input[type="text"], .modalBox textarea {
  width: 100%; padding: 10px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink);
  font: 12px ui-monospace, monospace; margin-bottom: 12px; }
/* Поле имени («Как подписывать ваши рассылки?») — пиксельный шрифт */
#nameInput { font-family: 'Press Start 2P', monospace; font-size: 11px; }
.btnRow { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.primary, .btnLink { background: var(--accent); color: var(--accent-ink); padding: 13px 18px; min-height: 48px;
  border: 3px solid var(--edge); box-shadow: 0 5px 0 var(--edge); text-decoration: none; display: inline-block;
  font-family: 'Press Start 2P', monospace; font-size: 9px; white-space: nowrap; text-align: center; }
.primary:active, .btnLink:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.ghost { border: 3px solid var(--edge); padding: 13px 18px; min-height: 48px; color: var(--muted);
  font-family: 'Press Start 2P', monospace; font-size: 9px; white-space: nowrap; background: var(--paper); }
.ghost.danger { color: var(--danger); border-color: var(--danger); }
.ghost.small { font-size: 8px; padding: 8px 12px; min-height: 38px; }
.setRow { display: flex; gap: 10px; align-items: center; padding: 9px 0; font: 700 12px/1.4 ui-monospace, monospace; }
/* На десктопе вибрация не нужна — прячем настройку и в модалке, и в меню «ЕЩЁ»
   (JS-гейт не ловит десктоп с сенсорным экраном). */
@media (min-width: 900px) { .setRowHaptics, [data-menu="haptics"] { display: none; } }
.setRow input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.setRow select { font: 700 12px ui-monospace, monospace; padding: 6px; border: 3px solid var(--ink);
  background: var(--paper); color: var(--ink); }
/* Строка сейва — тот же шрифт и жирность, что у текста ачивок (.achDesc). */
#saveIO { font: 700 12px/1.4 ui-monospace, monospace; }
.modalChar { display: flex; justify-content: center; margin-bottom: 12px; }

/* ===== Офлайн-дайджест «письмо» (U8) ===== */
.mailBox { padding: 0; }
.mailHead { padding: 12px 16px; border-bottom: 3px solid var(--ink); background: var(--paper); display: grid; gap: 4px; }
.mailRow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; font-size: 11.5px; }
.mailKey { color: var(--muted); flex: none; width: 46px; }
.mailSubject { font-family: 'Press Start 2P', monospace; font-size: 10px; }
.mailBody { padding: 12px 16px 4px; }
.mailHello { color: var(--muted); margin-bottom: 6px; }
.mailStat { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dashed var(--muted); }
.mailStat .mIco { width: 18px; height: 18px; color: var(--ink); flex: none; }
.mailStat b { margin-left: auto; font-family: 'Press Start 2P', monospace; font-size: 9px; white-space: nowrap; color: var(--amber); }
.mailBody .btnRow { padding-bottom: 6px; }
.mailFoot { padding: 10px 16px 14px; font-size: 10.5px; color: var(--muted); }

/* ===== Тосты ===== */
#toastRoot { position: fixed; bottom: 84px; left: 0; right: 0; z-index: 160; pointer-events: none; }
.toast { pointer-events: auto; margin: 6px auto; width: fit-content; max-width: 92%;
  background: var(--ink); color: var(--paper); border: 3px solid var(--edge); padding: 9px 14px;
  font: 700 11.5px/1.5 ui-monospace, monospace; animation: toastIn 0.25s steps(3); text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.3); }
body[data-era="2"] .toast { background: var(--card); color: var(--ink); }
/* Новость-чипса (мобайл): светло-жёлтая, с иконкой и рубрикой — заметно отличается
   от обычных тёмных тостов. .toast.newsToast (0,2,0) бьёт era-2 .toast (0,1,1). */
.toast.newsToast { background: #F7E6A8; color: #33291F; border-color: var(--amber);
  display: flex; align-items: center; gap: 9px; text-align: left; }
.toast.newsToast .ntIco { flex: none; width: 18px; height: 18px; color: var(--amber); }
.toast.newsToast .ntIco svg { width: 100%; height: 100%; }
.toast.newsToast .ntBody { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.toast.newsToast .ntTag { align-self: flex-start; font-family: 'Press Start 2P', monospace;
  font-size: 7px; line-height: 1; background: var(--amber-fill); color: #33291F; padding: 3px 5px 2px; }
.toast.newsToast .ntText { font: 700 11.5px/1.4 ui-monospace, monospace; }
/* Тап по новости-чипсе — закрыть с «разрушением»: чипса схлопывается, летят осколки. */
.toast.newsToast { cursor: pointer; }
.toast.newsToast.crush { pointer-events: none; animation: ntCrush 0.3s steps(4) forwards; }
@keyframes ntCrush {
  0% { transform: scale(1); }
  25% { transform: scale(1.07, 0.88); }
  100% { transform: scale(0.14) rotate(6deg); opacity: 0; }
}
.ntShards { position: fixed; z-index: 161; pointer-events: none; }
.ntShards i { position: absolute; display: block; image-rendering: pixelated;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); animation: ntShard 0.55s steps(6) forwards; }
@keyframes ntShard {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } }
/* На мобиле/планшете (<900) уведомления — СВЕРХУ: рука на ЖАХ снизу их перекрывала.
   Отступ под шапку-тикер + safe-area. На десктопе (>=900) остаются снизу (84px). */
@media (max-width: 899px) {
  /* верхняя грань уведомления — примерно на середине шапки-тикера (с бутербродом) */
  #toastRoot { top: calc(18px + env(safe-area-inset-top, 0px)); bottom: auto; }
}
.toastBtn { background: var(--amber-fill); color: #33291F; border: 2px solid var(--edge);
  padding: 4px 10px; margin-left: 8px; font-family: 'Press Start 2P', monospace; font-size: 8px; }

/* ===== Журнал ===== */
#journalList { list-style: none; max-height: 60dvh; overflow-y: auto;
  font: 700 13.5px/1.5 ui-monospace, monospace; } /* как названия параметров в Статистике */
#journalList li { padding: 7px 0; border-bottom: 2px dashed color-mix(in srgb, var(--muted) 40%, transparent); }

/* ===== FW-баннер ===== */
#fwBanner { position: fixed; top: 48px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--card); border: 3px solid var(--amber-fill); padding: 10px 14px;
  display: flex; gap: 12px; align-items: center; font: 700 11.5px/1.45 ui-monospace, monospace;
  max-width: 92%; box-shadow: 6px 6px 0 rgba(0,0,0,.3); }
#fwBanner button { font-family: 'Press Start 2P', monospace; font-size: 9px; }

/* ===== Финал ===== */
.finaleBox { text-align: center; }
.updBar { height: 12px; border: 3px solid var(--ink); background: var(--paper); margin-bottom: 16px; }
.updFill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 6px, color-mix(in srgb, var(--accent) 70%, var(--paper)) 6px 12px);
  animation: updFill 8s steps(24) forwards; }
@keyframes updFill { to { width: 100%; } }
.ccHead { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--muted); margin-bottom: 12px;
  display: flex; justify-content: space-between; gap: 10px; }
.contactCard { text-align: left; background: var(--card); border: 3px solid var(--edge); padding: 14px;
  margin-bottom: 16px; font: 11.5px/1.5 ui-monospace, monospace; }
.ccMain { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ccAvatar { width: 52px; height: 52px; border: 3px solid var(--edge); background: var(--paper);
  display: grid; place-items: center; font-family: 'Press Start 2P', monospace; font-size: 11px; flex: none; }
.ccName { font-family: 'Press Start 2P', monospace; font-size: 13px; line-height: 1.4; }
.ccSub { font-size: 10.5px; color: var(--muted); }
.ccScore { margin-left: auto; text-align: center; flex: none; }
.ccScoreNum { font-family: 'Press Start 2P', monospace; font-size: 14px; color: var(--amber); display: block; }
.ccScoreCap { font-size: 8px; color: var(--muted); letter-spacing: .1em; display: block; }
.ccScoreBar { display: flex; gap: 2px; margin-top: 4px; }
.ccScoreBar i { width: 6px; height: 8px; background: var(--check-dot); border: 1px solid var(--muted); }
.ccScoreBar i.on { background: var(--amber-fill); }
.ccRow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0;
  border-top: 2px solid color-mix(in srgb, var(--muted) 35%, transparent); }
.ccRow:first-child { border-top: 0; }
.ccRow span { color: var(--muted); flex: none; white-space: nowrap; }
.ccRow b { text-align: right; }
.finaleChoice { display: flex; flex-direction: column; gap: 12px; }
.finaleChoice button { min-height: 58px; font-family: 'Press Start 2P', monospace; font-size: 12px; border: 3px solid var(--edge); }
#endA { background: transparent; color: var(--ink); border-style: dashed !important; }
#endB { background: var(--accent); color: var(--accent-ink); box-shadow: 0 5px 0 var(--edge); }

/* Концовка A: тишина — без клетки, тёплая бумага */
.endingABox { background: #F7F1DF !important; background-image: none !important; color: #33291F !important;
  border-color: #33291F !important; }
.endTitle { font-family: 'Press Start 2P', monospace; font-size: 9px; color: #6E6250; margin-bottom: 22px; }
.endingA .mLine { opacity: 0; animation: mLineIn .1s steps(1) forwards; animation-delay: calc(var(--i) * .8s);
  font: 12.5px/1.7 ui-monospace, Menlo, Consolas, monospace; margin-bottom: 10px; text-align: left; }
@keyframes mLineIn { to { opacity: 1; } }
.endStats { margin: 24px 0 18px; padding: 12px 0; border-top: 3px solid #33291F; border-bottom: 3px solid #33291F;
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: #6E6250; display: flex; gap: 16px; flex-wrap: wrap; line-height: 1.8; }
.ctaText { font: 12.5px/1.55 ui-monospace, monospace; margin: 14px 0; }
.backLink { display: inline-block; margin-top: 14px; font: 11px ui-monospace, monospace; color: #6E6250; }

.confetti { position: fixed; top: -30px; z-index: 200; color: var(--accent);
  animation: confFall 3s steps(24) forwards; pointer-events: none; }
@keyframes confFall { to { transform: translateY(110vh) rotate(360deg); } }

/* ===== Персонажи ===== */
/* Фигурка «вас» в углу игровой зоны. Кликабельна: нажатие приплющивает героя,
   и кнопка ЖАХ не работает, пока он лежит. Иногда переходит вдоль кнопки. */
#playerFigure { position: absolute; left: 10px; bottom: 8px; z-index: 2; opacity: .95; cursor: pointer; }
#playerFigure.walking { transition-property: left; transition-timing-function: linear; }
#blastBtn.stunned { opacity: .5; cursor: not-allowed; }

/* Плашка аудита: Инспектор + кнопка «ПРЕДЪЯВИТЬ» (серия тапов) */
#auditBar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 200;
  display: flex; gap: 12px; align-items: center; max-width: 94vw;
  background: var(--card); border: 3px solid var(--filter);
  padding: 8px 12px; box-shadow: 4px 4px 0 rgba(0, 0, 0, .35); }
#auditBar .auditText b { display: block; font-family: 'Press Start 2P', monospace; font-size: 10px; margin-bottom: 4px; color: var(--filter); }
#auditBar small { color: var(--muted); font-size: 11px; }
#auditBtn { font-family: 'Press Start 2P', monospace; font-size: 10px; padding: 12px 12px; white-space: nowrap;
  border: 3px solid var(--edge); background: var(--amber-fill); color: #1F1811; cursor: pointer; }
#auditBtn:active { transform: translateY(2px); }
#auditBtn:disabled { opacity: .6; cursor: default; }

.pxChar { position: relative; display: inline-block; image-rendering: pixelated; }
.pxChar .pxF { position: absolute; inset: 0; opacity: 0; }
.pxChar .pxF1 { animation: pxFA var(--d, .8s) steps(1) infinite; }
.pxChar .pxF2 { animation: pxFB var(--d, .8s) steps(1) infinite; }
@keyframes pxFA { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pxFB { 0%, 49% { opacity: 0; } 50%, 100% { opacity: 1; } }
/* трёхкадровый цикл (походка) */
.pxChar.px3 .pxF1 { animation: px3A var(--d, .45s) steps(1) infinite; }
.pxChar.px3 .pxF2 { animation: px3B var(--d, .45s) steps(1) infinite; }
.pxChar.px3 .pxF3 { animation: px3C var(--d, .45s) steps(1) infinite; }
@keyframes px3A { 0%, 32% { opacity: 1; } 33%, 100% { opacity: 0; } }
@keyframes px3B { 0%, 32% { opacity: 0; } 33%, 65% { opacity: 1; } 66%, 100% { opacity: 0; } }
@keyframes px3C { 0%, 65% { opacity: 0; } 66%, 100% { opacity: 1; } }
body.reduced .pxChar .pxF1 { opacity: 1; animation: none; }
body.reduced .pxChar .pxF2, body.reduced .pxChar .pxF3 { opacity: 0; animation: none; }

/* ===== Полноэкранная вспышка рейда ===== */
#raidOverlay { position: fixed; inset: 0; z-index: 80; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(circle at 50% 42%, rgba(122, 79, 191, 0.22), rgba(15, 18, 38, 0.6));
  animation: roIn 0.18s steps(3); }
#raidOverlay .pxChar { animation: roShake 0.3s steps(2) infinite; filter: drop-shadow(6px 6px 0 rgba(0,0,0,.35)); }
@keyframes roIn { from { opacity: 0; } }
@keyframes roShake { 25% { transform: translate(-5px, 2px); } 75% { transform: translate(5px, -2px); } }
.roLabel { font-family: 'Press Start 2P', monospace; font-size: clamp(13px, 4vw, 20px); color: #fff;
  background: var(--filter); border: 4px solid #0F1226; padding: 12px 16px;
  box-shadow: 6px 6px 0 rgba(0,0,0,.4); animation: tagFlash 0.5s steps(2) infinite; }
#raidOverlay.out { opacity: 0; transition: opacity 0.3s; }

/* ===== Сцена концовки «тишина» ===== */
.endScene { aspect-ratio: 96 / 60; margin-bottom: 20px; border: 3px solid #33291F; overflow: hidden; }
.endScene svg { display: block; width: 100%; height: 100%; }

#cameoRoot { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.cameo { position: absolute; bottom: 64px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .45s steps(6), opacity .3s; opacity: 0; }
.cameo.left { left: 10px; transform: translateX(-110%); }
.cameo.right { right: 10px; transform: translateX(110%); }
.cameo.in { transform: translateX(0); opacity: 1; }
.cameo.out { opacity: 0; transform: translateY(30%); }
.bubble { order: -1; max-width: 190px; background: var(--card); color: var(--ink); border: 3px solid var(--edge);
  padding: 8px 10px; font: 700 10.5px/1.45 ui-monospace, monospace; text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.3); position: relative; }
.bubble::after { content: ''; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 9px;
  background: linear-gradient(45deg, transparent 45%, var(--edge) 45%); }
.catWalk { position: absolute; bottom: 18px; left: -70px; z-index: 8; animation: catWalk 5s steps(60) forwards; }
@keyframes catWalk { to { left: calc(100% + 20px); } }

/* ===== Пульсы и вспышки ===== */
.pulse { animation: pulseA 0.3s steps(3); }
@keyframes pulseA { 50% { transform: scale(1.06); } }
.cardPulse { animation: cardPulseA 0.35s steps(3); }
@keyframes cardPulseA { 40% { filter: brightness(1.3) saturate(1.3); } }
.flash { animation: flashA 0.6s steps(4); }
@keyframes flashA { 20% { filter: brightness(1.4); } }
body.shake { animation: bodyShake 0.45s steps(10); }
@keyframes bodyShake {
  10% { transform: translate(-5px, 3px); } 30% { transform: translate(5px, -3px); }
  50% { transform: translate(-4px, -2px); } 70% { transform: translate(3px, 2px); }
  90% { transform: translate(-2px, 1px); } 100% { transform: none; }
}
/* тревожная пульсация просевших чипов */
.chip.bad { animation: chipAlarm 1.1s steps(2) infinite; }
@keyframes chipAlarm { 50% { background: color-mix(in srgb, var(--danger) 14%, var(--card)); } }

/* ===== Ролевуха: РЕШЕНИЕ / СЦЕНАРИЙ / НОВЫЙ КАНАЛ ===== */
.questOverlay { position: fixed; inset: 0; z-index: 140; display: flex; align-items: center;
  justify-content: center; padding: 16px; background: rgba(20, 15, 8, 0.7); }
.questOverlay .qBox { animation: qIn 0.22s steps(4); }
body[data-era="2"] .questOverlay { background: rgba(5, 6, 18, 0.78); }
@keyframes qIn { from { transform: translateY(24px); } }
.qBox { background: var(--card); color: var(--ink); border: 4px solid var(--edge);
  box-shadow: 10px 10px 0 rgba(0,0,0,.4); padding: 22px; max-width: 460px; width: 100%;
  max-height: 92dvh; overflow-y: auto; text-align: center;
  font: 12.5px/1.55 ui-monospace, Menlo, Consolas, monospace; }
.qBox.qWide { max-width: 640px; }
/* сценка-иллюстрация дилеммы */
.qScene { aspect-ratio: 96 / 60; margin: -22px -22px 16px; border-bottom: 4px solid var(--edge); overflow: hidden; }
.qScene svg { display: block; width: 100%; height: 100%; }
.qKicker { display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Press Start 2P', monospace; font-size: 8px; padding: 5px 9px 4px;
  background: var(--amber-fill); color: #33291F; border: 2px solid var(--edge); margin-bottom: 14px; }
.qKicker svg { width: 12px; height: 12px; }
.qTitle { font-family: 'Press Start 2P', monospace; font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.qText { margin-bottom: 16px; }
.qOptions { display: flex; flex-direction: column; gap: 12px; }
.qOption { min-height: 56px; padding: 12px 16px; background: var(--paper);
  border: 3px solid var(--edge); box-shadow: 0 5px 0 var(--edge);
  font-family: 'Press Start 2P', monospace; font-size: 9.5px; line-height: 1.6; }
.qOption:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
@media (hover: hover) {
  .qOption:hover { background: color-mix(in srgb, var(--amber-fill) 14%, var(--paper)); }
}
/* исход */
.qOutcome .qChar { display: flex; justify-content: center; margin-bottom: 10px; min-height: 56px; }
.qToneTitle { font-family: 'Press Start 2P', monospace; font-size: 12px; margin-bottom: 12px; }
.qOutcomeText { margin-bottom: 16px; font-weight: 700; }
.questOverlay.tone-good .qBox { border-color: var(--ok); box-shadow: 10px 10px 0 rgba(0,0,0,.4), 0 0 0 4px color-mix(in srgb, var(--ok) 45%, transparent); }
.questOverlay.tone-good .qToneTitle { color: var(--ok); }
.questOverlay.tone-bad .qBox { border-color: var(--danger); box-shadow: 10px 10px 0 rgba(0,0,0,.4), 0 0 0 4px color-mix(in srgb, var(--danger) 45%, transparent); }
.questOverlay.tone-bad .qToneTitle { color: var(--danger); }
.questOverlay.tone-bad .qBox { animation: qShake 0.4s steps(8); }
@keyframes qShake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.questOverlay.tone-weak .qToneTitle { color: var(--muted); }
/* сценарий-коннектор */
.qCanvas { position: relative; display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px 40px;
  align-items: center; text-align: left; }
.qWire { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.qWire path { stroke: var(--amber-fill); stroke-width: 4; stroke-dasharray: 6 4; }
.qNode { position: relative; background: var(--paper); border: 3px solid var(--edge);
  padding: 12px 14px; font: 700 11.5px/1.5 ui-monospace, monospace; text-align: left;
  box-shadow: 0 4px 0 var(--edge); }
.qTrigger { grid-column: 1; cursor: grab; touch-action: none;
  border-color: var(--accent); font-family: 'Press Start 2P', monospace; font-size: 8.5px; line-height: 1.7; }
.qTrigger.armed { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); }
.qTargets { grid-column: 2; display: flex; flex-direction: column; gap: 12px; }
/* порты — пиксельные вилка (у триггера) и розетки (у блоков) */
.qPort { position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; }
.qPort svg { width: 100%; height: 100%; }
.qPortL { left: -14px; right: auto; }
.qTarget.hot, .qTarget.picked { border-color: var(--amber-fill);
  background: color-mix(in srgb, var(--amber-fill) 14%, var(--paper)); }
@media (hover: hover) { .qTarget:hover { border-color: var(--amber-fill); } }
@media (max-width: 560px) {
  .qCanvas { grid-template-columns: 1fr; gap: 18px; padding-left: 10px; }
  .qTargets { grid-column: 1; }
  /* Сокеты-«розеточки» видны и на мобиле: все порты сводим в вертикальный
     «рэйл» по левому краю (на десктопе они смотрят друг на друга между колонок). */
  .qPort { display: block; left: -13px; right: auto; }
}
/* креатив-батл: выбрать лучший макет глазами */
.qCards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.qCards.stacked { grid-template-columns: 1fr; }
.qCard { display: block; width: 100%; padding: 0; background: var(--paper);
  border: 3px solid var(--edge); box-shadow: 0 5px 0 var(--edge); overflow: hidden;
  image-rendering: pixelated; cursor: pointer; }
.qCard svg { display: block; width: 100%; height: 100%; }
.qCard:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
@media (hover: hover) {
  .qCard:hover { border-color: var(--amber-fill);
    box-shadow: 0 5px 0 var(--edge), 0 0 0 3px color-mix(in srgb, var(--amber-fill) 55%, transparent); }
}
@media (max-width: 560px) {
  .qCards { gap: 8px; }
  .qCards:not(.stacked) { grid-template-columns: repeat(3, 1fr); }
}
/* вручение награды + полка наград */
.qAwardArt { display: flex; justify-content: center; margin-bottom: 12px; }
.qAwardArt svg { width: 90px; height: 126px; image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); }
.shelfTitle { font-family: 'Press Start 2P', monospace; font-size: 11px; margin: 6px 0 8px; }
.awardShelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.awardCell { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 10px 6px 8px; border: 3px solid var(--edge); background: var(--paper);
  border-bottom-width: 6px; }
.awardCell .awardArt svg { width: 44px; height: 62px; }
.awardCell .awardName { font-family: 'Press Start 2P', monospace; font-size: 6.5px; line-height: 1.5; min-height: 20px; }
.awardCell .awardHint { font: 700 9.5px/1.4 ui-monospace, monospace; color: var(--muted); }
.awardCell.locked { opacity: .55; }
.awardCell.locked .awardArt { filter: grayscale(1) contrast(.7) brightness(.85); }
.awardCell.won { border-color: color-mix(in srgb, var(--amber-fill) 70%, var(--edge)); }
@media (max-width: 560px) { .awardShelf { grid-template-columns: repeat(2, 1fr); } }
/* новый канал: анимированный маскот */
.qChIcon { display: flex; justify-content: center; margin-bottom: 10px; min-height: 60px;
  align-items: flex-end; color: var(--accent); }
.qChIcon > svg { width: 56px; height: 56px; }
body[data-era="2"] .qChIcon { color: var(--amber); }
/* справочник каналов */
.chRow { display: grid; grid-template-columns: 30px 110px 1fr; gap: 4px 10px; align-items: center;
  text-align: left; padding: 9px 6px; border-bottom: 2px dashed color-mix(in srgb, var(--muted) 40%, transparent);
  color: var(--muted); font: 700 11.5px/1.45 ui-monospace, monospace; }
.chRow .chIco { width: 26px; height: 26px; opacity: .35; }
.chRow .chIco svg { width: 100%; height: 100%; }
.chRow b { font-family: 'Press Start 2P', monospace; font-size: 8.5px; }
.chRow.open { color: var(--ink); }
.chRow.open .chIco { opacity: 1; color: var(--accent); }
body[data-era="2"] .chRow.open .chIco { color: var(--amber); }
.chRow .chBlurb { font-weight: 400; font-size: 11px; }

/* ===== Ховеры (только устройства с мышью): мгновенные, по-пиксельному ===== */
@media (hover: hover) {
  .buyCard.affordable:hover { box-shadow: 6px 6px 0 rgba(0,0,0,.3); filter: brightness(1.05); }
  body[data-era="2"] .buyCard.affordable:hover { box-shadow: 6px 6px 0 rgba(0,0,0,.55); }
  .buyCard.affordable:hover::after { background: var(--amber-fill); color: #33291F; }
  .buyCard:not(.affordable):not(.locked):not(.owned):hover { filter: brightness(1.04); }
  .buyCard.locked:hover { border-style: solid; }
  .tab:hover:not(.active) { background: color-mix(in srgb, var(--ink) 8%, var(--card)); color: var(--ink); }
  body[data-era="2"] .tab:hover:not(.active) { background: color-mix(in srgb, var(--amber-fill) 12%, var(--card)); }
  .menuBtn:hover { background: color-mix(in srgb, var(--amber-fill) 12%, var(--card));
    box-shadow: 0 6px 0 var(--edge); transform: translateY(-2px); }
  .primary:hover, .btnLink:hover, #startBtn:hover, #fightBtn:hover { filter: brightness(1.1); }
  .ghost:hover { color: var(--ink); border-color: var(--ink); }
  .ghost.danger:hover { color: var(--danger); border-color: var(--danger); filter: brightness(1.15); }
  #blastBtn:hover { filter: brightness(1.06); }
  .chip:hover { border-color: var(--accent); }
  .chip.bad:hover { border-color: var(--danger); }
  .journalBtn:hover { color: var(--accent); }
  .term:hover { color: var(--accent); border-color: var(--accent); }
  .apToggle:hover { color: var(--ink); border-color: var(--ink); }
  #buffIcon:hover { box-shadow: 4px 4px 0 rgba(0,0,0,.3), 0 0 0 3px var(--amber-fill); }
  #ticker:hover .tickerMsg { color: var(--accent); }
  .backLink:hover, .softCta a:hover { color: var(--ink); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  body:not(.forceMotion) *, body:not(.forceMotion) *::before, body:not(.forceMotion) *::after {
    animation: none !important; transition: none !important; }
  body:not(.forceMotion) #raidBar.strike { box-shadow: 0 0 0 3px var(--filter); }
  body:not(.forceMotion) .mLine { opacity: 1 !important; }
  body:not(.forceMotion) .cameo { opacity: 1; transform: none; }
  body:not(.forceMotion) .cameo.out { opacity: 0; }
  body:not(.forceMotion) .pxChar .pxF1 { opacity: 1; }
}
body.reduced *, body.reduced *::before, body.reduced *::after { animation: none !important; transition: none !important; }
body.reduced .mLine { opacity: 1 !important; }
body.reduced .cameo { opacity: 1; transform: none; }
body.reduced .cameo.out { opacity: 0; }

/* ===== Десктоп ≥900: три колонки + журнал-лента (U2) ===== */
@media (min-width: 900px) {
  body { padding: 14px 0; }
  #app { max-width: 1280px; height: calc(100dvh - 28px); display: grid;
    grid-template-columns: 320px 1fr 320px; grid-template-rows: auto auto auto auto 1fr auto;
    gap: 0 18px; padding: 0 18px;
    /* рамка игрового поля, как device-рамка в макете */
    border: 4px solid #191612; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    background-color: var(--paper);
    background-image: repeating-conic-gradient(var(--check-dot) 0% 25%, transparent 0% 50%);
    background-size: 8px 8px; }
  body[data-era="2"] { background-color: #14172B; }
  #top { grid-column: 1 / -1; grid-row: 1; margin: 0 -18px; }
  /* бегущая строка на десктопе крупнее */
  #ticker { min-height: 50px; font-size: 14px; padding: 8px 12px 8px 14px; gap: 10px; }
  .tickerTag { font-size: 9px; padding: 5px 8px 4px; }
  .journalBtn { width: 34px; height: 34px; }
  #numbers { grid-column: 2; grid-row: 2; }
  #blastZone { grid-column: 2; grid-row: 3; }
  #tabs { grid-column: 2; grid-row: 4; border: 3px solid var(--edge); }
  #panels { display: contents; }
  #panels > .panel { display: none; }
  /* паддинг справа — чтобы скроллбар не прилипал к плиткам и не резал их */
  #panels > .panel.active { display: block; grid-column: 2; grid-row: 5; min-height: 0; overflow-y: auto; padding: 10px 10px 20px 2px; }
  #panels > #panel-sources { display: block !important; grid-column: 1; grid-row: 2 / 6; min-height: 0; overflow-y: auto;
    padding: 10px 12px 10px 0; border-right: 3px solid var(--edge); }
  /* колонка тянется до рамки приложения: скроллбар у рамки, зазор — у карточек */
  #panels > #panel-upgrades { display: block !important; grid-column: 3; grid-row: 2 / 6; min-height: 0; overflow-y: auto;
    margin-right: -18px; padding: 10px 8px 10px 12px; border-left: 3px solid var(--edge); }
  .colHead { display: block; }
  /* Источники/Апгрейды закреплены колонками — их вкладки скрыты, зато есть СВОДКА */
  .tab[data-tab="upgrades"], .tab[data-tab="sources"] { display: none; }
  .tab.deskTab { display: block; }
  .tab[data-tab="more"] { display: block; }
  #journalStrip { grid-column: 1 / -1; grid-row: 6; margin: 0 -18px;
    display: flex; gap: 9px; align-items: center; overflow-x: auto; min-height: 62px;
    padding: 10px var(--pp); border-top: 3px solid var(--edge); background: var(--card);
    font: 700 12.5px ui-monospace, monospace; white-space: nowrap; }
  .jItem { display: inline-flex; gap: 8px; align-items: center; flex: none; color: var(--muted);
    padding: 6px 10px; border: 2px solid var(--edge); background: var(--paper); }
  .jItem time { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--accent); }
  /* камео — у центральной колонки, на виду, крупнее */
  .cameo { bottom: 150px; }
  .cameo.left { left: calc(50% - 315px); }
  .cameo.right { right: calc(50% - 315px); }
}
