/* ═══════════════════════════════════════════════
   DARK ARENA — Game Screens Stylesheet
   Extends /css/style.css — uses same :root vars
═══════════════════════════════════════════════ */

/* ─── RESET & FONTS ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.btn, button {
  min-height: 44px;
  touch-action: manipulation;
}

.card-atk, .card-hp, .card-mana,
.end-turn-btn, .auto-btn {
  min-height: unset;
}

/* ── Battle card stat circles — defensive positioning ── */
.battle-card {
  overflow: visible !important;
}
.card-art-img {
  border-radius: 8px !important;
  overflow: hidden !important;
}
.card-atk {
  position: absolute !important;
  bottom: -8px !important;
  left: -8px !important;
  width: 26px !important;
  height: 26px !important;
  font-size: 10px !important;
  z-index: 4 !important;
  margin: 0 !important;
  transform: none !important;
}
.card-hp {
  position: absolute !important;
  bottom: -8px !important;
  right: -8px !important;
  width: 26px !important;
  height: 26px !important;
  font-size: 10px !important;
  z-index: 4 !important;
  margin: 0 !important;
  transform: none !important;
}

:root {
  --purple:       #7b2fff;
  --purple-deep:  #4a0e8f;
  --purple-glow:  rgba(123,47,255,0.4);
  --purple-dim:   rgba(123,47,255,0.15);
  --gold:         #d4a843;
  --gold-light:   #f0c96a;
  --red:          #e02020;
  --red-glow:     rgba(224,32,32,0.4);
  --green:        #00c864;
  --bg-void:      #050308;
  --bg-deep:      #0a0514;
  --bg-dark:      #100920;
  --bg-card:      #130d2a;
  --bg-panel:     rgba(255,255,255,0.03);
  --border:       rgba(123,47,255,0.25);
  --border-gold:  rgba(212,168,67,0.4);
  --text:         #e8deff;
  --text-muted:   rgba(232,222,255,0.55);
  --text-dim:     rgba(232,222,255,0.3);
  --font-display: 'Cinzel', serif;
  --font-body:    'Rajdhani', sans-serif;
  --radius:       8px;
  --radius-lg:    16px;
  --transition:   0.25s ease;
}

body {
  background: var(--bg-void);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.inline-token-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 2px;
  display: inline-block;
}
.icon-svg {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  margin: 0 3px;
  flex-shrink: 0;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }


/* ── HEADER LOGO (image) ── */
.game-header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.game-header-logo__icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 50%;
}
.game-header-logo__title {
  height: 26px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(212,168,67,0.4));
}

/* ── BALANCE DISPLAY ── */
.balance-display {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  color: #d4a843;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(212,168,67,0.1);
  border: 1px solid rgba(212,168,67,0.3);
  border-radius: 20px;
}

/* ── WIN CHANCE BAR ── */
.win-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}
.win-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.win-bar-fill.high   { background: linear-gradient(90deg, #00c864, #00ff88); }
.win-bar-fill.medium { background: linear-gradient(90deg, #ff9500, #ffcc00); }
.win-bar-fill.low    { background: linear-gradient(90deg, #e02020, #ff4444); }

/* ── CARD RARITY GLOW ── */
.card-glow-common    { box-shadow: 0 0 12px rgba(148,148,148,0.4); }
.card-glow-uncommon  { box-shadow: 0 0 16px rgba(0,200,100,0.5);  }
.card-glow-rare      { box-shadow: 0 0 16px rgba(77,143,255,0.5); }
.card-glow-epic      { box-shadow: 0 0 20px rgba(176,111,255,0.6);}
.card-glow-legendary { box-shadow: 0 0 24px rgba(212,168,67,0.7); }
.card-glow-mythic    { box-shadow: 0 0 28px rgba(255,107,138,0.7);}
.card-glow-ancient   { box-shadow: 0 0 32px rgba(255,149,0,0.8);  }
.card-glow-divine    { box-shadow: 0 0 40px rgba(255,255,255,0.9);}

/* ─── GAME HEADER ─── */
.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5,3,8,0.97);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-header__logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.15em;
  flex-shrink: 0;
  text-decoration: none;
}
.game-header__logo .icon-svg {
  width: 18px;
  height: 18px;
  margin: 0 6px 0 0;
  color: var(--gold);
  -webkit-text-fill-color: initial;
}

.game-header__stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.stat-pill__icon { font-size: 14px; }
.stat-pill--energy { border-color: rgba(0,200,100,0.4); color: var(--green); }
.stat-pill--dark   { border-color: var(--border-gold); color: var(--gold); }
.stat-pill--wallet { color: var(--text-muted); font-size: 11px; }
.stat-pill--level  { border-color: var(--purple); color: var(--purple); }

.game-header__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── GAME TABS ─── */
.game-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.game-tabs::-webkit-scrollbar { display: none; }

.game-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.game-tab .icon-svg { width: 13px; height: 13px; }
.game-tab:hover { color: var(--text); }
.game-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ─── MAIN CONTENT ─── */
.game-main {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.game-main--arena {
  max-width: none;
  width: 100%;
  padding-left: clamp(24px, 2.4vw, 40px);
  padding-right: clamp(24px, 2.4vw, 40px);
}
.game-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: 0 0 18px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(123,47,255,0.38);
  background: rgba(10,5,20,0.58);
  color: rgba(212,168,67,0.92);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.game-back-btn:hover,
.game-back-btn:focus-visible {
  color: #f1ca68;
  border-color: rgba(123,47,255,0.72);
  box-shadow: 0 0 22px rgba(123,47,255,0.22), inset 0 0 0 1px rgba(212,168,67,0.08);
  transform: translateX(-1px);
  outline: none;
}
.game-back-btn--standalone {
  margin-left: clamp(20px, 3vw, 40px);
  margin-top: 18px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn--primary {
  background: linear-gradient(135deg, #7b2fff, #4a0e8f);
  color: #fff;
  border: 1px solid var(--purple);
  box-shadow: 0 0 20px var(--purple-glow);
}
.btn--primary:hover {
  background: linear-gradient(135deg, #9146ff, #6020c0);
  box-shadow: 0 0 36px var(--purple-glow);
  transform: translateY(-1px);
}
.btn--gold {
  background: linear-gradient(135deg, #d4a843, #a07830);
  color: #000;
  border: 1px solid var(--gold);
}
.btn--gold:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn--outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(232,222,255,0.25);
}
.btn--outline:hover { border-color: var(--purple); color: var(--purple); }
.btn--danger {
  background: rgba(224,32,32,0.15);
  color: var(--red);
  border: 1px solid rgba(224,32,32,0.4);
}
.btn--danger:hover { background: var(--red); color: #fff; }
.btn--sm { padding: 6px 14px; font-size: 10px; }
.btn--lg { padding: 14px 36px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ─── SECTION HEADER ─── */
.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}
.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ─── BOSSES GRID ─── */
/* ── КАРТОЧКА БОССА ── */
.boss-card-game {
  flex: 0 0 200px;
  width: 200px;
  scroll-snap-align: start;
  background: rgba(10,5,20,0.8);
  border: 1px solid rgba(123,47,255,0.25);
  border-radius: 16px;
  overflow: hidden;
  cursor: default;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}
.boss-card-game:hover {
  border-color: rgba(212,168,67,0.4);
  box-shadow: 0 8px 32px rgba(123,47,255,0.2);
}

/* АРТ */
.boss-card-game__art-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  flex-shrink: 0;
}
.boss-card-game__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform 0.4s ease;
}
.boss-card-game:hover .boss-card-game__art {
  transform: scale(1.04);
}

/* Тир — поверх арта */
.boss-card-game__tier {
  position: absolute;
  top: 10px; left: 10px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(5,3,8,0.75);
  border: 1px solid rgba(123,47,255,0.4);
  border-radius: 20px;
  color: rgba(232,222,255,0.8);
  z-index: 2;
  backdrop-filter: blur(4px);
}

/* Градиент снизу арта */
.boss-card-game__art-fade {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to bottom, transparent 0%, rgba(10,5,20,0.95) 100%);
  pointer-events: none;
  z-index: 1;
}

/* BODY */
.boss-card-game__body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.boss-card-game__name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  color: #e8deff;
  margin: 0;
  line-height: 1.2;
}

/* Win chance bar */
.boss-card-game__winbar-wrap { display: flex; flex-direction: column; gap: 4px; }
.boss-card-game__winbar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.boss-card-game__winbar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #7b2fff, #d4a843);
  transition: width 0.5s ease;
}
.boss-card-game__winpct {
  font-size: 11px;
  color: rgba(232,222,255,0.5);
  font-weight: 500;
}

/* Кнопки сложности */
.boss-difficulty-btns { display: flex; gap: 6px; }
.diff-btn {
  flex: 1;
  padding: 6px 3px;
  border-radius: 8px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.2s ease;
  text-align: center;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
}
.diff-btn__label  { font-size: 9px; }
.diff-btn__reward { font-size: 7px; font-weight: 400; letter-spacing: 0.02em; opacity: 0.85; }
.diff-btn:hover   { transform: translateY(-2px); }

.diff-btn--easy   { color: #00c864; border-color: rgba(0,200,100,0.35); background: rgba(0,200,100,0.08); }
.diff-btn--easy:hover, .diff-btn--easy.diff-btn--selected {
  background: rgba(0,200,100,0.2); border-color: #00c864; box-shadow: 0 0 12px rgba(0,200,100,0.3);
}
.diff-btn--normal { color: #d4a843; border-color: rgba(212,168,67,0.35); background: rgba(212,168,67,0.08); }
.diff-btn--normal:hover, .diff-btn--normal.diff-btn--selected {
  background: rgba(212,168,67,0.2); border-color: #d4a843; box-shadow: 0 0 12px rgba(212,168,67,0.3);
}
.diff-btn--hard   { color: #e02020; border-color: rgba(224,32,32,0.35); background: rgba(224,32,32,0.08); }
.diff-btn--hard:hover, .diff-btn--hard.diff-btn--selected {
  background: rgba(224,32,32,0.2); border-color: #e02020; box-shadow: 0 0 12px rgba(224,32,32,0.3);
}
.diff-btn--selected { transform: scale(1.05) !important; }

/* FIGHT кнопка */
.boss-card-game__fight-wrap { margin-top: 2px; }
.boss-fight-btn {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #7b2fff, #4a0e8f);
  border: 1px solid #7b2fff;
  border-radius: 10px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 20px rgba(123,47,255,0.3);
}
.boss-fight-btn:hover {
  background: linear-gradient(135deg, #9146ff, #6020c0);
  box-shadow: 0 0 32px rgba(123,47,255,0.5);
  transform: translateY(-1px);
}
.boss-fight-btn--placeholder {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px dashed rgba(123,47,255,0.25);
  border-radius: 10px;
  color: rgba(232,222,255,0.25);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: center;
  cursor: default;
  display: block;
  box-sizing: border-box;
}

/* ─── DECK BUILDER MODAL ─── */
.deck-builder-modal {
  position: fixed; inset: 0; z-index: 9200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.deck-builder-modal.hidden { display: none; }
.deck-builder-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}
.deck-builder-content {
  position: relative; z-index: 1;
  width: 100%; max-width: 760px;
  max-height: 86vh;
  background: linear-gradient(145deg,#1a0533,#0d0220);
  border: 1px solid rgba(123,47,255,0.5);
  border-radius: 20px;
  padding: 24px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.deck-builder-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; flex-shrink: 0;
}
.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 4px;
  flex: 1;
  min-height: 0;
}
.mini-card {
  background: linear-gradient(145deg, #1a0533, #0d0220);
  border: 1px solid rgba(123,47,255,0.3);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}
.mini-card:hover:not(.exhausted):not(.deck-selected) { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(123,47,255,0.3); }
.mini-card.deck-selected {
  border: 2px solid #d4a843 !important;
  box-shadow: 0 0 20px rgba(212,168,67,0.6), 0 0 40px rgba(212,168,67,0.3), inset 0 0 20px rgba(212,168,67,0.1) !important;
  transform: translateY(-4px) scale(1.03) !important;
}
.mini-card.deck-selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: #00c864;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  z-index: 10;
  line-height: 20px;
  text-align: center;
}
.mini-card.exhausted { cursor: not-allowed !important; filter: brightness(0.45) grayscale(0.5) !important; transform: none !important; }
.mini-card.exhausted:hover { transform: none !important; box-shadow: none !important; }

.mini-card__art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
}
.mini-card__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}
.mini-card__exhausted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5,3,8,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 2;
}
.mini-card__timer {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(212,168,67,0.6);
}
.mini-card__no-energy {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: rgba(232,222,255,0.5);
  text-transform: uppercase;
}
.mini-card__info {
  padding: 4px 6px 2px;
}
.mini-card__name {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-card__rarity {
  font-size: 8px;
  letter-spacing: 0.1em;
}
.mini-card__energy {
  display: flex;
  gap: 2px;
  padding: 3px 6px 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.energy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.energy-dot--filled {
  background: var(--purple);
  box-shadow: 0 0 4px rgba(123,47,255,0.8);
}
.energy-dot--empty {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(123,47,255,0.2);
}
.mini-card__energy--empty .energy-dot--filled { display: none; }

/* ══════════════════════════════════════════════
   НОВЫЙ МОДАЛ ВЫБОРА КОЛОДЫ — deck-modal
══════════════════════════════════════════════ */

.deck-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  touch-action: none;
}
.deck-modal.hidden { display: none; }

.deck-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(6px);
  touch-action: none;
}

.deck-modal__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  max-height: 92vh;
  background: linear-gradient(145deg, #0d0220, #050308);
  border: 1px solid rgba(123,47,255,0.3);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 768px) {
  .deck-modal { align-items: center; }
  .deck-modal__content {
    border-radius: 20px;
    max-height: 88vh;
  }
}

.deck-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(123,47,255,0.2);
  flex-shrink: 0;
}
.deck-modal__title {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #d4a843;
  margin: 0 0 6px;
  letter-spacing: 0.1em;
}
.deck-modal__subtitle {
  font-size: 13px;
  color: rgba(232,222,255,0.6);
  margin: 0;
}
.deck-modal__subtitle strong { color: #e8deff; }
.deck-modal__close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(232,222,255,0.5);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.deck-modal__close:hover { border-color: #7b2fff; color: #7b2fff; }

.deck-modal__cards-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px 20px;
}
.deck-modal__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  max-height: 100% !important;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch !important;
  scroll-behavior: auto !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(123,47,255,0.5) rgba(255,255,255,0.04);
  overscroll-behavior-y: contain !important;
  touch-action: pan-y;
}
.deck-modal__cards::-webkit-scrollbar {
  width: 6px;
}
.deck-modal__cards::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  border-radius: 3px;
}
.deck-modal__cards::-webkit-scrollbar-thumb {
  background: rgba(123,47,255,0.5);
  border-radius: 3px;
}
.deck-modal__cards::-webkit-scrollbar-thumb:hover {
  background: #7b2fff;
}

/* ── Карточка выбора — полная ── */
.deck-pick-card {
  width: 100%;
  border-radius: 12px;
  border: 2px solid rgba(123,47,255,0.3);
  background: linear-gradient(145deg, #1a0533, #0d0220);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.deck-pick-card:hover:not(.deck-pick-card--exhausted) {
  transform: translateY(-4px);
  border-color: rgba(212,168,67,0.5);
  box-shadow: 0 8px 20px rgba(123,47,255,0.3);
}
.deck-pick-card--selected {
  border-color: #d4a843 !important;
  box-shadow: 0 0 20px rgba(212,168,67,0.5),
              0 0 40px rgba(212,168,67,0.2) !important;
  transform: translateY(-4px) !important;
}
.deck-pick-card--exhausted {
  cursor: not-allowed !important;
  filter: brightness(0.4) grayscale(0.6) !important;
  transform: none !important;
}

@media (max-width: 599px) {
  .deck-modal__cards-wrap { padding: 8px 12px; }
  .deck-modal__cards {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .deck-modal__content { max-height: 95vh; }
  .deck-modal__cards {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
  }
}

.deck-pick-card__rarity-bar {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
}

/* АРТ — верхние ~65% карточки */
.deck-pick-card__art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  flex: none;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(123,47,255,.24), transparent 55%),
    #0d0718;
}
.deck-pick-card__art-wrap--missing::after {
  content: 'ART UNAVAILABLE';
  position:absolute; inset:0;
  display:grid; place-items:center;
  padding:12px;
  color:rgba(232,222,255,.45);
  font:600 8px/1.4 var(--font-display);
  letter-spacing:.12em;
  text-align:center;
}
.deck-pick-card__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

/* ── Skeleton loading для артов карточек ── */
@keyframes imgSkeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.deck-pick-card__art[data-src],
.mini-card__art[data-src],
.coll-card__art[data-src],
.battle-card__img[data-src] {
  background: linear-gradient(
    90deg,
    #1a0533 25%,
    #2a1050 50%,
    #1a0533 75%
  );
  background-size: 200% 100%;
  animation: imgSkeleton 1.5s infinite linear;
}
.deck-pick-card__art:not([data-src]),
.mini-card__art:not([data-src]),
.coll-card__art:not([data-src]),
.battle-card__img:not([data-src]) {
  animation: none;
  background: none;
}

/* Мана — верхний левый */
.deck-pick-card__mana {
  position: absolute;
  top: 5px; left: 5px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a5fff, #0a3aaa);
  border: 1px solid #4d8fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 9px; font-weight: 700; color: #fff;
  z-index: 3;
}

/* Галочка */
.deck-pick-card__check {
  position: absolute;
  top: 5px; right: 5px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #00c864;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  z-index: 4;
  box-shadow: 0 0 8px rgba(0,200,100,0.6);
}

/* Оверлей исчерпанности */
.deck-pick-card__exhausted {
  position: absolute; inset: 0;
  background: rgba(5,3,8,0.75);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; z-index: 5;
}
.deck-pick-card__timer {
  font-family: 'Cinzel', serif;
  font-size: 12px; font-weight: 700;
  color: #d4a843;
}
.deck-pick-card__no-energy {
  font-size: 8px; letter-spacing: 0.12em;
  color: rgba(232,222,255,0.5);
}

/* Градиент снизу арта */
.deck-pick-card__gradient {
  display:none;
}

/* ИНФО — нижние ~35% */
.deck-pick-card__info {
  flex:1;
  padding: 9px 9px 10px;
  background: linear-gradient(to bottom, #100828, #050308);
  border-top:1px solid rgba(123,47,255,.18);
}
.deck-pick-card__name {
  font-family: 'Cinzel', serif;
  font-size: 10px; font-weight: 700;
  color: #d4a843;
  line-height:1.35;
  overflow-wrap:anywhere;
  margin-bottom: 3px;
}
.deck-pick-card__meta {
  font-size: 8px; letter-spacing: 0.08em;
  line-height:1.35;
  margin-bottom: 6px;
}
.deck-pick-card__power {
  font-family: 'Cinzel', serif;
  font-size: 10px; font-weight: 700;
  color: #e8deff; margin-bottom: 4px;
}
.deck-pick-card__stats {
  display: flex; justify-content: space-between;
  margin-bottom: 4px;
}
.stat-atk { font-family: 'Cinzel', serif; font-size: 9px; color: #ff9500; font-weight: 700; }
.stat-hp  { font-family: 'Cinzel', serif; font-size: 9px; color: #00c864; font-weight: 700; }

.deck-pick-card__energy { display: flex; gap: 2px; flex-wrap: wrap; }
.ep-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(123,47,255,0.2);
}
.ep-dot--on {
  background: #7b2fff;
  border-color: #7b2fff;
  box-shadow: 0 0 3px rgba(123,47,255,0.7);
}

/* Футер */
.deck-modal__footer {
  flex-shrink: 0;
  padding: 12px 24px 20px;
  border-top: 1px solid rgba(123,47,255,0.2);
  background: rgba(0,0,0,0.3);
}
.deck-modal__stats {
  display: flex; gap: 20px;
  font-size: 13px; color: rgba(232,222,255,0.6);
  margin-bottom: 8px;
}
.deck-modal__stats strong { color: #7b2fff; font-weight: 700; }
.deck-modal__bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px; overflow: hidden;
  margin-bottom: 14px;
}
.deck-modal__bar-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #7b2fff, #d4a843);
  transition: width 0.4s ease;
  width: 0%;
}
.deck-modal__actions { display: flex; gap: 10px; align-items: center; }
.btn-clear-deck {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid rgba(232,222,255,0.15);
  border-radius: 8px; color: rgba(232,222,255,0.4);
  font-family: 'Cinzel', serif; font-size: 11px;
  letter-spacing: 0.1em; cursor: pointer; transition: all 0.2s;
}
.btn-clear-deck:hover { border-color: #e02020; color: #e02020; }
.btn-cancel {
  padding: 12px 24px; flex: 1;
  background: transparent;
  border: 1px solid rgba(232,222,255,0.2);
  border-radius: 10px; color: rgba(232,222,255,0.6);
  font-family: 'Cinzel', serif; font-size: 12px;
  letter-spacing: 0.1em; cursor: pointer;
}
.btn-go-battle {
  padding: 12px 32px; flex: 2;
  background: linear-gradient(135deg, #7b2fff, #4a0e8f);
  border: 1px solid #7b2fff; border-radius: 10px;
  color: #fff; font-family: 'Cinzel', serif;
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.12em; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(123,47,255,0.3);
}
.btn-go-battle:hover:not(:disabled) {
  background: linear-gradient(135deg, #9146ff, #6020c0);
  box-shadow: 0 0 32px rgba(123,47,255,0.5);
}
.btn-go-battle:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

@media (max-width: 480px) {
  .btn-go-battle { font-size: 12px; padding: 12px 16px; }
  .btn-cancel    { padding: 12px 14px; font-size: 11px; }
}

/* Энергия в collection.html */
.card-energy-bar {
  padding: 4px 8px 8px;
  border-top: 1px solid rgba(123,47,255,0.15);
}
.card-energy-bar__label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(232,222,255,0.5);
  margin-bottom: 4px;
  font-family: var(--font-display);
}
.card-energy-bar__timer {
  color: var(--gold);
  font-weight: 700;
}
.card-energy-bar__track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.card-energy-bar__fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Старые классы (обратная совместимость) */
.mini-card-name { font-family: var(--font-display); font-size: 9px; color: var(--text); padding: 4px 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-card-rarity { font-size: 8px; padding: 0 4px; letter-spacing: 0.05em; }
.mini-card-power { font-size: 9px; color: var(--gold); padding: 2px 4px 5px; display: flex; align-items: center; justify-content: center; }

.deck-builder-footer { flex-shrink: 0; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.deck-builder-stats {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted); margin-bottom: 10px;
}
.deck-builder-stats b { color: var(--gold); }
.deck-builder-btns { display: flex; gap: 10px; justify-content: flex-end; }

.boss-energy-note {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 8px;
}
.boss-lock-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

/* ─── BOSSES HORIZONTAL SCROLL ─── */
.bosses-scroll-wrap {
  position: relative;
  margin-inline: calc(-1 * clamp(8px, 1.2vw, 18px));
  padding-inline: clamp(8px, 1.2vw, 18px);
  overflow: visible;
}
.bosses-scroll-wrap::before,
.bosses-scroll-wrap::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: clamp(24px, 4vw, 42px);
  z-index: 2;
  pointer-events: none;
}
.bosses-scroll-wrap::before { left: 0; background: linear-gradient(to right, rgba(10,5,20,0.92), rgba(10,5,20,0)); }
.bosses-scroll-wrap::after  { right: 0; background: linear-gradient(to left, rgba(10,5,20,0.92), rgba(10,5,20,0)); }

.bosses-scroll-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 16px clamp(10px, 1vw, 18px) 24px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
.bosses-scroll-track:active { cursor: grabbing; }
.bosses-scroll-track::-webkit-scrollbar { display: none; }
.bosses-scroll-track { -ms-overflow-style: none; scrollbar-width: none; }

/* boss-card-game flex/snap already set on base class */

/* ─── CARDS GRID ─── */
.cards-grid-game {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ─── CARDS HORIZONTAL SCROLL ─── */
.cards-scroll-wrap {
  position: relative;
  margin: 0 -20px;
  padding: 0 20px;
}
.cards-scroll-wrap::before,
.cards-scroll-wrap::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}
.cards-scroll-wrap::before { left: 0; background: linear-gradient(to right, #0a0514, transparent); }
.cards-scroll-wrap::after  { right: 0; background: linear-gradient(to left, #0a0514, transparent); }

.cards-scroll-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 12px 8px 20px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
.cards-scroll-track:active { cursor: grabbing; }
.cards-scroll-track::-webkit-scrollbar { display: none; }
.cards-scroll-track { -ms-overflow-style: none; scrollbar-width: none; }

.cards-scroll-track .game-card {
  flex: 0 0 130px;
  scroll-snap-align: start;
}

.game-card {
  background: linear-gradient(145deg, #1a0533, #0d0220);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.game-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--gold);
  box-shadow: 0 8px 28px rgba(212,168,67,0.2);
}
.game-card--selected {
  border-color: var(--purple) !important;
  box-shadow: 0 0 20px var(--purple-glow) !important;
}
.game-card--in-deck {
  border-color: var(--green) !important;
  box-shadow: 0 0 12px rgba(0,200,100,0.2) !important;
}

.game-card--common    { border-color: rgba(148,148,148,0.4); }
.game-card--uncommon  { border-color: rgba(0,200,100,0.4); }
.game-card--rare      { border-color: rgba(0,130,255,0.4); }
.game-card--epic      { border-color: rgba(140,0,255,0.5); }
.game-card--legendary { border-color: rgba(255,165,0,0.6); box-shadow: 0 0 10px rgba(255,165,0,0.15); }
.game-card--mythic    { border-color: rgba(255,50,100,0.7); box-shadow: 0 0 14px rgba(255,50,100,0.25); animation: mythicPulse 3s ease-in-out infinite; }
.game-card--ancient   { border-color: rgba(255,149,0,0.7); box-shadow: 0 0 18px rgba(255,149,0,0.3); }
.game-card--divine    { border-color: rgba(255,255,255,0.8); box-shadow: 0 0 24px rgba(255,255,255,0.4); animation: mythicPulse 3s ease-in-out infinite; }

@keyframes mythicPulse {
  0%,100% { box-shadow: 0 0 14px rgba(255,50,100,0.25); }
  50%      { box-shadow: 0 0 28px rgba(255,50,100,0.5); }
}

.game-card__rarity-bar { height: 3px; width: 100%; }
.game-card--common .game-card__rarity-bar    { background: #949494; }
.game-card--uncommon .game-card__rarity-bar  { background: #00c864; }
.game-card--rare .game-card__rarity-bar      { background: #0082ff; }
.game-card--epic .game-card__rarity-bar      { background: #8c00ff; }
.game-card--legendary .game-card__rarity-bar { background: linear-gradient(90deg,#ffa500,#ffdd00); }
.game-card--mythic .game-card__rarity-bar    { background: linear-gradient(90deg,#ff1464,#ff6b00,#ff1464); background-size: 200%; animation: mythicBar 2s linear infinite; }
@keyframes mythicBar { 0%{background-position:0%} 100%{background-position:200%} }

.game-card__art {
  width: 100%; height: 100px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.game-card__art img { width:100%;height:100%;object-fit:cover; }
.game-card__art-icon { pointer-events: none; }

/* New art wrap — vertical 3:4 */
.game-card__art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  position: relative;
  background: #0d0220;
  flex-shrink: 0;
}
.game-card__art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 0.3s ease;
}
.game-card:hover .game-card__art-img { transform: scale(1.06); }
.game-card__art-fallback {
  position: absolute;
  inset: 0;
  display: none;
}
.game-card__level {
  position: absolute; top: 4px; right: 4px;
  background: var(--purple); color: #fff;
  font-size: 9px; font-family: var(--font-display);
  padding: 2px 6px; border-radius: 4px;
}

.game-card__body { padding: 8px 10px; }
.game-card__name {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 700;
  color: var(--gold); letter-spacing: 0.05em;
  margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-card__type { font-size: 9px; color: var(--text-dim); margin-bottom: 6px; }
.game-card__power { display: flex; justify-content: space-between; align-items: center; }
.game-card__power-val { font-family: var(--font-display); font-size: 12px; font-weight: 700; }
.game-card__mana {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg,#1a5fff,#0a3aaa);
  border: 1px solid #4d8fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
}
.game-card__deck-btn {
  width: 100%; padding: 6px;
  background: var(--purple-dim);
  color: var(--purple);
  border-top: 1px solid var(--border);
  font-size: 9px; font-family: var(--font-display);
  letter-spacing: 0.1em;
  transition: all var(--transition);
}
.game-card__deck-btn:hover { background: var(--purple); color: #fff; }
.game-card__deck-btn--remove { background: rgba(224,32,32,0.1); color: var(--red); border-color: rgba(224,32,32,0.2); }
.game-card__deck-btn--remove:hover { background: var(--red); color: #fff; }

/* ─── SKELETONS ─── */
.card-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-art { height: 100px; background: rgba(255,255,255,0.04); }
.skeleton-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.skeleton-line {
  height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.06);
}
.skeleton-line--name { width: 70%; }
.skeleton-line--type { width: 50%; }
.skeleton-line--power { width: 40%; }
@keyframes shimmer {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ─── DECK PANEL ─── */
.deck-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}
.deck-panel__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.deck-power-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: rgba(212,168,67,0.1);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
}
.deck-power-badge__val {
  font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--gold);
}
.deck-power-badge__label { font-size: 11px; color: var(--text-muted); }

/* ─── BATTLE CARD — глобальное правило пропорции 3:4 ─── */
.battle-card {
  aspect-ratio: 3 / 4;
  height: auto !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
}
.card-art,
.card-art-img {
  width: 100% !important;
  height: 60% !important;
  object-fit: cover !important;
  object-position: top !important;
  display: block !important;
  flex-shrink: 0 !important;
}
.card-footer {
  height: 40% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  padding: 3px 5px 4px !important;
  box-sizing: border-box !important;
  position: relative !important;
}

/* ─── BATTLE SCREEN ─── */
.battle-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background: radial-gradient(ellipse at center, rgba(74,14,143,0.2) 0%, var(--bg-void) 70%);
}

.battle-arena {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  min-height: 60vh;
}

.battle-phase { display: none; flex-direction: column; align-items: center; gap: 20px; width: 100%; }

/* Boss display */
#boss-display {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.boss-display-art {
  width: 200px; height: 200px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(123,47,255,0.2) 0%, transparent 70%);
  border: 2px solid var(--border);
  border-radius: 50%;
  font-size: 100px;
  filter: drop-shadow(0 0 30px rgba(123,47,255,0.4));
  transition: all 0.3s ease;
}
.boss-display-name {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700;
  color: var(--text);
}
.boss-display-power {
  font-size: 14px; color: var(--text-muted);
}

.boss--shaking { animation: bossShake 0.5s ease; }
@keyframes bossShake {
  0%,100%{ transform: translateX(0); }
  20%    { transform: translateX(-10px) rotate(-3deg); }
  40%    { transform: translateX(10px) rotate(3deg); }
  60%    { transform: translateX(-8px) rotate(-2deg); }
  80%    { transform: translateX(8px) rotate(2deg); }
}
.boss--defeated { animation: bossDefeated 0.5s ease; }
@keyframes bossDefeated {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.1); filter: brightness(2) hue-rotate(120deg); }
  100% { transform: scale(0.8) rotate(10deg); filter: brightness(0.5); }
}

/* Battle flash */
.battle-flash {
  position: fixed; inset: 0; z-index: 999;
  pointer-events: none; opacity: 0;
}
.battle-flash--win  { background: rgba(0,200,100,0.15); }
.battle-flash--lose { background: rgba(224,32,32,0.15); }
@keyframes flashEffect {
  0%  { opacity: 0; }
  30% { opacity: 1; }
  100%{ opacity: 0; }
}

/* Flying cards */
#flying-cards {
  display: flex; gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0;
}
.flying-card {
  width: clamp(24px, 4vw, 42px); border-radius: 8px; overflow: hidden;
  opacity: 0; transform: translateY(40px) scale(0.8);
  transition: all 0.4s ease;
  border: 1px solid var(--border-gold);
  animation: cardAppear 0.3s ease forwards;
}
@keyframes cardAppear {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.flying-card--launched {
  transform: translateX(200px) translateY(-60px) rotate(15deg) scale(0.6) !important;
  opacity: 0 !important;
  transition: all 0.5s ease !important;
}
.flying-card__rarity-bar { height: 2px; }
.flying-card__art {
  height: 60px; display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.flying-card__name { padding: 4px; font-size: 8px; font-family: var(--font-display); color: var(--gold); text-align: center; }

.flying-card--common    .flying-card__rarity-bar { background: #949494; }
.flying-card--uncommon  .flying-card__rarity-bar { background: #00c864; }
.flying-card--rare      .flying-card__rarity-bar { background: #0082ff; }
.flying-card--epic      .flying-card__rarity-bar { background: #8c00ff; }
.flying-card--legendary .flying-card__rarity-bar { background: linear-gradient(90deg,#ffa500,#ffdd00); }
.flying-card--mythic    .flying-card__rarity-bar { background: linear-gradient(90deg,#ff1464,#ff6b00); }

/* Battle result */
#battle-phase-result { text-align: center; }
.battle-result-text {
  font-family: var(--font-display);
  font-size: clamp(40px, 10vw, 80px);
  font-weight: 900;
  letter-spacing: 0.1em;
  animation: resultPop 0.5s ease;
}
.battle-result-text--win  { color: var(--green); text-shadow: 0 0 40px rgba(0,200,100,0.5); }
.battle-result-text--lose { color: var(--red); text-shadow: 0 0 40px var(--red-glow); }
@keyframes resultPop {
  0%  { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100%{ transform: scale(1); opacity: 1; }
}

.battle-rewards {
  display: flex; gap: 16px; justify-content: center;
  flex-wrap: wrap; margin: 20px 0;
}
.reward-badge {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 100px;
}
.reward-badge__icon { font-size: 24px; }
.reward-badge__val {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
}
.reward-badge__label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.1em; }
.reward-badge--dark   { border-color: var(--border-gold); }
.reward-badge--dark .reward-badge__val { color: var(--gold); }
.reward-badge--exp    { border-color: rgba(123,47,255,0.4); }
.reward-badge--exp .reward-badge__val { color: var(--purple); }
.reward-badge--box { border-color: var(--border-gold); animation: boxBounce 0.6s ease 0.5s both; }
@keyframes boxBounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  80%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.battle-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ─── SHOP ─── */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

/* Opened cards reveal — also used by battle-ui.js box-open flow */
.opened-card {
  background: linear-gradient(145deg, #1a0533, #0d0220);
  border-radius: 10px; overflow: hidden;
  animation: cardReveal 0.4s ease both;
  border: 1px solid var(--border-gold);
}
@keyframes cardReveal {
  0%   { opacity:0; transform:scale(0.3) rotateY(180deg); }
  60%  { transform:scale(1.1) rotateY(0deg); }
  100% { opacity:1; transform:scale(1); }
}
.opened-card__rarity-bar { height: 3px; }
.opened-card__art {
  height: 100px; display: flex; align-items: center; justify-content: center;
}
.opened-card__info { padding: 8px 10px; }
.opened-card__name { font-family: var(--font-display); font-size: 10px; color: var(--gold); margin-bottom: 3px; }
.opened-card__rarity-text { font-size: 9px; font-weight: 700; margin-bottom: 3px; }
.opened-card__power { font-size: 11px; color: var(--text-muted); }

.opened-card--common    .opened-card__rarity-bar { background: #949494; }
.opened-card--uncommon  .opened-card__rarity-bar { background: #00c864; }
.opened-card--rare      .opened-card__rarity-bar { background: #0082ff; }
.opened-card--epic      .opened-card__rarity-bar { background: #8c00ff; }
.opened-card--legendary .opened-card__rarity-bar { background: linear-gradient(90deg,#ffa500,#ffdd00); }
.opened-card--mythic    .opened-card__rarity-bar { background: linear-gradient(90deg,#ff1464,#ff6b00); }

/* ─── SHOP TABS ─── */
.shop-tabs {
  display: flex; gap: 2px;
  padding: 0 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.shop-tab {
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.shop-tab:hover { color: var(--text); }
.shop-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.shop-section.hidden { display: none; }

/* ─── BOX SHOP GRID ─── */
.boxes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 8px 0;
  align-items: stretch;
}

.box-shop-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(123,47,255,0.2);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.box-shop-card:hover {
  border-color: rgba(212,168,67,0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.box-art-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}
.box-art-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--glow,rgba(123,47,255,0.3)), transparent 70%);
  pointer-events: none;
  animation: glowPulse 3s ease-in-out infinite;
}
.box-art-img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.6));
  transition: transform 0.3s ease;
}
.box-shop-card:hover .box-art-img { transform: scale(1.1) translateY(-4px); }

.box-art-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.box-fallback-icon { font-size: 64px; opacity: 0.6; }

.box-info {
  padding: 16px 16px 0;
  flex: 1;
}
.box-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.box-desc {
  font-size: 12px;
  color: rgba(232,222,255,0.5);
  margin-bottom: 14px;
  line-height: 1.5;
}

.box-odds {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.box-odd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.box-odd-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.box-odd-name { flex: 1; color: rgba(232,222,255,0.7); }
.box-odd-val {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(232,222,255,0.9);
}

/* Футер — прижат к низу */
.box-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid rgba(123,47,255,0.15);
  margin-top: 16px;
  background: rgba(0,0,0,0.2);
}
.box-price {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.box-price__icon { width: 18px; height: 18px; object-fit: contain; }
.box-price__amount {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #d4a843;
  line-height: 1;
}
.box-price__currency {
  font-size: 11px;
  color: rgba(232,222,255,0.5);
  font-weight: 600;
}
.box-buy-btn {
  padding: 10px 20px;
  min-height: 44px;
  background: linear-gradient(135deg, #7b2fff, #4a0e8f);
  border: 1px solid #7b2fff;
  border-radius: 8px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.box-buy-btn:hover {
  background: linear-gradient(135deg, #9146ff, #6020c0);
  box-shadow: 0 0 20px rgba(123,47,255,0.4);
  transform: translateY(-1px);
}

/* My boxes */
.my-boxes-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 0;
}
.my-box-item {
  width: 140px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(123,47,255,0.3);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.my-box-item:hover {
  transform: translateY(-4px);
  border-color: #d4a843;
  box-shadow: 0 8px 24px rgba(212,168,67,0.2);
}
.my-box-img {
  width: clamp(24px, 4vw, 42px); height: 80px;
  object-fit: contain;
  margin: 0 auto 10px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}
.my-box-name {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  color: #d4a843;
  margin-bottom: 4px;
}
.my-box-hint {
  font-size: 10px;
  color: rgba(232,222,255,0.35);
  letter-spacing: 0.05em;
}

/* Box-open modal */
.box-open-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.box-open-modal.hidden { display: none; }
.box-open-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
}
.box-open-content {
  position: relative;
  z-index: 1;
  width: 360px;
  min-height: 480px;
  background: linear-gradient(145deg,#1a0533,#0d0220);
  border: 1px solid rgba(123,47,255,0.5);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  overflow: hidden;
}
.box-open-stage { position: relative; }
.box-open-stage.hidden { display: none; }
.box-open-glow {
  position: absolute;
  inset: -20px;
  pointer-events: none;
  animation: glowPulse 2s ease-in-out infinite;
}
.box-open-img {
  width: 180px; height: 180px;
  object-fit: contain;
  filter: drop-shadow(0 0 32px rgba(123,47,255,0.6));
  animation: boxFloat 3s ease-in-out infinite;
  position: relative; z-index: 1;
}
.box-open-hint {
  font-size: 13px;
  color: rgba(232,222,255,0.5);
  margin: 16px 0 8px;
}
.box-open-btn {
  padding: 14px 48px;
  background: linear-gradient(135deg,#7b2fff,#4a0e8f);
  border: 1px solid #7b2fff;
  border-radius: 10px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 24px rgba(123,47,255,0.4);
}
.box-open-btn:hover {
  background: linear-gradient(135deg,#9146ff,#6020c0);
  box-shadow: 0 0 40px rgba(123,47,255,0.7);
  transform: scale(1.05);
}

/* Result */
.box-result { position: relative; }
.box-result.hidden { display: none; }
.result-glow {
  position: absolute;
  inset: -40px;
  pointer-events: none;
  animation: glowPulse 1.5s ease-in-out infinite;
}
.result-card {
  width: 180px;
  margin: 0 auto 16px;
  background: linear-gradient(145deg,#1a0533,#0d0220);
  border: 2px solid;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  opacity: 0;
}
.result-rarity-bar { height: 4px; width: 100%; }
.result-card-art {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: top;
  display: block;
  min-height: 120px;
  background: linear-gradient(135deg,#1a0533,#4a0e8f);
}
.result-card-body { padding: 10px; }
.result-rarity {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}
.result-name {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: #d4a843;
  margin-bottom: 4px;
}
.result-power { font-size: 11px; color: rgba(232,222,255,0.6); }

.result-label {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  position: relative; z-index: 1;
}
.btn-result {
  padding: 12px 40px;
  background: linear-gradient(135deg,#7b2fff,#4a0e8f);
  border: 1px solid #7b2fff;
  border-radius: 10px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  position: relative; z-index: 1;
}
.result-actions { position: relative; z-index: 1; }

/* Box-open animations */
@keyframes boxFloat {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-14px) rotate(2deg); }
}
@keyframes damageFloat {
  0%   { opacity:1; transform:translate(-50%,0) scale(1.4); }
  100% { opacity:0; transform:translate(-50%,-70px) scale(0.7); }
}
@keyframes boxShake {
  0%,100% { transform: rotate(0deg); }
  20%     { transform: rotate(-8deg) scale(1.05); }
  40%     { transform: rotate(8deg) scale(1.05); }
  60%     { transform: rotate(-5deg); }
  80%     { transform: rotate(5deg); }
}
@keyframes flashOut {
  0%   { opacity: 0.8; }
  100% { opacity: 0; }
}
@keyframes cardReveal2 {
  0%   { opacity:0; transform:scale(0.5) rotateY(90deg); }
  60%  { transform:scale(1.1) rotateY(0deg); }
  100% { opacity:1; transform:scale(1) rotateY(0deg); }
}
@keyframes glowPulse {
  0%,100% { opacity:0.5; }
  50%     { opacity:1; }
}

/* ─── LEADERBOARD ─── */
.leaderboard-tabs {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.lb-tab {
  padding: 8px 18px;
  font-family: var(--font-display); font-size: 10px; letter-spacing: 0.15em;
  border: 1px solid var(--border); border-radius: 20px;
  color: var(--text-muted); transition: all var(--transition);
  background: none;
}
.lb-tab:hover { border-color: var(--purple); color: var(--purple); }
.lb-tab.active { background: var(--purple); color: #fff; border-color: var(--purple); }

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th {
  padding: 10px 14px;
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.2em;
  color: var(--gold); border-bottom: 1px solid var(--border);
  text-align: left; font-weight: 600;
}
.leaderboard-table td {
  padding: 12px 14px; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.leaderboard-table tr:hover td { background: rgba(255,255,255,0.02); }
.leaderboard-table tr:nth-child(1) td { color: var(--gold); }
.leaderboard-table tr:nth-child(2) td { color: #c0c0c0; }
.leaderboard-table tr:nth-child(3) td { color: #cd7f32; }

.lb-rank { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.lb-wallet { font-size: 11px; color: var(--text-dim); }
.lb-value { font-family: var(--font-display); font-weight: 700; color: var(--gold); }

/* ─── PROFILE ─── */
.profile-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  display: flex; gap: 24px; align-items: flex-start;
  flex-wrap: wrap;
}
.profile-avatar {
  width: clamp(24px, 4vw, 42px); height: 80px;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  border: 2px solid var(--purple);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; flex-shrink: 0;
}
.profile-info { flex: 1; }
.profile-name {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  color: var(--text); margin-bottom: 4px;
}
.profile-wallet { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.profile-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.profile-stat { text-align: center; }
.profile-stat__val {
  display: block; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--gold);
}
.profile-stat__label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.1em; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.profile-panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.profile-panel__title {
  font-family: var(--font-display); font-size: 10px; letter-spacing: 0.2em;
  color: var(--gold); margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* History items */
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.history-item__result {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  padding: 4px 8px; border-radius: 4px;
  flex-shrink: 0;
}
.history-item__result--win { background: rgba(0,200,100,0.15); color: var(--green); }
.history-item__result--lose { background: rgba(224,32,32,0.1); color: var(--red); }
.history-item__info { flex: 1; }
.history-item__boss { color: var(--text); font-weight: 600; }
.history-item__meta { color: var(--text-muted); font-size: 10px; }
.history-item__reward { color: var(--gold); font-family: var(--font-display); font-weight: 700; }

/* ─── EMPTY STATES ─── */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state__icon { font-size: 64px; opacity: 0.4; margin-bottom: 16px; }
.empty-state__title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 8px;
}
.empty-state__desc { font-size: 13px; color: var(--text-dim); }

/* ─── CONNECT WALL ─── */
.connect-wall {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(74,14,143,0.25) 0%, var(--bg-void) 70%);
  padding: 20px;
}
.connect-card {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
}
.connect-card__logo {
  margin-bottom: 16px;
  color: var(--purple);
  filter: drop-shadow(0 0 20px rgba(123,47,255,0.4));
}
.connect-card__logo .icon-svg { width: 56px; height: 56px; margin: 0; }
.connect-card__title {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.connect-card__desc { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }
.connect-card__wallets { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.wallet-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: all var(--transition);
  cursor: pointer;
}
.wallet-btn:hover { border-color: var(--purple); box-shadow: 0 0 16px var(--purple-dim); }
.wallet-btn__icon { display: inline-flex; }
.wallet-btn__icon .icon-svg { width: 22px; height: 22px; margin: 0; }
.wallet-btn__name { flex: 1; text-align: left; }
.wallet-btn__badge {
  font-size: 9px; padding: 2px 8px;
  background: rgba(0,200,100,0.15);
  color: var(--green);
  border-radius: 10px;
  letter-spacing: 0.1em;
}
.connect-card__note { font-size: 11px; color: var(--text-dim); }

/* ── UPGRADE BUTTON STATES ── */
.upgrade-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s ease;
  border: 1px solid;
  margin-top: 6px;
}
.upgrade-btn__label { font-size: 11px; }
.upgrade-btn__exp,
.upgrade-btn__cost  { font-size: 9px; font-weight: 400; opacity: 0.8; }

.upgrade-btn--locked {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
  color: rgba(232,222,255,0.25);
  cursor: not-allowed;
}
.upgrade-btn--locked .upgrade-btn__exp { color: rgba(123,47,255,0.5); opacity: 1; }

.upgrade-btn--no-dark {
  background: rgba(212,168,67,0.05);
  border-color: rgba(212,168,67,0.2);
  color: rgba(212,168,67,0.4);
  cursor: not-allowed;
}
.upgrade-btn--no-dark .upgrade-btn__cost { color: rgba(224,32,32,0.6); opacity: 1; }

.upgrade-btn--ready {
  background: linear-gradient(135deg, rgba(0,200,100,0.15), rgba(0,200,100,0.05));
  border-color: #00c864;
  color: #00c864;
  cursor: pointer;
  animation: upgradePulse 2s ease-in-out infinite;
}
.upgrade-btn--ready:hover {
  background: linear-gradient(135deg, rgba(0,200,100,0.3), rgba(0,200,100,0.1));
  box-shadow: 0 0 20px rgba(0,200,100,0.4);
  transform: translateY(-1px);
}
.upgrade-btn--ready .upgrade-btn__cost { color: var(--gold); opacity: 1; }

@keyframes upgradePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,200,100,0.3); }
  50%       { box-shadow: 0 0 20px rgba(0,200,100,0.6); }
}

.upgrade-btn--maxed {
  background: rgba(212,168,67,0.08);
  border-color: rgba(212,168,67,0.3);
  color: var(--gold);
  cursor: default;
  letter-spacing: 0.15em;
}

/* ── TYPOGRAPHY IMPROVEMENTS ── */
/* Energy bar in collection */
.card-energy-bar__label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(232,222,255,0.7);
}
.card-energy-bar__timer {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}
/* Upgrade locked — more readable */
.upgrade-btn--locked {
  color: rgba(232,222,255,0.35);
}
.upgrade-btn--locked .upgrade-btn__exp {
  font-size: 10px;
  color: rgba(123,47,255,0.65);
  font-weight: 600;
  opacity: 1;
}
/* Section titles */
.section-title {
  font-size: 22px;
}
.section-sub {
  font-size: 13px;
  color: rgba(232,222,255,0.6);
}

/* ─── PARTICLES (CSS) ─── */
@keyframes particleBurst {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.modal__title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--gold); margin-bottom: 20px;
}

/* ─── BATTLE HEADER ───────────────────────────────────── */

.battle-header {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  align-items: center !important;
  padding: 10px 16px !important;
  min-height: 76px !important;
  height: auto !important;
  flex-shrink: 0 !important;
  background: rgba(5,3,8,0.95) !important;
  border-bottom: 1px solid rgba(123,47,255,0.2) !important;
  backdrop-filter: blur(8px) !important;
  z-index: 10 !important;
  position: relative !important;
  overflow: visible !important;
  gap: 8px !important;
}

.bh-player {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  justify-content: flex-start !important;
}

.bh-center {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 1px !important;
  flex-shrink: 0 !important;
  padding: 0 8px !important;
}

.bh-boss {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  justify-content: flex-end !important;
}

.bh-info {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  min-width: 0 !important;
}

.bh-name {
  font-family: 'Cinzel', serif !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #e8deff !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 160px !important;
}

.bh-hp-wrap {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
  flex-wrap: nowrap !important;
}
.bh-hp-bar {
  width: 120px !important;
  height: 6px !important;
  background: rgba(255,255,255,0.1) !important;
  border-radius: 3px !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
}
.bh-hp-text {
  font-size: 10px !important;
  display: block !important;
  color: rgba(232,222,255,0.5) !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.bh-turn-label {
  font-size: 8px !important;
  letter-spacing: 0.2em !important;
  color: rgba(232,222,255,0.4) !important;
  font-family: 'Cinzel', serif !important;
}
.bh-turn-num {
  font-family: 'Cinzel', serif !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  color: #d4a843 !important;
  line-height: 1 !important;
}
.bh-timer {
  font-family: 'Cinzel', serif !important;
  font-size: 13px !important;
  color: rgba(232,222,255,0.6) !important;
}
.bh-diff {
  font-size: 10px !important;
  letter-spacing: 0.15em !important;
  font-family: 'Cinzel', serif !important;
}

.bh-avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  border: 1px solid rgba(123,47,255,0.4) !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  background: rgba(5,3,8,0.8) !important;
}
.bh-boss-avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
}

@media (max-width: 600px) {
  .battle-header {
    padding: 6px 10px !important;
    min-height: 48px !important;
    gap: 6px !important;
  }
  .bh-name         { max-width: 80px !important; font-size: 10px !important; }
  .bh-hp-bar       { width: 70px !important; }
  .bh-hp-text      { display: none !important; }
  .bh-turn-num     { font-size: 18px !important; }
  .bh-avatar,
  .bh-boss-avatar  { width: 30px !important; height: 30px !important; }
}

/* ─── RESPONSIVE ─── */

/* ══════════════════════════════════
   SHOP — планшет 769px – 1024px
══════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  .boxes-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .box-footer { flex-direction: column; align-items: center; gap: 10px; }
  .box-price  { justify-content: center; }
  .box-price__amount { font-size: 14px; }
  .box-buy-btn {
    width: 100%;
    max-width: 200px;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
  }
  .box-info { padding: 12px 12px 0; }
}

/* ══════════════════════════════════
   GAME — 768px и меньше
══════════════════════════════════ */
@media (max-width: 768px) {

  /* HEADER (play.html) */
  .game-header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
    height: auto;
    min-height: 56px;
  }
  .game-header-right { gap: 6px; flex-wrap: wrap; }
  .header-stat { padding: 4px 8px; font-size: 11px; gap: 4px; }
  .header-username { display: none; }
  .game-header__stats { gap: 6px; }
  .stat-pill { padding: 4px 8px; font-size: 11px; }
  .stat-pill--wallet { display: none; }
  .game-main { padding: 12px; }

  /* ТАБЫ */
  .game-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 12px;
    gap: 0;
  }
  .game-tabs::-webkit-scrollbar { display: none; }
  .game-tab { font-size: 10px; padding: 10px 14px; white-space: nowrap; flex-shrink: 0; }

  /* БОССЫ */
  .bosses-scroll-wrap, .cards-scroll-wrap { margin: 0 -12px; padding: 0 12px; }
  .bosses-scroll-track { padding: 12px 16px 20px; gap: 12px; }
  .boss-card-game { flex: 0 0 200px; }
  .boss-card-game__name { font-size: 14px; }

  /* КАРТЫ */
  .cards-scroll-track { padding: 12px 16px 16px; gap: 10px; }
  .cards-scroll-track .player-card { flex: 0 0 120px; }
  .cards-scroll-track .game-card { flex: 0 0 110px; }
  .cards-grid-game { grid-template-columns: repeat(2, 1fr); }

  /* МОДАЛ КОЛОДЫ */
  .deck-builder-modal .modal-content {
    width: calc(100vw - 24px);
    max-height: 90vh;
    padding: 16px;
    overflow-y: auto;
  }
  .modal { width: calc(100vw - 32px); padding: 20px 16px; }
  .mini-card-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .mini-card {
    font-size: 9px;
    width: 100% !important;
  }

  /* ПРОЧИЕ */
  .profile-grid { grid-template-columns: 1fr; }
  .battle-rewards { gap: 10px; }
  .leaderboard-table { font-size: 11px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
  .leaderboard-table th, .leaderboard-table td { padding: 8px; white-space: nowrap; }
  .connect-card { padding: 32px 24px; }

  /* BATTLE — layout */
  .battle-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* BATTLE — поле */
  .battlefield {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 0;
    overflow: hidden;
    position: relative;
  }

  /* Обёртка слайдера */
  .field-row-wrap,
  .hand-wrap {
    width: 100%;
    overflow: hidden;
    position: relative;
  }

  /* Слайдер — горизонтальная прокрутка */
  .field-row,
  .hand-cards {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: scroll !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x mandatory !important;
    scroll-behavior: smooth !important;
    scrollbar-width: none !important;
    padding: 8px 16px !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 160px !important;
    align-items: center !important;
    justify-content: flex-start !important;
    cursor: grab;
  }
  .field-row:active,
  .hand-cards:active { cursor: grabbing; }
  .field-row::-webkit-scrollbar,
  .hand-cards::-webkit-scrollbar { display: none !important; }

  /* Карта — фиксированная ширина, не сжимается */
  .battle-card {
    flex: 0 0 120px !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    height: auto !important;
    scroll-snap-align: start !important;
    cursor: pointer !important;
    border-radius: 10px !important;
    overflow: visible !important;
    touch-action: pan-x;
  }
  .card-art,
  .card-art-img {
    width: 100% !important;
    height: 85px !important;
    object-fit: cover !important;
    object-position: top !important;
  }

  /* Карта в руке чуть меньше */
  .hand-cards .battle-card {
    flex: 0 0 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
  }
  .battle-card:last-child { margin-right: 16px !important; }

  /* Статы карты */
  .card-mana { width: 24px !important; height: 24px !important; font-size: 11px !important; top: 4px !important; left: 4px !important; }
  .card-atk  { width: 22px !important; height: 22px !important; font-size: 11px !important; bottom: 4px !important; left: 4px !important; }
  .card-hp   { width: 22px !important; height: 22px !important; font-size: 11px !important; bottom: 4px !important; right: 4px !important; }
  .card-name-overlay { font-size: 8px !important; }
  .card-footer       { padding: 4px 6px !important; }
  .card-type         { font-size: 8px !important; }

  /* Бейджи spell/artifact */
  .battle-card.hand.spell-card::after,
  .battle-card.hand.artifact-card::after {
    font-size: 6px;
    padding: 1px 4px;
    top: 4px;
    right: 4px;
  }

  /* END TURN */
  .end-turn-btn {
    width: 70px !important;
    height: 70px !important;
    font-size: 10px !important;
    flex-shrink: 0 !important;
  }

  /* AUTO */
  .auto-btn {
    padding: 8px 14px !important;
    font-size: 11px !important;
    height: 40px !important;
  }

  /* Свайп-индикатор */
  .field-row-wrap::after {
    content: '›';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: rgba(123,47,255,0.6);
    pointer-events: none;
    animation: swipeHint 1.5s ease-in-out 2;
  }
  @keyframes swipeHint {
    0%, 100% { opacity: 0.3; right: 4px; }
    50%       { opacity: 0.8; right: 0px; }
  }

  /* Числа урона */
  .damage-number { font-size: 28px !important; }

  /* Оверлей результата */
  .battle-result-overlay { padding: 24px 20px; }
  .result-title  { font-size: 36px; }
  .result-reward { font-size: 20px; }
  .result-btn    { padding: 14px 32px; font-size: 13px; }

  /* SHOP */
  .boxes-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .box-shop-card { border-radius: 12px; }
  .box-name { font-size: 12px; }
  .box-desc { font-size: 11px; }
  .box-odd-row { font-size: 10px; }
  .box-footer { flex-direction: column; align-items: center; gap: 8px; }
  .box-price { justify-content: center; }
  .box-price__amount { font-size: 15px; }
  .box-buy-btn { width: 100%; max-width: 220px; padding: 8px 12px; font-size: 13px; }
  .box-open-content { width: calc(100vw - 24px); padding: 24px 16px; }
  .box-open-img { width: 120px; height: 120px; }
  .result-card  { width: 140px; }
  .my-boxes-grid { gap: 10px; }
  .my-box-item  { width: 110px; padding: 12px; }
  .my-box-img   { width: 60px; height: 60px; }

  /* COLLECTION */
  .collection-filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; gap: 6px; }
  .filter-btn   { white-space: nowrap; flex-shrink: 0; padding: 6px 14px; font-size: 10px; }
  .collection-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .fusion-section { padding: 16px; }
  .fusion-cards-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

/* ══════════════════════════════════
   GAME — 480px и меньше
══════════════════════════════════ */
@media (max-width: 480px) {

  /* ── МОДАЛ ВЫБОРА КОЛОДЫ ── */
  .deck-builder-modal {
    padding: 0 !important;
  }
  .deck-builder-content {
    width: 100% !important;
    max-height: 100svh !important;
    border-radius: 0 !important;
    padding: 14px !important;
  }
  .deck-builder-header { margin-bottom: 10px !important; }

  /* Сетка — 2 колонки */
  .mini-card-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Мини-карточка */
  .mini-card__info   { padding: 4px 6px !important; }
  .mini-card__name   { font-size: 9px !important; }
  .mini-card__rarity { font-size: 7px !important; }
  .mini-card__energy { padding: 3px 6px 4px !important; }
  .energy-dot { width: 5px !important; height: 5px !important; }
  .mini-card__timer  { font-size: 11px !important; }

  /* ── БОССЫ В ИГРЕ ── */
  .boss-card-game { flex: 0 0 168px !important; }

  /* ── PLAY.HTML ТАБЫ ── */
  .game-tabs {
    overflow-x: auto !important;
    scrollbar-width: none !important;
    gap: 0 !important;
    padding: 0 !important;
  }
  .game-tabs::-webkit-scrollbar { display: none !important; }
  .game-tab {
    font-size: 10px !important;
    padding: 10px 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* ── БОЙ (battle-screen — для будущих страниц) ── */
  .battle-screen {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }
  .field-row--enemy,
  .field-row--player {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x mandatory !important;
    scrollbar-width: none !important;
    gap: 8px !important;
    padding: 8px 12px 12px !important;
    min-height: 120px !important;
    align-items: flex-start !important;
  }
  .field-row--enemy::-webkit-scrollbar,
  .field-row--player::-webkit-scrollbar { display: none !important; }
  .field-row .battle-card {
    flex: 0 0 90px !important;
    width: 90px !important;
    aspect-ratio: 3 / 4 !important;
    height: auto !important;
    scroll-snap-align: start !important;
    overflow: visible !important;
  }
  .hand-area {
    flex-shrink: 0 !important;
    min-height: 90px !important;
    max-height: 100px !important;
  }
  .hand-cards {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    gap: 8px !important;
  }
  .hand-cards::-webkit-scrollbar { display: none !important; }
  .hand-cards .battle-card {
    flex: 0 0 72px !important;
    width: 72px !important;
    aspect-ratio: 3 / 4 !important;
    height: auto !important;
    scroll-snap-align: start !important;
  }
  .end-turn-btn {
    width: 60px !important;
    height: 60px !important;
    font-size: 9px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
  }
  .auto-btn {
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 9px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  .spells-status { display: none !important; }
  .mana-crystals { display: none !important; }
  .mana-text     { font-size: 10px !important; }

  /* ── SHOP ── */
  .boxes-grid { grid-template-columns: 1fr !important; }
  .box-footer { flex-direction: column; gap: 8px; align-items: stretch; }
  .box-buy-btn { width: 100%; text-align: center; }

  /* ── COLLECTION ── */
  .collection-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .fusion-cards-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ══════════════════════════════════
   VISUAL POLISH & RESPONSIVE SAFETY
══════════════════════════════════ */
:where(button, a, [role="button"]):focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

.btn,
.btn-clear-deck,
.btn-cancel,
.btn-go-battle,
.boss-fight-btn,
.diff-btn,
.upgrade-btn,
.box-buy-btn {
  min-height: 44px;
  line-height: 1.2;
}

.btn,
.btn-clear-deck,
.btn-cancel,
.btn-go-battle,
.boss-fight-btn,
.diff-btn,
.box-buy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.deck-modal__cards {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-items: start;
  padding: 4px 4px 16px;
}

.deck-pick-card {
  min-width: 0;
  height: 100%;
}

.deck-pick-card--selected {
  transform: translateY(-2px) !important;
}

.deck-modal__footer {
  position: relative;
  z-index: 3;
}

@media (max-width: 768px) {
  .game-header-logo__title { display: none; }
  .game-header {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
  }
  .game-header__stats {
    min-width: 0;
    margin-left: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .balance-display {
    min-width: 0;
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .game-header__actions {
    grid-column: 1 / -1;
    width: 100%;
  }
  .game-header__actions .btn { flex: 1; }
  .game-main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

  .deck-modal {
    align-items: stretch;
    padding-top: env(safe-area-inset-top);
  }
  .deck-modal__content {
    max-height: 100dvh;
    border-radius: 0;
  }
  .deck-modal__header { padding: 14px 16px 12px; gap: 12px; }
  .deck-modal__title { font-size: 15px; line-height: 1.3; }
  .deck-modal__subtitle { font-size: 11px; line-height: 1.5; }
  .deck-modal__cards-wrap { padding: 10px 12px; }
  .deck-modal__cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .deck-modal__footer {
    padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  }
  .deck-modal__stats {
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
  }
  .deck-modal__actions { display: grid; grid-template-columns: auto 1fr 2fr; }
  .btn-clear-deck,
  .btn-cancel,
  .btn-go-battle { width: 100%; padding: 10px 12px; }

  .shop-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .shop-tabs::-webkit-scrollbar { display: none; }
  .shop-tab { flex: 0 0 auto; white-space: nowrap; }
}

@media (max-width: 599px) {
  .deck-modal__cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .deck-pick-card__info { padding: 8px; }
  .deck-pick-card__name { font-size: 9px; }
  .deck-pick-card__meta { font-size: 7px; }
  .deck-modal__actions { grid-template-columns: 1fr 1fr; }
  .btn-go-battle { grid-column: 1 / -1; grid-row: 1; }
  .btn-clear-deck, .btn-cancel { grid-row: 2; }
}

@media (max-width: 380px) {
  .game-header { padding-inline: 10px; }
  .game-header-logo__icon { width: 28px; height: 28px; }
  .balance-display { font-size: 11px; padding-inline: 8px; }
  .stat-pill--level { padding-inline: 7px; }
  .game-tabs { scroll-snap-type: x proximity; }
  .game-tab { scroll-snap-align: start; }
  .deck-modal__cards { gap: 8px; }
  .deck-modal__stats span { display:flex; flex-direction:column; gap:1px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════
   DECK BUILDER RESPONSIVE RAIL
══════════════════════════════════ */
:root {
  --deck-card-w-desktop: 170px;
  --deck-card-w-tablet: 145px;
  --deck-card-w-mobile: 132px;
  --deck-card-w-landscape: 112px;
}

.deck-modal__content {
  max-height: 92vh;
}

.deck-modal__cards-wrap {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.deck-modal__cards {
  grid-template-columns: repeat(auto-fill, var(--deck-card-w-desktop));
  justify-content: center;
  overflow-x: auto;
  overflow-y: auto;
  min-height: 0;
  max-height: 100%;
  scroll-padding-inline: 4px;
}

.deck-pick-card {
  min-width: 0;
  max-width: none;
  height: auto;
  align-self: start;
}

@media (min-width: 600px) and (max-width: 1024px) {
  .deck-modal__cards {
    grid-template-columns: repeat(auto-fill, var(--deck-card-w-tablet));
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .deck-modal__cards {
    grid-template-columns: repeat(2, var(--deck-card-w-mobile));
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .deck-modal {
    align-items: center;
    padding: 0;
    touch-action: auto;
  }

  .deck-modal__content {
    width: calc(100% - 16px);
    max-width: none;
    height: auto;
    max-height: 92vh;
    border-radius: 12px;
    overflow: visible;
  }

  .deck-modal__header {
    min-height: 0;
    padding: 6px 10px 5px;
    align-items: center;
  }
  .deck-modal__title {
    font-size: 12px;
    line-height: 1.15;
    margin-bottom: 2px;
  }
  .deck-modal__subtitle {
    font-size: 9px;
    line-height: 1.2;
    white-space: nowrap;
  }
  .deck-modal__close {
    width: 30px;
    height: 30px;
    min-height: 30px;
    font-size: 16px;
  }

  .deck-modal__cards-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: 5px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    pointer-events: auto;
  }

  .deck-modal__cards {
    display: flex;
    flex-flow: row nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    width: max-content;
    min-width: max-content;
    max-width: none;
    height: auto;
    max-height: none;
    padding: 2px 8px 5px 2px;
    overflow: visible;
    scroll-snap-type: x proximity;
    touch-action: pan-x;
  }

  .deck-pick-card {
    flex: 0 0 var(--deck-card-w-landscape);
    width: var(--deck-card-w-landscape);
    min-width: var(--deck-card-w-landscape);
    max-width: var(--deck-card-w-landscape);
    height: auto;
    scroll-snap-align: start;
    border-radius: 9px;
  }
  .deck-pick-card:hover:not(.deck-pick-card--exhausted),
  .deck-pick-card--selected {
    transform: none !important;
  }
  .deck-pick-card__info {
    padding: 4px 6px 5px;
  }
  .deck-pick-card__name {
    margin-bottom: 1px;
    font-size: 8px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .deck-pick-card__meta {
    margin-bottom: 2px;
    font-size: 6px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .deck-pick-card__power {
    margin-bottom: 2px;
    font-size: 8px;
    line-height: 1.1;
  }
  .deck-pick-card__stats {
    margin-bottom: 2px;
    line-height: 1;
  }
  .stat-atk,
  .stat-hp {
    font-size: 7px;
  }
  .deck-pick-card__energy {
    gap: 1px;
  }
  .ep-dot {
    width: 3px;
    height: 3px;
  }
  .deck-pick-card__mana,
  .deck-pick-card__check {
    width: 17px;
    height: 17px;
    min-height: 17px;
    font-size: 8px;
  }

  .deck-modal__footer {
    position: static;
    padding: 5px 10px 7px;
  }
  .deck-modal__stats {
    margin-bottom: 3px;
    gap: 14px;
    justify-content: flex-start;
    font-size: 9px;
    line-height: 1.1;
  }
  .deck-modal__stats span {
    display: inline;
  }
  .deck-modal__bar {
    height: 3px;
    margin-bottom: 5px;
  }
  .deck-modal__actions {
    display: flex;
    gap: 6px;
  }
  .btn-clear-deck,
  .btn-cancel,
  .btn-go-battle {
    grid-column: auto;
    grid-row: auto;
    width: auto;
    min-width: 0;
    min-height: 30px;
    padding: 5px 10px;
    font-size: 9px;
    line-height: 1;
  }
  .btn-clear-deck { flex: 0 1 auto; }
  .btn-cancel { flex: 1; }
  .btn-go-battle { flex: 2; }
}

/* ══════════════════════════════════
   BOSS CARDS RESPONSIVE SCALE
══════════════════════════════════ */
:root {
  --boss-card-width-desktop: 240px;
  --boss-card-width-tablet: 220px;
  --boss-card-width-mobile: clamp(260px, 82vw, 330px);
  --boss-card-width-landscape: clamp(160px, 22vw, 210px);
  --boss-card-gap-desktop: 16px;
  --boss-card-gap-mobile: 12px;
  --boss-card-gap-landscape: 10px;
}

.boss-card-game {
  flex-basis: var(--boss-card-width-desktop);
}

.bosses-scroll-track {
  gap: var(--boss-card-gap-desktop);
}

@media (min-width: 600px) and (max-width: 1024px) {
  .boss-card-game {
    flex-basis: var(--boss-card-width-tablet);
  }
  .boss-card-game__body {
    padding: 11px 14px 14px;
    gap: 9px;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .bosses-scroll-wrap {
    margin-inline: -12px;
    padding-inline: 0;
  }
  .bosses-scroll-wrap::before,
  .bosses-scroll-wrap::after {
    display: none;
  }
  .bosses-scroll-track {
    gap: var(--boss-card-gap-mobile);
    padding: 10px 16px 22px;
    scroll-padding-inline: 16px;
    scroll-snap-type: x mandatory;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
  }
  .boss-card-game,
  .boss-card-game:nth-child(n) {
    flex: 0 0 var(--boss-card-width-mobile) !important;
    width: var(--boss-card-width-mobile);
    max-width: var(--boss-card-width-mobile);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    border-radius: 14px;
  }
  .boss-card-game__art {
    object-fit: contain;
    object-position: center top;
    background: #090510;
  }
  .boss-card-game__body {
    padding: 11px 14px 14px;
    gap: 9px;
  }
  .boss-card-game__name {
    font-size: 15px;
  }
  .diff-btn {
    min-height: 44px;
    padding: 7px 3px;
  }
  .boss-fight-btn,
  .boss-fight-btn--placeholder {
    min-height: 44px;
    padding: 10px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .bosses-scroll-wrap {
    margin-inline: -12px;
    padding-inline: 0;
  }
  .bosses-scroll-wrap::before,
  .bosses-scroll-wrap::after {
    display: none;
  }
  .bosses-scroll-track {
    gap: var(--boss-card-gap-landscape);
    padding: 7px max(12px, env(safe-area-inset-left)) 14px;
    scroll-padding-inline: max(12px, env(safe-area-inset-left));
    scroll-snap-type: x proximity;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
  }
  .boss-card-game,
  .boss-card-game:nth-child(n) {
    flex: 0 0 var(--boss-card-width-landscape) !important;
    width: var(--boss-card-width-landscape);
    max-width: var(--boss-card-width-landscape);
    scroll-snap-align: start;
    border-radius: 11px;
  }
  .boss-card-game__art {
    object-fit: contain;
    object-position: center top;
    background: #090510;
  }
  .boss-card-game__tier {
    top: 7px;
    left: 7px;
    padding: 3px 7px;
    font-size: 7px;
  }
  .boss-card-game__body {
    padding: 7px 9px 9px;
    gap: 5px;
  }
  .boss-card-game__name {
    font-size: 12px;
  }
  .boss-card-game__winpct {
    font-size: 8px;
    line-height: 1.25;
  }
  .boss-difficulty-btns {
    gap: 3px;
  }
  .diff-btn {
    min-height: 44px;
    padding: 5px 2px;
    gap: 1px;
    border-radius: 6px;
  }
  .diff-btn__label {
    font-size: 8px;
  }
  .diff-btn__reward {
    font-size: 6px;
    line-height: 1.2;
  }
  .boss-fight-btn,
  .boss-fight-btn--placeholder {
    min-height: 44px;
    padding: 8px 5px;
    border-radius: 7px;
    font-size: 9px;
    letter-spacing: .1em;
  }
}

/* ══════════════════════════════════
   MOBILE SCROLL & HEADER SAFETY
══════════════════════════════════ */
@media (max-width: 768px) {
  html,
  body {
    min-height: 100%;
    height: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  html {
    overflow-x: clip;
    overflow-y: auto;
  }
  body {
    overflow-x: clip;
    overflow-y: visible;
  }

  .game-header {
    position: sticky;
    top: 0;
    z-index: 200;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
    row-gap: 6px;
  }
  .game-header-logo {
    align-self: center;
  }
  .game-header__stats {
    min-width: 0;
    overflow: visible;
  }
  .game-header__stats .connect-wallet-btn {
    min-width: 42px;
    max-width: none;
    min-height: 38px;
    padding: 7px 8px !important;
    overflow: visible;
    white-space: normal;
    line-height: 1.15;
    text-align: center;
    justify-content: center;
  }
  .balance-display {
    max-width: none;
    overflow: visible;
    white-space: nowrap;
  }
  .sfx-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .game-tabs {
    position: relative;
    z-index: 190;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
  }
  .game-main {
    min-height: 0;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  .bosses-scroll-wrap {
    overflow: visible;
  }
  .bosses-scroll-track {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    pointer-events: auto;
  }
  .boss-card-game {
    touch-action: pan-x pan-y;
  }
  .boss-card-game button {
    touch-action: manipulation;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .game-header {
    grid-template-rows: 38px auto;
  }
  .game-header__stats {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }
  .game-header__stats .balance-display,
  .game-header__stats .connect-wallet-btn {
    width: 100%;
    max-width: none;
    justify-content: center;
  }
  .game-header__stats .balance-display {
    gap: 3px;
    padding-inline: 7px;
    font-size: 10px;
  }
  .game-header__stats #modeBadge {
    margin-left: 0 !important;
    padding: 2px 5px !important;
    font-size: 8px !important;
    letter-spacing: .08em !important;
  }
  .game-header > .sfx-btn {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .game-header {
    display: flex;
    flex-wrap: nowrap;
    min-height: 48px;
    height: auto;
    gap: 6px;
  }
  .game-header__stats {
    margin-left: auto;
  }
  .game-header-logo__icon {
    width: 28px;
    height: 28px;
  }
  .game-header__stats .balance-display {
    max-width: none;
  }
  .game-header__stats .connect-wallet-btn {
    max-width: none;
    min-width: 0;
    flex: 0 1 auto;
    font-size: 9px !important;
  }
  .game-tabs {
    padding-top: 0;
  }
  .game-tab {
    min-height: 40px;
    padding-block: 8px !important;
  }
  .game-main {
    padding-top: 10px;
  }
  .bosses-scroll-track {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/* ─── Connect Wallet Button ─── */
.connect-wallet-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(123,47,255,0.2), rgba(123,47,255,0.05));
  border: 1px solid rgba(123,47,255,0.5);
  border-radius: 20px;
  color: #e8deff;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.connect-wallet-btn:hover {
  background: linear-gradient(135deg, rgba(123,47,255,0.4), rgba(123,47,255,0.15));
  border-color: #7b2fff;
  box-shadow: 0 0 20px rgba(123,47,255,0.3);
}
.connect-wallet-btn svg { flex-shrink: 0; }

/* ─── ARENA (HUB) nav button ─── */
.game-header-hub-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(123,47,255,0.1);
  border: 1px solid rgba(123,47,255,0.3);
  border-radius: 20px;
  color: rgba(232,222,255,0.7);
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.game-header-hub-btn:hover {
  border-color: #7b2fff;
  color: #7b2fff;
  background: rgba(123,47,255,0.2);
}

/* ─── Sound toggle button ─── */
.sound-toggle-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(123,47,255,0.25);
  color: rgba(232,222,255,0.6);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  min-height: 44px;
}
.sound-toggle-btn:hover {
  border-color: #7b2fff;
  color: #7b2fff;
}
.sound-toggle-btn.muted {
  opacity: 0.4;
  border-color: rgba(255,255,255,0.1);
}

/* ─── My Boxes header with Open All ─── */
.my-boxes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.btn-open-all {
  padding: 8px 20px;
  background: linear-gradient(135deg,#d4a843,#8a6a1a);
  border: 1px solid #d4a843;
  border-radius: 8px;
  color: #000;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
  min-height: unset;
}
.btn-open-all:hover {
  box-shadow: 0 0 20px rgba(212,168,67,0.4);
  transform: translateY(-1px);
}

/* ─── Open All Modal ─────────────────────────────────── */
.open-all-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.85); z-index:9000; display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity 0.3s ease; padding:16px; }
.open-all-overlay.visible { opacity:1; }
.open-all-modal { background:linear-gradient(160deg,#0e0b1a,#1a1030); border:1px solid rgba(123,47,255,0.35); border-radius:16px; width:min(720px,100%); max-height:90vh; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 0 60px rgba(123,47,255,0.2); }
.open-all-header { padding:24px 28px 16px; border-bottom:1px solid rgba(123,47,255,0.15); flex-shrink:0; }
.open-all-title { font-family:'Cinzel',serif; font-size:18px; font-weight:700; color:var(--gold,#d4a843); letter-spacing:0.12em; margin-bottom:12px; }
.open-all-chips { display:flex; flex-wrap:wrap; gap:8px; }
.open-all-chip { padding:4px 12px; border-radius:20px; border:1px solid; font-family:'Cinzel',serif; font-size:11px; font-weight:700; letter-spacing:0.08em; }
.open-all-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:12px; padding:20px 24px; overflow-y:auto; flex:1; }
.open-all-card { display:flex; flex-direction:column; align-items:center; gap:6px; opacity:0; transform:translateY(16px); animation:openAllCardIn 0.4s ease forwards; }
@keyframes openAllCardIn { to { opacity:1; transform:translateY(0); } }
.open-all-card-img-wrap { width:100%; aspect-ratio:3/4; border-radius:8px; border:2px solid; overflow:hidden; background:rgba(0,0,0,0.4); }
.open-all-card-img-wrap img { width:100%; height:100%; object-fit:cover; }
.open-all-card-name { font-family:'Cinzel',serif; font-size:10px; font-weight:600; color:rgba(232,222,255,0.8); text-align:center; line-height:1.3; }
.open-all-card-rarity { font-family:'Cinzel',serif; font-size:9px; font-weight:700; letter-spacing:0.1em; }
.open-all-footer { padding:16px 24px max(20px, env(safe-area-inset-bottom)); border-top:1px solid rgba(123,47,255,0.15); display:flex; justify-content:center; flex-shrink:0; }

@media (max-width: 600px) {
  .connect-wallet-btn {
    font-size: 10px;
    padding: 8px 9px;
    gap: 5px;
    white-space: normal;
    line-height: 1.15;
    text-align: center;
    justify-content: center;
  }
  .connect-wallet-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* ── CARD TOOLTIP ── */
.card-tooltip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  min-width: 220px;
  max-width: 260px;
}
.card-tooltip.visible { opacity: 1; }

.card-tooltip__inner {
  background: linear-gradient(145deg, #0d0220, #050308);
  border: 1px solid rgba(123,47,255,0.4);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8),
              0 0 20px rgba(123,47,255,0.15);
}

.card-tooltip__rarity-bar {
  height: 3px;
  border-radius: 2px;
  margin-bottom: 10px;
}

.card-tooltip__art {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  margin-bottom: 10px;
  display: block;
}

.card-tooltip__name {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  color: #d4a843;
  margin-bottom: 2px;
}
.card-tooltip__type {
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  opacity: 0.6;
}

.card-tooltip__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.card-tooltip__stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(123,47,255,0.15);
  border-radius: 6px;
  padding: 5px 8px;
  text-align: center;
}
.card-tooltip__stat-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(232,222,255,0.4);
  font-family: 'Cinzel', serif;
  display: block;
  margin-bottom: 2px;
}
.card-tooltip__stat-value {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
}

.card-tooltip__ability {
  background: rgba(123,47,255,0.08);
  border: 1px solid rgba(123,47,255,0.2);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
.card-tooltip__ability-name {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  font-weight: 700;
  color: #7b2fff;
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}
.card-tooltip__ability-desc {
  font-size: 11px;
  color: rgba(232,222,255,0.6);
  line-height: 1.5;
}

.card-tooltip__desc {
  font-size: 11px;
  color: rgba(232,222,255,0.5);
  line-height: 1.5;
  border-top: 1px solid rgba(123,47,255,0.1);
  padding-top: 8px;
}

.card-info-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(123,47,255,0.6);
  border: 1px solid rgba(123,47,255,0.8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  line-height: 1;
  font-family: serif;
}

@media (max-width: 768px) {
  .card-info-btn { display: flex; }
  .card-tooltip {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 280px !important;
    width: 90vw !important;
    pointer-events: auto !important;
    z-index: 99999 !important;
  }
  .card-tooltip.visible { pointer-events: auto; }
}


/* ─── Boss Selection premium width polish ─── */
.game-main--arena {
  max-width: none;
  width: 100%;
  padding-left: clamp(24px, 2.4vw, 40px);
  padding-right: clamp(24px, 2.4vw, 40px);
}
.game-main--arena .bosses-scroll-wrap {
  margin-inline: calc(-1 * clamp(8px, 1.2vw, 18px));
  padding-inline: clamp(8px, 1.2vw, 18px);
  overflow: visible;
}
.game-main--arena .bosses-scroll-wrap::before,
.game-main--arena .bosses-scroll-wrap::after {
  display: block;
  width: clamp(24px, 4vw, 42px);
}
.game-main--arena .bosses-scroll-wrap::before {
  background: linear-gradient(to right, rgba(10,5,20,0.82), rgba(10,5,20,0));
}
.game-main--arena .bosses-scroll-wrap::after {
  background: linear-gradient(to left, rgba(10,5,20,0.82), rgba(10,5,20,0));
}
.game-main--arena .bosses-scroll-track {
  padding-left: clamp(10px, 1vw, 18px);
  padding-right: clamp(10px, 1vw, 18px);
  scroll-padding-left: clamp(10px, 1vw, 18px);
  scroll-padding-right: clamp(10px, 1vw, 18px);
}
@media (max-width: 599px) and (orientation: portrait) {
  .game-main--arena {
    padding-left: 16px;
    padding-right: 16px;
  }
  .game-main--arena .bosses-scroll-wrap {
    margin-inline: -8px;
    padding-inline: 0;
  }
  .game-main--arena .bosses-scroll-wrap::before,
  .game-main--arena .bosses-scroll-wrap::after {
    display: none;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .game-main--arena {
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }
  .game-main--arena .bosses-scroll-wrap {
    margin-inline: -8px;
    padding-inline: 0;
  }
}

.game-main--arena .boss-card-game,
.game-main--arena .diff-btn,
.game-main--arena .boss-fight-btn,
.game-tab,
.game-back-btn {
  transition-duration: 200ms;
  transition-timing-function: ease;
}

.game-main--arena .boss-card-game--active {
  border-color: rgba(212,168,67,0.72);
  box-shadow: 0 0 0 1px rgba(212,168,67,0.22), 0 14px 42px rgba(123,47,255,0.32), 0 0 34px rgba(212,168,67,0.12);
  background: linear-gradient(180deg, rgba(25,10,42,0.94), rgba(10,5,20,0.86));
}
.game-main--arena .boss-card-game--active .boss-card-game__name {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(212,168,67,0.22);
}
