:root {
  --battle-bg: #0b1220;
  --bar-height: 44px;
  --bar-radius: 18px;
  --bar-padding: 28px;
  --gift-size: 96px;
  --gift-name-size: 16px;
  --points-size: 20px;
  --blue: #2563eb;
  --red: #ef4444;
  --blue-effect: #93c5fd;
  --red-effect: #fca5a5;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  background: var(--battle-bg);
  font-family: "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

.battle-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr minmax(140px, 220px);
  align-items: center;
  gap: 20px;
  width: 90%;
  max-width: 1400px;
  padding: var(--bar-padding);
  box-sizing: border-box;
}

.battle-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(226, 232, 240, 0.85);
  font-size: 16px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.battle-side img {
  width: var(--gift-size);
  height: var(--gift-size);
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  background: rgba(15, 23, 42, 0.8);
  transition: transform 0.2s ease;
}

.battle-side__name {
  max-width: 160px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: var(--gift-name-size);
}

.battle-side__points {
  font-size: var(--points-size);
  font-weight: 700;
  color: #e2e8f0;
}

.gift-zoom {
  transform: scale(1.08);
}

.battle-track {
  position: relative;
  height: var(--bar-height);
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--bar-radius);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.battle-track__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0%;
  transition: width 0.4s ease;
}

.battle-track__fill--blue {
  left: 0;
  background: var(--blue);
}

.battle-track__fill--red {
  right: 0;
  background: var(--red);
}

.bar-wave {
  animation: bar-wave 0.6s ease;
  transform-origin: center;
}

.battle-track__effect {
  position: absolute;
  opacity: 1;
  pointer-events: none;
  height: 100%;
  top: 0;
  overflow: hidden;
  transition: width 0.4s ease;
}

.battle-power {
  position: absolute;
  inset: 0;
  opacity: 1;
  clip-path: inset(0);
}

.battle-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  letter-spacing: 6px;
}

.battle-countdown--hidden {
  opacity: 0;
  pointer-events: none;
}

.countdown-pop {
  animation: countdown-pop 0.6s ease both;
}

@keyframes countdown-pop {
  0% { transform: scale(0.6); opacity: 0.1; }
  60% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.95; }
}

.effect-ray-left {
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.15) 35%, var(--blue-effect) 55%, rgba(255,255,255,0) 75%);
  clip-path: polygon(0 15%, 85% 0, 100% 50%, 85% 100%, 0 85%, 12% 50%);
  background-size: 200% 100%;
  animation: ray-left 0.9s ease-out;
}

.effect-ray-right {
  background: linear-gradient(270deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.15) 35%, var(--red-effect) 55%, rgba(255,255,255,0) 75%);
  clip-path: polygon(100% 15%, 15% 0, 0 50%, 15% 100%, 100% 85%, 88% 50%);
  background-size: 200% 100%;
  animation: ray-right 0.9s ease-out;
}

.effect-wave {
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0) 100%);
  clip-path: polygon(0 50%, 8% 30%, 16% 50%, 24% 30%, 32% 50%, 40% 30%, 48% 50%, 56% 30%, 64% 50%, 72% 30%, 80% 50%, 88% 30%, 100% 50%, 100% 70%, 88% 90%, 80% 70%, 72% 90%, 64% 70%, 56% 90%, 48% 70%, 40% 90%, 32% 70%, 24% 90%, 16% 70%, 8% 90%, 0 70%);
  background-size: 180% 100%;
  animation: wave-left 1.1s ease-out;
}

@keyframes ray-left {
  0% { background-position: 100% 50%; opacity: 0; }
  20% { opacity: 1; }
  100% { background-position: 0% 50%; opacity: 0; }
}

@keyframes ray-right {
  0% { background-position: 0% 50%; opacity: 0; }
  20% { opacity: 1; }
  100% { background-position: 100% 50%; opacity: 0; }
}

@keyframes wave-left {
  0% { background-position: 100% 50%; opacity: 0; }
  20% { opacity: 0.9; }
  100% { background-position: 0% 50%; opacity: 0; }
}

.effect-wave.effect-right {
  animation-name: wave-right;
}

@keyframes wave-right {
  0% { background-position: 0% 50%; opacity: 0; }
  20% { opacity: 0.9; }
  100% { background-position: 100% 50%; opacity: 0; }
}

@keyframes bar-wave {
  0% { transform: scaleY(1); }
  40% { transform: scaleY(1.08); }
  100% { transform: scaleY(1); }
}

.battle-timer {
  position: absolute;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 2px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.battle-win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}

.battle-win--hidden {
  opacity: 0;
  pointer-events: none;
}

.battle-win__card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 22px;
  padding: 28px 36px;
  text-align: center;
  color: #e2e8f0;
  min-width: 280px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.4);
}

.battle-win__wrap {
  transform: scale(var(--win-scale, 1));
  transform-origin: center;
}

.battle-win__text {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.battle-win__gift img {
  width: 120px;
  height: 120px;
  margin-top: 14px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.battle-win__name {
  margin-top: 10px;
  font-size: 18px;
  color: rgba(226, 232, 240, 0.85);
}

.win-zoom { animation: win-zoom 0.8s ease both; }
.win-pulse { animation: win-pulse 1.2s ease-in-out infinite; }
.win-shake { animation: win-shake 0.6s ease-in-out 2; }

@keyframes win-zoom {
  from { transform: scale(0.7); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes win-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes win-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
