/* Боевой интерфейс (HUD), лавка, инвентарь. Загружается после style.css и переопределяет его. Владелец — агент геймплея.
   Стиль — классическая панель команд: тёмный камень, кованый металл, золотая окантовка, пергамент подсказок.
   Слои: консоль 12, подсказка 30, лавка 25, выбор усиления 26 — обучение (#tut) ставить выше 40. */

#battle {
  --hud-stone: linear-gradient(180deg, #4a4037 0%, #2c261f 45%, #1d1914 100%);
  --hud-grain: repeating-linear-gradient(115deg, rgba(255,255,255,.025) 0 2px, transparent 2px 7px),
               repeating-linear-gradient(25deg, rgba(0,0,0,.08) 0 3px, transparent 3px 9px);
  --hud-gold: #c9a24a; --hud-gold-hi: #f3d68a; --hud-gold-lo: #7a5a1e;
  --hud-frame: 0 0 0 1px #0b0805, 0 0 0 3px var(--hud-gold-lo), 0 0 0 4px #0b0805, 0 6px 16px rgba(0,0,0,.6);
  --sl: max(8px, env(safe-area-inset-left)); --sr: max(8px, env(safe-area-inset-right));
  --st: max(6px, env(safe-area-inset-top)); --sb: max(6px, env(safe-area-inset-bottom));
  --cell: 52px; --sk: 58px; --roll: 62px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* кованая рамка: камень + двойная золотая окантовка */
#battle .b-frame, #battle .b-console, #battle .b-hero, #battle .b-top, #battle .shop-box {
  background: var(--hud-grain), var(--hud-stone);
  border: 2px solid var(--hud-gold);
  box-shadow: var(--hud-frame), inset 0 1px 0 rgba(255,235,180,.25), inset 0 -2px 6px rgba(0,0,0,.6);
}

/* ---------- верх: счёт и время ---------- */
#battle .b-top { top: var(--st); padding: 3px 16px; border-radius: 0 0 14px 14px; border-top: 0; gap: 14px; font-size: 15px;
  color: #f3e2b4; text-shadow: 0 1px 2px #000; z-index: 12; }
#battle .b-top .k0, #battle .b-top .k1 { font-size: 19px; }

/* ---------- портрет и полоски ---------- */
#battle .b-hero { top: var(--st); left: var(--sl); display: flex; gap: 8px; align-items: center; padding: 5px 10px 5px 5px;
  border-radius: 10px; pointer-events: none; z-index: 12; }
#battle .b-portrait { position: relative; width: 58px; height: 58px; flex: none; border-radius: 6px; overflow: visible;
  background: radial-gradient(circle at 50% 35%, #3f5a7a, #141a24 75%);
  box-shadow: 0 0 0 2px #0b0805, 0 0 0 4px var(--hud-gold), 0 0 0 5px #0b0805, inset 0 0 10px rgba(0,0,0,.8); }
#battle .b-portrait img { width: 100%; height: 100%; object-fit: contain; display: block; transform: scale(1.25) translateY(4px); }
#battle .b-lvl { position: absolute; right: -9px; bottom: -9px; width: 26px; height: 26px; font-size: 13px; border: 2px solid #2a1a08;
  box-shadow: 0 2px 4px rgba(0,0,0,.6); }
#battle .b-bars { width: min(210px, 28vw); display: flex; flex-direction: column; gap: 3px; }
#battle .b-hpbar { height: 16px; border-radius: 3px; background: #120c08; box-shadow: inset 0 1px 3px #000, 0 0 0 1px var(--hud-gold-lo); }
#battle .b-hpbar > div { background: linear-gradient(#8dff7a, #2c9e36 60%, #1e6e26); transition: width .1s; }
#battle .b-xpbar { height: 6px; border-radius: 2px; margin: 0; background: #120c08; box-shadow: 0 0 0 1px #3a2a12; }
#battle .b-xpbar > div { background: linear-gradient(#d7b4ff, #8b5bd6); }
#battle .b-stats { display: flex; align-items: center; gap: 8px; min-height: 30px; }
#battle .b-gold { color: #ffd34d; font-weight: 800; font-size: 15px; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#battle .b-passive { pointer-events: auto; width: 34px; height: 34px; border-radius: 6px; font-size: 19px; display: grid; place-items: center;
  background: radial-gradient(circle, #3a2e22, #18120d); box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo); touch-action: none; }
#battle .b-passive[hidden] { display: none; }
#battle .b-buffs { font-size: 13px; font-weight: 700; white-space: nowrap; text-shadow: 0 1px 2px #000; }

#battle .b-feed { top: calc(var(--st) + 80px); left: var(--sl); z-index: 11; }

/* ---------- рамки боя, вариант 08.11 (план п. 33): меньше и аккуратнее ---------- */
/* портрет — круглый медальон в золотом кольце, нависает над узкой плашкой с полосками */
#battle .b-hero { padding: 0 10px 0 0; gap: 0; border-radius: 40px 10px 10px 40px; background: var(--hud-grain), linear-gradient(180deg, #3d342b, #1d1914);
  border-width: 1px; box-shadow: 0 0 0 1px #0b0805, 0 4px 10px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,235,180,.2); }
#battle .b-portrait { width: 52px; height: 52px; border-radius: 50%; margin: -3px 8px -3px -3px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #4d6e94, #141a24 72%);
  box-shadow: 0 0 0 2px #0b0805, 0 0 0 4px var(--hud-gold), 0 0 0 5px #0b0805, 0 3px 8px rgba(0,0,0,.6), inset 0 0 10px rgba(0,0,0,.85); }
#battle .b-portrait img { transform: scale(1.35) translateY(6px); }
#battle .b-lvl { right: auto; left: 36px; bottom: -4px; width: 22px; height: 22px; font-size: 12px; z-index: 2; }
#battle .b-hero .b-portrait + .b-bars { margin-left: 0; }
#battle .b-bars { width: min(168px, 26vw); gap: 2px; padding: 5px 0; }
#battle .b-hpbar { height: 12px; border-radius: 6px; overflow: hidden; }
#battle .b-hpbar span { line-height: 12px; font-size: 9.5px; letter-spacing: .2px; }
#battle .b-xpbar { height: 4px; border-radius: 2px; }
#battle .b-stats { min-height: 20px; gap: 6px; }
#battle .b-gold { font-size: 12.5px; }
#battle .b-passive { width: 24px; height: 24px; font-size: 14px; border-radius: 50%; }
#battle .b-buffs { font-size: 11px; }
/* lvl вынесен из портрета: портрет обрезается кругом, значок уровня рисуем поверх края */
#battle .b-hero { position: absolute; }
#battle .b-hero .b-lvl { position: absolute; }
/* счёт и время: узкая плашка, счёт — в цветных медальонах команд */
#battle .b-top { padding: 1px 6px; gap: 8px; font-size: 13px; border-radius: 0 0 10px 10px; border-width: 1px; font-variant-numeric: tabular-nums; }
#battle .b-top .k0, #battle .b-top .k1 { font-size: 14px; min-width: 24px; height: 20px; line-height: 20px; text-align: center; border-radius: 10px; padding: 0 5px;
  color: #fff; font-weight: 800; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 1px #0b0805; }
#battle .b-top .k0 { background: linear-gradient(#5aa8ff, #1f5fb8); }
#battle .b-top .k1 { background: linear-gradient(#ff6a6a, #a82424); }
#battle .b-feed { top: calc(var(--st) + 62px); }
#battle .b-feed div { background: rgba(20,14,8,.7); border-left: 3px solid var(--hud-gold-lo); border-radius: 3px; }
#battle .b-buff { top: calc(var(--st) + 36px); z-index: 11; }
#battle .b-respawn { background: rgba(20,12,6,.8); border: 2px solid var(--hud-gold-lo); color: #f3e2b4; }
#battle .b-hint { top: auto; bottom: var(--sb); left: var(--sl); transform: none; max-width: min(420px, calc(100vw - 460px)); white-space: normal;
  line-height: 1.3; font-size: 12px; background: rgba(0,0,0,.5); padding: 4px 10px; border-radius: 8px; color: rgba(255,240,210,.85); z-index: 11; }
#battle .b-exit { top: var(--st); right: var(--sr); bottom: auto; left: auto; transform: none; width: 40px; height: 40px; z-index: 12;
  background: var(--hud-stone); box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo); color: #f3e2b4; border-radius: 8px; }

#battle .b-next { position: absolute; top: calc(var(--st) + 34px); left: 50%; transform: translateX(-50%); z-index: 12; padding: 6px 16px;
  font: inherit; font-size: 14px; font-weight: 700; color: #2a1804; background: linear-gradient(#ffd97a, #d99a2b); border: 0; border-radius: 14px;
  box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo), 0 3px 8px rgba(0,0,0,.5); }
#battle .b-next[hidden] { display: none; }

/* ---------- панель команд ---------- */
#battle .b-console { position: absolute; right: var(--sr); bottom: var(--sb); display: flex; align-items: flex-end; gap: 7px;
  padding: 8px; border-radius: 16px 16px 8px 8px; z-index: 12; }
#battle .b-console::before { content: ''; position: absolute; left: 14px; right: 14px; top: -6px; height: 6px; border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, transparent, var(--hud-gold-hi), transparent); opacity: .5; pointer-events: none; }

/* общая ячейка-кнопка: утопленный камень и металл */
#battle .inv-slot, #battle .skill, #battle .b-shopbtn, #battle .b-roll {
  position: relative; display: grid; place-items: center; touch-action: none; color: #fff; padding: 0;
  background: radial-gradient(circle at 50% 38%, #4a3c2c, #1a140e 80%);
  box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #6d5527, 0 0 0 4px #0b0805, inset 0 2px 5px rgba(0,0,0,.8), inset 0 -1px 0 rgba(255,220,150,.15);
}
#battle .inv-slot:active, #battle .skill:active, #battle .b-shopbtn:active, #battle .b-roll:active { transform: translateY(1px); filter: brightness(1.2); }

/* ячейки предметов: видны только занятые (пустые не загромождают экран боя) */
#battle .b-inv { display: flex; flex-wrap: wrap-reverse; align-content: flex-start; max-width: calc(var(--cell) * 3 + 12px); gap: 6px; padding: 2px; }
#battle .b-inv:not(:has(.inv-slot.usable)) { display: none; }
#battle .b-inv .inv-slot:not(.usable) { display: none; }
#battle .inv-slot.empty { display: none !important; }
#battle .inv-slot { width: var(--cell); height: var(--cell); border-radius: 6px; font-size: 26px; }
#battle .inv-slot.empty { background: radial-gradient(circle, #241c14, #110c08); }
#battle .inv-slot.empty .ic::before { content: ''; display: block; width: 18px; height: 18px; border: 1px dashed rgba(201,162,74,.25); border-radius: 3px; }
#battle .inv-slot.act { box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px var(--hud-gold), 0 0 0 4px #0b0805, inset 0 2px 5px rgba(0,0,0,.8); }
#battle .inv-slot .ch { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; }

#battle .b-cmd { position: relative; }
#battle .b-skills { position: static; display: grid; grid-template-columns: repeat(2, var(--sk)); grid-template-rows: repeat(2, var(--sk)); gap: 7px; padding: 2px; }
#battle .skill { width: var(--sk); height: var(--sk); border: 0; border-radius: 8px; font-size: 28px; }
#battle .skill.ult { grid-column: auto; justify-self: auto; width: var(--sk); height: var(--sk); font-size: 28px;
  box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #c0602a, 0 0 0 4px #0b0805, 0 0 12px rgba(255,120,40,.45), inset 0 2px 5px rgba(0,0,0,.8); }
#battle .skill .ic { line-height: 1; }
#battle .skill .cd, #battle .inv-slot .cd, #battle .b-roll .cd { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px;
  font-weight: 800; border-radius: inherit; text-shadow: 0 0 4px #000; pointer-events: none; }
#battle .skill.cooling .cd, #battle .inv-slot.cooling .cd, #battle .b-roll.cooling .cd { background: rgba(0,0,0,.62); }
#battle .skill.locked .ic { filter: grayscale(1) brightness(.55); }
#battle .skill.locked .cd { background: rgba(0,0,0,.35); font-size: 13px; }
#battle .skill.silenced .ic { filter: grayscale(1); }
#battle .skill.silenced::after { content: '🔇'; position: absolute; top: 2px; left: 3px; font-size: 13px; }
#battle .skill .lv { position: absolute; left: 0; right: 0; bottom: 3px; display: flex; justify-content: center; gap: 3px; pointer-events: none; }
#battle .skill .lv i { width: 7px; height: 7px; border-radius: 2px; background: #1a120a; box-shadow: 0 0 0 1px #6d5527; }
#battle .skill .lv i.on { background: linear-gradient(#fff2b0, #e0a52a); box-shadow: 0 0 0 1px #3a2608, 0 0 4px #ffcf5a; }
#battle .skill .up { display: none; position: absolute; top: -12px; right: -12px; width: 30px; height: 30px; border-radius: 50%;
  font-size: 22px; font-weight: 900; line-height: 28px; color: #2a1a08; z-index: 2;
  background: radial-gradient(circle at 40% 35%, #fff6c8, #f0b93a 60%, #a8721a); box-shadow: 0 0 0 2px #2a1a08, 0 0 10px #ffd34d;
  animation: hud-pulse 1s ease-in-out infinite; }
#battle .skill .up::before { content: ''; position: absolute; inset: -10px; } /* палец попадает легче */
#battle .skill.can-up .up { display: block; }
#battle .key { position: absolute; top: 1px; left: 3px; bottom: auto; right: auto; font-size: 10px; font-weight: 700; color: #f3e2b4;
  background: none; padding: 0; opacity: .75; text-shadow: 0 0 2px #000; pointer-events: none; }
@keyframes hud-pulse { 50% { transform: scale(1.15); box-shadow: 0 0 0 2px #2a1a08, 0 0 16px #ffe27a; } }

#battle .b-auto { position: absolute; right: 2px; top: -36px; min-width: 56px; height: 28px; padding: 0 10px; border-radius: 8px 8px 0 0;
  font-size: 12px; font-weight: 800; color: #c9b48a; background: var(--hud-stone); box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo); }
#battle .b-auto[hidden] { display: none; }
#battle .b-auto.on { color: #2a1a08; background: linear-gradient(#f6d47a, #b8862c); }
#battle .b-auto.want { color: #2a1a08; background: linear-gradient(#fff2b0, #e0a52a); animation: hud-pulse 1s ease-in-out infinite; }

#battle .b-side { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 2px; }
#battle .b-shopbtn { width: var(--cell); height: var(--cell); border-radius: 8px; font-size: 24px; filter: grayscale(.7) brightness(.7); }
#battle .b-shopbtn.near { filter: none; box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px var(--hud-gold), 0 0 0 4px #0b0805, 0 0 14px rgba(255,211,77,.7); animation: hud-glow 1.4s ease-in-out infinite; }
@keyframes hud-glow { 50% { box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px var(--hud-gold-hi), 0 0 0 4px #0b0805, 0 0 22px rgba(255,211,77,.9); } }
#battle .b-roll { width: var(--roll); height: var(--roll); border-radius: 50%; font-size: 28px;
  background: radial-gradient(circle at 50% 38%, #3a5a74, #142130 80%);
  box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #8fb6d6, 0 0 0 4px #0b0805, inset 0 2px 6px rgba(0,0,0,.8); }

/* ---------- подсказка (пергамент) ---------- */
#battle .b-tip { position: absolute; left: 50%; bottom: 160px; width: max-content; max-width: min(330px, 86vw); z-index: 30;
  padding: 9px 12px; border-radius: 6px; color: #2a1d0c; font-size: 13px; line-height: 1.35; pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, #fbf0d2, #e6d3a3 70%, #d4bb83);
  border: 2px solid #7a5a1e; box-shadow: 0 0 0 1px #2a1a08, 0 8px 22px rgba(0,0,0,.6); }
#battle .b-tip[hidden] { display: none; }
#battle .b-tip p { margin: 5px 0; }
#battle .tip-h { display: flex; align-items: center; gap: 6px; font-size: 15px; }
#battle .tip-ic { font-size: 22px; }
#battle .tip-lv { margin-left: auto; font-size: 11px; color: #6a4a18; white-space: nowrap; }
#battle .tip-ult { font-size: 10px; text-transform: uppercase; color: #fff; background: #b04a1a; padding: 1px 5px; border-radius: 4px; }
#battle .tip-rows div { font-size: 13px; }
#battle .tip-rows .nx { color: #1d7a2a; font-weight: 700; }
#battle .tip-stat { font-size: 12px; color: #5a4520; margin-top: 3px; }
#battle .tip-sub { font-size: 11px; color: #6a5530; margin-top: 3px; font-style: italic; }
#battle .tip-req { font-size: 12px; color: #9a2a10; margin-top: 4px; }
#battle .tip-up { font-size: 12px; color: #1d6a2a; margin-top: 4px; font-weight: 700; }

/* ---------- лавка ---------- */
#battle .b-shop { position: absolute; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); padding: var(--st) var(--sr) var(--sb) var(--sl); pointer-events: none; }
#battle .shop-box { pointer-events: auto; } /* панель команд под лавкой остаётся живой: можно изучить умение и выпить зелье */
#battle .b-shop[hidden] { display: none; }
#battle .shop-box { width: min(780px, 100%); max-height: 100%; display: flex; flex-direction: column; border-radius: 12px; padding: 8px; gap: 6px; color: #f3e2b4; }
#battle .shop-head { display: flex; align-items: center; gap: 12px; min-height: 40px; }
#battle .shop-head b { font-size: 16px; color: var(--hud-gold-hi); text-shadow: 0 1px 2px #000; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#battle .shop-gold { font-weight: 800; color: #ffd34d; font-size: 17px; white-space: nowrap; }
#battle .shop-x, #battle .shop-go { min-width: 44px; height: 40px; border-radius: 8px; font-weight: 800; font-size: 18px;
  background: linear-gradient(#5a4a36, #2c241a); box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo); color: #f3e2b4; }
#battle .shop-go { padding: 0 18px; font-size: 16px; color: #2a1a08; background: linear-gradient(#f6d47a, #b8862c); box-shadow: 0 0 0 1px #2a1a08, 0 0 12px rgba(255,211,77,.5); }
#battle .shop-go .shop-cd { display: inline-block; min-width: 22px; margin-left: 6px; padding: 0 5px; border-radius: 10px; background: #2a1a08; color: #ffd34d; font-size: 13px; }
#battle .shop-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--hud-gold-lo); }
#battle .shop-tabs button { flex: 1; min-height: 36px; font-size: 13px; font-weight: 700; color: #c9b48a; border-radius: 8px 8px 0 0;
  background: linear-gradient(#3a3026, #221c15); box-shadow: inset 0 0 0 1px #4a3a22; padding: 0 6px; }
#battle .shop-tabs button.on { color: #2a1a08; background: linear-gradient(#f6d47a, #b8862c); }
#battle .shop-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 42%); gap: 8px; }
#battle .shop-grid { overflow-y: auto; touch-action: pan-y; display: grid; grid-template-columns: repeat(auto-fill, 62px); grid-auto-rows: 68px;
  gap: 8px; align-content: start; padding: 6px 4px; overscroll-behavior: contain; }
#battle .shop-it { position: relative; width: 62px; height: 68px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #4a3c2c, #1a140e 80%); box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #6d5527, 0 0 0 4px #0b0805; touch-action: pan-y; }
#battle .shop-it .ic { font-size: 28px; line-height: 1.1; }
#battle .shop-it .pr { font-size: 12px; font-weight: 800; color: #ffd34d; }
#battle .shop-it.poor .pr { color: #ff8a7a; }
#battle .shop-it.poor .ic { filter: saturate(.5) brightness(.8); }
#battle .shop-it.sel { box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px var(--hud-gold-hi), 0 0 0 4px #0b0805, 0 0 14px rgba(255,211,77,.7); }
#battle .shop-info { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35;
  background: radial-gradient(ellipse at 30% 10%, #fbf0d2, #e6d3a3 70%, #d4bb83); color: #2a1d0c; box-shadow: inset 0 0 0 2px #7a5a1e; }
#battle .shop-info p { margin: 4px 0; }
#battle .si-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
#battle .si-head .ic { font-size: 28px; }
#battle .si-stats { color: #1d5a2a; font-weight: 700; margin: 4px 0; }
#battle .si-rec { font-size: 12px; color: #5a4520; margin: 4px 0; }
#battle .si-rec span { white-space: nowrap; opacity: .7; }
#battle .si-rec span.have { opacity: 1; color: #1d6a2a; font-weight: 700; }
#battle .si-empty, #battle .si-hint { color: #6a5530; font-size: 12px; }
#battle .shop-buy, #battle .shop-sell { display: block; width: 100%; min-height: 44px; margin: 6px 0 2px; border-radius: 8px; font-weight: 800; font-size: 15px;
  color: #2a1a08; background: linear-gradient(#f6d47a, #b8862c); box-shadow: 0 0 0 1px #2a1a08; }
#battle .shop-buy[disabled] { color: #6a5a40; background: linear-gradient(#cfc2a2, #a89a7a); }
#battle .shop-sell { background: linear-gradient(#e8c0a0, #b07850); }
#battle .shop-bag { margin-top: 8px; border-top: 1px solid #b89a5a; padding-top: 6px; }
#battle .si-cap { font-size: 11px; color: #6a5530; text-transform: uppercase; letter-spacing: .05em; }
#battle .shop-inv { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 4px; }
#battle .shop-slot { position: relative; height: 44px; border-radius: 6px; font-size: 22px; background: radial-gradient(circle, #4a3c2c, #1a140e); box-shadow: 0 0 0 1px #3a2608; }
#battle .shop-slot i { position: absolute; right: 2px; bottom: 0; font-size: 11px; font-style: normal; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000; }
#battle .shop-slot.sel { box-shadow: 0 0 0 2px #2a1a08, 0 0 0 4px var(--hud-gold-hi); }
#battle .shop-msg { background: #8a2a10; color: #fff; padding: 4px 8px; border-radius: 6px; font-weight: 700; margin-bottom: 6px; }

/* ---------- выбор усиления ---------- */
#battle .b-pick { z-index: 26; }
#battle .pick-card { background: var(--hud-grain), var(--hud-stone); border: 2px solid var(--hud-gold); border-radius: 10px;
  box-shadow: 0 0 0 1px #0b0805, 0 6px 16px rgba(0,0,0,.6); color: #f3e2b4; }
#battle .pick-title { color: var(--hud-gold-hi); text-shadow: 0 2px 4px #000; }

/* ---------- размеры экранов ---------- */
/* телефон боком: высота 360–420 */
@media (max-height: 430px) {
  #battle { --cell: 52px; --sk: 54px; --roll: 58px; }
  #battle .b-console { padding: 6px; gap: 6px; }
  #battle .b-inv { gap: 4px; }
  #battle .b-skills { gap: 6px; }
  #battle .b-side { gap: 6px; }
  #battle .b-portrait { width: 46px; height: 46px; }
  #battle .b-lvl { left: 30px; }
  #battle .b-hpbar { height: 11px; } #battle .b-hpbar span { line-height: 11px; font-size: 9px; }
  #battle .b-feed { top: calc(var(--st) + 70px); font-size: 12px; }
  #battle .shop-body { grid-template-columns: minmax(0, 1fr) minmax(210px, 44%); }
  #battle .shop-grid { grid-template-columns: repeat(auto-fill, 58px); grid-auto-rows: 62px; gap: 7px; }
  #battle .shop-it { width: 58px; height: 62px; }
  #battle .shop-it .ic { font-size: 25px; }
  #battle .shop-head { min-height: 36px; }
  #battle .shop-tabs button { min-height: 34px; }
  /* сумка уезжает под портрет: панель команд справа становится низкой и не заходит на середину */
  #battle .b-inv { position: fixed; left: var(--sl); top: calc(var(--st) + 58px); padding: 5px; gap: 5px; border-radius: 8px;
    background: var(--hud-grain), var(--hud-stone); border: 2px solid var(--hud-gold); box-shadow: var(--hud-frame); z-index: 12; }
  #battle .b-feed { top: calc(var(--st) + 44px); left: 50%; transform: translateX(-50%); text-align: center; }
  #battle .b-feed div { margin: 0 auto 3px; }
  #battle .b-buff { top: auto; bottom: calc(var(--sb) + 40px); }
  #battle .b-hint { max-width: calc(100vw - 300px); }
}
/* узкий экран: сумку прячем под умения, чтобы не закрывать середину */
@media (max-width: 640px) {
  #battle .shop-body { grid-template-columns: 1fr; grid-template-rows: minmax(120px, 1fr) auto; }
  #battle .b-hint { display: none; }
}
/* большой экран (ПК, планшет) */
@media (min-height: 640px) and (min-width: 1000px) {
  #battle { --cell: 60px; --sk: 68px; --roll: 72px; }
  #battle .skill, #battle .skill.ult { font-size: 34px; }
  #battle .inv-slot { font-size: 30px; }
  #battle .b-portrait { width: 60px; height: 60px; }
  #battle .b-lvl { left: 42px; }
  #battle .b-bars { width: 200px; }
  #battle .b-hpbar { height: 14px; } #battle .b-hpbar span { line-height: 14px; font-size: 10.5px; }
}
/* на сенсорных экранах подписи клавиш не нужны */
@media (hover: none) and (pointer: coarse) { #battle .key { display: none; } }

/* На сенсорных экранах подсказка про клавиши ПК не нужна — там есть обучение. */
@media (pointer: coarse) { .b-hint { display: none !important; } }

/* ---------- подземелья: делёж добычи (кости) ---------- */
.dun-loot { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(rgba(10,6,2,.55), rgba(0,0,0,.85)); }
.dl-box { width: min(720px, 100%); max-height: 100%; overflow-y: auto; padding: 14px; border-radius: 10px; color: #f1e6cf;
  background: linear-gradient(#2a1f14, #160f09); border: 2px solid #c8962f; box-shadow: 0 0 30px rgba(233,196,106,.25), 0 10px 30px #000; }
.dl-h { font: 700 20px 'Cinzel', serif; color: #e9c46a; text-align: center; }
.dl-note { font-size: 12.5px; color: #b5a68c; text-align: center; margin: 4px 0 10px; }
.dl-item { display: grid; grid-template-columns: 48px 1fr; gap: 6px 10px; padding: 10px; margin-bottom: 8px; border-radius: 8px;
  background: rgba(0,0,0,.35); border-left: 4px solid var(--rc); }
.dl-ic { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 28px; border-radius: 6px; box-shadow: inset 0 0 0 2px var(--rc); }
.dl-txt b { color: var(--rc); font-size: 15px; }
.dl-sub, .dl-who { font-size: 12px; color: #b5a68c; }
.dl-st { font-size: 12.5px; }
.dl-fx { font-size: 12.5px; color: #ffd27a; }
.dl-btns { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.dl-btns button { flex: 1; min-width: 92px; padding: 9px 6px; border-radius: 6px; font: 700 13.5px sans-serif; color: #f1e6cf; cursor: pointer;
  background: linear-gradient(#4a3826, #2a1d12); border: 1px solid #7a5a2a; }
.dl-btns button.on { color: #2c1a05; background: linear-gradient(#ffe9a6, #d4a24a); }
.dl-btns button:disabled { opacity: .35; cursor: default; }
.dl-btns.done button { pointer-events: none; }
.dl-res { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: #cdbd9e; }
.dl-res .win { color: #7bd88a; font-weight: 700; }
.dl-winner { width: 100%; font-weight: 700; color: #ffe08a; }
.dl-foot { text-align: center; margin-top: 6px; }
.dl-go { padding: 11px 30px; border-radius: 6px; font: 700 16px sans-serif; color: #2c1a05; cursor: pointer;
  background: linear-gradient(#ffe9a6, #d4a24a); border: 1px solid #6e4812; }
.dl-go:disabled { opacity: .45; cursor: default; }

/* ---------- рамки союзников: нажатие — цель лечения (план 08.11, п. 13) ---------- */
#battle .b-party { position: absolute; top: 34%; left: var(--sl); z-index: 12; display: flex; flex-direction: column; gap: 6px; }
#battle .b-party:empty { display: none; }
#battle .pf { position: relative; display: flex; align-items: center; gap: 6px; width: 132px; padding: 3px 6px 3px 3px; border-radius: 8px;
  background: rgba(20,14,8,.78); box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo); color: #f3e2b4; font: 700 11px system-ui, sans-serif;
  text-align: left; touch-action: none; }
#battle .pf img { width: 30px; height: 30px; object-fit: contain; border-radius: 4px; background: radial-gradient(circle, #3f5a7a, #141a24 75%); flex: none; }
#battle .pf .pf-b { display: block; flex: 1; min-width: 0; }
#battle .pf .pf-n { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
#battle .pf .pf-hp { display: block; height: 7px; margin-top: 3px; border-radius: 2px; background: #120c08; box-shadow: inset 0 1px 2px #000; overflow: hidden; }
#battle .pf .pf-hp > div { height: 100%; background: linear-gradient(#8dff7a, #2c9e36); transition: width .1s; }
#battle .pf.low .pf-hp > div { background: linear-gradient(#ff8a6a, #c0301a); }
#battle .pf.dead { filter: grayscale(1) brightness(.6); }
#battle .pf.sel { box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #6dff8a, 0 0 12px rgba(109,255,138,.7); }
#battle .b-party.aim .pf { animation: pf-aim .6s ease-in-out infinite; }
@keyframes pf-aim { 50% { box-shadow: 0 0 0 1px #0b0805, 0 0 0 3px #6dff8a, 0 0 16px rgba(109,255,138,.9); } }
@media (max-height: 420px) { #battle .pf { width: 112px; padding: 2px 5px 2px 2px; } #battle .pf img { width: 24px; height: 24px; } #battle .b-party { top: 30%; gap: 4px; } }

/* ---------- умения полукругом вокруг кувырка (план 08.11, п. 15); лавка — в левый нижний угол ---------- */
#battle { --R: 150px; }
#battle .b-console { width: calc(var(--R) + var(--roll) / 2 + var(--sk) / 2 + 6px); height: calc(var(--R) + var(--roll) / 2 + var(--sk) / 2 + 6px);
  padding: 0; background: none; border: 0; box-shadow: none; }
#battle .b-console::before { display: none; }
#battle .b-cmd { position: static; }
#battle .b-skills { position: absolute; inset: 0; display: block; padding: 0; }
#battle .skill, #battle .skill.ult { position: absolute; border-radius: 50%;
  right: calc(var(--roll) / 2 + var(--R) * var(--c) - var(--sk) / 2); bottom: calc(var(--roll) / 2 + var(--R) * var(--s) - var(--sk) / 2); }
#battle .skill.ult { --sk2: calc(var(--sk) * 1.12); width: var(--sk2); height: var(--sk2);
  right: calc(var(--roll) / 2 + var(--R) * var(--c) - var(--sk2) / 2); bottom: calc(var(--roll) / 2 + var(--R) * var(--s) - var(--sk2) / 2); }
#battle .skill .lv { bottom: 5px; }
#battle .skill .up { top: -10px; right: -10px; }
#battle .b-side { position: static; }
#battle .b-roll { position: absolute; right: 0; bottom: 0; }
#battle .b-auto { top: auto; bottom: calc(var(--roll) + 8px); right: 0; border-radius: 8px; }
#battle .b-inv { position: absolute; right: calc(100% + 8px); bottom: 0; }
#battle .b-shopbtn { position: fixed; left: var(--sl); bottom: var(--sb); z-index: 12; width: calc(var(--cell) + 4px); height: calc(var(--cell) + 4px); filter: none; }
#battle .b-hint { bottom: calc(var(--sb) + var(--cell) + 14px); }
@media (max-height: 430px) {
  #battle { --R: 140px; --sk: 50px; --roll: 56px; }
  #battle .b-inv { position: absolute; left: auto; top: auto; right: calc(100% + 6px); bottom: 0; }
}
@media (min-height: 640px) and (min-width: 1000px) { #battle { --R: 172px; } }

/* рамки союзников — в стиле рамки героя (п. 33): круглый аватар, плашка скруглена со стороны аватара */
#battle .pf { border-radius: 20px 8px 8px 20px; width: 124px; background: var(--hud-grain), linear-gradient(180deg, rgba(61,52,43,.92), rgba(29,25,20,.92));
  box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold-lo), 0 3px 8px rgba(0,0,0,.5); }
#battle .pf img { border-radius: 50%; box-shadow: 0 0 0 1px #0b0805, 0 0 0 2px var(--hud-gold); }
#battle .pf .pf-hp { height: 6px; border-radius: 3px; }

/* Арабский (dir=rtl, п.35): раскладка боя — как в оригинале (джойстик слева, умения справа, счёт синие:красные),
   а сами надписи внутри — с направлением по содержимому. Окна лавки и подсказки — справа налево. */
[dir="rtl"] #battle, [dir="rtl"] #td { direction: ltr; }
[dir="rtl"] #battle :is(.b-feed, .b-hint, .b-party, .b-pick, .b-respawn) *,
[dir="rtl"] #td :is(.b-feed, .td-label) { unicode-bidi: plaintext; }
[dir="rtl"] #battle :is(#b-shop, #b-tip), [dir="rtl"] #tip, [dir="rtl"] #td .td-panel { direction: rtl; }

/* иконки умений картинками: заполняют круглую кнопку целиком */
#battle .skill .ic:has(.skimg) { position: absolute; inset: 3px; border-radius: 50%; overflow: hidden; display: block; z-index: 0; }
#battle .skill .ic .skimg { width: 100%; height: 100%; }
#battle .b-passive { overflow: hidden; padding: 0; }
#battle .tip-ic .skimg, .tip .tip-ic .skimg { width: 30px; height: 30px; border-radius: 6px; display: inline-block; vertical-align: middle; }

/* эпичные карты усилений (09.11): картина на всю карту, золотая рамка, свечение, появление веером, блик */
#battle .b-pick { background: radial-gradient(ellipse at 50% 55%, rgba(60,30,8,.55), rgba(0,0,0,.82)); }
#battle .pick-title { font: 700 clamp(18px, 3vw, 28px) var(--f-head, Georgia, serif); letter-spacing: 1px; margin-bottom: 10px;
  background: linear-gradient(#fff4c0, #ffd34d 55%, #e08a1a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 3px #000); }
#battle .pick-row:has(.epic) { gap: clamp(10px, 2vw, 22px); }
#battle .pick-card.epic { position: relative; width: clamp(118px, 17vw, 190px); aspect-ratio: 2 / 3.1; padding: 0; overflow: hidden; border-radius: 14px;
  border: 3px solid transparent; background: linear-gradient(#1a1209, #1a1209) padding-box, linear-gradient(160deg, #fff1b8, #c9922e 30%, #7a4a12 55%, #ffd77a 80%, #8a5a1a) border-box;
  box-shadow: 0 0 0 1px #000, 0 10px 26px rgba(0,0,0,.7), 0 0 24px rgba(255,190,80,.25); color: #fff;
  animation: card-in .55s cubic-bezier(.2,.9,.3,1.3) both; animation-delay: var(--d, 0s); transition: transform .18s, box-shadow .18s; }
#battle .pick-card.epic:hover, #battle .pick-card.epic:active { transform: translateY(-8px) scale(1.04); box-shadow: 0 0 0 1px #000, 0 16px 30px rgba(0,0,0,.75), 0 0 34px rgba(255,200,90,.6); }
#battle .pc-art { position: absolute; inset: 0; background: var(--art) center / cover no-repeat; }
#battle .pc-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 50%, rgba(10,6,2,.92) 82%); }
#battle .pc-shine { position: absolute; inset: -40% -60%; background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.28) 50%, transparent 58%);
  animation: card-shine 3.2s ease-in-out infinite; animation-delay: calc(var(--d, 0s) + .6s); pointer-events: none; }
#battle .pc-txt { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 2px; text-align: center; }
#battle .pc-txt b { font: 700 clamp(13px, 1.7vw, 17px) var(--f-head, Georgia, serif); color: #ffe39a; text-shadow: 0 2px 3px #000; }
#battle .pc-txt span { font-size: clamp(11px, 1.3vw, 13px); color: #f3ead2; text-shadow: 0 1px 2px #000; }
@keyframes card-in { from { opacity: 0; transform: translateY(40px) rotateY(80deg) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes card-shine { 0%, 60% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }
@media (prefers-reduced-motion: reduce) { #battle .pick-card.epic, #battle .pc-shine { animation: none; } }
/* Нарисованные иконки предметов лавки (п. 50) */
#battle .it-pic { width: 1.5em; height: 1.5em; object-fit: contain; vertical-align: middle; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
#battle .shop-slot .it-pic, #battle .si-head .it-pic { width: 36px; height: 36px; }
#battle .si-rec .it-pic { width: 22px; height: 22px; }

#battle .shop-it.locked { opacity: .4; filter: grayscale(.7); }
#battle .shop-lock-hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted, #bba); text-align: center; padding: 4px; }
