/* ============================================================
   AEXOR Legends — Battle Styles (Tactical Round-Based)
   ============================================================ */

/* ── Battle Setup Screen ── */
.battle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.battle-stats { display: flex; gap: 6px; font-size: 12px; }
.stat-win { color: #22c55e; font-weight: 600; }
.stat-lose { color: #ef4444; font-weight: 600; }
.stat-rank { color: var(--tg-btn); font-weight: 600; }

#battle-deck-preview { margin-bottom: 8px; }

.deck-row { display: flex; gap: 8px; justify-content: center; }

.deck-card {
  flex: 1;
  max-width: 120px;
  text-align: center;
  background: var(--tg-secondary-bg);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  border: 2px solid transparent;
}

.deck-card.card-common { border-color: var(--card-common); }
.deck-card.card-rare { border-color: var(--card-rare); }
.deck-card.card-epic { border-color: var(--card-epic); }
.deck-card.card-legendary { border-color: var(--card-legendary); }

.deck-card-type { font-size: 20px; margin-bottom: 2px; }
.deck-card-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-card-stats { font-size: 10px; color: var(--tg-hint); margin-top: 2px; }

/* ── Battle Arena (fullscreen overlay inside #app-root) ── */
.battle-arena {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #0a0e1a 0%, #1a1040 50%, #0d1117 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.battle-arena.hidden { display: none; }

/* ── VS Screen ── */
.vs-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  animation: vsAppear 0.5s ease;
}

@keyframes vsAppear {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.vs-player { text-align: center; }
.vs-name { font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.vs-cards { display: flex; gap: 6px; justify-content: center; }

.vs-card-badge {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 20px;
  border: 2px solid transparent;
}

.vs-card-badge.card-common { border-color: var(--card-common); background: rgba(107,114,128,0.15); }
.vs-card-badge.card-rare { border-color: var(--card-rare); background: rgba(59,130,246,0.15); }
.vs-card-badge.card-epic { border-color: var(--card-epic); background: rgba(168,85,247,0.15); }
.vs-card-badge.card-legendary { border-color: var(--card-legendary); background: rgba(245,158,11,0.15); }

.vs-text {
  font-size: 36px;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 0 0 30px rgba(239,68,68,0.6);
  animation: vsPulse 1s ease-in-out infinite;
}

@keyframes vsPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ── Round Header ── */
.round-header {
  text-align: center;
  padding: 12px 16px 8px;
  background: rgba(0,0,0,0.4);
}

.round-label {
  font-size: 14px;
  font-weight: 700;
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.round-score {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  margin-top: 4px;
}

.round-score .score-player { color: #22c55e; }
.round-score .score-bot { color: #ef4444; }

/* ── Card Selection Phase ── */
.card-select-phase {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
}

.opponent-reveal {
  text-align: center;
  margin-bottom: 12px;
}

.opponent-reveal-label {
  font-size: 12px;
  color: var(--tg-hint);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ── Battle Card (used in both selection and arena) ── */
.battle-card {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  transition: all 0.2s;
}

.battle-card.card-common { border-color: rgba(107,114,128,0.5); }
.battle-card.card-rare { border-color: rgba(59,130,246,0.5); }
.battle-card.card-epic { border-color: rgba(168,85,247,0.5); }
.battle-card.card-legendary { border-color: rgba(245,158,11,0.5); animation: legendaryGlow 2s ease-in-out infinite; }

@keyframes legendaryGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.3); }
  50% { box-shadow: 0 0 20px rgba(245,158,11,0.6); }
}

.battle-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.battle-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.battle-card-type {
  font-size: 18px;
}

.battle-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.battle-card-stats span { font-weight: 600; }
.stat-atk { color: #ef4444; }
.stat-def { color: #3b82f6; }
.stat-hp { color: #22c55e; }

.battle-card-ability {
  margin-top: 6px;
  font-size: 11px;
  color: #a78bfa;
  font-style: italic;
}

/* ── Player Card Selection Tray ── */
.pick-label {
  font-size: 13px;
  color: var(--tg-hint);
  text-align: center;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-select-tray {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: nowrap;
}

.select-card {
  flex: 1;
  max-width: 140px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.select-card:active { transform: scale(0.95); }
.select-card.selected { border-color: #a78bfa; background: rgba(167,139,250,0.15); box-shadow: 0 0 12px rgba(167,139,250,0.3); }
.select-card.used { opacity: 0.3; pointer-events: none; }

.select-card .type-emoji { font-size: 22px; display: block; margin-bottom: 4px; }
.select-card .card-name { font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-card .card-mini-stats { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 2px; }

/* Type advantage indicator */
.type-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.type-badge.advantage { background: #22c55e; color: #fff; }
.type-badge.disadvantage { background: #ef4444; color: #fff; }

/* Fight button */
.fight-btn {
  display: block;
  width: 80%;
  max-width: 240px;
  margin: 16px auto 12px;
  padding: 14px 0;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #a855f7, #6c5ce7);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(108,92,231,0.4);
}

.fight-btn:active { transform: scale(0.95); }
.fight-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ── Combat Arena ── */
.combat-arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  position: relative;
  overflow: hidden;
}

.combatants {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.combatant {
  flex: 1;
  max-width: 46%;
  text-align: center;
  position: relative;
}

.combatant-card {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 10px 8px;
  position: relative;
}

.combatant-card.side-player { border-color: rgba(34,197,94,0.4); }
.combatant-card.side-bot { border-color: rgba(239,68,68,0.4); }

.combatant-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.combatant-label.player-label { color: #22c55e; }
.combatant-label.bot-label { color: #ef4444; }

.combatant-type { font-size: 28px; margin: 4px 0; }
.combatant-name { font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combatant-stats { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 2px; }
.combatant-ability { font-size: 10px; color: #a78bfa; margin-top: 2px; }

/* HP Bar */
.hp-bar-container {
  width: 100%;
  margin-top: 8px;
}

.hp-bar {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}

.hp-bar-fill.hp-high { background: linear-gradient(90deg, #22c55e, #4ade80); }
.hp-bar-fill.hp-mid { background: linear-gradient(90deg, #eab308, #facc15); }
.hp-bar-fill.hp-low { background: linear-gradient(90deg, #ef4444, #f87171); }

.hp-text {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
  text-align: center;
}

/* VS divider in combat */
.combat-vs {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 900;
  color: rgba(255,255,255,0.15);
  z-index: 1;
}

/* ── Floating Damage Numbers ── */
.float-dmg {
  position: absolute;
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  z-index: 10;
  animation: floatDmgUp 0.8s ease-out forwards;
}

.float-dmg.dmg-normal { color: #fff; }
.float-dmg.dmg-crit { color: #f59e0b; font-size: 22px; }
.float-dmg.dmg-type { color: #60a5fa; }
.float-dmg.dmg-poison { color: #a78bfa; }
.float-dmg.dmg-heal { color: #22c55e; }
.float-dmg.dmg-dodge { color: #94a3b8; font-size: 14px; }

@keyframes floatDmgUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; transform: translateY(-25px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.8); }
}

/* ── Combat Event Log (bottom of arena) ── */
.combat-log {
  padding: 8px 0;
  text-align: center;
  min-height: 32px;
}

.combat-log-msg {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  animation: logAppear 0.3s ease;
}

@keyframes logAppear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Attack Animations ── */
.combatant-card.attacking-right {
  animation: attackRight 0.35s ease;
}

.combatant-card.attacking-left {
  animation: attackLeft 0.35s ease;
}

@keyframes attackRight {
  0% { transform: translateX(0); }
  40% { transform: translateX(30px) scale(1.05); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes attackLeft {
  0% { transform: translateX(0); }
  40% { transform: translateX(-30px) scale(1.05); }
  100% { transform: translateX(0) scale(1); }
}

/* Hit effect */
.combatant-card.hit {
  animation: hitShake 0.3s ease;
}

@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.combatant-card.hit-flash {
  animation: hitFlash 0.3s ease;
}

@keyframes hitFlash {
  0% { filter: brightness(1); }
  30% { filter: brightness(2) saturate(0.3); }
  100% { filter: brightness(1); }
}

/* Death animation */
.combatant-card.dying {
  animation: cardDeath 0.6s ease forwards;
}

@keyframes cardDeath {
  0% { opacity: 1; transform: scale(1) rotate(0); }
  50% { opacity: 0.5; transform: scale(0.8) rotate(5deg); }
  100% { opacity: 0; transform: scale(0.3) rotate(15deg); }
}

/* ── Ability Effects ── */
.combatant-card.eff-crit::after {
  content: 'CRIT!';
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  color: #f59e0b;
  text-shadow: 0 0 6px rgba(245,158,11,0.8);
  animation: critPopup 0.5s ease forwards;
}

@keyframes critPopup {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.2); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(1); }
}

.combatant-card.eff-shield {
  box-shadow: 0 0 15px rgba(59,130,246,0.5), inset 0 0 8px rgba(59,130,246,0.2);
  transition: box-shadow 0.3s;
}

.combatant-card.eff-poison {
  box-shadow: 0 0 12px rgba(139,92,246,0.5);
  transition: box-shadow 0.3s;
}

.combatant-card.eff-regen {
  box-shadow: 0 0 12px rgba(34,197,94,0.5);
  transition: box-shadow 0.3s;
}

.combatant-card.eff-fury {
  box-shadow: 0 0 15px rgba(239,68,68,0.5);
  animation: furyPulse 0.5s ease;
}

@keyframes furyPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 25px rgba(239,68,68,0.7); }
}

.combatant-card.eff-dodge {
  animation: dodgeSlide 0.4s ease;
}

@keyframes dodgeSlide {
  0% { transform: translateX(0); }
  30% { transform: translateX(15px); opacity: 0.5; }
  60% { transform: translateX(-10px); opacity: 0.7; }
  100% { transform: translateX(0); opacity: 1; }
}

/* ── Type Advantage Flash ── */
.type-adv-banner {
  text-align: center;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 700;
  color: #22c55e;
  animation: advFlash 0.5s ease;
}

@keyframes advFlash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

/* ── Round Result Overlay ── */
.round-result-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 20;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.round-result-text {
  font-size: 28px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.round-result-text.round-won { color: #22c55e; text-shadow: 0 0 20px rgba(34,197,94,0.6); }
.round-result-text.round-lost { color: #ef4444; text-shadow: 0 0 20px rgba(239,68,68,0.6); }
.round-result-text.round-draw { color: #eab308; text-shadow: 0 0 20px rgba(234,179,8,0.6); }

.round-score-display {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
}

/* ── Final Result Screen ── */
.final-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: resultAppear 0.5s ease;
}

@keyframes resultAppear {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.final-result-title {
  font-size: 32px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.final-result-title.result-win { color: #22c55e; text-shadow: 0 0 30px rgba(34,197,94,0.5); }
.final-result-title.result-lose { color: #ef4444; text-shadow: 0 0 30px rgba(239,68,68,0.5); }
.final-result-title.result-draw { color: #eab308; text-shadow: 0 0 30px rgba(234,179,8,0.5); }

.final-score {
  font-size: 20px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 12px;
}

.final-crystals {
  font-size: 24px;
  font-weight: 800;
  color: var(--tg-btn);
  margin-bottom: 24px;
}

.final-btns {
  display: flex;
  gap: 12px;
}

.final-btns .axl-btn {
  min-width: 120px;
}

/* ── Searching Animation ── */
.searching-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.search-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.search-text {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}

/* ── Packs (kept from original) ── */
.packs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.crystals-display {
  background: rgba(108,92,231,0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--tg-btn);
}

.packs-grid { display: flex; flex-direction: column; gap: 12px; }

.pack-card {
  background: var(--tg-secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

.pack-visual {
  position: relative;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.pack-basic .pack-visual { background: linear-gradient(135deg, #374151, #4b5563); }
.pack-premium .pack-visual { background: linear-gradient(135deg, #1e40af, #3b82f6); }
.pack-elite .pack-visual { background: linear-gradient(135deg, #6b21a8, #a855f7); }

.pack-glow {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  filter: blur(20px);
}

.pack-count {
  position: relative;
  font-size: 20px;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.pack-name { font-size: 16px; margin-bottom: 4px; }
.pack-odds { font-size: 11px; color: var(--tg-hint); margin-bottom: 12px; }
.pack-buy-btn { width: 100%; }
.pack-result.hidden { display: none; }

/* ── Profile ── */
.profile-card {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, var(--tg-secondary-bg), rgba(108,92,231,0.1));
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--tg-btn);
  color: white;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}

.profile-name { font-size: 18px; }
.profile-username { font-size: 13px; color: var(--tg-hint); margin: 2px 0 8px; }

.profile-rank {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rank-bronze { background: rgba(205,127,50,0.2); color: #CD7F32; }
.rank-silver { background: rgba(192,192,192,0.2); color: #C0C0C0; }
.rank-gold { background: rgba(255,215,0,0.2); color: #FFD700; }
.rank-platinum { background: rgba(229,228,226,0.2); color: #E5E4E2; }
.rank-diamond { background: rgba(185,242,255,0.2); color: #B9F2FF; }
.rank-legend { background: rgba(255,69,0,0.2); color: #FF4500; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--tg-secondary-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.stat-card-val { display: block; font-size: 18px; font-weight: 700; }
.stat-card-label { display: block; font-size: 11px; color: var(--tg-hint); margin-top: 2px; }

.stat-crystals .stat-card-val { color: var(--tg-btn); }
.stat-wins .stat-card-val { color: #22c55e; }
.stat-losses .stat-card-val { color: #ef4444; }

.profile-deck { margin-top: 8px; }
.profile-deck h3 { margin-bottom: 8px; }

.profile-deck-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--tg-secondary-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  border-left: 3px solid transparent;
  font-size: 13px;
}

.profile-deck-card.card-common { border-left-color: var(--card-common); }
.profile-deck-card.card-rare { border-left-color: var(--card-rare); }
.profile-deck-card.card-epic { border-left-color: var(--card-epic); }
.profile-deck-card.card-legendary { border-left-color: var(--card-legendary); }
