/* Игра в стиле пиксель-арт: пиксельный шрифт, ступенчатые рамки, «объёмные» кнопки.
   Остальной журнал остаётся в обычном стиле. */

:root {
  --px-font: 'Tiny5', ui-monospace, monospace;          /* текст: компактный и читаемый */
  --px-title: 'Press Start 2P', ui-monospace, monospace; /* заголовки и кнопки */
  --px-ink: #120d18;      /* контур */
  --px-bg: #1b1622;       /* фон подземелья */
  --px-panel: #2b2238;    /* панели */
  --px-panel-2: #3a2f4b;
  --px-light: #5a4a72;    /* светлая кромка */
  --px-text: #f2ead8;
  --px-dim: #b5a8c8;
  --px-gold: #ffd34d;
  --px-red: #e8445a;
  --px-blue: #4aa3ff;
  --px-green: #5bd66f;
}

/* Пиксельные шрифты чёткие только на «своих» размерах: Tiny5 — 16/20/24, Press Start 2P — 8/12/16/24 */

/* Пиксельная рамка: контур + светлая кромка сверху-слева + тень снизу-справа */
.px-panel, .arena-panel, .px-btn, .arena-btn, .up, .px-hero {
  box-shadow:
    0 0 0 3px var(--px-ink),
    inset 3px 3px 0 rgba(255, 255, 255, .08),
    inset -3px -3px 0 rgba(0, 0, 0, .35);
}

/* ---------- Экран «Игра» в журнале ---------- */
.px-game {
  font-family: var(--px-font); color: var(--px-text);
  max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 3px 12px;
}
.px-game, .px-game button { -webkit-font-smoothing: none; }
.px-title {
  text-align: center; font-family: var(--px-title); font-size: 24px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--px-gold); text-shadow: 3px 3px 0 #a3471d, 6px 6px 0 var(--px-ink);
  margin: 6px 0 4px;
}
.px-panel { background: var(--px-panel); padding: 14px; margin: 3px; }
.px-center { text-align: center; }
.px-h {
  font-family: var(--px-title); font-size: 12px; line-height: 1.5; text-transform: uppercase;
  color: var(--px-gold); margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.px-note { color: var(--px-dim); font-size: 16px; margin-top: 4px; line-height: 1.25; }
.px-label { font-size: 24px; }
.px-coins { color: var(--px-gold); }

.px-tries { display: flex; gap: 16px; align-items: center; }
.px-big {
  min-width: 76px; height: 76px; display: flex; align-items: center; justify-content: center;
  font-family: var(--px-title); font-size: 32px; color: var(--px-gold);
  background: var(--px-ink); box-shadow: inset 0 0 0 3px var(--px-light);
  text-shadow: 3px 3px 0 #a3471d;
}
.px-ladder { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.px-ladder span {
  min-width: 30px; height: 26px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--px-panel-2); color: var(--px-dim); font-size: 16px;
  box-shadow: 0 0 0 2px var(--px-ink);
}
.px-ladder span.used { opacity: .35; text-decoration: line-through; }
.px-ladder span.next { background: var(--px-gold); color: var(--px-ink); }

.px-chosen { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.px-chosen-art {
  width: 104px; height: 128px; flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
  background: linear-gradient(var(--px-panel-2) 75%, #241c30 75%);
  box-shadow: 0 0 0 3px var(--px-ink), inset 0 0 0 3px var(--px-light);
}
.px-chosen-name { font-family: var(--px-title); font-size: 16px; line-height: 1.4; }
.px-weapon { display: flex; align-items: center; gap: 6px; }

.px-btn, .arena-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; margin: 3px 0; padding: 0 14px;
  font-family: var(--px-title); font-size: 16px; line-height: 1.4; text-transform: uppercase;
  color: #fff; background: #4a3d5e; border: 0; border-radius: 0; cursor: pointer;
  text-shadow: 2px 2px 0 var(--px-ink);
}
.arena-btn { margin-top: 12px; }
.px-btn.play, .arena-btn.primary { background: #c2412f; }
.px-btn.play:not([disabled]) { animation: px-glow 1.6s steps(2) infinite; }
@keyframes px-glow { 50% { background: #d9533e; } }
.px-btn:active:not([disabled]), .arena-btn:active { transform: translateY(2px); box-shadow: 0 0 0 3px var(--px-ink), inset 3px 3px 0 rgba(0, 0, 0, .35); }
.px-btn[disabled] { background: #3a3346; color: #8d82a0; cursor: default; animation: none; text-shadow: none; }
.px-btn.small { width: auto; min-height: 40px; font-size: 12px; padding: 0 12px; background: #8a6418; }

.px-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; margin: 16px 3px 10px; }
.px-hero {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
  min-height: 112px; padding: 8px 4px 6px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--px-panel-2); color: var(--px-text); font-family: var(--px-font);
}
.px-hero.on { background: #5b3b8a; box-shadow: 0 0 0 3px var(--px-gold), inset 3px 3px 0 rgba(255, 255, 255, .12), inset -3px -3px 0 rgba(0, 0, 0, .35); }
.px-hero.locked .px-hero-art { filter: brightness(.35) saturate(.4); }
.px-hero[disabled] { opacity: .65; cursor: default; }
.px-hero:active:not([disabled]) { transform: translateY(2px); }
.px-hero-art { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.px-hero-name { font-size: 16px; line-height: 1; text-align: center; }
.px-price { font-size: 16px; color: var(--px-gold); }
.px-price.poor { color: #8d82a0; }
.hero-icon { display: block; image-rendering: pixelated; background-repeat: no-repeat; }

.px-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.px-stats div { background: var(--px-ink); padding: 8px 4px; text-align: center; box-shadow: inset 0 0 0 2px var(--px-light); }
.px-stats b { display: block; font-size: 24px; color: var(--px-gold); }
.px-stats span { font-size: 16px; color: var(--px-dim); }

.px-shop { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.px-shop li { display: flex; align-items: center; gap: 12px; background: var(--px-panel-2); padding: 10px 12px; box-shadow: 0 0 0 2px var(--px-ink); }
.px-shop-txt { flex: 1; min-width: 0; }
.px-shop-txt b { display: block; font-size: 20px; }
.px-shop-txt small { display: block; color: var(--px-dim); font-size: 16px; }
.px-pips { display: flex; gap: 3px; margin-top: 5px; flex-wrap: wrap; }
.px-pips i { width: 10px; height: 10px; background: var(--px-ink); box-shadow: inset 0 0 0 1px var(--px-light); }
.px-pips i.on { background: var(--px-gold); box-shadow: none; }
.px-tag { font-family: var(--px-title); font-size: 8px; color: var(--px-green); padding: 0 8px; }
.px-rules { margin: 0; padding-left: 20px; color: var(--px-dim); font-size: 16px; line-height: 1.3; }
.px-rules li { margin: 6px 0; }
.px-credit { font-family: var(--px-font); text-align: center; color: #6e6380; font-size: 16px; margin: 0; }

/* Экран «Игра» тёмный в любой теме — это подземелье */
.main:has(.px-game) { background: var(--px-bg); }

/* ---------- Арена ---------- */
body.in-arena { overflow: hidden; overscroll-behavior: none; }
body.in-arena .fab { display: none !important; }

.arena {
  position: fixed; inset: 0; z-index: 100;
  background: var(--px-bg); color: var(--px-text);
  touch-action: none; user-select: none; -webkit-user-select: none;
  font-family: var(--px-font); -webkit-font-smoothing: none;
}
.arena-canvas { position: absolute; inset: 0; display: block; image-rendering: pixelated; }
.arena-hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(12px + env(safe-area-inset-top)) 14px 0; pointer-events: none; }
.hud-top { display: flex; gap: 12px; align-items: center; }
.hud-bars { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.hud-hp, .hud-xp, .hud-boss > div {
  position: relative; height: 18px; overflow: hidden;
  background: var(--px-ink); box-shadow: 0 0 0 3px var(--px-ink), inset 0 0 0 2px var(--px-light);
}
.hud-xp { height: 16px; }
.hud-hp i, .hud-xp i, .hud-boss i { position: absolute; inset: 2px auto 2px 2px; max-width: calc(100% - 4px); transition: width .12s steps(4); }
.hud-hp i { background: linear-gradient(var(--px-red) 50%, #b8293f 50%); }
.hud-xp i { background: linear-gradient(var(--px-blue) 50%, #2f72c4 50%); }
.hud-hp b, .hud-xp b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px; text-shadow: 2px 2px 0 var(--px-ink);
}
.hud-xp b { font-size: 16px; }
.hud-pause {
  pointer-events: auto; width: 46px; height: 46px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--px-panel-2); color: var(--px-text); font-family: var(--px-title); font-size: 12px;
  box-shadow: 0 0 0 3px var(--px-ink), inset 3px 3px 0 rgba(255, 255, 255, .1), inset -3px -3px 0 rgba(0, 0, 0, .35);
}
.hud-row { display: flex; gap: 14px; margin-top: 8px; font-size: 16px; text-shadow: 2px 2px 0 var(--px-ink); }
.hud-coins { color: var(--px-gold); }
.hud-weapons { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.hud-weapons span {
  position: relative; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: rgba(18, 13, 24, .75); box-shadow: 0 0 0 2px var(--px-ink), inset 0 0 0 2px var(--px-light);
}
.hud-weapons .up-icon { transform: scale(.6); }
.hud-weapons i { position: absolute; right: 2px; bottom: 0; font-size: 16px; font-style: normal; color: var(--px-gold); text-shadow: 1px 1px 0 var(--px-ink); }
.hud-boss { margin-top: 12px; text-align: center; font-size: 16px; color: #ff9db0; text-shadow: 2px 2px 0 var(--px-ink); }
.hud-boss > div { height: 12px; margin-top: 4px; }
.hud-boss i { background: linear-gradient(#ff5c7a 50%, #b0123a 50%); }

.arena-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 7, 14, .78);
}
.arena-overlay[hidden] { display: none; }
.arena-panel { width: 100%; max-width: 380px; text-align: center; background: var(--px-panel); padding: 18px 16px; margin: 3px; }
.panel-title { font-family: var(--px-title); font-size: 16px; line-height: 1.5; text-transform: uppercase; color: var(--px-gold); text-shadow: 3px 3px 0 #a3471d; }
.panel-sub { color: var(--px-dim); font-size: 20px; margin: 8px 0 16px; }
.up-list { display: flex; flex-direction: column; gap: 12px; }
.up {
  display: flex; gap: 12px; align-items: center; text-align: left;
  min-height: 70px; padding: 10px 12px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--px-panel-2); color: var(--px-text); font-family: var(--px-font);
  animation: up-in .2s steps(3) backwards;
}
.up:nth-child(2) { animation-delay: .07s; }
.up:nth-child(3) { animation-delay: .14s; }
.up:active { transform: translateY(2px); background: #4a3d5e; }
@keyframes up-in { from { opacity: 0; transform: translateY(12px); } }
.up b { display: block; font-size: 20px; }
.up small { display: block; color: var(--px-dim); font-size: 16px; margin-top: 2px; }
.up em { color: var(--px-gold); font-style: normal; }
.up-icon { flex: 0 0 auto; display: inline-block; image-rendering: pixelated; background-repeat: no-repeat; }
.up > .up-icon { margin: 0 8px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.res-grid div { background: var(--px-ink); padding: 10px; box-shadow: inset 0 0 0 2px var(--px-light); }
.res-grid b { display: block; font-size: 24px; color: var(--px-gold); }
.res-grid span { font-size: 16px; color: var(--px-dim); }
.result.won .panel-title { color: var(--px-green); text-shadow: 3px 3px 0 #1f6e46; }

/* ---------- Баннер на обзоре ---------- */
.game-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 16px; color: var(--text); }
.game-banner:hover { text-decoration: none; border-color: var(--border-strong); }
.game-banner .gi { font-size: 22px; }
.game-banner .gt { flex: 1; min-width: 0; }
.game-banner .gt b { display: block; }
.game-banner .gt span { font-size: 13px; color: var(--muted); }
.game-banner.ready { background: linear-gradient(90deg, var(--accent-weak), var(--surface)); border-color: var(--accent); }

/* Статус синхронизации внизу бокового меню */
#sync { margin-top: auto; }

@media (max-width: 899px) {
  .px-title { font-size: 16px; }
  .px-chosen-art { width: 92px; height: 116px; }
  .main:has(.px-game) .page-head { display: none; }
}

/* Редкое улучшение: золотая рамка и мерцание */
.up.rare { background: #4b3a1c; box-shadow: 0 0 0 3px var(--px-gold), inset 3px 3px 0 rgba(255, 255, 255, .12), inset -3px -3px 0 rgba(0, 0, 0, .35); animation: up-in .2s steps(3) backwards, rare-glow 1s steps(2) infinite; }
.up.rare b { color: var(--px-gold); }
@keyframes rare-glow { 50% { background: #5c4822; } }

/* ---------- Круги, эволюции, достижения ---------- */
.px-tiers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
.px-tier {
  min-height: 40px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--px-panel-2); color: var(--px-text); font-family: var(--px-title); font-size: 12px;
  box-shadow: 0 0 0 3px var(--px-ink), inset 3px 3px 0 rgba(255, 255, 255, .08), inset -3px -3px 0 rgba(0, 0, 0, .35);
}
.px-tier.on { background: #8a2f3b; color: var(--px-gold); box-shadow: 0 0 0 3px var(--px-gold), inset 3px 3px 0 rgba(255, 255, 255, .1), inset -3px -3px 0 rgba(0, 0, 0, .35); }
.px-tier[disabled] { background: var(--px-ink); color: #4e4460; cursor: default; }
.px-tier:active:not([disabled]) { transform: translateY(2px); }
.px-count { color: var(--px-dim); font-family: var(--px-font); font-size: 16px; margin-left: 6px; }
.px-evos, .px-ach { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.px-evos li, .px-ach li { display: flex; align-items: center; gap: 12px; background: var(--px-ink); padding: 8px 10px; }
.px-evos li > div, .px-ach li > div { flex: 1; min-width: 0; }
.px-evos b, .px-ach b { display: block; font-size: 20px; color: var(--px-dim); }
.px-evos small, .px-ach small { display: block; color: #8d82a0; font-size: 16px; }
.px-evos li.got b, .px-ach li.got b { color: var(--px-gold); }
.px-evos li:not(.got) .hero-icon { filter: brightness(.5) saturate(.4); }
.px-ach li.got { box-shadow: inset 0 0 0 2px #6b5520; }
.px-ach li.got .px-coins { color: var(--px-green); }

.hud-tier { color: #ff9db0; }
.hud-weapons span.evolved { box-shadow: 0 0 0 2px var(--px-ink), inset 0 0 0 2px var(--px-gold); background: rgba(75, 58, 28, .85); }

/* Список эволюций в паузе */
.evo-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; text-align: left; max-height: 40vh; overflow-y: auto; }
.evo-list > div { display: flex; align-items: center; gap: 10px; background: var(--px-ink); padding: 6px 8px; }
.evo-list .up-icon { transform: scale(.7); margin: -6px; }
.evo-list b { display: block; font-size: 16px; }
.evo-list small { display: block; color: var(--px-dim); font-size: 16px; }
.evo-list .done b { color: var(--px-gold); }
.arena-panel .up-list + .arena-btn, .arena-panel.evolved .up + .arena-btn { margin-top: 14px; }
.arena-panel.evolved .up { cursor: default; }
