:root{
  --glass: rgba(0,0,0,.35);
  --glass2: rgba(255,255,255,.06);
}
body{ margin:0; background:#0b0b0f !important; min-height:100vh; }
/* Battle/Arena: use dynamic viewport height and avoid fixed-attachment (mobile bars cause gaps) */
body.battle-page, body.arena-page{
  min-height: 100dvh;
  background-image: var(--battle-bg);
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
}
/* Ensure the whole app wrapper uses the same battle background (prevents black bottom gap) */
body.battle-page .portal-game,
body.arena-page .portal-game{
  min-height: 100dvh;
  background: #0b0b0f;
  background-image: var(--battle-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* Disable portal decorative layer images on battle/arena (prevents double-background artifacts) */
body.battle-page .portal-game::before,
body.arena-page .portal-game::before{ opacity: 0 !important; }
a{ text-underline-offset: 3px; }
.mini-card{
  background: var(--glass);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 14px;
}
.mini-title{ font-weight: 600; margin-bottom: 6px; }
.portal-frame{ background: rgba(0,0,0,.55); }
.portal-overlay{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  padding: 16px;
  background: radial-gradient(closest-side, rgba(0,160,255,.25), rgba(0,0,0,.55) 70%);
}
.portal-glow{
  position:absolute; inset:-20%;
  pointer-events:none;
  background: radial-gradient(circle at 50% 50%, rgba(0,170,255,.18), transparent 60%);
  filter: blur(18px);
}
.avatar-box{
  width: 72px; height: 72px;
  border-radius: 18px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
}
.avatar-box img{ width:100%; height:100%; object-fit:cover; }
.battle-card{
  background: rgba(0,0,0,.25);
  background-image: var(--battle-bg);
  background-size: cover;
  background-position: center;
  background-blend-mode: overlay;
}
/* NOTE: board background is rendered by .board-bg element. Avoid duplicating it here. */

.tile-img{ width: 70%; height: 70%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); pointer-events:none; }
.tile-emoji{ font-size: 22px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); pointer-events:none; }
.board{
  display:grid;
  grid-template-columns: repeat(var(--board-size, 6), 1fr);
  gap: 8px;
  user-select:none;
  touch-action: none;
  overflow:hidden;
}
.gem{
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow:hidden;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 700;
  letter-spacing: .5px;
  cursor:pointer;
  transition: transform .08s ease, filter .08s ease;
}

/* live swap animation (opponent/bot move) */
.gem.swap{ animation: gemSwap .20s ease-in-out; }
@keyframes gemSwap{
  0%{ transform: translate(0,0); }
  60%{ transform: translate(calc(var(--dx,0) * 100%), calc(var(--dy,0) * 100%)); }
  100%{ transform: translate(0,0); }
}

/* subtle rune tints */
.gem[data-t="A"]{ background: linear-gradient(180deg, rgba(255,80,80,.20), rgba(255,255,255,.04)); }
.gem[data-t="B"]{ background: linear-gradient(180deg, rgba(255,90,180,.18), rgba(255,255,255,.04)); }
.gem[data-t="C"]{ background: linear-gradient(180deg, rgba(80,200,255,.18), rgba(255,255,255,.04)); }
.gem[data-t="D"]{ background: linear-gradient(180deg, rgba(255,170,60,.18), rgba(255,255,255,.04)); }
.gem[data-t="E"]{ background: linear-gradient(180deg, rgba(120,255,220,.14), rgba(255,255,255,.04)); }
.gem[data-t="F"]{ background: linear-gradient(180deg, rgba(255,235,100,.16), rgba(255,255,255,.04)); }
.gem.drag{ outline: 2px solid rgba(255,193,7,.9); filter: brightness(1.12); }
.gem:active{ transform: scale(.96); }
.gem.sel{ outline: 2px solid rgba(13,110,253,.9); filter: brightness(1.12); }
.gem.hint{ outline: 2px dashed rgba(25,135,84,.9); }
.gem.hint-strong{ outline: 3px solid rgba(255,215,70,.98) !important; box-shadow: 0 0 0 3px rgba(255,215,70,.28), 0 0 22px rgba(255,215,70,.55); filter: brightness(1.22) saturate(1.18); }
.gem.jump-src{ outline: 3px solid rgba(70,180,255,.96) !important; box-shadow: 0 0 0 3px rgba(70,180,255,.22), 0 0 20px rgba(70,180,255,.45); }
.gem.jump-dst{ outline: 3px solid rgba(167,92,255,.98) !important; box-shadow: 0 0 0 3px rgba(167,92,255,.22), 0 0 22px rgba(167,92,255,.45); filter: brightness(1.18); }
.gem.jump-path{ box-shadow: inset 0 0 0 2px rgba(255,255,255,.08), 0 0 0 2px rgba(104,211,255,.18); }
.gem.jump-src::after,.gem.jump-dst::after,.gem.hint-strong::after{ opacity:1; transform:scale(1.04); }


/* ===== Match-3 polish: selection ring + smooth change ===== */
.gem{ position: relative; overflow: hidden; }
.gem::after{
  content:"";
  position:absolute;
  inset:-10%;
  background: url('/assets/img/effects/ring.gif') center/contain no-repeat;
  opacity:0;
  pointer-events:none;
  transform: scale(.92);
  filter: drop-shadow(0 0 10px rgba(80,180,255,.55));
  transition: opacity .12s ease, transform .12s ease;
}
/* selected */
.gem.sel::after{
  opacity: 0.95;
  transform: scale(1.02);
}
/* drag highlight */
.gem.drag::after{
  opacity: 0.75;
  transform: scale(1.06);
}
/* direction hint (neighbor) */
.gem.dir::after{
  opacity: 0.45;
  transform: scale(0.98);
  filter: drop-shadow(0 0 10px rgba(255,210,120,.45));
}

/* quick click pulse (tap feedback) */
.gem.pulse{ animation: gemPulse .18s ease-out; }
@keyframes gemPulse{
  0%{ transform: scale(1); }
  70%{ transform: scale(.93); }
  100%{ transform: scale(1); }
}

/* when server updates a cell, animate content pop for smoothness */
.gem.chg{ animation: gemChg .14s ease-out; }
@keyframes gemChg{
  0%{ transform: translateY(2px) scale(.92); filter: brightness(1.20); }
  100%{ transform: translateY(0) scale(1); filter: none; }
}

/* smoother swap curve */
.gem.swap{ animation-duration: .24s; animation-timing-function: cubic-bezier(.2,.9,.2,1); }

.hpbar{ height: 8px; background: rgba(255,255,255,.08); border-radius: 999px; overflow:hidden; }
.hpbar .progress-bar{ width: 100%; }

@media (max-width: 576px){
  .board-wrap{ padding: 10px; }
  .board{ gap: 6px; }
  .gem{ border-radius: 12px; }
  .chat-box{ height: 320px; }
}
.chat-box{
  height: 420px;
  overflow:auto;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  padding: 10px;
  background: rgba(0,0,0,.25);
}
.chat-msg{ padding: 8px 10px; border-radius: 12px; margin-bottom: 8px; border: 1px solid rgba(255,255,255,.06); background: rgba(255,255,255,.04); }
.chat-meta{ font-size: 12px; color: rgba(255,255,255,.60); margin-bottom: 2px; }

/* Твой оригинальный оверлей */
.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}

/* Твоя карточка + RGB НЕОН */
.result-card {
  width: min(560px, 96vw);
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.15) !important;
  background: rgba(10,14,24,.95) !important; /* Чуть плотнее, чтобы неон выделялся */
  padding: 18px;
  position: relative;
  
  /* RGB BLOOM EFFECT (Зеленый + Фиолетовый) */
  box-shadow: 
    0 30px 80px rgba(0,0,0,.6),
    0 0 0 1px rgba(96, 246, 142, 0.4),  /* Тонкая зеленая нить */
    0 0 20px rgba(96, 246, 142, 0.2),   /* Зеленое свечение */
    0 0 40px rgba(215, 96, 246, 0.2) !important; /* Фиолетовое свечение */
  
  animation: resultPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* КНОПКИ: ШИКАРНЫЙ ВИД */ 
.result-card .btn {
  padding: 12px 24px !important;
  border-radius: 12px !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  transition: all 0.2s ease !important;
  border: none !important;
}

/* Кнопка "Главная" / Второстепенная */
.result-card .btn-outline-light {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;
}
.result-card .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  transform: translateY(-2px);
}

/* Кнопка "Новый бой" / Акцентная RGB */
.result-card .btn-primary {
  background: linear-gradient(135deg, #00f2fe 0%, #7c3aed 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4) !important;
}
.result-card .btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.6) !important;
}

/* АНИМАЦИЯ ПОЯВЛЕНИЯ */
@keyframes resultPop {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
 
@media (max-width: 576px) {
  .result-card { padding: 14px; }
}
/* ===== Battle v5 layout (bright, no scroll) ===== */
.battle-stage{
  min-height: calc(100vh - 66px);
  display:flex;
  flex-direction:column;
  background-image: var(--battle-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.12);
  overflow: hidden;
  position: relative;
  padding: 14px;
}
.battle-stage:before{
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(1000px 600px at 30% 0%, rgba(255,255,255,.12), transparent 60%),
              linear-gradient(180deg, rgba(10,14,24,.35), rgba(10,14,24,.65));
  pointer-events:none;
}
.battle-stage > *{ position:relative; z-index:1; }

.battle-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
}
.battle-title__h{ font-weight:800; font-size: 20px; letter-spacing:.2px; color: rgba(255,255,255,.96); }
.battle-title__s{ color: rgba(255,255,255,.80); font-size: 12px; }
.battle-actions{ display:flex; gap:8px; flex-wrap:wrap; }

.battle-hud{
  display:grid;
  grid-template-columns: 1fr minmax(220px, 320px) 1fr;
  gap:12px;
  margin-bottom: 10px;
}
.player-panel{
  display:flex;
  gap:10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
}
.player-panel.is-active{
  box-shadow: 0 0 0 2px rgba(120,235,255,.30), 0 18px 40px rgba(0,0,0,.35);
  border-color: rgba(140,240,255,.35);
}
.player-panel.is-wait{ opacity: .82; }
.player-panel__avatar img{
  width: 62px; height:62px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.25);
  object-fit: cover;
  display:block;
}
.player-panel__name{ font-weight:800; color: rgba(255,255,255,.96); line-height:1.1; }
.player-panel__nums{ display:flex; flex-wrap:wrap; gap:6px; margin-top: 6px; }
.pill{
  display:inline-flex; align-items:center; gap:6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  font-size: 12px;
}
.hpbar{
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.30);
  border: 1px solid rgba(255,255,255,.14);
  overflow:hidden;
  margin-top: 4px;
}
.hpbar__fill{
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, rgba(60,255,170,.95), rgba(255,210,90,.95));
}
.center-hud{
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  text-align:center;
}
.turn-label{ color: rgba(255,255,255,.78); font-size: 12px; }
.turn-who{
  font-weight: 900;
  font-size: clamp(18px, 2.2vw, 26px);
  letter-spacing: .6px;
  color: rgba(255,255,255,.98);
  text-shadow: 0 10px 25px rgba(0,0,0,.55);
}
.timers{
  display:flex;
  justify-content:center;
  gap:10px;
  margin-top: 6px;
}
.timerbox{
  min-width: 110px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
}
.timerbox__t{ font-size: 11px; color: rgba(255,255,255,.78); }
.timerbox__v{ font-weight: 900; font-size: 18px; color: rgba(255,255,255,.96); }
.timerbox--main .timerbox__v{ font-size: 20px; }

.battle-body{
  display:grid;
  grid-template-columns: 1fr 340px;
  gap:12px;
  flex: 1;
  min-height: 0;
}
.battle-left{ display:flex; flex-direction:column; gap:10px; min-width:0; }
.battle-tools{ display:flex; gap:8px; flex-wrap:wrap; }
.board-wrap{
  flex: 1;
  position: relative;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  /*backdrop-filter: blur(8px);*/ 
  max-width: none;
  margin: 0;
  display:flex;
  align-items:center;
  justify-content:center;
}
.board-bg{
  position:absolute;
  inset: 10px;
  border-radius: 18px;
  background-image: var(--board-bg);
  background-size: cover;
  background-position:center;
  opacity: .65;
  filter: saturate(1.15) contrast(1.05);
}

/* FX overlay inside board (subtle portal shimmer on each move) */
.move-fx{
  position:absolute;
  inset: 10px;
  border-radius: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity: 0;
  pointer-events:none;
  transition: opacity .18s ease;
  z-index: 2;
}

/* ===== Operation 5: Epoch glitch (stability < 30) ===== */
body.epoch-glitch::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index: 9998;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.03) 0px,
      rgba(255,255,255,0.03) 1px,
      rgba(0,0,0,0) 3px,
      rgba(0,0,0,0) 6px
    );
  mix-blend-mode: overlay;
  opacity:.35;
  animation: glitchScan 2.6s linear infinite;
}

body.epoch-glitch::after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index: 9997;
  background: radial-gradient(circle at 50% 40%, rgba(124,58,237,.12), rgba(0,0,0,0) 55%);
  opacity:.8;
  animation: glitchPulse 1.8s ease-in-out infinite;
}

@keyframes glitchScan{
  0%{ transform:translateY(0); }
  100%{ transform:translateY(18px); }
}

@keyframes glitchPulse{
  0%,100%{ opacity:.35; }
  50%{ opacity:.85; }
}
.move-fx img{
  width: min(520px, 78%);
  opacity: .55;
  filter: saturate(1.15) drop-shadow(0 12px 28px rgba(0,0,0,.55));
}
.move-fx.show{ opacity: 1; }
.board{
  width: min(560px, 60vh, 88vmin);
  max-width: 560px;
}
.board .gem{
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.10);
}
.chat-panel{
  height: 100%;
  display:flex;
  flex-direction:column;
  border-radius: 22px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  overflow:hidden;
}
.chat-panel__head{
  padding: 10px 12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.92);
}
.chat-panel__box{
  flex:1;
  overflow:auto;
  padding: 10px;
}
.chat-panel__send{
  display:flex;
  gap:8px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.rotate-overlay{
  display:none;
  position:absolute; inset:0;
  align-items:center; justify-content:center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}
.rotate-overlay.show{ display:flex; }
.rotate-card{
  width: min(420px, 92vw);
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.55);
}

@media (max-width: 992px){
  .battle-hud{ grid-template-columns: 1fr; }
  .battle-body{ grid-template-columns: 1fr; height:auto; min-height: 0; }
  /* Chat becomes a bottom sheet on mobile (no page scrolling) */
  .chat-panel{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    height: 46vh;
    z-index: 1080;
    display: none;
  }
  .chat-panel.show{ display:flex; }
  .board{ width: min(560px, 96vw); }
}

/* Battle/Arena pages should not scroll; UI must fit viewport */
/* Battle/Arena should remain playable on desktop too.
   Keep body locked to avoid background scroll, but don't clip UI blocks. */
body.battle-page, body.arena-page{ overflow:hidden; }
/* Use svh/dvh to avoid mobile address-bar gaps */
body.battle-page main, body.arena-page main{
  height: calc(100svh - 66px);
  height: calc(100dvh - 66px);
  overflow: visible;
 /* background-image: var(--battle-bg); не включать не за что */ 
  background-size: cover;
  background-position: center;
}
body.battle-page .battle-stage{ height: 100%; min-height: 0; }

/* Arena waiting screen */
.arena-stage{
  height: calc(100svh - 66px);
  height: calc(100dvh - 66px);
  display:flex;
  align-items:center;
  justify-content:center;
  background-image: var(--battle-bg);
  background-size: cover;
  background-position: center;
  position: relative;
}
.arena-stage:before{
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(900px 520px at 50% 0%, rgba(255,255,255,.16), transparent 60%),
              linear-gradient(180deg, rgba(10,14,24,.35), rgba(10,14,24,.75));
}
.arena-card{
  position:relative;
  width: min(560px, 92vw);
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.50);
  backdrop-filter: blur(10px);
  padding: 18px;
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
}
.arena-title{ font-weight: 900; font-size: 20px; }
.arena-sub{ font-size: 12px; margin-top: 2px; }
.arena-timer{ font-weight: 900; font-size: 72px; text-align:center; line-height:1; margin: 10px 0 4px; }
.arena-hint{ text-align:center; }
.arena-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top: 14px; }



/* ===== Arena layout: left/right stats, center board, bottom horizontal chat ===== */
.battle-topinfo{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 12px;
}
.battle-topinfo__card{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
  padding: 12px 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}
.battle-topinfo__title{
  font-weight: 900;
  letter-spacing: .25px;
  margin-bottom: 6px;
}
.battle-topinfo__text{ color: rgba(255,255,255,.85); font-size: 13px; line-height: 1.35; }

.arena-layout{
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  grid-template-areas: "left center right";
  gap: 12px;
  align-items: start;
}

@media (max-width: 720px){
  .battle-topinfo{ grid-template-columns: 1fr; }
  .battle-topinfo__text{ font-size: 12.5px; }
}
.arena-side--left{ grid-area:left; }
.arena-center{ grid-area:center; }
.arena-side--right{ grid-area:right; }
.arena-side{ min-width:0; display:flex; flex-direction:column; gap:10px; }
.arena-center{ min-width:0; display:flex; flex-direction:column; gap:10px; align-items:center; }

/* Battle center ordering: mobile = topinfo -> boosters -> board, desktop = boosters -> board -> topinfo */
.battle-page .arena-center .battle-topinfo{ width: 100%; max-width: 920px; }
@media (max-width: 991px){
  .battle-page .arena-center .battle-topinfo{ order: 0; }
  .battle-page .arena-center .boostbar--top{ order: 1; }
  .battle-page .arena-center .board-wrap--arena{ order: 2; }
}
@media (min-width: 992px){
  .battle-page .arena-center .boostbar--top{ order: 0; }
  .battle-page .arena-center .board-wrap--arena{ order: 1; }
  .battle-page .arena-center .battle-topinfo{ order: 2; margin-top: 10px; }
}

.side-note{
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
}

.board-wrap--arena{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 12px;
  max-width: none;
}

/* ===== Use board_bg as full board art (frame + 6x6 cells).
   Place stones into the cell area using --grid-inset. ===== */
.board-wrap--arena{
  position: relative;
  padding: 0;
  border: none;
  background: transparent;
  /* Classic feel: board is scaled via transform.
     Base size must be stable, otherwise HUD spacing becomes unpredictable on desktop. */
  --board-base: min(92vmin, 560px);
  width: var(--board-base);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  transform: scale(var(--board-scale, 1));
  transform-origin: center;
  will-change: transform;
}

/* When user increases board scale on mobile, keep UI compact.
   We shrink paddings/fonts proportionally via --ui-scale (set by JS). */
@media (max-width: 992px){
  .battle-topinfo__card{ padding: calc(12px * var(--ui-scale, 1)) calc(14px * var(--ui-scale, 1)); }
  .battle-topinfo__text{ font-size: calc(13px * var(--ui-scale, 1)); }
  .battle-topinfo__title{ font-size: calc(14px * var(--ui-scale, 1)); }
  .player-panel{ padding: calc(10px * var(--ui-scale, 1)); gap: calc(12px * var(--ui-scale, 1)); }
  .player-panel__name{ font-size: calc(15px * var(--ui-scale, 1)); }
  .pill{ font-size: calc(12px * var(--ui-scale, 1)); }
  .hero-card{ transform: scale(var(--ui-scale, 1)); transform-origin: top left; }
}

/* Desktop: State/Hint handled inside .arena-center ordering (see battle center ordering block). */

/* Loot / reward modal (used for season quests and future achievements) */
.pt-loot-card{
  border-radius: 22px;
  background: rgba(10,14,24,.92);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 80px rgba(0,0,0,.65);
  overflow:hidden;
}
.pt-loot-head{
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  background: linear-gradient(90deg, rgba(255,215,90,.18), rgba(120,235,255,.10));
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.pt-loot-title{ font-weight: 900; letter-spacing: .25px; color: rgba(255,255,255,.96); }
.pt-loot-body{ padding: 16px; }
.pt-loot-reward{
  margin-top: 10px;
  padding: 14px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  font-weight: 900;
  font-size: 18px;
}
.pt-loot-pop{ animation: ptLootPop .28s ease-out; }
@keyframes ptLootPop{ from{ transform: scale(.92); opacity:.0 } to{ transform: scale(1); opacity:1 } }

.battle-qm-row{
  display:flex;
  gap:10px;
}
.battle-qm-row .battle-qm-btn{ flex:1; }

.board-wrap--arena .board-bg{
  position:absolute;
  inset:0;
  z-index:1;
  background-image: var(--board-bg);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 18px;
  opacity: 1; /* важно: без прозрачности, иначе "дублируется" фон боя под доской */
  filter: none;
}

.board-wrap--arena .board-frame{
  position:absolute;
  inset:0;
  z-index:3;
  width:100%;
  height:100%;
  object-fit: contain;
  pointer-events:none;
  border-radius: 18px;
}

.board-wrap--arena .board{
  position:absolute;
  touch-action: none;
  overscroll-behavior: contain;
  /* Prefer percentage insets (scale-safe on mobile). Fallback to px insets. */
  inset: var(--grid-inset-top-pct, var(--grid-inset-top, var(--grid-inset, 164px)))
         var(--grid-inset-right-pct, var(--grid-inset-right, var(--grid-inset, 164px)))
         var(--grid-inset-bottom-pct, var(--grid-inset-bottom, var(--grid-inset, 164px)))
         var(--grid-inset-left-pct, var(--grid-inset-left, var(--grid-inset, 164px)));
  z-index:2;
  width: auto;
  max-width: none;
  display:grid;
  grid-template-columns: repeat(var(--board-size, 6), 1fr);
  grid-template-rows: repeat(var(--board-size, 6), 1fr);
  gap: var(--grid-gap, 0px);
}

.board-wrap--arena .gem{
  border: none;
  background: transparent;
  border-radius: 10px;
}

.board-wrap--arena .board.targeting .gem{
  cursor: crosshair;
}
.board-wrap--arena .board.targeting .gem:hover{
  outline: 2px solid rgba(255,255,255,.35);
  outline-offset: -2px;
  background: rgba(255,255,255,.06);
}

.board-wrap--arena .tile-img{ width:78%; height:78%; max-width:78%; max-height:78%; object-fit:contain; display:block; margin:auto; }

/* ===== Move FX: render inside 6x6 grid area (not over full frame) ===== */
.board-wrap--arena .move-fx{
  inset: var(--grid-inset-top-pct, var(--grid-inset-top, var(--grid-inset, 164px)))
         var(--grid-inset-right-pct, var(--grid-inset-right, var(--grid-inset, 164px)))
         var(--grid-inset-bottom-pct, var(--grid-inset-bottom, var(--grid-inset, 164px)))
         var(--grid-inset-left-pct, var(--grid-inset-left, var(--grid-inset, 164px)));
  border-radius: 14px;
  z-index: 5;
}
.board-wrap--arena .move-fx img{
  width: min(420px, 86%);
  opacity: .72;
}

.boostbar--top{ margin-bottom: 3px; }

/* Mobile: portrait and landscape behave differently */
@media (max-width: 768px) and (orientation:portrait){
  /* Portrait: keep boosters ABOVE the board */
  .boostbar--top{ position: static; transform:none; left:auto; bottom:auto; margin-bottom: 8px; }
  /* Horizontal scroll booster row: show ~3 items, scroll for the rest */
  .boostbar--top{
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 6px;
  }
  .boostbar--top::-webkit-scrollbar{ height: 6px; }
  .boostbar--top::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.22); border-radius: 8px; }
  .boostbar--top .boostbtn{ flex: 0 0 auto; }
  .battle-tip{ display:none; }
}

/* Tight spacing: boosters -> board on desktop */
.battle-page .boostbar--top{ margin-bottom: 3px !important; }
.battle-page #boardScalePad{ height: 3px !important; }

@media (max-width: 768px) and (orientation:landscape){
  /* Landscape: keep boosters reachable at the bottom */
  .boostbar--top{
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 10px;
    margin-bottom: 0;
    z-index: 10;
  }
  .battle-tip{ display:none; }
}

/* Stats: show only icons, values live in title tooltips */
.player-panel__nums .pill b{ display:none; }

/* Fit board on 1365x647 @100% without page scroll */
.board{
  width: min(520px, calc(100vh - 245px), calc(100vw - 640px));
  max-width: 520px;
}

.move-fx{
  opacity: 0;
  transition: opacity .08s ease;
  pointer-events:none;
}
.move-fx.show{ opacity: 1; }
.move-fx img{
  width: min(520px, 92%);
  opacity: .60;
  mix-blend-mode: screen;
  filter: saturate(1.2) drop-shadow(0 10px 22px rgba(0,0,0,.55));
}

/* Result reward box */
.reward-box{
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
}

/* Bottom chatbar: horizontal scroll */
.chatbar{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 110px 1fr 240px;
  align-items:center;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  overflow:hidden;
}
.chatbar__strip{
  display:flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.chatbar__send{
  display:flex;
  gap: 8px;
}
.chat-msg{
  display:inline-flex;
  flex-direction:column;
  min-width: 200px;
  max-width: 360px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
}

@media (max-width: 992px) and (orientation:portrait){
  /* Portrait: show both player cards together on top, board below */
  .arena-layout{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "left right"
      "center center";
    gap: 10px;
  }
  .board{ width: min(92vw, 520px); }
  .chatbar{ grid-template-columns: 1fr; }
  .chatbar__send{ width:100%; }
}

@media (max-width: 992px) and (orientation:landscape){
  /* Landscape tablets: narrower side panels */
  .arena-layout{ grid-template-columns: 240px 1fr 240px; }
  .board{ width: min(64vh, 520px); }
}

/* ===== Avatar turn ring + active highlight ===== */
.avatar-ring{
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  padding: 5px;
  background: conic-gradient(rgba(0,255,180,.9) calc(var(--p)*1%), rgba(255,255,255,.12) 0);
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
.avatar-ring img{
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display:block;
  border: 2px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.2);
}
.avatar-time{
  position:absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  font-size: 18px;
  text-shadow: 0 2px 10px rgba(0,0,0,.7);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events:none;
}
.avatar-time.show{ opacity: 1; }
.avatar-time.warn{
  color: #ff4d4d;
  animation: blinkWarn .5s infinite;
}
@keyframes blinkWarn{ 0%,49%{opacity:1} 50%,100%{opacity:.35} }

.player-panel{
  display:flex;
  gap: 12px;
  align-items:center;
}
.player-panel.is-active{
  border-color: rgba(0,255,180,.55) !important;
  box-shadow: 0 0 0 2px rgba(0,255,180,.14), 0 14px 40px rgba(0,0,0,.55);
  animation: pulseTurn 1.2s infinite;
}
.player-panel.is-wait{
  opacity: .85;
  filter: saturate(.85);
}
@keyframes pulseTurn{ 0%,100%{transform:translateY(0)} 50%{transform:translateY(-1px)} }

/* ===== Board sizing for 1365x647 @100% ===== */
.board{ width: min(520px, calc(100vh - 245px), calc(100vw - 680px)); }


.enemy-intel{margin-top:10px;padding:12px;border-radius:16px;background:linear-gradient(180deg,rgba(7,12,26,.72),rgba(9,16,32,.88));border:1px solid rgba(255,255,255,.12);display:grid;gap:8px;max-width:100%;overflow:hidden;word-break:break-word}
.enemy-intel--hidden{display:none}
.enemy-intel[data-frame="boss"]{border-color:rgba(255,168,107,.34);box-shadow:0 0 0 1px rgba(255,168,107,.12) inset}
.enemy-intel[data-frame="elite"]{border-color:rgba(147,214,255,.34);box-shadow:0 0 0 1px rgba(147,214,255,.12) inset}
.enemy-intel__top{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;min-width:0}
.enemy-intel__eyebrow{font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:rgba(255,255,255,.56);font-weight:900}
.enemy-intel__title{font-size:.98rem;font-weight:900;color:#fff;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.enemy-intel__status{flex:0 0 auto;display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:999px;border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.05);font-size:.72rem;font-weight:900;color:#fff}
.enemy-intel__warning,.enemy-intel__line{font-size:.8rem;line-height:1.35;color:rgba(255,255,255,.82);overflow-wrap:anywhere}
.enemy-intel__line b{color:#fff}
@media (max-width: 768px){.enemy-intel{padding:10px}.enemy-intel__top{flex-direction:column;align-items:flex-start}.enemy-intel__status{align-self:flex-start}}

/* ===== Steam-like chat drawer ===== */
.chat-fab{
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 60;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px;
  background: rgba(0,0,0,.45);
  color: rgba(255,255,255,.92);
  padding: 10px 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 28px rgba(0,0,0,.55);
}
.chat-fab__badge{
  display:inline-flex;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  background: rgba(0,255,180,.18);
  border: 1px solid rgba(0,255,180,.35);
}

.chat-drawer{
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  max-width: 920px;
  margin: 0 auto;
  height: 320px;
  display: none;
  grid-template-rows: 48px 1fr 46px;
  border-radius: 18px;
  background: rgba(10,10,18,.72);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,.65);
}
.chat-drawer.open{ display:grid; }
.chat-drawer__head{
  padding: 10px 12px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.chat-drawer__box{
  padding: 10px 12px;
  overflow: auto;
}
.chat-drawer__send{
  padding: 8px 12px;
  display:flex;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.chat-msg{
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  margin-bottom: 8px;
}
.chat-msg.me{ background: rgba(0,255,180,.08); border-color: rgba(0,255,180,.18); }
.chat-meta{ font-size: 11px; color: rgba(255,255,255,.70); margin-bottom: 4px; }
.chat-meta b{ font-weight:800; color: rgba(255,255,255,.92); }
.chat-time{ opacity:.75; margin-left:6px; }
.chat-body{ margin-top:2px; line-height:1.25; white-space:pre-wrap; }

.player-panel.is-wait{border-color: rgba(255,80,80,.28) !important;}

/* ==================== Boosters bar + shop modal ==================== */
.boostbar{ display:flex; gap:10px; align-items:center; justify-content:center; width:100%; }
.boostbar__arrow{
  width:42px; height:42px; flex:0 0 42px; border-radius:14px;
  border:1px solid rgba(255,255,255,.16);
  background:linear-gradient(180deg, rgba(18,27,58,.96), rgba(8,12,28,.94));
  color:#fff; font-size:26px; font-weight:900; line-height:1;
  display:inline-flex; align-items:center; justify-content:center;
  box-shadow:0 10px 24px rgba(0,0,0,.22);
}
.boostbar__arrow:hover{ background:linear-gradient(180deg, rgba(36,53,112,.98), rgba(15,23,52,.96)); }
.boostbar__arrow.is-disabled{ opacity:.35; pointer-events:none; }
.boostbar__scroll{
  display:flex; gap:10px; align-items:center;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  overflow-x:auto; overflow-y:hidden;
  scrollbar-width:none; -ms-overflow-style:none;
}
.boostbar__scroll::-webkit-scrollbar{display:none}
.boost{
  width: 52px; height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.05));
  color: rgba(255,255,255,.92);
  font-size: 18px;
  display:inline-flex; align-items:center; justify-content:center;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  overflow:hidden;
  flex:0 0 auto;
  padding:0;
}
.boost__emoji{font-size:22px;line-height:1}
.boost__art{width:100%;height:100%;display:block;object-fit:cover;border-radius:15px}
.boost--basic{background:linear-gradient(180deg, rgba(34,52,99,.96), rgba(15,22,48,.94))}
.boost--energy{width:auto;min-width:78px;padding:0 16px;gap:8px;font-size:16px;font-weight:900;background:linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04))}
.boost__qty{
  position:absolute;
  right: 4px;
  bottom: 4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(4,8,20,.88);
  border: 1px solid rgba(255,255,255,.22);
  color: rgba(244,248,255,.98);
  font-size: 11px;
  line-height: 17px;
  font-weight: 900;
  box-shadow: 0 4px 14px rgba(0,0,0,.42);
  pointer-events:none;
}
.boost:hover{ transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0,0,0,.35); background: rgba(255,255,255,.12); }
.boost:active{ transform: translateY(0); }
.boost.is-disabled{ opacity:.45; }
.battle-log-toggle{display:inline-flex;align-items:center;gap:6px;font-weight:800}
.battle-log-drawer{position:fixed;inset:0;z-index:1250;pointer-events:none}
.battle-log-drawer__backdrop{position:absolute;inset:0;background:rgba(4,8,20,.52);opacity:0;transition:opacity .18s ease}
.battle-log-drawer__panel{position:absolute;top:12px;right:12px;width:min(420px,calc(100vw - 24px));height:calc(100vh - 24px);border-radius:22px;border:1px solid rgba(122,188,255,.18);background:linear-gradient(180deg,rgba(10,16,38,.97),rgba(6,10,24,.98));box-shadow:0 20px 60px rgba(0,0,0,.42);transform:translateX(18px);opacity:0;transition:transform .18s ease,opacity .18s ease;display:flex;flex-direction:column;overflow:hidden}
.battle-log-drawer__head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.08)}
.battle-log-drawer__title{font-weight:900;color:#fff}
.battle-log-drawer__sub{font-size:.82rem;color:rgba(255,255,255,.62);margin-top:2px}
.battle-log-drawer__close{width:40px;height:40px;border-radius:14px;border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.06);color:#fff;font-size:24px;line-height:1}
.battle-log-drawer__body{flex:1 1 auto;overflow:auto;padding:12px;display:grid;gap:8px}
.battle-log-drawer.is-open{pointer-events:auto}
.battle-log-drawer.is-open .battle-log-drawer__backdrop{opacity:1}
.battle-log-drawer.is-open .battle-log-drawer__panel{transform:translateX(0);opacity:1}
body.battle-log-open{overflow:hidden}
@media (max-width: 760px){
  .battle-log-drawer__panel{top:auto;right:10px;left:10px;bottom:10px;width:auto;height:min(56vh,420px);transform:translateY(16px)}
  .battle-log-drawer__body{padding:10px}
}
.boostbar__shop{
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(120,235,255,.10);
  color: rgba(255,255,255,.95);
  font-size: 18px;
}
.boostbar__shop:hover{ background: rgba(120,235,255,.16); }

.modal-portal{
  background: rgba(20,22,40,.92);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  color: rgba(255,255,255,.92);
}
.shop-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.shop-item{ padding: 12px; border-radius: 16px; background: rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12); }
.shop-icon{ font-size: 28px; }
.shop-name{ font-weight:800; margin-top:8px; }
.shop-desc{ font-size: 12px; color: rgba(255,255,255,.70); margin: 6px 0 10px; min-height: 34px; }
@media (max-width: 992px){ .shop-grid{ grid-template-columns: 1fr; } }

/* ===== v12 Avatar ring, FX overlays, subtle sway ===== */
.avatar-ring{
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
}
.avatar-ring img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
  border-radius: 50%;
}
.avatar-ring::before{
  content:"";
  position:absolute;
  inset:-6px;
  border-radius:50%;
  background: conic-gradient(rgba(0,255,128,.95) calc(var(--p,0)*1%), rgba(255,255,255,.08) 0);
  filter: drop-shadow(0 0 14px rgba(0,255,128,.18));
  opacity: .85;
  pointer-events:none;
}
/* active/wait colors */
.player-panel.is-active .avatar-ring::before{
  background: conic-gradient(rgba(0,255,128,.95) calc(var(--p,0)*1%), rgba(255,255,255,.08) 0);
}
.player-panel.is-wait .avatar-ring::before{
  background: conic-gradient(rgba(255,80,80,.95) calc(var(--p,0)*1%), rgba(255,255,255,.08) 0);
  filter: drop-shadow(0 0 14px rgba(255,80,80,.16));
}

.avatar-time{
  position:absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  font-size: 18px;
  color: rgba(255,255,255,.0);
  text-shadow: 0 2px 12px rgba(0,0,0,.55);
  pointer-events:none;
}
.avatar-time.show{ color: rgba(255,255,255,.92); }
.avatar-time.danger{ animation: avatarDanger .5s linear infinite; }
@keyframes avatarDanger{ 0%,100%{ color: rgba(255,110,110,.95);} 50%{ color: rgba(255,255,255,.95);} }

/* FX over avatar (sword/heal/shield/medal) */
.avatar-fx{
  position:absolute;
  inset:-18px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  transform: scale(.98);
  transition: opacity .12s ease, transform .12s ease;
  pointer-events:none;
}
.avatar-fx.show{ opacity:.78; transform: scale(1); }
.avatar-fx img{ width: 140%; height: 140%; object-fit: contain; filter: drop-shadow(0 10px 22px rgba(0,0,0,.55)); }

/* subtle sway for card art (if you later replace avatar with a full card image) */
@keyframes sway{ 0%,100%{ transform: translateY(0px) rotate(-.15deg);} 50%{ transform: translateY(-2px) rotate(.15deg);} }
.player-panel .avatar-ring{ animation: sway 4.8s ease-in-out infinite; }

/* Mobile: allow scrolling for chat + layout */
@media (max-width: 992px){
  body.battle-page, body.arena-page{ overflow:auto !important; }
  body.battle-page main, body.arena-page main{ height:auto !important; overflow:visible !important; }
}

/* === HERO CARD UI (fixed size like 168x355) === */
.player-panel{
  width:168px;
  min-width:168px;
  height:355px;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:flex-start;
  padding:10px;
}
.player-panel .hero-card{
  position:relative;
  width:100%;
  height:245px;
  border-radius:18px;
  overflow:hidden;
  background: rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.12);
}
.player-panel .hero-art{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  filter:saturate(1.1) contrast(1.05);
}
/* move avatar ring to top-left corner of card */
.player-panel .avatar-ring{
  position:absolute;
  left:12px;
  top:12px;
  width:68px;
  height:68px;
  z-index:3;
}
.player-panel__meta{
  margin-top:10px;
}
/* On smaller heights, scale panels and board */
@media (max-height: 720px){
  .player-panel{ transform:scale(.92); transform-origin: top left; }
  .arena-side--right .player-panel{ transform-origin: top right; }
}

.player-panel{ position:relative; }


/* =========================================================
   Stage 5 — Battle HUD polish (mobile-first, APK-friendly)
   - Gradient stat bars (HP/Armor/Energy)
   - Hide hero art on mobile, keep nick + bars
   - Symmetry on desktop
   ========================================================= */

.battle-page{ overflow: hidden; }

/* Ensure battle takes the whole viewport inside layout wrapper */
.battle-page .battle-stage{ min-height: 100svh; }

/* Stat bars */
.statbars{ display:grid; grid-template-columns: 1fr; gap: 6px; }
.statbar{
  position: relative;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.30);
  overflow:hidden;
}

/* =========================================================
   Stage 1 — Center notifications (bell anim + daily gift)
   ========================================================= */

.hud-bell{ position: relative; }
.hud-bell-img{ width: 18px; height: 18px; display:inline-block; object-fit:contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.hud-bell.has-unread{ transform:translate3d(0,0,0); }
.hud-bell.is-attn{ animation: ptBellShake .82s ease-in-out 2; }
@keyframes ptBellShake{
  0%,100%{ transform: rotate(0deg); }
  10%{ transform: rotate(-10deg); }
  20%{ transform: rotate(10deg); }
  30%{ transform: rotate(-8deg); }
  40%{ transform: rotate(8deg); }
  50%{ transform: rotate(-5deg); }
  60%{ transform: rotate(5deg); }
  70%{ transform: rotate(-2deg); }
  80%{ transform: rotate(2deg); }
}

/* Daily gift “card unfold” */
.pt-gift-card{
  width: min(420px, 92vw);
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.55);
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
  overflow:hidden;
}
.pt-gift-head{ padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.10); display:flex; align-items:center; justify-content:space-between; }
.pt-gift-title{ font-weight: 900; letter-spacing:.3px; }
.pt-gift-body{ padding: 16px; }
.pt-gift-scroll{ perspective: 1000px; }
.pt-gift-cardface{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: radial-gradient(closest-side, rgba(0,170,255,.18), rgba(0,0,0,.45) 70%);
  padding: 16px;
  transform-origin: center;
  animation: ptUnfold .55s ease both;
}
@keyframes ptUnfold{
  0%{ transform: rotateX(-75deg); opacity:0; }
  65%{ transform: rotateX(8deg); opacity:1; }
  100%{ transform: rotateX(0deg); opacity:1; }
}
.pt-gift-reward{
  margin-top: 10px;
  display:flex; align-items:center; justify-content:center;
  font-weight: 900;
  font-size: 28px;
  text-shadow: 0 10px 25px rgba(0,0,0,.55);
  animation: ptRewardPop .65s ease both;
}

.pt-gift-reward-img{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  animation: ptRewardPop .65s ease both;
}
@keyframes ptRewardPop{
  0%{ transform: scale(.85); opacity:0; }
  60%{ transform: scale(1.06); opacity:1; }
  100%{ transform: scale(1); opacity:1; }
}
.statbar__fill{
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width .18s ease;
}
.statbar__label{
  position:absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  letter-spacing: .3px;
  font-weight: 900;
  color: rgba(255,255,255,.78);
  text-transform: uppercase;
  mix-blend-mode: screen;
  pointer-events:none;
}

.statbar--hp .statbar__fill{
  background: linear-gradient(90deg, rgba(255,70,90,.92), rgba(255,170,80,.75));
}
.statbar--armor .statbar__fill{
  background: linear-gradient(90deg, rgba(80,190,255,.90), rgba(120,120,255,.75));
}
.statbar--energy .statbar__fill{
  background: linear-gradient(90deg, rgba(140,120,255,.90), rgba(88,167,255,.70));
}
.statbar__label{
  left: 50%;
  transform: translate(-50%,-50%);
  width: calc(100% - 16px);
  text-align:center;
  color:#fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  font-size: 11px;
}
.statbar--hp.is-mid .statbar__fill{
  background: linear-gradient(90deg, rgba(255,120,70,.95), rgba(255,80,80,.82));
}
.statbar--hp.is-low .statbar__fill{
  background: linear-gradient(90deg, rgba(255,70,70,.98), rgba(214,18,18,.9));
}
.statbar--hp.is-critical .statbar__fill{
  background: linear-gradient(90deg, rgba(255,20,20,1), rgba(145,0,0,.96));
  animation: hpCriticalPulse .9s ease-in-out infinite;
}
@keyframes hpCriticalPulse{
  0%,100%{ filter: drop-shadow(0 0 0 rgba(255,0,0,0)); opacity:1; }
  50%{ filter: drop-shadow(0 0 10px rgba(255,0,0,.75)); opacity:.78; }
}

/* Desktop symmetry: equal sides */
@media (min-width: 992px){
  .battle-page .arena-layout{
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 320px);
    align-items: start;
    gap: 18px;
  }
  .battle-page .arena-side--left{ justify-self: start; }
  .battle-page .arena-side--right{ justify-self: end; }
}

/* Mobile: maximize board + hide hero arts */
@media (max-width: 991px){
  .battle-page .hero-card{ display:none !important; }
  .battle-page .player-panel{ padding: 10px 10px !important; }
  .battle-page .player-panel__nums{ gap: 6px; }
  .battle-page .battle-actions .btn{ padding: .25rem .4rem; }
}

/* Portrait phones: board near full-screen */
@media (max-width: 520px){
  .battle-page .battle-topbar{ padding: 10px 10px; }
  .battle-page .battle-title__s{ display:none; }

  /* Boosters: swipe bar */
  .battle-page .boostbar__scroll{
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 8px;
  }
  .battle-page .boostbar__scroll::-webkit-scrollbar{ display:none; }
  .battle-page .boost{ scroll-snap-align: start; }

  /* Make board large */
  .battle-page .board-wrap{
    width: min(96vw, 560px);
    height: auto;
  }
  .battle-page .board{
    touch-action: none;
    overscroll-behavior: contain;
  }
}

/* =========================================================
   Stage 2 UI hotfix: compact hero panels on mobile
   (removes empty vertical space, keeps board visible)
   ========================================================= */
@media (max-width: 991.98px){
  .player-panel{
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 10px !important;
  }
  .player-panel .hero-card,
  .player-panel .hero-art{ display:none !important; }

  .player-panel .avatar-ring{
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 52px !important;
    height: 52px !important;
  }
  .player-panel__meta{ margin-top: 0 !important; }

  /* keep only bars + name on mobile */
  .player-panel__nums{ display:none !important; }
}


/* ===== Stage9: Battle quick horizontal menu (no layout shift) ===== */
.battle-qm{
  position: fixed;
  top: 74px;
  right: 16px;
  z-index: 2500;
  display: none;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,12,22,.72);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.battle-qm.open{ display:flex; }
.battle-qm-btn{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.92);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}
.battle-qm-btn:hover{ background: rgba(255,255,255,.10); }
.battle-qm-btn.danger{
  border-color: rgba(255,80,80,.35);
  background: rgba(255,80,80,.10);
}
@media (max-width: 520px){
  .battle-qm{
    left: 12px;
    right: 12px;
    top: 66px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .battle-qm-btn{ flex: 1 1 auto; text-align:center; }
}

/* Settings: reduced motion (local device option) */
.pt-reduced-motion *,
.pt-reduced-motion *::before,
.pt-reduced-motion *::after{
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}


/* Center toast (battle events) */
.center-toast{
  position:absolute;
  left:50%;
  top:45%;
  transform:translate(-50%,-50%);
  padding:12px 16px;
  border-radius:16px;
  background:rgba(0,0,0,.72);
  border:1px solid rgba(255,255,255,.18);
  color:#fff;
  font-weight:900;
  font-size:18px;
  letter-spacing:.2px;
  z-index:50;
  max-width:92%;
  text-align:center;
  backdrop-filter: blur(10px);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}
.center-toast--danger{ border-color: rgba(255, 82, 82, .35); color:#ffd8d8; }
.center-toast--success{ border-color: rgba(46, 213, 115, .35); color:#d7ffe6; }
.center-toast--info{ border-color: rgba(84, 160, 255, .35); color:#d8e8ff; }
.center-toast.show{ display:block !important; animation: ct 1.4s ease both; }
@keyframes ct{
  0%{opacity:0; transform:translate(-50%,-55%) scale(.98)}
  10%{opacity:1}
  80%{opacity:1}
  100%{opacity:0; transform:translate(-50%,-40%) scale(1)}
}


/* ===== Match-3 polish: smooth transitions (ghost layer) ===== */
.board{ position: relative; }
.board-ghost-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 5;
  overflow:hidden;
}
.ghost-tile{
  position:absolute;
  width: var(--ghost-size, calc((100% - (5 * var(--grid-gap, 8px))) / 6));
  height: var(--ghost-size, auto);
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  transform: translate(var(--x,0), var(--y,0));
  opacity: .95;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.35));
  transition: transform .26s cubic-bezier(.2,.9,.2,1), opacity .26s ease;
}
.ghost-tile.fade-out{ opacity: 0; transform: translate(var(--x,0), var(--y,0)) scale(.96); }

.gem.fade-in{ animation: gemFadeIn .22s ease-out; }
@keyframes gemFadeIn{
  0%{ opacity: .0; transform: translateY(4px) scale(.96); }
  100%{ opacity: 1; transform: translateY(0) scale(1); }
}


/* ===== Match-3 polish: FLIP-style slide ===== */
.ghost-tile.ghost-move{
  transition: transform .30s cubic-bezier(.2,.9,.2,1), opacity .24s ease;
}
.gem.is-hidden{ opacity: 0 !important; }

/* ===== Global modal safety (battle HUD overlays) ===== */
.modal{ z-index: 99999 !important; }
.modal-backdrop{ z-index: 99990 !important; }

/* ===== Bomb targeting: 3x3 preview ===== */
.board-wrap--arena .board.targeting .gem.target3{
  outline: 2px solid rgba(255,120,60,.55);
  outline-offset: -2px;
  background: linear-gradient(180deg, rgba(255,120,60,.14), rgba(255,255,255,.04));
  filter: brightness(1.10);
}
.board-wrap--arena .board.targeting .gem.center3{
  outline: 2px solid rgba(255,220,120,.85);
  background: linear-gradient(180deg, rgba(255,220,120,.20), rgba(255,255,255,.05));
  filter: brightness(1.18);
}

/* ===== Bomb FX: brief flash + hide field ===== */
.board.bomb-blast .gem{ opacity: 0; transition: opacity .08s ease; }
.board.bomb-blast::before{
  content:"";
  position:absolute;
  inset:-10%;
  background: radial-gradient(circle at 50% 50%, rgba(255,210,120,.55), rgba(255,90,40,.25), transparent 60%);
  filter: blur(2px);
  opacity: 0;
  animation: bombFlash .45s ease-out;
  pointer-events:none;
  z-index: 10;
}
@keyframes bombFlash{
  0%{ opacity:0; transform: scale(.96); }
  35%{ opacity:1; transform: scale(1.02); }
  100%{ opacity:0; transform: scale(1.06); }
}

/* ===== Custom modal (battle-safe, no Bootstrap stacking issues) ===== */
.pt-modal{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120000;
}
.pt-modal.is-open{ display:flex; }
.pt-modal__backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
}
.pt-modal__panel{
  position:relative;
  width:min(860px, 94vw);
  max-height: min(82vh, 720px);
  overflow:auto;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(10,14,22,.94);
  box-shadow: 0 25px 80px rgba(0,0,0,.55);
}
.pt-modal__head{
  position: sticky;
  top: 0;
  z-index: 2;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  background: rgba(10,14,22,.92);
}
.pt-modal__title{ font-weight: 900; letter-spacing:.2px; color:#fff; }
.pt-modal__x{
  border:none;
  background: rgba(255,255,255,.10);
  color:#fff;
  width:36px; height:36px;
  border-radius: 12px;
  font-size: 18px;
  line-height: 36px;
  text-align:center;
}
.pt-modal__x:hover{ background: rgba(255,255,255,.16); }
.pt-modal__body{ padding: 14px; }

/* ===== Stage 10 — Portrait battle viewport fix (remove dark empty band) ===== */
@media (max-width: 520px) and (orientation: portrait){
  .battle-page .battle-stage{ min-height: 100svh; }
  .battle-page .arena-layout{ min-height: 100svh; }
  .battle-page .arena-center{ flex: 1; justify-content: center; padding-bottom: calc(env(safe-area-inset-bottom) + 10px); }
  .battle-page .board-wrap--arena{ transform-origin: center; }
}

/* Battle/Arena viewport fixes for portrait mobile (no black bottom gap) */
body.battle-page .pt-screen,
body.arena-page .pt-screen,
body.battle-page #ajax-content,
body.arena-page #ajax-content{
  min-height: 100dvh;
}

@media (max-width: 576px){
  body.battle-page .battle-stage,
  body.arena-page .battle-stage{
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    padding: 10px;
  }
}



/* Arena board background override (fix alignment / remove extra field bg) */
.board-wrap--arena .board-bg{
  position:absolute;
  inset:0 !important;
  z-index:1;
  background-image: var(--board-bg) !important;
  background-size: contain !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-radius:18px;
  opacity:1 !important;
  filter:none !important;
}

/* ===== Season quests (meta progression) ===== */
.pt-quests{ display:flex; flex-direction:column; gap:10px; }
.pt-quest{
  border:1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.18));
  border-radius:16px;
  padding:12px;
  box-shadow: inset 0 0 22px rgba(0,0,0,.45);
}
.pt-quest__top{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.pt-quest__title{ font-weight:900; letter-spacing:.2px; color: rgba(255,255,255,.92); }
.pt-quest__reward{ font-size:12px; color: rgba(255,255,255,.70); white-space:nowrap; }
.pt-quest__desc{ margin-top:6px; font-size:12px; color: rgba(255,255,255,.70); line-height:1.35; }
.pt-quest__bar{ margin-top:10px; height:10px; border-radius:999px; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.10); overflow:hidden; }
.pt-quest__fill{ height:100%; width:0%; border-radius:999px; background: linear-gradient(90deg, rgba(45,226,255,.95), rgba(255,0,230,.65)); box-shadow:0 0 18px rgba(45,226,255,.25); transition: width .35s ease; }
.pt-quest__foot{ margin-top:10px; display:flex; align-items:center; justify-content:space-between; gap:10px; }

/* ===== Chest rewards ===== */
.reward-box--chest{background:transparent;border:none;padding:0}
.reward-chest-card{cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 10px;border-radius:18px;background:linear-gradient(180deg,rgba(255,215,0,.14),rgba(40,22,0,.35));border:1px solid rgba(255,215,0,.38);box-shadow:0 10px 30px rgba(0,0,0,.28), inset 0 0 20px rgba(255,255,255,.05);min-width:220px;transition:transform .18s ease, box-shadow .18s ease}
.reward-chest-card:hover{transform:translateY(-2px) scale(1.02);box-shadow:0 14px 38px rgba(255,196,0,.18)}
.reward-chest-card.is-claimed{opacity:.88;filter:saturate(.9)}
.reward-chest-card__img{width:112px;height:112px;object-fit:contain;filter:drop-shadow(0 12px 28px rgba(0,0,0,.35))}
.reward-chest-card__title{font-weight:900;color:#fff;text-align:center}
.reward-chest-card__sub{font-size:12px;color:rgba(255,255,255,.76);text-align:center}
.inv-slot.is-chest .inv-slot__icon{background:radial-gradient(circle at 50% 30%, rgba(255,220,90,.25), rgba(60,30,0,.25));border-color:rgba(255,215,0,.38)}
.pt-chest-menu__head{display:flex;gap:14px;align-items:center;margin-bottom:12px}
.pt-chest-menu__icon{width:86px;height:86px;object-fit:contain;filter:drop-shadow(0 10px 25px rgba(0,0,0,.35))}
.pt-chest-menu__title{font-size:20px;font-weight:900;color:#fff}
.pt-chest-menu__sub{font-size:12px;color:rgba(255,255,255,.72)}
.pt-chest-open{text-align:center}
.pt-chest-open__gif img{width:140px;height:140px;object-fit:contain;filter:drop-shadow(0 14px 30px rgba(0,0,0,.35))}
.pt-chest-open__coin{margin-top:8px}
.pt-chest-open__coin img{width:92px;height:92px;object-fit:contain}
.pt-coin-spin{animation:ptCoinSpin 1.8s linear infinite}
.pt-chest-open__amount{margin-top:10px;font-size:24px;font-weight:900;color:#ffd86a;text-shadow:0 0 18px rgba(255,216,106,.45)}
@keyframes ptCoinSpin{from{transform:rotateY(0deg)}to{transform:rotateY(360deg)}}


/* ===== Stage 10: HUD Level/XP ===== */
.hud-name .lvl{margin-top:6px;font-size:12px;color:rgba(255,255,255,.84)}
.hud-name .xpbar{margin-top:4px;height:6px;border-radius:999px;background:rgba(255,255,255,.10);overflow:hidden;border:1px solid rgba(255,255,255,.12)}
.hud-name .xpbar i{display:block;height:100%;background:linear-gradient(90deg, rgba(45,226,255,.95), rgba(176,123,255,.80));border-radius:999px}
.hud-name .xpmeta{margin-top:3px;font-size:11px;color:rgba(255,255,255,.58)}


/* ===== Chronosphere warp overlay ===== */
.pt-warp-gate{position:fixed;inset:0;z-index:30000;pointer-events:none;opacity:0;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at 50% 50%, rgba(45,226,255,.10), rgba(0,0,0,.72));transition:opacity .15s ease}
.pt-warp-gate img{width:min(92vmin,860px);height:auto;opacity:.92;filter:saturate(1.2) contrast(1.1) drop-shadow(0 30px 80px rgba(0,0,0,.55));transform:scale(.92);transition:transform .9s ease}
.pt-warp-gate.show{opacity:1}
.pt-warp-gate.show img{transform:scale(1.03)}


.reward-drop-card{ position:relative; width:min(260px, 82vw); margin:0 auto; perspective:900px; cursor:pointer; }
.reward-drop-card__inner{ position:relative; border-radius:24px; padding:18px 18px 16px; background:linear-gradient(180deg, rgba(22,28,48,.98), rgba(10,14,24,.98)); border:1px solid rgba(255,255,255,.16); box-shadow:0 18px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08); animation:rewardFlip .7s ease, rewardFloat 2.3s ease-in-out infinite; overflow:hidden; }
.reward-drop-card__shine{ position:absolute; inset:-20%; background:radial-gradient(circle at center, rgba(116,241,255,.32), rgba(116,241,255,0) 52%); filter:blur(10px); pointer-events:none; }
.reward-drop-card__kind{ font-size:12px; text-transform:uppercase; letter-spacing:.16em; color:rgba(180,231,255,.78); text-align:center; }
.reward-drop-card__media{ display:flex; align-items:center; justify-content:center; min-height:132px; margin-top:8px; }
.reward-drop-card__img{ width:120px; height:120px; object-fit:contain; filter:drop-shadow(0 8px 18px rgba(46,226,255,.38)); }
.reward-drop-card__title{ margin-top:8px; text-align:center; font-weight:900; color:#fff; }
.reward-drop-card__qty{ text-align:center; margin-top:4px; color:rgba(255,255,255,.72); font-weight:800; }
.reward-drop-card.is-claimed{ opacity:.9; cursor:default; }
.pt-loot-stage{ display:flex; justify-content:center; margin-top:4px; }
.pt-loot-grid{ display:grid; grid-template-columns:1fr; gap:10px; margin-top:12px; }
.pt-loot-mini{ display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:14px; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.1); color:#e9f7ff; font-size:13px; }
.pt-loot-mini img{ width:34px; height:34px; object-fit:contain; }
@keyframes rewardFlip{ from{ opacity:0; transform:rotateY(-90deg) scale(.86);} to{ opacity:1; transform:rotateY(0) scale(1);} }
@keyframes rewardFloat{ 0%,100%{ transform:translateY(0);} 50%{ transform:translateY(-5px);} }


.reward-seal-card{cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 10px;border-radius:22px;background:linear-gradient(180deg,rgba(255,236,165,.18),rgba(80,42,0,.32));border:1px solid rgba(255,219,107,.42);box-shadow:0 12px 34px rgba(0,0,0,.32), inset 0 0 24px rgba(255,255,255,.06);min-width:220px;transition:transform .18s ease, box-shadow .18s ease;animation:rewardFloat 2.3s ease-in-out infinite}
.reward-seal-card:hover{transform:translateY(-2px) scale(1.02);box-shadow:0 16px 42px rgba(255,196,0,.22)}
.reward-seal-card.is-claimed{opacity:.88;filter:saturate(.92)}
.reward-seal-card__img{width:128px;height:128px;object-fit:contain;border-radius:50%;filter:drop-shadow(0 10px 24px rgba(0,0,0,.28))}
.reward-seal-card__title{font-weight:900;color:#fff;text-align:center}
.reward-seal-card__sub{font-size:12px;color:rgba(255,255,255,.76);text-align:center;max-width:220px}

.result-card--compact .result-sub{margin-bottom:10px}
.result-card--compact .result-scores{margin-top:10px}
.result-card--compact .reward-wrap{margin-top:12px}
.result-card .btn{min-width:144px}
@media (max-width: 576px){
  .result-card .btn{min-width:0;flex:1 1 0}
}

.pt-chest-open{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center;min-height:260px}.pt-chest-open__gif{display:flex;align-items:center;justify-content:center}.pt-chest-open__gif img{width:160px;height:160px;object-fit:contain;filter:drop-shadow(0 14px 30px rgba(0,0,0,.35));mix-blend-mode:screen}.pt-chest-open__reveal{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:12px 18px;border-radius:22px;background:radial-gradient(circle at 50% 20%, rgba(255,220,120,.16), rgba(255,255,255,.02) 55%, rgba(0,0,0,.12));border:1px solid rgba(255,255,255,.08)}
.pt-chest-open__line{display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap;max-width:100%}.pt-reward-icon{display:block;width:min(72px,20vw);height:min(72px,20vw);object-fit:contain;filter:drop-shadow(0 10px 22px rgba(0,0,0,.28))}


/* Stage 35: polished loot/chest modal centering */
#ptLootModal .modal-dialog.pt-loot-dialog{max-width:min(520px,calc(100vw - 24px));margin:1.25rem auto;display:flex;align-items:center;min-height:calc(100% - 2.5rem)}
#ptLootModal .modal-content.pt-loot-card{width:100%;margin:0;border:none;background:linear-gradient(180deg, rgba(11,18,33,.98), rgba(7,10,18,.98));}
#ptLootModal .pt-loot-actions{flex-wrap:wrap}
#ptLootModal .pt-loot-actions .btn{min-width:132px}
.pt-chest-open{min-height:auto;padding:4px 0}
.pt-chest-open__gif,.pt-chest-open__coin{display:flex;align-items:center;justify-content:center}
.pt-chest-open__gif img,.pt-chest-open__coin img{background:transparent !important;mix-blend-mode:normal;isolation:isolate}
.pt-chest-open__gif img{width:min(180px,48vw);height:min(180px,48vw)}
.pt-chest-open__coin img{width:min(104px,30vw);height:min(104px,30vw);filter:drop-shadow(0 14px 26px rgba(255,215,91,.18))}
.pt-chest-open__reveal{background:transparent;border:none;padding:0;gap:8px}
.pt-chest-open__amount{margin-top:0;line-height:1.15}
@media (max-width: 576px){
  #ptLootModal .modal-dialog.pt-loot-dialog{max-width:calc(100vw - 16px);margin:.5rem auto;min-height:calc(100% - 1rem)}
  #ptLootModal .pt-loot-head{padding:14px 14px 10px}
  #ptLootModal .pt-loot-body{padding:14px}
  #ptLootModal .pt-loot-actions .btn{flex:1 1 0;min-width:0}
  .pt-chest-open__gif img{width:min(150px,46vw);height:min(150px,46vw)}
}

/* Stage 36: hard-center loot modal and cleaner reward reveal */
#ptLootModal.show{display:flex !important;align-items:center;justify-content:center;padding:10px}
#ptLootModal .modal-dialog.pt-loot-dialog{margin:0 !important;min-height:auto !important;transform:none !important}
#ptLootModal .modal-content.pt-loot-card{max-width:min(520px, calc(100vw - 20px));}
#ptLootModal .pt-loot-body{text-align:center}
#ptLootModal .pt-loot-reward{display:flex;align-items:center;justify-content:center}
.pt-chest-open__gif img,.pt-chest-open__coin img{display:block}
.pt-chest-open__coin{perspective:900px}
.pt-coin-spin{backface-visibility:hidden;transform-style:preserve-3d}
@media (max-width: 576px){
  #ptLootModal.show{padding:8px}
  #ptLootModal .modal-content.pt-loot-card{max-width:calc(100vw - 16px)}
}

/* Stage 63 hotfix: desktop boosters get arrows + invisible native scroll */
.boostbar--top{
  width:min(100%,1180px);
  max-width:100%;
  overflow:visible;
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto auto;
  align-items:center;
  gap:10px;
}
.boostbar--top .boostbar__scroll{
  min-width:0;
  flex:1 1 auto;
  scroll-behavior:smooth;
  scroll-snap-type:x proximity;
  cursor:grab;
  touch-action:pan-x;
  overscroll-behavior-inline:contain;
}
.boostbar--top .boostbar__scroll.is-dragging{cursor:grabbing;scroll-behavior:auto}
.boostbar--top .boost,.boostbar--top .boostbtn{ flex:0 0 auto; scroll-snap-align:start; }
@media (min-width:769px){ .battle-page .boostbar--top{ margin-inline:auto; } }
@media (max-width:768px){ .boostbar--top{ display:flex; gap:10px; } .boostbar__arrow{ display:none; } }



/* ===== Stage 69 battle/admin stability overrides ===== */
body.battle-page main,
body.arena-page main{
  background: transparent !important;
  background-image: none !important;
}
body.battle-page .battle-card,
body.arena-page .battle-card,
body.battle-page .battle-stage,
body.arena-page .battle-stage{
  background-image: none !important;
}
body.battle-page .board-wrap--arena,
body.arena-page .board-wrap--arena{
  overflow: hidden !important;
  align-self: center !important;
  justify-self: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
body.battle-page .board-wrap--arena .board-bg,
body.arena-page .board-wrap--arena .board-bg{
  background-size: 100% 100% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  filter: none !important;
  opacity: 1 !important;
}
body.battle-page .board-wrap--arena .board-frame,
body.arena-page .board-wrap--arena .board-frame{
  object-fit: fill !important;
}
body.battle-page .result-overlay,
body.arena-page .result-overlay{
  position: fixed !important;
  inset: 0 !important;
  z-index: 5000 !important;
  padding: 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
body.battle-page .result-overlay .result-card,
body.arena-page .result-overlay .result-card{
  width: min(640px, 92vw) !important;
  max-height: calc(100dvh - 32px);
  overflow: auto;
}
body.battle-page .result-overlay .d-flex.gap-2,
body.arena-page .result-overlay .d-flex.gap-2{
  flex-wrap: wrap;
}
body.battle-page .center-toast,
body.arena-page .center-toast{
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}
@media (max-width: 600px){
  body.battle-page .arena-layout,
  body.arena-page .arena-layout{
    grid-template-columns: 1fr 1fr !important;
    grid-template-areas: "left right" "center center" !important;
    gap: 8px !important;
    align-content: start !important;
  }
  body.battle-page .arena-center,
  body.arena-page .arena-center{
    gap: 6px !important;
    justify-content: flex-start !important;
  }
  body.battle-page .player-panel,
  body.arena-page .player-panel{
    padding: 8px !important;
    gap: 8px !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
  }
  body.battle-page .player-panel__meta,
  body.arena-page .player-panel__meta{
    margin-top: 0 !important;
  }
  body.battle-page .boostbar--top,
  body.arena-page .boostbar--top{
    position: static !important;
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: 100% !important;
    margin: 0 0 6px !important;
  }
  body.battle-page .boostbar__scroll,
  body.arena-page .boostbar__scroll{
    padding: 8px 10px !important;
    gap: 8px !important;
  }
  body.battle-page .board-wrap--arena,
  body.arena-page .board-wrap--arena{
    --board-base: min(88vw, 338px) !important;
    transform: scale(1) !important;
  }
}
body.admin-page .portal-game{
  background: #07111f !important;
}
body.admin-page .pt-screen{
  padding-bottom: 24px;
}
body.admin-page .portal-panel,
body.admin-page #ajax-content{
  width: 100%;
  max-width: none;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}
body.admin-page .table-responsive{
  overflow: auto;
}
body.admin-page .btn{
  white-space: nowrap;
}



/* ===== Artem hotfix R3: restore battle field geometry and overlay visibility ===== */
body.battle-page .board-wrap--arena,
body.arena-page .board-wrap--arena{
  width: min(92vmin, 560px) !important;
  aspect-ratio: 1 / 1 !important;
  padding: 0 !important;
  overflow: visible !important;
}
body.battle-page .board-wrap--arena .board-bg,
body.arena-page .board-wrap--arena .board-bg{
  background-size: contain !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  opacity: 1 !important;
  filter: none !important;
}
body.battle-page .board-wrap--arena .board-frame,
body.arena-page .board-wrap--arena .board-frame{
  object-fit: contain !important;
  width: 100% !important;
  height: 100% !important;
}
body.battle-page .board-wrap--arena .board,
body.arena-page .board-wrap--arena .board,
body.battle-page .board-wrap--arena .move-fx,
body.arena-page .board-wrap--arena .move-fx{
  inset:
    var(--grid-inset-top-pct, var(--grid-inset-top, 72px))
    var(--grid-inset-right-pct, var(--grid-inset-right, 72px))
    var(--grid-inset-bottom-pct, var(--grid-inset-bottom, 72px))
    var(--grid-inset-left-pct, var(--grid-inset-left, 72px)) !important;
}
body.battle-page #resultOverlay.d-none,
body.arena-page #resultOverlay.d-none{
  display: none !important;
}
body.battle-page #resultOverlay:not(.d-none),
body.arena-page #resultOverlay:not(.d-none){
  display: flex !important;
}


/* =========================================================
   Stage 8.1 mobile rescue — keep battle cards readable
   ========================================================= */
@media (max-width: 991.98px){
  body.battle-page .player-panel,
  body.arena-page .player-panel{
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow: hidden;
  }
  body.battle-page .player-panel .hero-card,
  body.arena-page .player-panel .hero-card{
    display: block !important;
    position: relative;
    flex: 0 0 82px;
    width: 82px;
    height: 108px;
    min-height: 108px;
    border-radius: 16px;
    overflow: hidden;
  }
  body.battle-page .player-panel .hero-art,
  body.arena-page .player-panel .hero-art{
    display: block !important;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  body.battle-page .player-panel .avatar-ring,
  body.arena-page .player-panel .avatar-ring{
    position: absolute !important;
    left: 7px !important;
    top: 7px !important;
    width: 38px !important;
    height: 38px !important;
    z-index: 4;
  }
  body.battle-page .player-panel__meta,
  body.arena-page .player-panel__meta{
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0 !important;
    display: grid;
    gap: 6px;
  }
  body.battle-page .player-panel__name,
  body.arena-page .player-panel__name{
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.battle-page .player-panel__nums,
  body.arena-page .player-panel__nums{
    display: flex !important;
    gap: 4px !important;
    flex-wrap: wrap;
    margin-top: 0;
  }
  body.battle-page .player-panel__nums .pill,
  body.arena-page .player-panel__nums .pill{
    font-size: 10px;
    padding: 3px 6px;
  }
  body.battle-page .statbar,
  body.arena-page .statbar{
    height: 10px;
  }
  body.battle-page .statbar__label,
  body.arena-page .statbar__label{
    font-size: 9px;
  }
}
@media (max-width: 575.98px){
  body.battle-page .player-panel .hero-card,
  body.arena-page .player-panel .hero-card{
    flex-basis: 68px;
    width: 68px;
    height: 92px;
    min-height: 92px;
  }
  body.battle-page .player-panel__nums,
  body.arena-page .player-panel__nums{
    display: none !important;
  }
}


/* ===== Stage 8.2 battle follow-up ===== */
.boostbar--top.has-no-picked-boosts{
  grid-template-columns: minmax(0,1fr) auto !important;
}
.boostbar--top.has-no-picked-boosts .boostbar__arrow{
  display:none !important;
}
.boostbar__scroll.is-basic-only{
  width:auto;
  justify-self:center;
  scroll-snap-type:none;
}
@media (max-width: 600px){
  body.battle-page .board-wrap--arena,
  body.arena-page .board-wrap--arena{
    --board-base: min(94vw, 360px) !important;
  }
  body.battle-page .boostbar__scroll.is-basic-only,
  body.arena-page .boostbar__scroll.is-basic-only{
    padding-inline: 10px !important;
  }
}

/* ===== Stage 8.4 inventory + mobile rescue ===== */
.pt-loot-inline{
  display:flex;
  align-items:center;
  gap:14px;
  margin-bottom:14px;
  padding:14px;
  border-radius:20px;
  background:linear-gradient(180deg,rgba(15,24,52,.88),rgba(9,14,30,.94));
  border:1px solid rgba(255,255,255,.10);
}
.pt-loot-inline__icon{
  width:96px;
  height:96px;
  min-width:96px;
  border-radius:24px;
  overflow:hidden;
  display:grid;
  place-items:center;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
  box-shadow:0 18px 36px rgba(0,0,0,.26);
}
.pt-loot-inline__icon img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}
.pt-loot-inline__meta{min-width:0;display:grid;gap:4px}
.pt-loot-inline__title{font-size:1.15rem;font-weight:900;color:#fff;line-height:1.12}
.pt-loot-inline__sub{font-size:.86rem;color:rgba(255,255,255,.66)}
.pt-loot-cardstack{display:grid;gap:8px}
.pt-loot-cardline{
  padding:10px 12px;
  border-radius:14px;
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.08);
  color:rgba(255,255,255,.86);
  line-height:1.45;
  overflow-wrap:anywhere;
}
@media (max-width: 640px){
  .pt-loot-inline{align-items:flex-start}
  .pt-loot-inline__icon{
    width:78px;
    height:78px;
    min-width:78px;
    border-radius:20px;
  }
  .pt-loot-inline__title{font-size:1rem}
}

@media (max-width: 600px){
  body.battle-page .enemy-intel,
  body.arena-page .enemy-intel{
    display:none !important;
  }
}

/* ===== Portal Time release patch: global FX + logs + booster modal ===== */
.pt-system-log{
  position:fixed;
  right:14px;
  bottom:90px;
  z-index:10020;
  display:grid;
  gap:10px;
  width:min(360px, calc(100vw - 24px));
  pointer-events:none;
}
.pt-system-log__item{
  opacity:0;
  transform:translateY(10px) scale(.98);
  transition:opacity .22s ease, transform .22s ease;
  padding:12px 14px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.14);
  background:linear-gradient(180deg, rgba(9,16,34,.94), rgba(8,12,24,.94));
  box-shadow:0 18px 42px rgba(0,0,0,.34);
  backdrop-filter:blur(12px);
  color:#fff;
}
.pt-system-log__item.is-show{opacity:1;transform:translateY(0) scale(1)}
.pt-system-log__item--ok{border-color:rgba(62,214,130,.32)}
.pt-system-log__item--warning{border-color:rgba(255,196,92,.34)}
.pt-system-log__item--danger{border-color:rgba(255,108,108,.34)}
.pt-system-log__title{font-size:12px;font-weight:900;letter-spacing:.08em;text-transform:uppercase;color:rgba(214,236,255,.82)}
.pt-system-log__text{margin-top:4px;font-size:13px;line-height:1.45;color:rgba(255,255,255,.88)}

.pt-screen-shake{animation:ptScreenShake .38s linear}
@keyframes ptScreenShake{
  0%,100%{transform:translate3d(0,0,0)}
  20%{transform:translate3d(calc(-1px * var(--pt-shake-power,1)),0,0)}
  40%{transform:translate3d(calc(2px * var(--pt-shake-power,1)),calc(-1px * var(--pt-shake-power,1)),0)}
  60%{transform:translate3d(calc(-2px * var(--pt-shake-power,1)),calc(1px * var(--pt-shake-power,1)),0)}
  80%{transform:translate3d(calc(1px * var(--pt-shake-power,1)),0,0)}
}
.pt-fx-pulse{animation:ptFxPulse 1.1s ease}
@keyframes ptFxPulse{0%{box-shadow:0 0 0 rgba(113,216,255,0)}35%{box-shadow:0 0 0 1px rgba(113,216,255,.24),0 0 42px rgba(113,216,255,.22)}100%{box-shadow:0 0 0 rgba(113,216,255,0)}}
.pt-bar-ticking{filter:brightness(1.12) saturate(1.06)}

.pt-boost-modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  opacity:0;
  visibility:hidden;
  z-index:10010;
  background:rgba(5,8,19,.78);
  backdrop-filter:blur(8px);
  transition:opacity .18s ease, visibility .18s ease;
}
.pt-boost-modal.show{opacity:1;visibility:visible}
.pt-boost-modal__lock{overflow:hidden}
.pt-boost-modal__dialog{
  width:min(880px, 96vw);
  max-height:min(90vh, 860px);
  overflow:auto;
  border-radius:28px;
  background:linear-gradient(180deg, rgba(12,18,40,.98), rgba(7,10,22,.98));
  border:1px solid rgba(255,255,255,.12);
  box-shadow:0 28px 90px rgba(0,0,0,.48);
  padding:18px;
}
.pt-boost-modal__head,.pt-boost-modal__foot{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.pt-boost-modal__body{margin-top:14px}
.pt-boost-modal__close{
  width:42px;height:42px;border-radius:999px;border:1px solid rgba(255,255,255,.16);background:rgba(255,255,255,.06);color:#fff;font-size:24px;line-height:1;
}
.pt-boost-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.pt-boost-group{padding:14px;border-radius:18px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04)}
.pt-boost-group h6{margin:0 0 10px;font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:rgba(255,255,255,.62)}
.pt-boost-list{display:grid;gap:10px}
.pt-boost-row{display:grid;grid-template-columns:54px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:16px;background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.07)}
.pt-boost-row__icon{width:54px;height:54px;border-radius:14px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.06);overflow:hidden}
.pt-boost-row__icon img{width:100%;height:100%;object-fit:cover}
.pt-boost-row__title{font-weight:900;color:#fff;line-height:1.15}
.pt-boost-row__desc{margin-top:4px;font-size:12px;line-height:1.35;color:rgba(255,255,255,.7)}
.pt-boost-row__btn{border:none;border-radius:14px;padding:10px 12px;background:linear-gradient(180deg, rgba(79,178,255,.22), rgba(109,89,255,.18));color:#fff;font-weight:800}
.pt-boost-row__btn.is-remove{background:linear-gradient(180deg, rgba(255,124,124,.18), rgba(255,255,255,.08))}

.pt-boostbar{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:center}
.pt-boostbar__viewport{overflow:auto hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;cursor:grab;scrollbar-width:none}
.pt-boostbar__viewport::-webkit-scrollbar{display:none}
.pt-boostbar__viewport.is-dragging{cursor:grabbing}
.pt-boostbar__track{display:flex;gap:10px;min-width:max-content;padding:2px 2px 6px}
.pt-boost-arrow{width:38px;height:38px;border-radius:999px;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.06);color:#fff;font-size:22px;line-height:1}
.pt-boost-arrow:disabled{opacity:.42;cursor:not-allowed}
.pt-boost-mini{display:grid;grid-template-columns:44px minmax(0,1fr) auto;gap:10px;align-items:center;min-width:235px;padding:10px 12px;border-radius:16px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.04);color:#fff;scroll-snap-align:start}
.pt-boost-mini__art{width:44px;height:44px;border-radius:12px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.06);overflow:hidden}.pt-boost-mini__art img{width:100%;height:100%;object-fit:cover}
.pt-boost-mini__name{display:block;font-weight:900;line-height:1.1}.pt-boost-mini__sub,.pt-boost-mini__state,.pt-boost-mini__qty{display:block;margin-top:4px;font-size:12px;color:rgba(255,255,255,.68)}
.pt-boost-mini.is-equipped{border-color:rgba(62,214,130,.26);box-shadow:0 0 0 1px rgba(62,214,130,.08) inset}
.pt-boost-mini.is-cooldown{opacity:.78}

/* Workshop reel / eye magnet */
.chrono-workshop-reel{display:flex;gap:10px;overflow:hidden;padding:8px 2px}
.chrono-workshop-reel__item{position:relative;flex:0 0 72px;height:72px;border-radius:18px;border:1px solid rgba(255,255,255,.1);background:linear-gradient(180deg,rgba(255,255,255,.08),rgba(255,255,255,.03));display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 1px rgba(113,216,255,.04) inset;animation:ptReelFloat 3.8s ease-in-out infinite, ptReelGlow 2.8s ease-in-out infinite}
.chrono-workshop-reel__item:nth-child(2n){animation-delay:.25s,.32s}
.chrono-workshop-reel__item:nth-child(3n){animation-delay:.5s,.6s}
.chrono-workshop-reel__item img{width:68%;height:68%;object-fit:contain;filter:drop-shadow(0 8px 18px rgba(0,0,0,.3))}
@keyframes ptReelFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
@keyframes ptReelGlow{0%,100%{box-shadow:0 0 0 1px rgba(113,216,255,.06) inset,0 0 0 rgba(113,216,255,0)}50%{box-shadow:0 0 0 1px rgba(113,216,255,.18) inset,0 0 28px rgba(113,216,255,.18)}}

/* Mobile battle rescue */
@media (max-width: 767px){
  .pt-system-log{right:10px;left:10px;width:auto;bottom:84px}
  .pt-boost-grid{grid-template-columns:1fr}
  .pt-boost-modal{padding:10px}
  .pt-boost-modal__dialog{width:min(96vw,96vw);padding:14px;max-height:92vh}
  .pt-boost-row{grid-template-columns:46px minmax(0,1fr);}
  .pt-boost-row__btn{grid-column:1 / -1;width:100%}
  .pt-boostbar{grid-template-columns:1fr;}
  .pt-boost-arrow{display:none}
  .pt-boost-mini{min-width:220px}
  body.battle-page .battle-stage,
  body.arena-page .battle-stage{ --grid-gap:min(1.15vw, 4px) !important; }
  body.battle-page .board-wrap--arena,
  body.arena-page .board-wrap--arena{ --board-base:min(90vw, 356px) !important; width:var(--board-base)!important; }
  body.battle-page .board-wrap--arena .board,
  body.arena-page .board-wrap--arena .board{ gap:min(1.15vw, 4px)!important; }
  body.battle-page .board-wrap--arena .gem,
  body.arena-page .board-wrap--arena .gem{ border-radius:min(2.2vw, 10px)!important; }
}

/* Touch details instead of cramped stats under mob art */
@media (max-width:767px){
  .enemy-intel{display:none!important}
}


/* Mob enemy card: no avatar bubble, only mob poster */
.player-panel--mob .avatar-ring{ display:none !important; }
.player-panel--mob .player-panel__meta{ margin-top: 10px; }
.player-panel--mob .hero-card{ margin-inline:auto; }


/* Stage hotfix: mob enemy card should show poster only, no extra intel/avatars */
body.battle-page .player-panel--mob .avatar-ring{display:none!important;}
body.battle-page .player-panel--mob #opAvatar{display:none!important;}
body.battle-page .player-panel--mob .enemy-intel{display:none!important;}

/* Stage hotfix: disable ghost layers that throw tiles outside the board */
body.battle-page .board-wrap--arena .board{overflow:hidden!important;}
body.battle-page .board-wrap--arena .board-ghost-layer{display:none!important;overflow:hidden!important;pointer-events:none!important;}
body.battle-page .board-wrap--arena .ghost-tile{display:none!important;}


/* Stage restore: keep live board clipped to its frame; no stale overlays */
body.battle-page .board-wrap--arena .board,
body.arena-page .board-wrap--arena .board{ overflow:hidden!important; }
body.battle-page .board-wrap--arena .board-ghost-layer,
body.arena-page .board-wrap--arena .board-ghost-layer{ display:none!important; pointer-events:none!important; }


/* ===== R10 final board geometry lock ===== */
body.battle-page .board-wrap--arena,
body.arena-page .board-wrap--arena{
  display:block!important;
  width:min(92vmin,560px)!important;
  max-width:100%!important;
  aspect-ratio:1 / 1 !important;
  padding:0!important;
  overflow:visible!important;
  align-self:center!important;
  justify-self:center!important;
  margin-left:auto!important;
  margin-right:auto!important;
  transform:scale(var(--board-scale,1))!important;
  transform-origin:center center!important;
}
@media (max-width: 767px){
  body.battle-page .board-wrap--arena,
  body.arena-page .board-wrap--arena{ width:min(96vw,560px)!important; }
}
body.battle-page .board-wrap--arena .board-bg,
body.arena-page .board-wrap--arena .board-bg{
  inset:0!important;
  background-image:var(--board-bg)!important;
  /*background-size:100% 100%!important;*/
  background-position:center!important;
  background-repeat:no-repeat!important;
  opacity:1!important;
  filter:none!important;
}
body.battle-page .board-wrap--arena .board-frame,
body.arena-page .board-wrap--arena .board-frame{
  inset:0!important;
  width:100%!important;
  height:100%!important;
  object-fit:fill!important;
}
body.battle-page .board-wrap--arena .board,
body.arena-page .board-wrap--arena .board,
body.battle-page .board-wrap--arena .move-fx,
body.arena-page .board-wrap--arena .move-fx{
  position:absolute!important;
  inset: var(--grid-inset-top-pct, 14.2857%)
         var(--grid-inset-right-pct, 23.2143%)
         var(--grid-inset-bottom-pct, 32.1429%)
         var(--grid-inset-left-pct, 23.2143%) !important;
}
body.battle-page .board-wrap--arena .board,
body.arena-page .board-wrap--arena .board{
  display:grid!important;
  grid-template-columns:repeat(var(--board-size,6), minmax(0,1fr))!important;
  grid-template-rows:repeat(var(--board-size,6), minmax(0,1fr))!important;
  gap:var(--grid-gap,0px)!important;
  width:auto!important;
  height:auto!important;
  overflow:hidden!important;
}
@media (max-width: 767px){
  body.battle-page .player-panel--mob .enemy-intel,
  body.arena-page .player-panel--mob .enemy-intel{ display:grid!important; }
}


/* ===== PortalVremeni release polish: mobile perf + preload + combat numbers ===== */
.battle-stage,
.center-toast,
#battleLogInline,
#battleCoachLine,
.hud-bell,
.hud-bell-img,
#hudBellBtn,
.chat-fab,
.chat-fab__badge{
  transform:translate3d(0,0,0);
  backface-visibility:hidden;
  will-change:transform,opacity;
}

.battle-preloader{
  position:absolute;
  inset:0;
  z-index:95;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:linear-gradient(180deg,rgba(5,9,24,.94),rgba(7,12,30,.88));
  transition:opacity .22s ease,visibility .22s ease;
}
.battle-preloader.is-hidden{opacity:0;visibility:hidden;pointer-events:none}
.battle-preloader__card{
  width:min(360px,92vw);
  border-radius:20px;
  padding:18px 18px 16px;
  border:1px solid rgba(130,190,255,.16);
  background:linear-gradient(180deg,rgba(16,24,53,.94),rgba(8,12,28,.96));
  box-shadow:0 20px 60px rgba(0,0,0,.45);
  color:#fff;
}
.battle-preloader__title{font-weight:900;letter-spacing:.04em;font-size:1rem;margin-bottom:8px}
.battle-preloader__text{font-size:.88rem;color:rgba(255,255,255,.76);margin-bottom:12px}
.battle-preloader__bar{height:10px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden;border:1px solid rgba(255,255,255,.08)}
.battle-preloader__fill{height:100%;width:6%;border-radius:inherit;background:linear-gradient(90deg,#2DE2FF,#87A8FF);box-shadow:0 0 18px rgba(45,226,255,.32);transition:width .2s ease}

.pt-float-number{
  position:fixed;
  z-index:120;
  pointer-events:none;
  transform:translate3d(-50%,0,0) scale(.92);
  opacity:0;
  font-weight:900;
  letter-spacing:.02em;
  text-shadow:0 8px 18px rgba(0,0,0,.36);
  animation:ptFloatCombatNumber 1s ease forwards;
}
.pt-float-number.is-show{opacity:1}
.pt-float-number--damage{color:#ff8f8f;font-size:1.2rem}
.pt-float-number--heal{color:#88ffb2;font-size:1.08rem}
.pt-float-number--armor{color:#9fd4ff;font-size:1.04rem}
@keyframes ptFloatCombatNumber{
  0%{opacity:0;transform:translate3d(-50%,10px,0) scale(.86)}
  12%{opacity:1}
  100%{opacity:0;transform:translate3d(-50%,-58px,0) scale(1.06)}
}

@media (max-width: 768px){
  .hud-bell-img{filter:none!important}
  .hud-bell.has-unread{animation-duration:1.45s;transform-origin:center}
  .chat-fab,
  .chat-drawer,
  .result-overlay{backdrop-filter:none!important}
  .chat-fab{box-shadow:0 10px 22px rgba(0,0,0,.42)}
  .avatar-fx img{filter:none}
  .pt-screen-shake{animation-duration:.24s}
}


/* ===== PortalVremeni rescue hotfix: stable preload + no global drift ===== */
.battle-stage.is-loading > :not(#battlePreloader){
  opacity:0 !important;
  visibility:hidden !important;
  pointer-events:none !important;
}
.battle-stage.is-loading{
  min-height: 520px;
}

body.battle-page .player-panel.is-active,
body.arena-page .player-panel.is-active{
  animation:none !important;
  transform:none !important;
}
body.battle-page .player-panel .avatar-ring,
body.arena-page .player-panel .avatar-ring{
  animation:none !important;
}
body.battle-page .avatar-ring::before,
body.arena-page .avatar-ring::before{
  filter:none !important;
}

body.battle-page .board-wrap--arena.pt-screen-shake,
body.arena-page .board-wrap--arena.pt-screen-shake{
  will-change:transform;
}

@media (max-width: 768px){
  .hud-bell,
  .hud-bell-img,
  #hudBellBtn{
    will-change:transform;
    transform:translate3d(0,0,0);
  }
  .hud-bell-img{
    filter:none !important;
  }
  .hud-bell.has-unread{
    animation:none !important;
  }
  .hud-top,
  .hud-btn,
  .hud-badge{
    backdrop-filter:none !important;
  }
  body.battle-page .player-panel,
  body.arena-page .player-panel,
  body.battle-page .battle-topbar,
  body.arena-page .battle-topbar{
    transform:translate3d(0,0,0);
  }
}



/* ===== Portal forge progression ===== */
.pt-forge-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.pt-forge-slot{display:grid;gap:8px;align-content:center;min-height:132px;padding:14px;border-radius:20px;border:1px dashed rgba(255,255,255,.16);background:linear-gradient(180deg,rgba(255,255,255,.04),rgba(255,255,255,.02));color:#fff;text-align:left;transition:transform .16s ease,border-color .16s ease,box-shadow .16s ease}
.pt-forge-slot:hover{transform:translateY(-2px);border-color:rgba(126,193,255,.34);box-shadow:0 16px 34px rgba(0,0,0,.22)}
.pt-forge-slot.is-recipe{border-style:solid;background:linear-gradient(180deg,rgba(100,190,255,.12),rgba(139,92,246,.10));box-shadow:0 0 0 1px rgba(126,193,255,.10) inset,0 14px 30px rgba(0,0,0,.18)}
.pt-forge-slot__sig{font-size:1.5rem;font-weight:900;line-height:1}
.pt-forge-slot__title{font-weight:900;font-size:.92rem}
.pt-forge-slot__sub{font-size:.78rem;line-height:1.35;color:rgba(255,255,255,.72)}
.pt-forge-ready-note{margin-top:10px;padding:10px 12px;border-radius:14px;border:1px solid rgba(255,204,0,.22);background:rgba(255,204,0,.08);color:#ffe7a8;font-size:.82rem}
.pt-forge-modal{width:min(560px,96vw)}
.pt-forge-recipe{display:grid;gap:14px}
.pt-forge-recipe__head{display:grid;grid-template-columns:72px minmax(0,1fr);gap:12px;align-items:center}
.pt-forge-recipe__icon{width:72px;height:72px;border-radius:18px;border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.06);display:grid;place-items:center;overflow:hidden}
.pt-forge-recipe__icon img{width:100%;height:100%;object-fit:contain;display:block}
.pt-forge-recipe__title{font-weight:900;font-size:1rem;color:#fff}
.pt-forge-recipe__sub{font-size:.82rem;color:rgba(255,255,255,.68)}
.pt-forge-recipe__desc{font-size:.87rem;line-height:1.45;color:rgba(255,255,255,.82)}
.pt-forge-reqs{display:grid;gap:8px}
.pt-forge-req{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 12px;border-radius:14px;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.08);font-size:.84rem;color:#fff}
.pt-forge-req.is-ready{border-color:rgba(62,214,130,.28);box-shadow:0 0 0 1px rgba(62,214,130,.08) inset}
.pt-forge-actions{display:flex;justify-content:flex-end}
#hudBellBtn{transform:translate3d(0,0,0);will-change:transform}
#hudBellBtn.is-attn{transform:translate3d(0,0,0)}
#hudBellBtn.is-ready,.hud-btn.is-ready{box-shadow:0 0 20px #ffcc00;animation:pulseGlow 2s infinite}
@keyframes pulseGlow{0%,100%{box-shadow:0 0 0 rgba(255,204,0,0)}50%{box-shadow:0 0 20px #ffcc00}}
.is-scroll-ready,.chrono-boss-arena__scroll.is-scroll-ready,.chrono-boss-chip.is-scroll-ready{box-shadow:0 0 20px #ffcc00;animation:pulseGlow 2s infinite}
#chronoEpochBossStrike.is-scroll-ready{box-shadow:0 0 20px #ffcc00;animation:pulseGlow 2s infinite}
@media (max-width:768px){
  .pt-forge-grid{grid-template-columns:1fr;}
  .pt-forge-slot{min-height:108px;padding:12px 13px}
  .pt-forge-modal{width:min(100%,96vw)}
  .pt-forge-recipe__head{grid-template-columns:60px minmax(0,1fr)}
  .pt-forge-recipe__icon{width:60px;height:60px}
}

.hud-bell,.hud-bell-img,#hudBellBtn{transform:translate3d(0,0,0)!important;}
.hud-bell-img{filter:none!important;}

/* ===== Emergency battle restore: readability + FX + echo avatar ===== */
body.battle-page .player-panel.is-active,
body.arena-page .player-panel.is-active{
  animation:pulseTurn 1.2s infinite !important;
}
body.battle-page .player-panel .avatar-ring,
body.arena-page .player-panel .avatar-ring{
  animation:sway 4.8s ease-in-out infinite !important;
}
body.battle-page .avatar-ring::before,
body.arena-page .avatar-ring::before{
  filter:drop-shadow(0 0 14px rgba(0,255,128,.18)) !important;
}
body.battle-page .player-panel.is-wait .avatar-ring::before,
body.arena-page .player-panel.is-wait .avatar-ring::before{
  filter:drop-shadow(0 0 14px rgba(255,80,80,.16)) !important;
}
body.battle-page .avatar-fx img,
body.arena-page .avatar-fx img{
  filter:drop-shadow(0 10px 22px rgba(0,0,0,.55)) !important;
}
body.battle-page .hud-bell-img,
body.arena-page .hud-bell-img{
  filter:drop-shadow(0 4px 10px rgba(0,0,0,.35)) !important;
}
body.battle-page .hud-bell.is-attn,
body.arena-page .hud-bell.is-attn{
  animation:ptBellShake .82s ease-in-out 2 !important;
}
body.battle-page .hud-bell.has-unread,
body.arena-page .hud-bell.has-unread{
  animation:ptBellShake 1.45s ease-in-out infinite !important;
  transform-origin:center !important;
}
body.battle-page .board-wrap--arena.pt-screen-shake,
body.arena-page .board-wrap--arena.pt-screen-shake,
body.battle-page .battle-stage.pt-screen-shake,
body.arena-page .battle-stage.pt-screen-shake{
  animation:ptScreenShake .38s linear !important;
}

/* Keep echo/avatar enemies readable. Poster-only mode stays only for true mob posters. */
body.battle-page .player-panel--mob #opAvatar,
body.arena-page .player-panel--mob #opAvatar{
  display:none !important;
}
body.battle-page .player-panel:not(.player-panel--mob) #opAvatar,
body.arena-page .player-panel:not(.player-panel--mob) #opAvatar,
body.battle-page .player-panel:not(.player-panel--mob) .avatar-ring,
body.arena-page .player-panel:not(.player-panel--mob) .avatar-ring{
  display:block !important;
}

/* Slightly calmer move/effect pacing on touch so swaps remain visible. */
@media (max-width: 768px){
  body.battle-page .move-fx.show,
  body.arena-page .move-fx.show{
    opacity:1 !important;
  }
  body.battle-page .board-wrap--arena .move-fx img,
  body.arena-page .board-wrap--arena .move-fx img{
    width:min(440px, 90%) !important;
    opacity:.78 !important;
  }
}

/* ===== stage 70 mobile arena input hotfix ===== */
body.battle-page .board-wrap--arena, body.arena-page .board-wrap--arena{touch-action:none!important;overscroll-behavior:contain!important;-webkit-user-select:none;user-select:none}
body.battle-page .board-wrap--arena .board, body.arena-page .board-wrap--arena .board{touch-action:none!important;overscroll-behavior:contain!important;-webkit-user-select:none;user-select:none}
body.battle-page .board-wrap--arena .gem, body.arena-page .board-wrap--arena .gem{touch-action:none!important;-webkit-tap-highlight-color:transparent}
