*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: #000;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── CONTAINER UTAMA (9:16) ─────────────────────────────────── */
.battle {
  container-type: size;
  position: relative;
  /* Lebar penuh di mobile; di desktop dibatasi tinggi layar */
  width: min(100vw, calc(100vh * 9 / 16));
  aspect-ratio: 9 / 16;
  background:
    radial-gradient(ellipse at 25% 65%, rgba(220,40,0,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 65%, rgba(0,60,200,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 40%, rgba(255,180,0,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(255,100,0,0.2) 0%, transparent 50%),
    #060612;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
}

/*
  Semua ukuran pakai cqw (container query width).
  Karena rasio 9:16, tinggi = 16/9 × lebar.
  1px pada desain asli 1080×1920 = 100/1080 ≈ 0.0926 cqw
  (berlaku sama untuk posisi horizontal MAUPUN vertikal)
*/


/* ─── SCORE BAR ──────────────────────────────────────────────── */
.score {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 12cqw;
  display: flex;
  box-shadow:
    0 5px 20px rgba(0,0,0,0.75),
    0 2px 6px rgba(0,0,0,0.5);
  z-index: 2;
}

.madridScore,
.barcaScore {
  display: flex;
  align-items: center;
  font-size: 6.5cqw;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  transition: width 0.65s cubic-bezier(0.25,0.8,0.25,1);
}

/* Madrid — silver metallic */
.madridScore {
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #e8e8e8 18%,
    #d0d0d0 45%,
    #b0b0b0 75%,
    #909090 100%
  );
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,1),
    inset 0 -4px 10px rgba(0,0,0,0.28),
    inset -4px 0 12px rgba(0,0,0,0.12);
  justify-content: flex-end;
  padding-right: 3.7cqw;
  color: #1a1a1a;
}

/* Shimmer Madrid */
.madridScore::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    108deg,
    transparent 20%,
    rgba(255,255,255,0.65) 48%,
    transparent 76%
  );
  background-size: 300% 100%;
  background-position: 130% 0;
  animation: shimmer 3.5s ease-in-out infinite;
  pointer-events: none;
}

/* Barcelona — ruby gem */
.barcaScore {
  background: linear-gradient(
    180deg,
    #d4004a 0%,
    #b8003c 22%,
    #a20035 50%,
    #820028 78%,
    #5e001c 100%
  );
  box-shadow:
    inset 0 2px 0 rgba(255,150,150,0.3),
    inset 0 -4px 10px rgba(0,0,0,0.4),
    inset 4px 0 12px rgba(0,0,0,0.2);
  justify-content: flex-start;
  padding-left: 3.7cqw;
  color: #fff;
}

/* Shimmer Barcelona */
.barcaScore::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    108deg,
    transparent 20%,
    rgba(255,120,120,0.35) 48%,
    transparent 76%
  );
  background-size: 300% 100%;
  background-position: 130% 0;
  animation: shimmer 3.5s ease-in-out infinite 0.8s;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { background-position:  150% 0; }
  100% { background-position: -150% 0; }
}

/* Angka — floating idle */
.madridScore span,
.barcaScore span {
  display: inline-block;
  position: relative;
  z-index: 1;
  animation: scoreFloat 2.4s ease-in-out infinite;
}

.madridScore span {
  text-shadow:
    0 1px 0 rgba(255,255,255,0.9),
    0 2px 8px rgba(0,0,0,0.4);
}

.barcaScore span {
  text-shadow:
    0 0 16px rgba(255,120,120,0.9),
    0 0 32px rgba(255,50,50,0.4),
    0 2px 6px rgba(0,0,0,0.6);
}

@keyframes scoreFloat {
  0%, 100% { transform: translateY(0)    scale(1);    }
  50%       { transform: translateY(-6%) scale(1.04); }
}

/* Pop saat angka berubah */
@keyframes scorePop {
  0%   { transform: scale(1);
         filter: brightness(1); }
  20%  { transform: scale(1.5);
         filter: brightness(2.2) drop-shadow(0 0 8px white); }
  55%  { transform: scale(0.88);
         filter: brightness(1.3); }
  100% { transform: scale(1);
         filter: brightness(1); }
}

.score-pop {
  animation: scorePop 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards !important;
}

/* ─── BALL CANVAS ────────────────────────────────────────────── */
.fire-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 4;
}


/* ─── TIMER ──────────────────────────────────────────────────── */
.timer {
  position: absolute;
  top: 15.7cqw;           /* 170px */
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 1.4cqw 3.7cqw; /* 15px 40px */
  border-radius: 5cqw;
  font-size: 4.2cqw;      /* 45px */
  font-weight: bold;
  color: #111;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}


/* ─── GIFT COLUMNS ───────────────────────────────────────────── */
.gifts-col {
  position: absolute;
  top: 22cqw;
  display: flex;
  flex-direction: column;
  gap: 3cqw;
}

.gifts-col.left  { left:  4cqw; }
.gifts-col.right { right: 4cqw; }

.gift-btn {
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s;
}
.gift-btn:active { transform: scale(0.92); }

.gift {
  color: #fff;
  font-size: 2.5cqw;
  font-weight: bold;
  text-align: center;
}

.gift-row {
  display: flex;
  align-items: center;
  gap: 1.5cqw;
  justify-content: center;
}

.gift-icon {
  width: 12cqw;
  height: 12cqw;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 1.8cqw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2cqw;
}

.gift-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gift-count {
  font-size: 3.2cqw;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.gift p {
  margin: 1.2cqw 0 0;
  line-height: 1.35;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}


/* ─── VS WRAPPER ─────────────────────────────────────────────── */
.vs-wrapper {
  position: absolute;
  top: 68cqw;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8cqw;
  white-space: nowrap;
}

.vs {
  font-size: 18cqw;
  font-weight: 900;
  font-style: italic;
  color: transparent;
  -webkit-text-stroke: 0.5cqw #fff;
  text-shadow:
    0 0 6cqw rgba(255,200,0,0.9),
    0 0 12cqw rgba(255,120,0,0.7),
    0 0 2cqw #fff;
  letter-spacing: -0.5cqw;
  line-height: 1;
  user-select: none;
}

.trophy-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8cqw;
}

.trophy-icon {
  font-size: 7cqw;
  line-height: 1;
  filter: drop-shadow(0 0 2cqw rgba(255,200,0,0.7));
}

.trophy-count {
  font-size: 5.5cqw;
  font-weight: 900;
  color: #ffd700;
  text-shadow:
    0 0 4cqw rgba(255,200,0,0.9),
    0 2px 6px rgba(0,0,0,0.9);
  line-height: 1;
  min-width: 4cqw;
  text-align: center;
  transition: transform 0.2s;
}

/* Animasi tambah piala */
@keyframes trophyPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.8); filter: brightness(2) drop-shadow(0 0 4cqw gold); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.trophy-pop {
  animation: trophyPop 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
}


/* ─── WINNER POPUP ───────────────────────────────────────────── */
#winnerPopup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  animation: fadeInPopup 0.4s ease-out;
}

@keyframes fadeInPopup {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.winner-inner {
  text-align: center;
  padding: 7cqw 9cqw;
  border-radius: 5cqw;
  border: 0.5cqw solid rgba(255,255,255,0.25);
  box-shadow: 0 0 20cqw rgba(0,0,0,0.8), 0 0 6cqw rgba(255,220,0,0.4);
  animation: popBounce 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popBounce {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.winner-madrid {
  background: linear-gradient(160deg, #1a1a2e 0%, #2a2a50 40%, #1a1a1a 100%);
}

.winner-barca {
  background: linear-gradient(160deg, #1a0010 0%, #3a0020 40%, #0a0030 100%);
}

.winner-trophy {
  font-size: 18cqw;
  line-height: 1;
  animation: trophySpin 1.5s ease-in-out infinite alternate;
}

@keyframes trophySpin {
  from { transform: rotate(-10deg) scale(1);    filter: drop-shadow(0 0 4cqw rgba(255,200,0,0.6)); }
  to   { transform: rotate(10deg)  scale(1.1);  filter: drop-shadow(0 0 8cqw rgba(255,220,0,1)); }
}

.winner-label {
  font-size: 6cqw;
  font-weight: 900;
  color: #ffd700;
  letter-spacing: 0.5cqw;
  text-shadow: 0 0 3cqw rgba(255,200,0,0.9), 0 0 8cqw rgba(255,150,0,0.6);
  margin: 2cqw 0 1cqw;
}

.winner-name {
  font-size: 7.5cqw;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.2cqw;
  text-shadow: 0 0 4cqw rgba(255,255,255,0.8), 0 2px 8px rgba(0,0,0,0.8);
  margin-bottom: 5cqw;
}

.winner-countdown {
  font-size: 10cqw;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 4cqw rgba(255,200,0,0.9), 0 2px 8px rgba(0,0,0,0.8);
  animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.7; }
}

/* ─── PEMAIN ─────────────────────────────────────────────────── */
.madrid {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 55.6cqw;         /* 600px */
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s;
}

.barca {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 55.6cqw;
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s;
}

.madrid:active { filter: brightness(1.4) drop-shadow(0 0 8px rgba(255,255,200,0.9)); }
.barca:active  { filter: brightness(1.4) drop-shadow(0 0 8px rgba(255,100,100,0.9)); }

@keyframes madridGlow {
  0%   { filter: brightness(1) drop-shadow(0 0 0px rgba(255,255,200,0)); }
  30%  { filter: brightness(1.5) drop-shadow(0 0 20px rgba(255,230,80,0.95)) drop-shadow(0 0 40px rgba(255,200,0,0.7)); }
  60%  { filter: brightness(1.3) drop-shadow(0 0 12px rgba(255,220,60,0.6)); }
  100% { filter: brightness(1) drop-shadow(0 0 0px rgba(255,255,200,0)); }
}

@keyframes barcaGlow {
  0%   { filter: brightness(1) drop-shadow(0 0 0px rgba(180,0,60,0)); }
  30%  { filter: brightness(1.5) drop-shadow(0 0 20px rgba(220,30,80,0.95)) drop-shadow(0 0 40px rgba(150,0,200,0.6)); }
  60%  { filter: brightness(1.3) drop-shadow(0 0 12px rgba(200,20,60,0.6)); }
  100% { filter: brightness(1) drop-shadow(0 0 0px rgba(180,0,60,0)); }
}

.madrid.player-glow { animation: madridGlow 0.6s ease-out forwards; }
.barca.player-glow  { animation: barcaGlow  0.6s ease-out forwards; }

/* ─── GOL SHAKE ──────────────────────────────────────────────── */
@keyframes goalShake {
  0%   { transform: translate(0,0) rotate(0deg); }
  10%  { transform: translate(-3px, 2px) rotate(-1.5deg); }
  20%  { transform: translate(3px, -2px) rotate(1.5deg); }
  30%  { transform: translate(-4px, 1px) rotate(-1deg); }
  40%  { transform: translate(4px, -1px) rotate(1deg); }
  50%  { transform: translate(-3px, 2px) rotate(-0.8deg); }
  60%  { transform: translate(3px, -2px) rotate(0.8deg); }
  70%  { transform: translate(-2px, 1px) rotate(-0.4deg); }
  80%  { transform: translate(2px, -1px) rotate(0.4deg); }
  90%  { transform: translate(-1px, 0px) rotate(0deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}

.goal-shake {
  animation: goalShake 0.55s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

/* ─── GOL FLASH ──────────────────────────────────────────────── */
@keyframes goalFlash {
  0%   { opacity: 0; }
  10%  { opacity: 0.55; }
  40%  { opacity: 0.2; }
  70%  { opacity: 0.4; }
  100% { opacity: 0; }
}

.goal-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  border-radius: inherit;
  animation: goalFlash 0.55s ease-out forwards;
}
.goal-flash.madrid-flash { background: radial-gradient(ellipse at 25% 80%, rgba(220,220,100,0.9) 0%, transparent 60%); }
.goal-flash.barca-flash  { background: radial-gradient(ellipse at 75% 80%, rgba(220,30,30,0.9) 0%, transparent 60%); }
