*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --left: #3b82f6;
  --left-glow: #60a5fa;
  --right: #ef4444;
  --right-glow: #f87171;
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --border: #27272a;
  --radius: 16px;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- BG --- */

.bg-effects { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }

.bg-orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.15; }
.bg-orb-1 { width: 600px; height: 600px; background: var(--left); top: -200px; left: -150px; animation: float1 12s ease-in-out infinite; }
.bg-orb-2 { width: 600px; height: 600px; background: var(--right); bottom: -200px; right: -150px; animation: float2 14s ease-in-out infinite; }

@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(80px,60px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-80px,-60px)} }

header, main, footer { position: relative; z-index: 1; }

/* --- Header --- */

header { text-align: center; padding: 2.5rem 1rem 0.5rem; }

.logo-link { text-decoration: none; }

.logo {
  font-family: 'Orbitron', monospace;
  font-size: 2.8rem;
  letter-spacing: 2px;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.logo-battle { background: linear-gradient(135deg, var(--left), var(--left-glow)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-tg { background: linear-gradient(135deg, var(--right), var(--right-glow)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.subtitle { color: var(--text-dim); margin-top: 0.4rem; font-size: 0.95rem; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* --- Mode badge --- */

.mode-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.9rem; border-radius: 60px;
  font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.mode-badge-live { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: #22c55e; }
.mode-badge-scrape { background: rgba(234,179,8,0.1); border-color: rgba(234,179,8,0.3); color: #eab308; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; }
.mode-dot-live { background: #22c55e; animation: livePulse 1.2s ease-in-out infinite; }
.mode-dot-scrape { background: #eab308; }

/* --- Search --- */

.search-section { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }

.search-row { display: flex; align-items: center; gap: 1rem; width: 100%; max-width: 720px; }

.search-card {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.3rem;
  transition: border-color .3s, box-shadow .3s;
}
.search-card-left:focus-within { border-color: var(--left); box-shadow: 0 0 24px rgba(59,130,246,.15); }
.search-card-right:focus-within { border-color: var(--right); box-shadow: 0 0 24px rgba(239,68,68,.15); }

.search-card label {
  display: block; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim); margin-bottom: .4rem;
}

.input-wrap { display: flex; align-items: center; gap: .3rem; }
.input-at { font-size: 1.2rem; color: var(--text-dim); font-weight: 700; }

.input-wrap input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1.15rem; font-family: inherit; font-weight: 600;
}
.input-wrap input::placeholder { color: #3f3f46; }

.vs-badge-search {
  font-family: 'Orbitron', monospace; font-size: 1.1rem; font-weight: 900;
  color: var(--text-dim); background: var(--surface2);
  border: 1px solid var(--border); border-radius: 50%;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* --- Button --- */

.btn-battle {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .85rem 2.2rem; font-size: 1.05rem; font-weight: 700;
  font-family: inherit; border: none; border-radius: 60px; cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--left), #8b5cf6, var(--right));
  background-size: 200% 200%; animation: gradShift 4s ease infinite;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 24px rgba(139,92,246,.3);
}
.btn-battle:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(139,92,246,.45); }
.btn-battle:active { transform: scale(.97); }
.btn-battle:disabled { opacity: .6; cursor: wait; }

@keyframes gradShift { 0%,100%{background-position:0 50%} 50%{background-position:100% 50%} }

.btn-icon { font-size: 1.2rem; }
.error-msg { color: var(--right); font-size: .85rem; min-height: 1.2rem; }

/* --- Popular --- */

.popular-section { margin-top: 1rem; text-align: center; }
.popular-title { font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: .7rem; }

.popular-grid { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }

.popular-card {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: 60px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: .82rem; font-weight: 600;
  text-decoration: none; transition: border-color .2s, background .2s;
}
.popular-card:hover { border-color: #8b5cf6; background: var(--surface2); }
.pop-vs { color: var(--text-dim); font-size: .7rem; font-weight: 400; }

/* --- Arena --- */

.hidden { display: none !important; }

.battle-arena { animation: fadeUp .5s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(30px)} to{opacity:1;transform:translateY(0)} }

.arena-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .5rem; }
.arena-top-right { display: flex; align-items: center; gap: .6rem; }

.btn-back {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-family: inherit; font-size: .85rem; padding: .45rem 1.1rem;
  border-radius: 60px; cursor: pointer; transition: color .2s, border-color .2s;
}
.btn-back:hover { color: var(--text); border-color: var(--text-dim); }

.btn-share {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font-family: inherit; font-size: .8rem; padding: .4rem 1rem;
  border-radius: 60px; cursor: pointer; transition: color .2s, border-color .2s;
}
.btn-share:hover { color: var(--text); border-color: var(--text-dim); }

.source-badge {
  font-size: .68rem; font-weight: 600; padding: .25rem .7rem;
  border-radius: 60px; text-transform: uppercase; letter-spacing: .5px;
}
.source-live { background: rgba(34,197,94,.15); color: #22c55e; }
.source-scrape { background: rgba(234,179,8,.15); color: #eab308; }

/* --- Fighters --- */

.arena-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.2rem; align-items: center; margin-bottom: 1.5rem; }

.fighter {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.8rem 1.2rem; text-align: center; overflow: hidden;
  transition: border-color .4s;
}
.fighter-left.winning { border-color: var(--left); }
.fighter-right.winning { border-color: var(--right); }

.fighter-glow {
  position: absolute; top: -60px; width: 200px; height: 200px;
  border-radius: 50%; filter: blur(80px); opacity: 0; transition: opacity .6s;
}
.fighter-glow-left { left: -40px; background: var(--left); }
.fighter-glow-right { right: -40px; background: var(--right); }
.fighter.winning .fighter-glow { opacity: .2; }

.fighter-avatar-wrap {
  width: 72px; height: 72px; border-radius: 50%; overflow: hidden;
  margin: 0 auto .8rem; border: 3px solid var(--border); transition: border-color .4s;
}
.fighter-left.winning .fighter-avatar-wrap { border-color: var(--left); }
.fighter-right.winning .fighter-avatar-wrap { border-color: var(--right); }

.fighter-avatar { width: 100%; height: 100%; object-fit: cover; }

.avatar-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', monospace; font-size: 1.8rem; font-weight: 900;
  color: #fff;
}

.fighter-name { font-size: 1.1rem; font-weight: 700; margin-bottom: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fighter-username { font-size: .8rem; color: var(--text-dim); margin-bottom: .8rem; }

.fighter-count {
  font-family: 'Orbitron', monospace; font-size: 2.4rem; font-weight: 900;
  line-height: 1; margin-bottom: .25rem; transition: color .4s;
}
.fighter-left .fighter-count { color: var(--left-glow); }
.fighter-right .fighter-count { color: var(--right-glow); }

.fighter-label { font-size: .75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.fighter-diff { margin-top: .5rem; font-size: .82rem; font-weight: 600; min-height: 1.2rem; }
.fighter-diff.positive { color: #22c55e; }
.fighter-diff.negative { color: var(--right); }

/* --- VS --- */

.vs-center { display: flex; flex-direction: column; align-items: center; gap: .8rem; }

.vs-circle {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', monospace; font-weight: 900; font-size: 1.3rem;
  color: var(--text-dim); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(139,92,246,.3)} 50%{box-shadow:0 0 20px 4px rgba(139,92,246,.2)} }

.live-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .75rem; background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.3); border-radius: 60px;
  font-size: .7rem; font-weight: 700; color: var(--right);
  text-transform: uppercase; letter-spacing: 1px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--right); animation: livePulse 1.2s ease-in-out infinite; }
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* --- Progress --- */

.progress-section { margin-bottom: 1.5rem; }

.progress-bar-wrap {
  display: flex; height: 26px; border-radius: 13px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
}
.progress-bar-left, .progress-bar-right { height: 100%; transition: width .8s cubic-bezier(.22,1,.36,1); }
.progress-bar-left { background: linear-gradient(90deg, var(--left), #6366f1); width: 50%; }
.progress-bar-right { background: linear-gradient(90deg, #a855f7, var(--right)); width: 50%; }

.progress-labels { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; font-size: .82rem; color: var(--text-dim); }
.progress-diff-label { font-weight: 600; }

/* --- Stats --- */

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.stat-title { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: .4rem; }
.stat-value { display: block; font-family: 'Orbitron', monospace; font-size: .95rem; font-weight: 700; }

/* --- Toast --- */

.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: .6rem 1.5rem; border-radius: 60px;
  font-size: .85rem; font-weight: 600; z-index: 100;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from{opacity:0;transform:translateX(-50%) translateY(10px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }

/* --- Footer --- */

footer { text-align: center; padding: 2rem; color: var(--text-dim); font-size: .78rem; }
.online-counter { margin-bottom: .4rem; font-weight: 600; color: #22c55e; }

/* --- Crown --- */

.winner-crown::after {
  content: '👑'; position: absolute; top: -8px; right: 14px;
  font-size: 1.5rem; animation: crownBounce 1s ease infinite;
}
@keyframes crownBounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }

/* --- Count bump --- */

@keyframes countBump { 0%{transform:scale(1)} 50%{transform:scale(1.07)} 100%{transform:scale(1)} }
.count-bump { animation: countBump .35s ease; }

/* --- Lead change flash --- */

@keyframes leadFlash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
.lead-change-flash {
  position: absolute; inset: 0; border-radius: var(--radius);
  pointer-events: none; animation: leadFlash 1s ease forwards;
}
.fighter-left .lead-change-flash { background: rgba(59,130,246,.15); }
.fighter-right .lead-change-flash { background: rgba(239,68,68,.15); }

/* --- Responsive --- */

@media (max-width: 700px) {
  .logo { font-size: 1.8rem; }
  .search-row { flex-direction: column; }
  .vs-badge-search { width: 36px; height: 36px; font-size: .9rem; }
  .arena-grid { grid-template-columns: 1fr; gap: .8rem; }
  .vs-center { flex-direction: row; gap: .6rem; }
  .vs-circle { width: 48px; height: 48px; font-size: 1rem; }
  .fighter-count { font-size: 1.8rem; }
  .stats-row { grid-template-columns: 1fr; }
  .arena-top-row { flex-direction: column; align-items: flex-start; }
}
