/* ============================================================
   Карты в духе FUT: металлические фаски по редкости,
   тонировка клуба, бегущий блик, у легенд — перелив.
   ============================================================ */

.card {
  position: relative;
  width: 148px;
  height: 210px;
  border-radius: 14px 14px 20px 20px;
  flex-shrink: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1.2), filter 0.25s;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.5));
  --c1: #c98d5a; --c2: #8a5a34; --c3: #e8b489; /* бронза по умолчанию */
  --club: #888;
}
.card:hover { transform: translateY(-8px) rotate(-1.2deg) scale(1.04); z-index: 5; }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(160deg, var(--c3) 0%, var(--c1) 30%, var(--c2) 68%, var(--c1) 100%);
  border: 1px solid rgba(0, 0, 0, 0.35);
}

/* верхняя скошенная грань */
.card-face::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.36) 0%, transparent 18%, transparent 68%, rgba(255,255,255,0.14) 100%);
  clip-path: polygon(0 0, 100% 0, 100% 12%, 21% 21%, 0 38%);
  pointer-events: none;
}

/* бегущий блик */
.card-face::after {
  content: '';
  position: absolute;
  top: -60%;
  left: -80%;
  width: 55%;
  height: 220%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.30), transparent);
  transform: rotate(18deg);
  animation: cardShimmer 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cardShimmer {
  0%, 55% { left: -80%; }
  85%, 100% { left: 140%; }
}

/* --- Редкости --- */
.card.rarity-rare   { --c1: #c9d4de; --c2: #7d8ea0; --c3: #f2f7fb; }
.card.rarity-epic   { --c1: #f0d060; --c2: #a8801a; --c3: #fdf0b0; }
.card.rarity-icon {
  --c1: #e8c8ff; --c2: #8a4fd0; --c3: #fff0ff;
}
.card.rarity-icon .card-face {
  background:
    linear-gradient(150deg, #fff0ff 0%, #e8c8ff 25%, #b07ae8 50%, #e8c8ff 75%, #fff0ff 100%);
  background-size: 220% 220%;
  animation: iconFlow 5s ease-in-out infinite;
}
@keyframes iconFlow {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

/* Иконы (prime): ледяное переливание */
.card.rarity-prime { --c1: #bdf3ff; --c2: #1e9ebd; --c3: #eafcff; }
.card.rarity-prime .card-face {
  background:
    linear-gradient(155deg, #eafcff 0%, #bdf3ff 30%, #37c5e8 55%, #7df0ff 80%, #eafcff 100%);
  background-size: 240% 240%;
  animation: primeFlow 4s ease-in-out infinite;
}
@keyframes primeFlow {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}
.card.rarity-prime::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 1.5px solid rgba(125, 240, 255, 0.65);
  box-shadow: 0 0 18px rgba(125, 240, 255, 0.35), inset 0 0 12px rgba(125, 240, 255, 0.2);
  pointer-events: none;
  animation: primePulse 2.2s ease-in-out infinite;
}
@keyframes primePulse {
  50% { box-shadow: 0 0 30px rgba(125, 240, 255, 0.6), inset 0 0 18px rgba(125, 240, 255, 0.35); }
}

/* --- Улучшение дублями: ленточка звёзд и эффекты уровней --- */
/* Лента-«закладка» у верхнего края, поверх карты: вне потока,
   под ней резервируется место (has-stars), вёрстка не съезжает */
.card-ribbon {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 62%;
  max-width: 86%;
  padding: 2px 12px 3px;
  border-radius: 3px 3px 6px 6px;
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 3px;
  color: #2a1e04;
  background: linear-gradient(180deg, #ffe9a8, #f0cf6a 45%, #d4af37);
  border: 1px solid rgba(255, 255, 240, 0.8);
  border-top: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.35), inset 0 1px 4px rgba(255, 255, 255, 0.4);
  pointer-events: auto;
  white-space: nowrap;
  overflow: hidden;
}
/* «хвостики» ленты по бокам — вид сложенной ленты */
.card-ribbon::before, .card-ribbon::after {
  content: '';
  position: absolute;
  top: 100%;
  border: 4px solid transparent;
}
.card-ribbon::before { left: 0; border-top-color: #8a6a12; border-left-color: #8a6a12; }
.card-ribbon::after { right: 0; border-top-color: #8a6a12; border-right-color: #8a6a12; }
.ribbon-stars {
  display: block;
  font-size: 13px;
  text-shadow: 0 0 6px rgba(255, 240, 170, 0.9), 0 1px 1px rgba(90, 60, 0, 0.6);
}
/* место под лентой: шапка карты опускается, ничего не перекрывается */
.card.has-stars .card-face .card-top { padding-top: 22px; }
.card.has-stars.small .card-face .card-top { padding-top: 18px; }

/* цвет ленты по уровню улучшения */
.card-ribbon.tier-1 { background: linear-gradient(180deg, #ffe9a8, #f0cf6a 45%, #d4af37); }
.card-ribbon.tier-2 { background: linear-gradient(180deg, #eef4fb, #c9d4de 45%, #8fa3b8); color: #1c2733; }
.card-ribbon.tier-3 {
  background: linear-gradient(180deg, #fff3c0, #f5d76e 45%, #c8961f);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 10px rgba(245, 215, 110, 0.65), inset 0 1px 4px rgba(255, 255, 255, 0.4);
}
.card-ribbon.tier-4 {
  background: linear-gradient(180deg, #f3e3ff, #d9a8ff 45%, #9a4fe0);
  color: #2a0a3d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 12px rgba(190, 120, 255, 0.7), inset 0 1px 4px rgba(255, 255, 255, 0.4);
  text-shadow: none;
}
.card-ribbon.tier-5 {
  background: linear-gradient(180deg, #eafcff, #bdf3ff 40%, #37c5e8 85%);
  color: #062a35;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), 0 0 14px rgba(125, 240, 255, 0.85), inset 0 1px 5px rgba(255, 255, 255, 0.6);
}
.card-ribbon.tier-4 .ribbon-stars, .card-ribbon.tier-5 .ribbon-stars { text-shadow: none; }
/* мелкие карты — компактная, но контрастная лента */
.card.small .card-ribbon, .hand-cards .card .card-ribbon, .duel-slot .card .card-ribbon {
  letter-spacing: 1.6px;
  padding: 1px 7px 2px;
  min-width: 56%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 9px rgba(255, 215, 0, 0.4), inset 0 1px 3px rgba(255, 255, 255, 0.4);
}
.card.small .card-ribbon .ribbon-stars, .hand-cards .card .card-ribbon .ribbon-stars, .duel-slot .card .card-ribbon .ribbon-stars {
  font-size: 10.5px;
}
.card-ribbon::before, .card-ribbon::after { border-width: 4px; }

/* надбавка статов от звёзд — надстрочная, ширину стата не меняет */
.card-stat b { position: relative; }
.card-stat .stat-up {
  position: absolute;
  top: -7px;
  right: -9px;
  font-style: normal;
  font-size: 7.5px;
  font-weight: 800;
  color: #12602f;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
  letter-spacing: 0;
}
.chip-stars { color: #ffd700; font-size: 10px; letter-spacing: 1px; text-shadow: 0 0 5px rgba(255,215,0,.7); }

/* визуальный эффект каждого уровня улучшения */
.card.stars-1 { box-shadow: 0 10px 18px rgba(0,0,0,0.5), 0 0 10px rgba(255, 215, 0, 0.35); }
.card.stars-2 {
  box-shadow: 0 10px 18px rgba(0,0,0,0.5), 0 0 14px rgba(200, 220, 255, 0.5);
  outline: 1px solid rgba(200, 220, 255, 0.55);
  outline-offset: -1px;
}
.card.stars-3 {
  box-shadow: 0 10px 18px rgba(0,0,0,0.5), 0 0 18px rgba(245, 215, 110, 0.65);
  outline: 2px solid rgba(245, 215, 110, 0.7);
  outline-offset: -2px;
}
.card.stars-4 {
  box-shadow: 0 10px 18px rgba(0,0,0,0.5), 0 0 22px rgba(190, 120, 255, 0.7);
  outline: 2px solid rgba(190, 120, 255, 0.8);
  outline-offset: -2px;
}
.card.stars-5 {
  box-shadow: 0 10px 18px rgba(0,0,0,0.5), 0 0 26px rgba(125, 240, 255, 0.8), inset 0 0 16px rgba(125, 240, 255, 0.25);
  outline: 2px solid rgba(125, 240, 255, 0.9);
  outline-offset: -2px;
}
.card.stars-5 .card-face::before {
  background:
    linear-gradient(115deg, rgba(255,255,255,0.5) 0%, rgba(125,240,255,0.25) 20%, transparent 45%, transparent 70%, rgba(255,255,255,0.2) 100%);
}

/* вспышка сразу после улучшения (модалка апгрейда) */
.card.upgraded { position: relative; }
.card.upgraded.upgraded-burst { animation: upgradeBurst 1.1s cubic-bezier(0.2, 0.7, 0.3, 1.2); }
@keyframes upgradeBurst {
  0% { filter: brightness(2.6) saturate(0.4); transform: scale(1.12); }
  35% { filter: brightness(1.7); transform: scale(1.06); }
  100% { filter: none; transform: scale(1); }
}
.uf-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px 0;
  /* фиксированная высота + скрытое переполнение: пульс-анимация
     не порождает полосу прокрутки у модалки */
  height: 300px;
  overflow: hidden;
}
.uf-burst {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 140, 0.55), rgba(255, 215, 0, 0.18) 45%, transparent 70%);
  animation: ufPulse 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes ufPulse {
  0% { transform: scale(0.5); opacity: 0.95; }
  100% { transform: scale(1.7); opacity: 0; }
}
.up-note { font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.up-hint { color: var(--gold-dim); }
.up-btn { margin-top: 12px; width: 100%; }
.cd-stars { color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,.6); letter-spacing: 2px; }
.cd-stars-row { letter-spacing: 2px; }
.cd-stars-empty { font-style: normal; opacity: 0.25; }
.cd-upgrade { margin-top: 6px; }

/* Выбор карты: свечение в цвет редкости */
.card.selected {
  outline: 2px solid var(--rarity-glow, #d4af37);
  outline-offset: 2px;
  box-shadow: 0 0 22px var(--rarity-glow, #d4af37);
}

/* --- Внутренняя компоновка --- */
.card-top {
  display: flex;
  padding: 10px 10px 0;
  gap: 8px;
  align-items: flex-start;
}
.card-ovr {
  font-size: 26px;
  font-weight: 800;
  color: #1d1508;
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.card-ovr small { font-size: 11px; display: block; font-weight: 700; letter-spacing: 1px; opacity: .8; }
.card-pos {
  font-size: 13px;
  font-weight: 800;
  color: #241b08;
  letter-spacing: 1px;
  margin-top: 3px;
}
.card-spacer { flex: 1; }
.card-crest {
  width: 34px;
  height: 38px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.card-name {
  margin: 4px 10px 0;
  font-size: 13px;
  font-weight: 800;
  color: #20160a;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}

.card-club-band {
  margin: 6px 10px 0;
  height: 3px;
  border-radius: 2px;
  background: var(--club);
  box-shadow: 0 0 8px var(--club);
}

.card-stats {
  margin-top: auto;
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 8px 6px 6px;
}
.card-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
  color: #1d1508;
  line-height: 1.05;
}
.card-stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.card-stat span { font-size: 9px; letter-spacing: 1.2px; opacity: 0.75; }

.card-ability {
  margin: 0 8px 8px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(20, 14, 6, 0.35);
  color: #fff8e8;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Состояния --- */
.card.disabled { filter: grayscale(0.9) brightness(0.55); cursor: default; }
.card.disabled:hover { transform: none; }
.card.selected { outline: 3px solid var(--gold); outline-offset: 2px; }
.card.small { width: 104px; height: 148px; }
.card.small .card-ovr { font-size: 19px; }
.card.small .card-name { font-size: 10.5px; }
.card.small .card-stat b { font-size: 13px; }
.card.small .card-ability { font-size: 9px; padding: 3px 6px; }
.card.small .card-crest { width: 24px; height: 27px; }
.card.big { width: 190px; height: 268px; }
.card.big .card-ovr { font-size: 32px; }
.card.big .card-name { font-size: 16px; }
.card.big .card-stat b { font-size: 20px; }
.card.big .card-ability { font-size: 12px; }

/* мини-чип карты (в списках составов) */
.card-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 13px;
}
.card-chip:hover { background: rgba(212, 175, 55, 0.08); border-color: var(--line); }
.card-chip .chip-ovr {
  font-weight: 800;
  font-size: 15px;
  color: var(--gold-2);
  min-width: 26px;
  text-align: center;
}
.card-chip .chip-pos {
  font-size: 10px;
  font-weight: 800;
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-2);
  padding: 2px 5px;
  border-radius: 4px;
}
.card-chip .chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-chip .chip-club { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* флип для дуэлей */
.card-flip { perspective: 900px; }

/* длинные имена — две строки в модалке эпизода и при вскрытии паков */
.evd-side .card .card-name,
.pack-open .card.small .card-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.15;
  overflow: hidden;
}
.card-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.3, 0.8, 0.3, 1);
}
.card-flip.flipped .card-flip-inner { transform: rotateY(180deg); }
.card-back, .card-flip .card-face {
  backface-visibility: hidden;
  position: absolute;
  inset: 0;
}
.card-flip .card-face { transform: rotateY(180deg); }
.card-back {
  border-radius: 14px 14px 20px 20px;
  background:
    repeating-linear-gradient(45deg, rgba(212,175,55,0.08) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #1a2436 0%, #101724 60%, #0b101b 100%);
  border: 1px solid rgba(212, 175, 55, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-back .card-back-logo {
  font-size: 40px;
  font-weight: 900;
  color: rgba(212, 175, 55, 0.65);
  letter-spacing: 2px;
  text-shadow: 0 0 24px rgba(212, 175, 55, 0.35);
}
