/* ============================================================
   BIG BENIS GAME — экран дуэлей
   Иерархия: топбар → заголовок → карточки соперников → арена
   с бойцами → ставка и таймер → CTA → смена соперника → док
   ============================================================ */

.screen--duels {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  grid-template-columns: minmax(0, 1fr);
  row-gap: clamp(6px, 1vh, 12px);
  padding: calc(var(--safe-top) + 1.4vh) 3% calc(var(--safe-bottom) + 12vh);
}

.duel-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: #050b15 url("../assets/duel/duel-flat-arena.webp") center / cover no-repeat;
}
.screen--duels::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 10, 21, 0.66), rgba(7, 16, 30, 0.08) 40%, rgba(3, 7, 17, 0.62));
}

/* --- заголовок --- */
.duel-head { text-align: center; }
.duel-title {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 14px);
  font: 400 clamp(26px, 8vw, 44px)/1 var(--font-display);
  color: #f3eee4;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 0 #2a3140, 0 8px 14px #000;
}
.duel-title img { height: 0.95em; width: auto; filter: drop-shadow(0 3px 4px #000); }
.duel-title-mirror { transform: scaleX(-1); }
.duel-sub {
  margin: 0.3vh 0 0;
  color: #9ea9bd;
  font: 700 clamp(11px, 2.8vw, 15px)/1 var(--font-body);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 4px #000;
}

/* --- карточки соперников --- */
.duel-fighters {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 2.4vw, 16px);
  z-index: 2;
}
.fighter-card {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.8vw, 12px);
  padding: clamp(8px, 1.4vh, 14px) clamp(8px, 2.2vw, 14px);
  border-radius: clamp(12px, 3vw, 18px);
  border: 2px solid;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), 0 8px 16px rgba(0, 0, 0, 0.45);
}
.fighter-card--me {
  border-color: #7b46e8;
  background: linear-gradient(180deg, rgba(52, 34, 96, 0.94), rgba(24, 17, 48, 0.96));
}
.fighter-card--foe {
  border-color: #d84a3c;
  background: linear-gradient(180deg, rgba(96, 30, 26, 0.94), rgba(46, 15, 13, 0.96));
  text-align: right;
}
.fighter-ava {
  flex: none;
  width: clamp(34px, 9.5vw, 52px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: #0c1424;
}
.fighter-ava img { width: 100%; height: 100%; object-fit: contain; }
/* у Громыча нет иконки-головы — кадрируем полноростовой спрайт */
.fighter-ava--crop { position: relative; }
.fighter-ava--crop img {
  position: absolute;
  width: 230%;
  height: auto;
  left: -65%;
  top: -12%;
}
.fighter-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.5vh, 5px);
}
.fighter-card--foe .fighter-info { align-items: flex-end; }
.fighter-info b {
  font: 400 clamp(13px, 3.6vw, 20px)/1 var(--font-display);
  color: #f3eee4;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 3px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.fighter-info small {
  color: #b9c0cf;
  font: 700 clamp(9px, 2.4vw, 13px)/1 var(--font-body);
}
.fighter-card--me .fighter-info em { color: #b087ff; font-style: normal; font-weight: 700; }
.fighter-card--foe .fighter-info em { color: #ff8071; font-style: normal; font-weight: 700; }
.fighter-bar {
  width: 100%;
  height: clamp(6px, 1.1vh, 9px);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  position: relative;
}
.fighter-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--w, 50%);
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.fighter-card--me .fighter-bar::before { background: linear-gradient(180deg, #a06bff, #6e2fe0); }
.fighter-card--foe .fighter-bar::before { background: linear-gradient(180deg, #ff6a55, #c72f22); margin-left: auto; right: 0; left: auto; }

/* VS-значок между карточками */
.vs-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(38px, 10vw, 54px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #39445c, #1a2234);
  border: 2px solid #4c5871;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  z-index: 3;
}
.vs-badge img { width: 62%; height: auto; }

/* --- арена: бойцы по кругам разметки (placement.json: x 0.25 / 0.75) --- */
.duel-stage { position: relative; min-height: clamp(190px, 34vh, 320px); z-index: 1; }
.duel-me, .duel-foe {
  position: absolute;
  bottom: -7%;
  /* размер от высоты вьюпорта, а не от гибкого ряда грида — иначе на
     невысоком мобильном экране ряд схлопывается и герои становятся крошечными */
  height: clamp(170px, 31vh, 300px);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.55));
}
/* скины смотрят вправо от природы: слева стоят как есть,
   справа отражаются классом is-flipped (ставит duels.js) */
.duel-me { left: 25%; transform: translateX(-50%); }
.duel-foe { right: 25%; transform: translateX(50%); }
.duel-me.is-flipped { transform: translateX(-50%) scaleX(-1); }
.duel-foe.is-flipped { transform: translateX(50%) scaleX(-1); }
.duel-vs {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  font: 400 clamp(30px, 9.5vw, 54px)/1 var(--font-display);
  color: var(--gold-2);
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 #8a5200, 0 6px 0 #5c3300, 0 10px 16px #000;
  z-index: 2;
}

/* --- ставка и таймер --- */
.duel-stakes {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  align-items: center;
  /* рамка тоньше базовой .card + минимальный вертикальный воздух,
     чтобы плашка не занимала пол-экрана на мобиле */
  border-width: clamp(7px, 1.8vw, 11px);
  border-image-width: clamp(7px, 1.8vw, 11px);
  padding: clamp(3px, 0.6vh, 7px) 3%;
  font-family: var(--font-display);
  text-align: center;
}
.stakes-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-right: 2px solid #37415a;
  padding-right: 3%;
}
.stakes-right { display: flex; flex-direction: column; gap: 1px; }
.duel-stakes small {
  color: #cfd5e1;
  font-size: clamp(9px, 2.4vw, 12px);
  letter-spacing: 0.05em;
  text-shadow: 0 2px 3px #000;
}
.duel-stakes strong {
  color: var(--gold-2);
  font-weight: 400;
  font-size: clamp(18px, 5vw, 26px);
  line-height: 1;
  text-shadow: 0 2px 0 #7c4a00, 0 4px 8px #000;
}
.stakes-left span { font: 700 clamp(8px, 2vw, 11px)/1 var(--font-body); color: #9aa3b5; }
.stakes-left mark { color: var(--green); background: none; }
.stakes-left em { color: var(--red); font-style: normal; }
.duel-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.duel-timer img { height: clamp(12px, 3vw, 16px); width: auto; opacity: 0.85; }
.duel-timer b {
  color: #ff5f51;
  font-weight: 400;
  font-size: clamp(16px, 4.4vw, 24px);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #5c1510, 0 4px 6px #000;
}

/* --- кнопки --- */
.duel-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 12px);
}
.duel-cta img { height: 1.1em; width: auto; filter: drop-shadow(0 2px 2px #754000); }
.duel-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 10px);
  min-height: clamp(38px, 5.4vh, 52px);
  background: url("../assets/ui/chip-9slice.svg") center / 100% 100% no-repeat;
  color: #d9deea;
  font: 400 clamp(13px, 3.4vw, 18px)/1 var(--font-display);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 3px #000;
  cursor: pointer;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.4));
}
.duel-switch:active { transform: translateY(1px); }
.duel-switch:disabled { opacity: 0.6; cursor: default; }

/* --- скелетон при поиске соперника --- */
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.is-searching .fighter-info b,
.is-searching .fighter-info small {
  color: transparent !important;
  text-shadow: none !important;
  border-radius: 6px;
  background: linear-gradient(90deg, #333e56 25%, #47546f 50%, #333e56 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
  user-select: none;
}
.is-searching .fighter-info small em { color: transparent !important; }
.is-searching .fighter-info b { min-width: 64%; }
.is-searching .fighter-info small { min-width: 46%; }
.is-searching .fighter-ava img { visibility: hidden; }
.is-searching .fighter-ava {
  background: linear-gradient(90deg, #333e56 25%, #47546f 50%, #333e56 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
}
.is-searching .fighter-bar::before {
  background: linear-gradient(90deg, #333e56 25%, #47546f 50%, #333e56 75%) !important;
  background-size: 200% 100% !important;
  width: 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
}
/* боец на арене — тёмный пульсирующий силуэт */
@keyframes silhouette-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.45; }
}
.duel-foe.is-searching {
  filter: brightness(0) drop-shadow(0 14px 14px rgba(0, 0, 0, 0.55));
  animation: silhouette-pulse 1.1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .is-searching .fighter-info b,
  .is-searching .fighter-info small,
  .is-searching .fighter-ava,
  .is-searching .fighter-bar::before,
  .duel-foe.is-searching { animation: none; }
}

/* --- низкие экраны --- */
@media (max-height: 700px) {
  .duel-sub { display: none; }
  .duel-stage { min-height: clamp(140px, 27vh, 200px); }
  .duel-me, .duel-foe { height: clamp(130px, 25vh, 190px); }
  .duel-stakes strong { font-size: clamp(16px, 4.5vw, 22px); }
}
