:root {
  --bg: #14101c;
  --bg2: #1d1730;
  --panel: #241b3a;
  --panel2: #2e2350;
  --gold: #e8b84b;
  --gold-soft: #f3d27e;
  --text: #ece6f5;
  --muted: #9a8fb8;
  --green: #4fd47e;
  --red: #ef5d6b;
  --blue: #5aa9ff;
  --common: #9aa6b2;
  --rare: #4f9dff;
  --epic: #c46bff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Handjet', 'Segoe UI', system-ui, sans-serif;
  font-size: 19px; font-weight: 500; letter-spacing: .3px;
  background:
    radial-gradient(1200px 800px at 50% -10%, var(--bg2), var(--bg)),
    repeating-linear-gradient(0deg, rgba(0,0,0,.10) 0 2px, rgba(0,0,0,0) 2px 4px); /* лёгкая «сканлайн» текстура */
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* заголовки/кнопки — жирный пиксель */
h1, h2, h3, h4, .logo, .btn, .act-btn, .turn-indicator, .brand, .result-title, .cc-name { font-weight: 900; letter-spacing: .5px; }

#app { max-width: 920px; margin: 0 auto; padding: 0 16px 40px; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: 1px; }
.brand span { color: var(--gold); }
.top-right { display: flex; align-items: center; gap: 10px; }
.online { font-size: 13px; color: var(--muted); }
.online b { color: var(--green); }
.snd-toggle { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  font-size: 16px; line-height: 1; padding: 6px 8px; cursor: pointer; transition: opacity .15s, filter .15s; }
.snd-toggle.off { opacity: .35; filter: grayscale(1); }
.snd-toggle:hover { filter: brightness(1.2); }

/* ---------- scenes ---------- */
.scene { display: none; animation: fade .35s ease; }
.scene.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), inset 0 0 0 2px rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.06);
}
.center { text-align: center; max-width: 460px; margin: 6vh auto 0; }

/* фон экрана меню — пиксельный лес (картинка из интернета, автор в подписи) */
#scene-menu.active {
  background:
    linear-gradient(180deg, rgba(20,16,28,.55), rgba(20,16,28,.82)),
    url('/assets/bg/menu_bg.png') center 30%/cover no-repeat;
  border-radius: 18px; padding: 18px 0 26px; margin-top: 6px;
  box-shadow: inset 0 0 0 2px rgba(232,184,75,.18);
}
#scene-menu .center { margin-top: 3vh; }
.menu-credit { margin-top: 14px; font-size: 11px; color: rgba(255,255,255,.55); }
.menu-credit a { color: var(--gold-soft); }

.logo {
  font-size: 58px; line-height: .95; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 0 rgba(0,0,0,.35); margin-bottom: 12px;
}
.subtitle { color: var(--muted); margin-bottom: 22px; line-height: 1.5; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- controls ---------- */
.input {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.1);
  color: var(--text); font-size: 16px; text-align: center; margin-bottom: 14px;
}
.input:focus { outline: none; border-color: var(--gold); }

/* фэнтези-плашки: толстая фаска + объём (как каменные/золотые таблички) */
.btn {
  font-family: 'Handjet', system-ui, sans-serif; border: 2px solid rgba(0,0,0,.45); border-radius: 8px;
  padding: 13px 22px; font-size: 22px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: transform .1s, filter .1s; color: #fff;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.28), inset 0 -4px 0 rgba(0,0,0,.32), 0 4px 0 rgba(0,0,0,.4);
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,.2), inset 0 -2px 0 rgba(0,0,0,.3), 0 1px 0 rgba(0,0,0,.4); }
.btn-primary { background: linear-gradient(180deg, #f6d987, #cf9b34); color: #3a2a06; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: linear-gradient(180deg, #3b3157, #271d40); color: var(--gold-soft); border-color: rgba(0,0,0,.5); }
.btn-ghost:hover { filter: brightness(1.15); }
.btn.big { width: 100%; padding: 16px; font-size: 23px; }
.row { display: flex; }
.row.gap { gap: 12px; }
.row .btn { flex: 1; }

/* ---------- выбор класса: карусель ---------- */
.class-label { text-align: center; font-size: 14px; color: var(--muted); margin: 6px 2px 6px; }
.class-carousel { display: flex; align-items: center; justify-content: center; gap: 6px; }
.carousel-stage {
  position: relative; flex: 1 1 auto; max-width: 400px; height: 366px; overflow: hidden;
  border-radius: 16px;
  /* мягкий фон без рамки — сцена «растворяется» в панели */
  background:
    radial-gradient(120% 75% at 50% 6%, rgba(90,60,140,.30), rgba(0,0,0,0) 62%),
    linear-gradient(180deg, rgba(36,27,58,.55) 0%, rgba(18,14,28,.85) 75%, rgba(10,8,16,.95) 100%);
}
.carousel-hero { position: absolute; inset: 0; z-index: 3; }
/* живой спрайт главного героя стоит на «полу» по центру */
.carousel-hero .sprite { z-index: 3; bottom: 18px; }
/* подсветка героя — пульсирующее золотое сияние позади (на уровне сцены, не уезжает с героем) */
.hero-glow {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: 290px; height: 290px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle, rgba(232,184,75,.50), rgba(232,184,75,.12) 52%, rgba(232,184,75,0) 70%);
  filter: blur(2px); animation: hero-glow-pulse 2.4s ease-in-out infinite;
}
@keyframes hero-glow-pulse { 0%,100% { opacity: .6; transform: translateX(-50%) scale(.92); } 50% { opacity: .95; transform: translateX(-50%) scale(1.06); } }
.hero-floor {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: 180px; height: 30px; border-radius: 50%; z-index: 2;
  background: radial-gradient(ellipse, rgba(0,0,0,.55), rgba(0,0,0,0) 70%);
}
/* фоновые соседи (пред./след. классы) — тусклые силуэты позади, «стоят сзади» */
.bg-hero {
  position: absolute; bottom: 14px; width: 52%; height: 72%; z-index: 1;
  opacity: .3; filter: brightness(.28) blur(1.5px); pointer-events: none;
}
#cls-bg-left { left: -16%; }
#cls-bg-right { right: -16%; }
.bg-hero .sprite { bottom: 0; }
/* анимации смены героя */
.carousel-hero.in-next { animation: hero-in-next .34s ease; }
.carousel-hero.in-prev { animation: hero-in-prev .34s ease; }
@keyframes hero-in-next { from { transform: translateX(70px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes hero-in-prev { from { transform: translateX(-70px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.carousel-arrow {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
  background: var(--panel2); color: var(--gold-soft); border: 2px solid rgba(232,184,75,.4);
  font-size: 30px; line-height: 1; font-weight: 900; cursor: pointer; user-select: none;
  display: grid; place-items: center; padding-bottom: 4px;
  box-shadow: 0 3px 0 rgba(0,0,0,.45); transition: transform .1s, background .12s, box-shadow .1s;
}
.carousel-arrow:hover { background: var(--gold); color: #2a1d05; }
.carousel-arrow:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,.45); }

.carousel-info { text-align: center; margin: 10px 0 6px; }
.ci-name { font-weight: 900; font-size: 26px; letter-spacing: .5px; color: var(--gold-soft); }
.ci-stats { margin: 8px auto 6px; max-width: 320px; }
.ci-desc { font-size: 13px; color: var(--muted); min-height: 34px; padding: 0 6px; }

/* стат-бары героя при выборе (#7) */
.stat-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.stat-row .sr-label { flex: 0 0 92px; text-align: left; font-size: 12px; color: var(--muted); white-space: nowrap; }
.stat-row .sr-bar { flex: 1 1 auto; height: 10px; background: rgba(0,0,0,.4); border-radius: 6px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.5); }
.stat-row .sr-fill { display: block; height: 100%; border-radius: 6px; transition: width .25s ease; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }
.stat-row .sr-fill.sr-hp { background: linear-gradient(90deg, #4fd47e, #8be36a); }
.stat-row .sr-fill.sr-mana { background: linear-gradient(90deg, #3d6bff, #5aa9ff); }
.stat-row .sr-fill.sr-dmg { background: linear-gradient(90deg, #ef5d6b, #ff9a6a); }
.stat-row .sr-fill.sr-pierce { background: linear-gradient(90deg, #ffb43d, #ffe06a); }
.stat-row .sr-fill.sr-block { background: linear-gradient(90deg, #7a8cff, #aab6ff); }
.stat-row .sr-val { flex: 0 0 auto; min-width: 70px; text-align: right; font-size: 12px; font-weight: 800; color: var(--text); }

.carousel-dots { display: flex; justify-content: center; gap: 8px; margin: 4px 0 14px; }
.carousel-dots .dot {
  width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.22);
  cursor: pointer; transition: background .15s, transform .15s;
}
.carousel-dots .dot.on { background: var(--gold); transform: scale(1.3); }

/* ---------- ростер выбора героя (файтинг-стиль: плитки с лицами) ---------- */
.class-roster {
  display: grid; grid-template-columns: repeat(4, 76px); gap: 8px;
  justify-content: center; margin: 6px auto 14px;
}
.roster-cell {
  position: relative; width: 76px; height: 76px; padding: 0; overflow: hidden;
  border: 2px solid rgba(232,184,75,.22); border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #2a2142 0%, #14101f 100%);
  box-shadow: inset 0 0 14px rgba(0,0,0,.55);
  transition: border-color .12s, transform .1s, box-shadow .12s;
}
.roster-cell:hover { border-color: rgba(232,184,75,.6); transform: translateY(-2px); }
.roster-cell.on {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(232,184,75,.5), inset 0 0 10px rgba(0,0,0,.4);
  transform: translateY(-2px);
}
.roster-cell .face {
  position: absolute; left: 0; top: 0; pointer-events: none;
  background-repeat: no-repeat; image-rendering: pixelated;
}
.roster-cell .rc-name {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  font-size: 10px; font-weight: 800; text-align: center; padding: 3px 0 2px;
  color: var(--gold-soft); letter-spacing: .3px; pointer-events: none;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.82) 55%);
}
.roster-cell.on .rc-name { color: var(--gold); }

/* ---------- searching ---------- */
.searching { margin-top: 22px; }
.searching.hidden { display: none; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid rgba(232,184,75,.2); border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ---------- match found ---------- */
.vs-row { display: flex; align-items: center; justify-content: space-around; margin: 18px 0; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.vs-side .avatar {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 38px; background: rgba(255,255,255,.06); border: 2px solid rgba(232,184,75,.3);
}
.vs { font-size: 26px; font-weight: 900; color: var(--gold); }
.name { font-weight: 700; }

/* ---------- toast (уведомления о реконнекте и т.п.) ---------- */
.toast {
  position: fixed; left: 50%; top: 16px; transform: translate(-50%, -18px);
  z-index: 50; background: rgba(20,16,28,.95); color: var(--text);
  border: 2px solid var(--gold); border-radius: 12px; padding: 10px 18px;
  font-weight: 900; letter-spacing: .4px; box-shadow: 0 6px 22px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- timers ---------- */
.timer-bar { height: 8px; background: rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; margin: 16px 0; }
.timer-bar.small { height: 6px; margin: 8px 0; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .25s linear; }
.timer-fill.low { background: linear-gradient(90deg, var(--red), #ff9248); }

/* ---------- phase heads ---------- */
.phase-head { text-align: center; margin: 18px 0; }
.phase-head h2 { margin-bottom: 8px; }
.turn-indicator {
  display: inline-block; padding: 6px 18px; border-radius: 8px; font-weight: 900; font-size: 18px;
  background: linear-gradient(180deg, #3b3157, #271d40); color: var(--gold-soft); border: 2px solid var(--gold);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.1), 0 3px 0 rgba(0,0,0,.4);
}
.turn-indicator.mine { background: rgba(79,212,126,.16); color: var(--green); border-color: rgba(79,212,126,.4); }

/* ---------- сундуки: рулетка (CS-кейс) ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-4deg); } 100% { transform: scale(1); } }

.roulette {
  position: relative; overflow: hidden; height: 132px; margin: 14px 0 18px;
  border-radius: 14px; border: 2px solid #5a431f;
  background: linear-gradient(180deg, #2a2012, #1a140b);
  box-shadow: inset 0 0 34px rgba(0,0,0,.65);
}
/* центральный маркер «выпавшего» сундука */
.roulette-marker {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%);
  background: var(--gold); box-shadow: 0 0 12px var(--gold); z-index: 3;
}
.roulette-marker::before, .roulette-marker::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent;
}
.roulette-marker::before { top: -1px; border-top-color: var(--gold); border-bottom: 0; }
.roulette-marker::after  { bottom: -1px; border-bottom-color: var(--gold); border-top: 0; }
/* фейд по краям ленты */
.roulette::before, .roulette::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 60px; z-index: 2; pointer-events: none;
}
.roulette::before { left: 0;  background: linear-gradient(90deg, #1a140b, transparent); }
.roulette::after  { right: 0; background: linear-gradient(270deg, #1a140b, transparent); }

.reel {
  position: absolute; top: 0; bottom: 0; left: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 6px; will-change: transform;
}
.reel-chest {
  flex: 0 0 auto; width: 86px; height: 108px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(180deg, #3a2c18, #271d10); border: 2px solid #5a431f;
}
.reel-chest.landed { transform: scale(1.08); }

/* спрайт сундука: полоска кадров 48x40 (9 кадров), 1-й = закрыт, последний = открыт.
   Анимация открытия — сдвигом background-position-x в game.js (animateChestOpen). */
.chest-sprite {
  width: 72px; height: 60px;
  background-repeat: no-repeat; background-size: 648px 60px; background-position: 0 0;
  image-rendering: pixelated;
}

/* ауры = свечение тайла по цвету тира (чем выше тир — тем ярче) */
.reel-chest.aura-copper  { border-color: rgba(230,140,70,.65); box-shadow: 0 0 14px rgba(230,140,70,.4); }
.reel-chest.aura-silver  { border-color: rgba(205,213,228,.6); box-shadow: 0 0 14px rgba(205,213,228,.4); }
.reel-chest.aura-azure   { border-color: rgba(79,157,255,.6);  box-shadow: 0 0 15px rgba(79,157,255,.45); }
.reel-chest.aura-crimson { border-color: rgba(239,93,107,.6);  box-shadow: 0 0 16px rgba(239,93,107,.45); }
.reel-chest.aura-violet  { border-color: rgba(196,107,255,.65);box-shadow: 0 0 18px rgba(196,107,255,.5); }
.reel-chest.aura-amber   { border-color: rgba(232,184,75,.9);  box-shadow: 0 0 22px rgba(232,184,75,.65); }

/* ---------- открытый сундук: 3 предмета на выбор ---------- */
.chest-open { text-align: center; margin: 2px 0 16px; animation: pop .4s ease; }
.chest-open.hidden { display: none; }
.chest-open-title { font-size: 20px; margin-bottom: 10px; color: var(--gold-soft); }
.chest-options { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.chest-card {
  flex: 0 1 260px; cursor: pointer; border-radius: 12px; padding: 8px 8px 6px;
  border: 2px solid rgba(255,255,255,.12); background: rgba(255,255,255,.03);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.chest-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 8px 22px rgba(232,184,75,.3); }
.chest-card .cc-slot { font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
/* внутри сундука рамку даёт сам .chest-card (узорная, v44) — у предмета её гасим */
.chest-card .item { cursor: pointer; margin: 0; background: transparent; border: none; padding: 2px; }
.chest-card.taken { opacity: .45; pointer-events: none; }
.chest-card.taken::after { content: '✅ взято'; display: block; margin-top: 4px; color: #4fd47e; font-size: 13px; }
.chest-card.pop { animation: pop .45s ease; }

/* «рубашки» — скрытая добыча соперника во время фазы (#2) */
.facedown { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.card-back { width: 24px; height: 30px; display: grid; place-items: center; font-size: 14px;
  background: linear-gradient(180deg, #3a2c58, #241b3a); border: 1px solid rgba(232,184,75,.3); border-radius: 5px; }

/* ---------- inventories ---------- */
.inventories { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.inv-col h3 { font-size: 14px; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.inv-list { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }

.item {
  display: flex; flex-direction: column; gap: 7px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.08); border-left-width: 4px;
  text-align: left;
}
.item-head { display: flex; align-items: center; gap: 10px; }
.item .item-ic { font-size: 30px; width: 42px; min-width: 42px; height: 42px; display: grid; place-items: center;
  background: rgba(0,0,0,.3); border-radius: 9px; }
.item .item-ic img, .item .item-ic.ic-atlas { display: block; }
.item .item-id { flex: 1; min-width: 0; }
.item .nm { font-weight: 800; font-size: 16px; line-height: 1.15; }
.item .rar-tag { font-size: 11px; letter-spacing: .3px; margin-top: 2px; text-transform: uppercase; opacity: .9; }
.rar-tag.rt-common { color: var(--common); }
.rar-tag.rt-rare   { color: var(--rare); }
.rar-tag.rt-epic   { color: var(--epic); }
.item .item-desc { font-size: 13px; line-height: 1.35; color: #d7d2e6; }
.item .item-desc b { color: #fff; }
.item .val { font-weight: 800; font-size: 16px; white-space: nowrap; align-self: flex-start; }
.item .val.dmg { color: var(--red); }
.item .val.def { color: var(--blue); }
.item .val.chg { color: var(--gold-soft); }
/* перки оружия — отдельными строками с подписью */
.item .perk-list { display: flex; flex-direction: column; gap: 4px; margin-top: 1px; }
.item .perk-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  padding: 4px 7px; border-radius: 7px; background: rgba(255,255,255,.05); }
.item .perk-row.bad { opacity: .72; filter: saturate(.6); }
.item .perk-row .perk-name { font-weight: 700; color: #f0ead8; }
.item .perk-row .perk-desc { color: var(--muted); font-size: 11.5px; }
.item .perk-row .pic-atlas { flex: 0 0 auto; }
.item.rar-common { border-left-color: var(--common); }
.item.rar-rare { border-left-color: var(--rare); }
.item.rar-epic { border-left-color: var(--epic); }
.item.selectable { cursor: pointer; transition: transform .1s, background .1s, box-shadow .1s; }
.item.selectable:hover { background: rgba(232,184,75,.1); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.item.equipped { outline: 2px solid var(--gold); background: rgba(232,184,75,.08); }

/* ---------- equip ---------- */
/* ромбовидные слоты tinyRPG: рамка по типу (CSS background), иконка предмета поверх.
   Пусто — видна типовая рамка (меч/щит/кольцо); надето — зелёная рамка (*_on) + иконка. */
.equip-slots { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 8px 0 4px; justify-items: center; }
.slot { background: none; border: none; border-radius: 0; padding: 0; text-align: center; min-height: auto; }
.slot .slot-pic {
  width: 76px; height: 76px; margin: 0 auto; display: grid; place-items: center;
  background-repeat: no-repeat; background-size: contain; background-position: center;
  image-rendering: pixelated;
}
/* пусто → пустой ромб (без типовой иконки); надето → рамка по типу + иконка предмета */
.slot .slot-pic { background-image: url('/assets/ui/frames/empty.png?v=19'); }
.slot.filled.frame-weapon   .slot-pic { background-image: url('/assets/ui/frames/weapon_on.png?v=19'); }
.slot.filled.frame-armor    .slot-pic { background-image: url('/assets/ui/frames/armor_on.png?v=19'); }
.slot.filled.frame-artifact .slot-pic { background-image: url('/assets/ui/frames/artifact_on.png?v=19'); }
.slot .slot-ic { filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.slot-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.slot-name { font-size: 13px; font-weight: 700; color: var(--gold-soft); min-height: 16px; }
.equip-inventory { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 14px 0 18px; align-items: start; }
.equip-group { background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 10px; }
.equip-group h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; text-align: center; }
.equip-group .item { margin-bottom: 6px; }
.equip-group .item:last-child { margin-bottom: 0; }
.equip-synergy { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 24px; margin: 4px 0 2px; }
.syn-chip { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: rgba(232,184,75,.14); border: 1px solid rgba(232,184,75,.35); color: var(--gold-soft); }
.syn-chip.t3 { background: rgba(196,107,255,.18); border-color: rgba(196,107,255,.5); color: #e2bdff; }
.item .tags { font-size: 10px; opacity: .8; }
@media (max-width: 560px) { .equip-inventory { grid-template-columns: 1fr; } }

/* ---------- battle: арена + покадровые спрайты ---------- */
.arena {
  position: relative; min-height: 500px; margin: 12px 0; padding: 14px 8px 0;
  display: flex; align-items: flex-end; justify-content: center; gap: 150px;
  overflow: hidden; border-radius: 18px; background: #1a1424;
}
/* HUD полос HP/маны сверху, как в файтингах */
.hud { position: absolute; top: 12px; width: 42%; z-index: 6; }
.hud-left { left: 14px; }
.hud-right { right: 14px; }
.hud .hp-bar { height: 20px; border-radius: 6px; border: 2px solid rgba(0,0,0,.5); box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.hud .mana-bar { height: 16px; border-radius: 5px; margin-top: 3px; border: 2px solid rgba(0,0,0,.5); }
.hud .hp-text { font-size: 12px; }
.hud .mana-text { font-size: 11px; }
.hud-right .hp-fill, .hud-right .mana-fill { float: right; }   /* у правого полоса убывает справа налево */
/* имя игрока + счётчик побед/поражений ПОД барами (#1/#2) */
.hud-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.hud-right .hud-foot { flex-direction: row-reverse; }
.hud-name { font-weight: 900; font-size: 15px; text-shadow: 0 1px 3px #000, 0 0 4px #000; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-record { font-size: 13px; font-weight: 900; white-space: nowrap; text-shadow: 0 1px 3px #000; display: inline-block; }
.hud-record .rec-w { color: #7fe39a; }
.hud-record .rec-l { color: #ef8a96; }
.hud-record.flash-win { animation: rec-win 1s ease; }
.hud-record.flash-lose { animation: rec-lose 1s ease; }
/* #6: активная абилка/эффект под баром — читаемая плашка с подложкой */
.hud-ability { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.hud-right .hud-ability { justify-content: flex-end; }
.hud-ability:empty { display: none; }
.hab { display: inline-block; font-size: 11px; font-weight: 800; line-height: 1.2; padding: 3px 7px;
  border-radius: 7px; color: #fff; background: rgba(12,10,28,.8); border: 1.5px solid rgba(255,210,120,.55);
  box-shadow: 0 2px 0 rgba(0,0,0,.45), inset 0 0 8px rgba(255,200,90,.12); text-shadow: 0 1px 2px #000;
  white-space: nowrap; animation: hab-in .25s ease; }
.hab-dmg { border-color: rgba(255,120,110,.75); }
.hab-armor { border-color: rgba(170,180,255,.75); }
.hab-thorns { border-color: rgba(140,220,140,.75); }
.hab-life { border-color: rgba(255,110,150,.75); }
.hab-block { border-color: rgba(150,200,255,.8); }
@keyframes hab-in { from { transform: translateY(-4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes rec-win { 0% { transform: scale(1); } 25% { transform: scale(1.75); filter: drop-shadow(0 0 12px var(--green)) brightness(1.5); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes rec-lose { 0% { transform: scale(1); } 25% { transform: scale(1.6); filter: drop-shadow(0 0 12px var(--red)) brightness(1.4); } 12%, 36% { transform: translateX(-4px) scale(1.5); } 24%, 48% { transform: translateX(4px) scale(1.5); } 100% { transform: scale(1); } }

/* Таймер раунда — одно крупное число по центру, между группами полос HP/маны */
.battle-clock {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 7; font-family: 'Handjet', monospace; font-weight: 900; line-height: 1;
  font-size: 52px; color: #fff; min-width: 60px; text-align: center;
  text-shadow: 0 3px 0 #000, 0 0 12px rgba(0,0,0,.85);
}
.battle-clock.low { color: var(--red); text-shadow: 0 3px 0 #000, 0 0 16px rgba(239,93,107,.9); animation: clock-pulse .5s ease-in-out infinite; }
@keyframes clock-pulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.22); } }

/* ===== ФОНЫ АРЕН — детализированный пиксель-арт (craftpix / Free Game Assets) ===== */
.arena.lawn, .arena.colosseum, .arena.dungeon, .arena.snow, .arena.hall, .arena.forest {
  background-size: cover; background-position: center bottom; background-repeat: no-repeat;
  image-rendering: pixelated;
}
.arena.lawn      { background-image: url(../assets/arenas/lawn.png?v=40); }
.arena.colosseum { background-image: url(../assets/arenas/colosseum.png?v=40); }
.arena.dungeon   { background-image: url(../assets/arenas/dungeon.png?v=40); }
.arena.snow      { background-image: url(../assets/arenas/snow.png?v=40); }
.arena.hall      { background-image: url(../assets/arenas/hall.png?v=40); }
.arena.forest    { background-image: url(../assets/arenas/forest.png?v=40); }
/* лёгкая виньетка сверху — HUD и таймер читаются на ярких фонах; за бойцами (z-index 1 < 3) */
.arena.lawn::after, .arena.colosseum::after, .arena.dungeon::after,
.arena.snow::after, .arena.hall::after, .arena.forest::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(8,6,18,.38), rgba(8,6,18,.05) 34%, rgba(8,6,18,0) 55%);
}
/* снегопад поверх снежной арены */
.arena.snow::before {
  content: ''; position: absolute; inset: 0; opacity: .9; z-index: 1; pointer-events: none;
  background:
    radial-gradient(2px 2px at 20% 10%, #fff, transparent 60%),
    radial-gradient(2px 2px at 50% 18%, #fff, transparent 60%),
    radial-gradient(2px 2px at 80% 14%, #fff, transparent 60%),
    radial-gradient(3px 3px at 35% 38%, #fff, transparent 60%),
    radial-gradient(2px 2px at 65% 48%, #fff, transparent 60%),
    radial-gradient(2px 2px at 90% 58%, #fff, transparent 60%),
    radial-gradient(3px 3px at 10% 66%, #fff, transparent 60%);
  background-size: 100% 220px; animation: snowfall 5s linear infinite;
}
@keyframes snowfall { from { background-position: 0 -220px; } to { background-position: 18px 220px; } }
/* светлячки в чародейском лесу */
.arena.forest::before {
  content: ''; position: absolute; inset: 0; opacity: .8; z-index: 1; pointer-events: none;
  background:
    radial-gradient(3px 3px at 16% 30%, #ffe98a, transparent 65%),
    radial-gradient(2px 2px at 38% 52%, #ffe98a, transparent 65%),
    radial-gradient(3px 3px at 62% 24%, #fff3b0, transparent 65%),
    radial-gradient(2px 2px at 84% 44%, #ffe98a, transparent 65%);
  background-size: 100% 320px; animation: fireflies 11s linear infinite;
}
@keyframes fireflies { from { background-position: 0 320px; } to { background-position: -26px -320px; } }
.clash { z-index: 4; align-self: center; margin-bottom: 110px; }
.fighter { flex: 0 0 310px; text-align: center; position: relative; z-index: 3; --run: 80px; padding-bottom: 8px; }
/* атакующий — поверх соперника, чтобы при сближении бойцы не «прятались» друг за друга */
.fighter.attacking, .fighter.casting { z-index: 5; }

.stage { position: relative; height: 320px; display: flex; align-items: flex-end; justify-content: center; }
.avatar { position: relative; width: 286px; height: 286px; will-change: transform; }

/* ===== анимированный спрайт: кадры листает JS (background-position в нативном размере) ===== */
.sprite {
  position: absolute; left: 50%; bottom: 0; transform-origin: bottom center;
  background-repeat: no-repeat; background-position: 0 0;
  image-rendering: pixelated; z-index: 2;
  /* держим спрайт в собственном GPU-слое — иначе при старте анимации бега родителя
     слой пере-промотируется и спрайт мигает в пустоту на кадр («боец пропадает») */
  will-change: transform; backface-visibility: hidden;
}

/* ===== БЕГ К ЦЕНТРУ: спрайт едет к сопернику (кадры бега — внутри спрайта) ===== */
.fighter.attacking .avatar { animation: run-right .8s ease-in-out; }
.fighter.right.attacking .avatar { animation: run-left .8s ease-in-out; }
@keyframes run-right {
  0%   { transform: translateX(0); }
  46%  { transform: translateX(var(--run)); }
  54%  { transform: translateX(calc(var(--run) + 8px)); }  /* доводка удара */
  62%  { transform: translateX(var(--run)); }
  100% { transform: translateX(0); }
}
@keyframes run-left {
  0%   { transform: translateX(0); }
  46%  { transform: translateX(calc(var(--run) * -1)); }
  54%  { transform: translateX(calc(var(--run) * -1 - 8px)); }
  62%  { transform: translateX(calc(var(--run) * -1)); }
  100% { transform: translateX(0); }
}

/* защита: лёгкий присед + синее свечение */
.fighter.defending .avatar { animation: crouch .5s ease; }
.fighter.defending .sprite { filter: drop-shadow(0 0 10px var(--blue)); }
@keyframes crouch { 0%,100%{ transform: scaleY(1);} 50%{ transform: scaleY(.92) translateY(5px);} }
/* каст: подлёт + золотое свечение */
.fighter.casting .avatar { animation: cast .6s ease; }
.fighter.casting .sprite { filter: drop-shadow(0 0 16px var(--gold)); }
@keyframes cast { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-10px);} }
/* урон: красная вспышка спрайта + отдача (только если сам не в выпаде) */
.fighter.hurt .sprite { animation: flash-hit .35s; }
.fighter.hurt:not(.attacking) .avatar { animation: knock-left .3s; }
.fighter.right.hurt:not(.attacking) .avatar { animation: knock-right .3s; }
@keyframes flash-hit { 0%,100%{ filter: none;} 30%{ filter: drop-shadow(0 0 10px var(--red)) brightness(1.6) saturate(1.4);} }
@keyframes knock-left { 0%{ transform: translateX(0);} 40%{ transform: translateX(-16px);} 100%{ transform: translateX(0);} }
@keyframes knock-right { 0%{ transform: translateX(0);} 40%{ transform: translateX(16px);} 100%{ transform: translateX(0);} }

/* подпись авторства спрайтов */
.credit { margin-top: 10px; font-size: 11px; color: var(--muted); opacity: .7; text-align: center; }
.credit a { color: var(--gold-soft); }

.fighter-gear { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 18px; }

/* ---------- профиль / винрейт ---------- */
.profile-bar {
  margin: 4px auto 14px; padding: 8px 14px; border-radius: 10px; font-size: 14px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(232,184,75,.18); color: var(--muted);
}
.profile-bar b { color: var(--gold-soft); }
#result-stats { display: inline-block; margin: 10px auto 4px; }
.bars { margin-bottom: 8px; }
.hp-bar { height: 16px; background: rgba(0,0,0,.4); border-radius: 8px; overflow: hidden; position: relative; margin-bottom: 4px; }
.hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), #8be36a); transition: width .35s ease; }
.hp-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.mana-bar { height: 10px; background: rgba(0,0,0,.4); border-radius: 6px; overflow: hidden; position: relative; }
.mana-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #3d6bff, #5aa9ff); transition: width .35s ease; }
.mana-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.fighter-buffs { font-size: 14px; min-height: 20px; margin-top: 4px; letter-spacing: 2px; }

/* ---------- кнопки действий ---------- */
.battle-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 4px; }
.act-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px;
  font-family: 'Handjet', system-ui, sans-serif;
  background: linear-gradient(180deg, #3b3157, #271d40); border: 2px solid rgba(0,0,0,.5);
  border-radius: 8px; color: var(--text); cursor: pointer; transition: transform .1s, filter .1s;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.12), inset 0 -4px 0 rgba(0,0,0,.32), 0 4px 0 rgba(0,0,0,.4);
}
.act-btn:hover:not(:disabled) { filter: brightness(1.18); }
.act-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,.1), 0 1px 0 rgba(0,0,0,.4); }
.act-btn:disabled { opacity: .4; cursor: not-allowed; }
.act-btn.chosen { border-color: var(--green); box-shadow: inset 0 0 0 2px rgba(79,212,126,.6), 0 0 14px rgba(79,212,126,.45); }
.act-ic { font-size: 26px; }
.act-name { font-weight: 900; font-size: 20px; text-transform: uppercase; letter-spacing: .5px; }
.act-sub { font-size: 14px; color: var(--muted); text-align: center; line-height: 1.1; }
.battle-actions.locked { pointer-events: none; opacity: .7; }
.btn-auto { display: block; margin: 10px auto 0; padding: 8px 18px; font-size: 13px; }
.btn-auto.on { background: linear-gradient(180deg, #4fd47e, #2fa85c); color: #06351b; }
.clash { font-size: 30px; opacity: 0; transition: opacity .15s, transform .15s; }
.clash.show { opacity: 1; transform: scale(1.5); }
.clash.crit { font-size: 44px; filter: drop-shadow(0 0 12px var(--red)); }
.arena.shake { animation: arena-shake .3s; }
@keyframes arena-shake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-6px);} 40%{transform:translateX(6px);} 60%{transform:translateX(-4px);} 80%{transform:translateX(4px);} }
.spark { position: absolute; left: 50%; top: 45%; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-soft); pointer-events: none; animation: spark-fly .45s ease-out forwards; }
@keyframes spark-fly { to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); } }
.floaters { position: absolute; top: 30px; left: 0; right: 0; height: 0; pointer-events: none; }
.floater { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 22px; animation: float-up 1s ease forwards; white-space: nowrap; }
.floater.dmg { color: var(--red); }
.floater.heal { color: var(--green); }
.floater.fx { color: var(--gold-soft); font-size: 15px; }
@keyframes float-up { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -50px); } }
.battle-log { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); max-height: 160px; overflow-y: auto; }
.battle-log .ln { padding: 6px 9px; border-radius: 6px; background: rgba(0,0,0,.2); }
.battle-log .ln-head { font-weight: 900; color: var(--gold-soft); font-size: 12px; margin-bottom: 2px; }
.battle-log .ln-row { font-size: 13px; color: var(--text); }
.battle-log .ln-who { font-weight: 800; }
.battle-log .ln-calc { font-size: 11px; color: var(--muted); margin: 1px 0 3px 12px; line-height: 1.3; }
.battle-log .ln-calc b { color: #ffcf6a; }
.battle-log .ln-ab { color: var(--gold-soft); }

/* ---------- выбор арены ---------- */
.arena-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.arena-card {
  cursor: pointer; border: 2px solid rgba(0,0,0,.45); border-radius: 10px; overflow: hidden;
  background: var(--panel); transition: transform .1s, filter .1s;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.1), 0 4px 0 rgba(0,0,0,.4);
}
.arena-card:hover { filter: brightness(1.14); transform: translateY(-2px); }
.arena-card.sel { border-color: var(--green); box-shadow: inset 0 0 0 2px rgba(79,212,126,.6), 0 0 14px rgba(79,212,126,.45); }
.arena-options.locked .arena-card { pointer-events: none; }
.arena-options.locked .arena-card:not(.sel) { opacity: .45; }
.arena-thumb { height: 76px; background-size: cover; background-position: center bottom; image-rendering: pixelated; }
.arena-card-name { padding: 9px; font-weight: 900; font-size: 18px; }
.arena-thumb.lawn      { background-image: url(../assets/arenas/lawn.png?v=40); }
.arena-thumb.colosseum { background-image: url(../assets/arenas/colosseum.png?v=40); }
.arena-thumb.dungeon   { background-image: url(../assets/arenas/dungeon.png?v=40); }
.arena-thumb.snow      { background-image: url(../assets/arenas/snow.png?v=40); }
.arena-thumb.hall      { background-image: url(../assets/arenas/hall.png?v=40); }
.arena-thumb.forest    { background-image: url(../assets/arenas/forest.png?v=40); }

/* ---------- result ---------- */
.result-title { font-size: 44px; font-weight: 900; }
.result-title.win { color: var(--green); text-shadow: 0 0 30px rgba(79,212,126,.4); }
.result-title.lose { color: var(--red); }
.result-title.draw { color: var(--gold); }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .roulette { height: 108px; }
  .reel-chest { width: 68px; height: 88px; }
  .reel-chest .chest-sprite { width: 56px; height: 47px; background-size: 504px 47px; }
  .chest-options { gap: 8px; }
  .chest-card { flex: 1 1 100%; }
  .slot .slot-pic { width: 64px; height: 64px; }
  .logo { font-size: 46px; }
  .arena { min-height: 380px; gap: 56px; }
  .arena-options { grid-template-columns: repeat(2, 1fr); }
  .fighter { flex: 0 0 185px; --run: 55px; }
  .stage { height: 280px; transform: scale(.60); transform-origin: bottom center; }
  .hud { width: 44%; }
  .hud-name { font-size: 12px; }
  .battle-clock { font-size: 40px; top: 14px; }
  .act-name { font-size: 16px; }
  .inventories { grid-template-columns: 1fr; }
  .carousel-stage { height: 300px; }
  .carousel-arrow { width: 42px; height: 42px; font-size: 26px; }
  .hero-glow { width: 210px; height: 210px; }
  .ci-name { font-size: 22px; }
  .stat-row .sr-label { flex: 0 0 84px; }
  .hud-name { font-size: 12px; }
  .hud-record { font-size: 11px; }
}

/* ===== Справочник предметов (модалка-таблица) ===== */
.codex-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(8,5,16,.78); padding: 16px; }
.codex-overlay.hidden { display: none; }
.codex-panel { width: min(720px, 96vw); max-height: 88vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--panel2)); border: 2px solid var(--gold);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.6); overflow: hidden; }
.codex-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid rgba(232,184,75,.25); }
.codex-head h2 { margin: 0; color: var(--gold-soft); font-size: 22px; }
.codex-close { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15); color: #fff;
  width: 34px; height: 34px; border-radius: 8px; font-size: 16px; cursor: pointer; }
.codex-close:hover { background: var(--red); }
.codex-tabs { display: flex; gap: 6px; padding: 10px 16px 0; }
.codex-tab { flex: 1; padding: 8px 6px; border-radius: 8px 8px 0 0; cursor: pointer; font-family: inherit; font-size: 15px; font-weight: 700;
  background: rgba(255,255,255,.05); border: 1px solid rgba(232,184,75,.2); border-bottom: none; color: var(--muted); }
.codex-tab.on { background: rgba(232,184,75,.16); color: var(--gold-soft); }
.codex-body { overflow-y: auto; padding: 6px 16px 16px; }
.codex-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.codex-table th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12px; padding: 6px; border-bottom: 1px solid rgba(255,255,255,.12); position: sticky; top: 0; background: var(--panel2); }
.codex-table td { padding: 7px 6px; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: middle; }
.codex-table tr.rar-common td:first-child { box-shadow: inset 3px 0 0 var(--common); }
.codex-table tr.rar-rare td:first-child { box-shadow: inset 3px 0 0 var(--rare); }
.codex-table tr.rar-epic td:first-child { box-shadow: inset 3px 0 0 var(--epic); }
.codex-table .cx-ic { font-size: 20px; width: 30px; text-align: center; }
.codex-table .cx-nm { font-weight: 700; }
.codex-table .cx-num { font-weight: 800; white-space: nowrap; }
.codex-table .cx-num.dmg { color: var(--red); }
.codex-table .cx-num.def, .codex-table .cx-num.mana { color: var(--blue); }
.codex-table .cx-arch { color: var(--muted); font-size: 12px; white-space: nowrap; }
.codex-table .cx-note { color: var(--gold-soft); font-size: 12px; }
.codex-table .muted { color: var(--muted); font-weight: 500; }
.codex-table .tags { font-size: 11px; opacity: .85; }
.codex-foot { margin: 12px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.codex-link { background: none; border: none; color: var(--gold-soft); text-decoration: underline; cursor: pointer; font-family: inherit; font-size: inherit; padding: 0; }
.item .val.mana { color: var(--blue); }
.act-btn.low-mana .act-sub { color: var(--red); }
@media (max-width: 560px) { .codex-table { font-size: 12px; } .codex-table .cx-arch, .codex-table th:nth-child(5) { display: none; } }

/* ============================================================
   PHASE 2 — UI-АССЕТЫ (Phase 2, кэш ?v=16)
   Источники: tinyRPG «Mana Soul GUI» (tiopalada, CC0) + ManaFrame
   «2DPixelUIPack» (комм. лицензия, использование в игре разрешено).
   Кадры нарезаны в /assets/ui/. Везде image-rendering: pixelated.
   Блок в КОНЦЕ файла — переопределяет базовые правила выше.
   ============================================================ */

/* --- стрелки карусели выбора героя: пиксель-арт вместо текстовых ‹ › --- */
.carousel-arrow {
  width: 46px; height: 28px; padding: 0; border: none; border-radius: 0;
  background-color: transparent; box-shadow: none; color: transparent; font-size: 0;
  background-repeat: no-repeat; background-position: center; background-size: contain;
  image-rendering: pixelated; transition: transform .08s, filter .12s;
}
#cls-prev { background-image: url('/assets/ui/arrow_left_0.png?v=17'); }
#cls-next { background-image: url('/assets/ui/arrow_right_0.png?v=17'); }
/* :hover/:active ДОЛЖНЫ переустановить repeat/size/position — старое правило
   .carousel-arrow:hover{background:var(--gold)} (шорткат) сбрасывало их в repeat/auto,
   из-за чего стрелка 21×14 тайлилась 2×2 = 4 копии. */
.carousel-arrow:hover { background-color: transparent; background-repeat: no-repeat; background-size: contain; background-position: center; filter: brightness(1.15); }
#cls-prev:hover { background-image: url('/assets/ui/arrow_left_1.png?v=18'); }
#cls-next:hover { background-image: url('/assets/ui/arrow_right_1.png?v=18'); }
.carousel-arrow:active { background-color: transparent; background-repeat: no-repeat; background-size: contain; background-position: center; box-shadow: none; transform: translateY(2px); }
#cls-prev:active { background-image: url('/assets/ui/arrow_left_2.png?v=17'); }
#cls-next:active { background-image: url('/assets/ui/arrow_right_2.png?v=17'); }

/* --- кнопки: фэнтези-рамка tinyRPG (btn_B, без заливки) + цвет фона по типу --- */
.btn {
  border: 8px solid transparent; border-radius: 0;
  border-image: url('/assets/ui/btn_B_0.png') 7 / 8px / 0 stretch;
  background-clip: padding-box; box-shadow: none; image-rendering: pixelated;
  padding: 8px 18px; color: var(--gold-soft); text-shadow: 0 2px 0 rgba(0,0,0,.6);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.big { padding: 12px 18px; }
.btn-primary { background: linear-gradient(180deg, #f6d987, #cf9b34); color: #3a2a06; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.btn-ghost { background: linear-gradient(180deg, #3b3157, #271d40); color: var(--gold-soft); }
/* авто-бой — БЕЗ рамки вообще (id бьёт оба блока .btn: с border-image btn_B и с box-shadow-
   полочкой). Двойная кромка возникала из-за рамки поверх заливки на тёмной панели — убрали
   рамку/тень/border-image целиком, осталась чистая пилюля = одна граница (панель→фон кнопки). */
#btn-auto { display: block; margin: 10px auto 0; padding: 10px 22px; font-size: 13px;
  background: linear-gradient(180deg, #3a2f5c, #241c3b); background-clip: border-box;
  border: none; border-image: none; border-radius: 10px; box-shadow: none; color: var(--gold-soft);
  outline: none; -webkit-tap-highlight-color: transparent; }
/* ВАЖНО: «вторая линия» вокруг кнопки = ОБВОДКА ФОКУСА браузера (кнопка в фокусе сразу после
   клика «ВКЛ»), а не border — снимаем outline во всех состояниях (доказано headless-снимком). */
#btn-auto:focus, #btn-auto:focus-visible, #btn-auto:active { outline: none; box-shadow: none; }
#btn-auto:active { transform: translateY(1px); }
#btn-auto.on { background: linear-gradient(180deg, #4fd47e, #2fa85c); color: #06351b; }

/* боевые кнопки действий — та же рамка, каменный фон */
.act-btn {
  border: 7px solid transparent; border-radius: 0;
  border-image: url('/assets/ui/btn_B_0.png') 7 / 7px / 0 stretch;
  background: linear-gradient(180deg, #34304c, #211d34); background-clip: padding-box;
  box-shadow: none; image-rendering: pixelated; padding: 8px 4px;
}
.act-btn:hover:not(:disabled) { filter: brightness(1.18); }
.act-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.act-btn.chosen { box-shadow: 0 0 0 2px rgba(79,212,126,.7), 0 0 14px rgba(79,212,126,.5); }

/* --- рамки панелей: 9-slice tinyRPG (узорные углы + тёмно-синий центр) --- */
.panel {
  border: 24px solid transparent; border-radius: 0;
  border-image: url('/assets/ui/panel9_A.png') 22 fill / 24px / 0 stretch;
  background: none; image-rendering: pixelated;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  padding: 16px;
}

/* --- HP/мана бары HUD: ornate-рамка bar_A поверх заливки (::after) --- */
.hud .hp-bar, .hud .mana-bar {
  position: relative; border: none; border-radius: 2px; box-shadow: none;
  background: rgba(8,5,14,.6); overflow: visible;
}
.hud .hp-bar > .hp-fill, .hud .mana-bar > .mana-fill { border-radius: 2px; image-rendering: pixelated; }
.hud .hp-bar::after, .hud .mana-bar::after {
  content: ''; position: absolute; inset: -3px -8px; pointer-events: none;
  border: 3px solid transparent;
  border-image: url('/assets/ui/bar_A.png') 3 13 / 3px 9px / 0 stretch;
  image-rendering: pixelated; z-index: 3;
}

/* --- таймер раунда: тёмная подложка с узорной рамкой (как кнопки btn_B) --- */
.battle-clock {
  top: 10px; font-size: 40px; line-height: 1; min-width: 72px;
  padding: 6px 16px 4px; color: var(--gold-soft);
  border: 11px solid transparent; border-radius: 0;
  border-image: url('/assets/ui/btn_B_0.png') 7 / 11px / 0 stretch;
  background: linear-gradient(180deg, rgba(26,19,48,.94), rgba(11,8,24,.96));
  background-clip: padding-box; image-rendering: pixelated;
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.7);
}
.battle-clock.low {
  color: var(--red);
  background: linear-gradient(180deg, rgba(58,18,26,.95), rgba(28,8,14,.97));
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(239,93,107,.85);
}

/* ===== НОВЫЕ ГЕРОИ: снаряды дальнего боя + компаньоны-фамильяры (чистый визуал) ===== */
.projectile, .companion-fly {
  position: absolute; left: 0; top: 0; z-index: 5;
  image-rendering: pixelated; background-repeat: no-repeat; pointer-events: none;
}
.companion {
  position: absolute; left: 50%; bottom: 0;
  image-rendering: pixelated; background-repeat: no-repeat; pointer-events: none;
  transform-origin: bottom center;
}

/* ===================== БОЁВКА-ЛАЙТ: СЕРДЕЧКИ И ЩИТЫ В HUD ===================== */
.hud .hearts { display: flex; gap: 2px; flex-wrap: wrap; min-height: 24px; }
.hud-right .hearts { justify-content: flex-end; }
.hud .shields { display: flex; gap: 2px; flex-wrap: wrap; min-height: 18px; margin-top: 2px; }
.hud-right .shields { justify-content: flex-end; }
.hh, .sh { display: inline-block; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.55)); }
.hh { font-size: 21px; }
.sh { font-size: 15px; }
.hh.on::before { content: '❤️'; }
.hh.off::before { content: '🖤'; }
.hh.off { opacity: .55; }
.sh.on::before { content: '🛡️'; }
.sh.off::before { content: '🛡️'; }
.sh.off { opacity: .22; filter: grayscale(1); }
/* последние сердца пульсируют */
.hh.on.low { animation: heart-low .9s ease-in-out infinite; }
@keyframes heart-low { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
/* выбитое сердце: разбивается и подлетает */
.hh.off.pop { opacity: 1; }
.hh.off.pop::before { content: '💔'; }
.hh.off.pop { animation: heart-pop .85s cubic-bezier(.2,.8,.4,1); }
@keyframes heart-pop {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  35%  { transform: translateY(-14px) scale(1.7) rotate(-12deg); opacity: 1; }
  100% { transform: translateY(2px) scale(1); opacity: .8; }
}
/* отлеченное сердце вплывает */
.hh.on.gain { animation: heart-gain .6s ease; }
@keyframes heart-gain { 0% { transform: scale(.2); opacity: 0; } 60% { transform: scale(1.45); opacity: 1; } 100% { transform: scale(1); } }
/* треснувший щит */
.sh.off.crack { animation: shield-crack .7s ease; }
@keyframes shield-crack {
  0%   { transform: scale(1.4) rotate(0); opacity: 1; filter: none; }
  50%  { transform: scale(1.1) rotate(14deg); opacity: .7; }
  100% { transform: scale(1) rotate(0); opacity: .22; filter: grayscale(1); }
}
/* подпись «все герои равны» на выборе героя */
.equal-note { font-size: 15px; color: var(--gold-soft, #e8c987); opacity: .9; padding: 4px 0; }
/* флоатер разбитых сердец покрупнее */
.floater.dmg { font-size: 24px; }
@media (max-width: 560px) {
  .hh { font-size: 15px; }
  .sh { font-size: 12px; }
}

/* ============ v42: ПЕРКИ ОРУЖИЯ (кристаллы) + ЧИТАЕМОСТЬ БОЙЦОВ ============ */

/* Чипы-кристаллы перков: тёмная капсула, кристалл из атласа, тултип через title */
.perk-chips { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 6px; }
.perk-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 1px 2px;
  background: rgba(8,5,18,.62); border: 1px solid rgba(255,209,102,.35); border-radius: 5px;
  cursor: help; line-height: 1;
}
.perk-chip.bad { border-color: rgba(150,150,170,.35); filter: saturate(.55) brightness(.85); }
.item .nm .perk-chips .perk-chip { min-width: 18px; height: 18px; }
.act-sub .perk-chips { margin-left: 4px; }
.act-sub .perk-chip { min-width: 22px; height: 22px; }

/* кодекс: колонка граней + легенда перков */
.cx-perks { white-space: nowrap; }
.cx-perks .perk-chips { margin-left: 0; }
.perk-legend { margin-top: 10px; display: grid; gap: 6px; }
.perk-row { display: flex; align-items: center; gap: 8px; font-size: 17px; color: var(--ink-soft, #cfc7e8); }
.perk-row .perk-chip { flex: 0 0 auto; min-width: 24px; height: 24px; }
.perk-row.bad { opacity: .75; }
.codex-foot .rar-common { color: #b9b4cf; }
.codex-foot .rar-rare { color: #58a6ff; }
.codex-foot .rar-epic { color: #c792ea; }

/* Читаемость бойцов на детализированных фонах арен (#1 фидбека):
   тёмный пиксель-контур по силуэту + мягкий тёплый ореол — отделяет тёмных
   героев от тёмного фона (лес/пещера), не рисуя «кругов» на земле. */
.fighter .sprite {
  filter: drop-shadow(0 0 1px rgba(0,0,0,.95)) drop-shadow(0 0 1px rgba(0,0,0,.9))
          drop-shadow(0 0 7px rgba(255,228,150,.42));
}
.companion, .companion-fly { filter: drop-shadow(0 0 1px rgba(0,0,0,.9)); }

/* v42b: последовательные удары — звезда столкновения позиционируется JS в точке попадания */
.clash { position: absolute; left: 50%; top: 45%; margin: 0; align-self: auto;
  transform: translate(-50%,-50%) scale(.6); pointer-events: none; }
.clash.show { transform: translate(-50%,-50%) scale(1.4); }

/* ============ v44: ДЖЕКПОТ ЗОЛОТОГО СУНДУКА + РАМКИ КАРТОЧЕК ============ */

/* оверлей вылета золотого сундука: затемнение, подлёт с ростом, дрожь-саспенс */
.golden-reveal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 44%, rgba(64,44,8,.55), rgba(8,6,2,.82));
  pointer-events: none; animation: gr-bg .35s ease;
}
@keyframes gr-bg { from { opacity: 0; } to { opacity: 1; } }
.golden-reveal.gone { animation: gr-out .35s ease forwards; }
@keyframes gr-out { to { opacity: 0; } }
.gr-wrap { display: flex; flex-direction: column; align-items: center; gap: 60px; }
.gr-title {
  font-family: 'Handjet', monospace; font-weight: 900; font-size: 38px; letter-spacing: 2px;
  color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 22px rgba(232,184,75,.8);
  animation: gr-title-pulse 1s ease infinite alternate;
}
@keyframes gr-title-pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
.gr-sub { font-size: 20px; color: var(--gold-soft); text-shadow: 0 2px 0 #000; opacity: .9; }
.gr-chest {
  filter: drop-shadow(0 0 34px rgba(255,204,84,.95));
  animation: gr-fly .75s cubic-bezier(.18,.85,.3,1.18) forwards;
}
@keyframes gr-fly {
  0%   { transform: scale(.9) translateY(80px); opacity: .25; }
  100% { transform: scale(3.4) translateY(0);   opacity: 1; }
}
.gr-tremble { animation: gr-tremble .14s linear infinite alternate; }
.gr-tremble.still { animation: none; }
@keyframes gr-tremble { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@media (max-width: 560px) { .gr-chest { animation-name: gr-fly-m; } @keyframes gr-fly-m { 0% { transform: scale(.8) translateY(60px); opacity: .25; } 100% { transform: scale(2.4) translateY(0); opacity: 1; } } }

/* карточки предметов сундука: узорная рамка (как кнопки) + свечение по редкости */
.chest-card {
  border: 8px solid transparent; border-radius: 0;
  border-image: url('/assets/ui/btn_B_0.png') 7 / 8px / 0 stretch;
  background: linear-gradient(180deg, rgba(40,32,66,.94), rgba(18,14,34,.96));
  background-clip: padding-box; image-rendering: pixelated;
  padding: 10px 8px 8px;
}
.chest-card.rar-common { box-shadow: 0 0 10px rgba(185,180,207,.16); }
.chest-card.rar-rare   { box-shadow: 0 0 14px rgba(88,166,255,.38); }
.chest-card.rar-epic   { box-shadow: 0 0 20px rgba(199,146,234,.55); }
.chest-card:hover {
  transform: translateY(-4px); filter: brightness(1.16);
  box-shadow: 0 6px 22px rgba(232,184,75,.45);
}
.chest-card.taken { opacity: .42; filter: grayscale(.5); }
