/* ===== STADIUM ATMOSPHERE (battle page only) ===== */
/* Adds arena arc lights and floor glow on top of the shared body background */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    /* Stadium spotlight from above */
    radial-gradient(ellipse 80% 35% at 50% -5%, rgba(180,120,255,0.09) 0%, transparent 65%),
    /* Left-side arena wall glow */
    radial-gradient(ellipse 20% 80% at -2% 50%, rgba(68,136,255,0.07) 0%, transparent 70%),
    /* Right-side arena wall glow */
    radial-gradient(ellipse 20% 80% at 102% 50%, rgba(255,68,68,0.07) 0%, transparent 70%),
    /* Floor energy from below */
    radial-gradient(ellipse 100% 25% at 50% 105%, rgba(120,60,220,0.10) 0%, transparent 55%);
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; position: relative; z-index: 1; }

/* ===== COLORS ===== */
.p1-color { color: #4488ff; }
.p2-color { color: #ff4444; }

/* ===== BACK LINK ===== */
.back-link {
  display: inline-block;
  color: #FFD700;
  font-weight: 900;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 8px 16px;
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 20px;
  margin-bottom: 10px;
  transition: all 0.2s;
  position: relative;
  z-index: 1;
}
.back-link:hover {
  background: rgba(255,215,0,0.12);
  border-color: #FFD700;
}

/* ===== SELECTION SCREEN ===== */
#selection-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px auto 20px;
  max-width: 700px;
  position: relative;
  z-index: 1;
  padding: 0 16px;
}

.player-slot {
  flex: 1;
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.03);
}

#p1-slot { border-color: rgba(68,136,255,0.3); background: rgba(68,136,255,0.06); }
#p2-slot { border-color: rgba(255,68,68,0.3); background: rgba(255,68,68,0.06); }
#p1-slot.selecting { border-color: #4488ff; box-shadow: 0 0 20px rgba(68,136,255,0.5); }
#p2-slot.selecting { border-color: #ff4444; box-shadow: 0 0 20px rgba(255,68,68,0.5); }

.slot-label {
  font-family: 'Bangers', cursive;
  font-size: 1.2rem;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.slot-preview {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.slot-preview img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
}

.slot-empty {
  color: #666;
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.slot-pokemon-name {
  color: #e0e0ff;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: capitalize;
}

.vs-orb {
  font-family: 'Bangers', cursive;
  font-size: 2.5rem;
  color: #FFD700;
  text-shadow: 0 0 20px #FFD700, 0 0 40px #FF8C00;
  flex-shrink: 0;
  animation: titlePulse 2s ease-in-out infinite;
}

/* ===== TYPE FILTERS ===== */
#type-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 860px;
  margin: 0 auto 14px;
  position: relative;
  z-index: 1;
  padding: 0 12px;
}

.type-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 2px solid var(--type-color, #FFD700);
  background: transparent;
  color: var(--type-color, #FFD700);
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 0.75rem;
  text-transform: capitalize;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.5px;
}

.type-btn:hover,
.type-btn.active {
  background: var(--type-color, #FFD700);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  transform: scale(1.06);
  box-shadow: 0 0 10px var(--type-color, #FFD700);
}

.type-btn.active[style*="FFD700"],
.type-btn:hover[style*="FFD730"] {
  color: #1a1a1a;
}

/* ===== SELECTION GRID ===== */
#select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 20px;
  padding: 0 12px;
  position: relative;
  z-index: 1;
  max-height: 380px;
  overflow-y: auto;
}

.select-card {
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 4px 6px;
  text-align: center;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  transition: all 0.15s ease;
}

.select-card:hover {
  border-color: #FFD700;
  background: rgba(255,215,0,0.08);
  transform: scale(1.06);
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
}

.select-card img {
  width: 60px;
  height: 60px;
  image-rendering: pixelated;
}

.select-name {
  font-size: 0.65rem;
  font-weight: 900;
  color: #b0b0d0;
  text-transform: capitalize;
  margin-top: 2px;
}

.select-card.picked-p1 {
  border-color: #4488ff;
  background: rgba(68,136,255,0.15);
  box-shadow: 0 0 12px rgba(68,136,255,0.4);
}

.select-card.picked-p2 {
  border-color: #ff4444;
  background: rgba(255,68,68,0.15);
  box-shadow: 0 0 12px rgba(255,68,68,0.4);
}

/* ===== BATTLE LAUNCH BUTTON ===== */
.battle-launch-btn {
  display: block;
  margin: 6px auto 24px;
  padding: 14px 54px;
  font-family: 'Bangers', cursive;
  font-size: 2rem;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #FF4500, #FF8C00);
  color: white;
  border: 3px solid #FFD700;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(255,69,0,0.4), 0 0 30px rgba(255,140,0,0.15);
  position: relative;
  z-index: 1;
}

.battle-launch-btn:not(:disabled):hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 8px 30px rgba(255,69,0,0.6), 0 0 50px rgba(255,140,0,0.35);
}

.battle-launch-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ===== BATTLE SCREEN ===== */
#battle-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 12px;
  position: relative;
  z-index: 1;
}

/* HUD bars */
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  margin-bottom: 4px;
}

.p2-hud {
  background: rgba(255,68,68,0.08);
  border: 1px solid rgba(255,68,68,0.25);
  flex-direction: row-reverse;
  margin-top: 0;
}

.p1-hud {
  background: rgba(68,136,255,0.08);
  border: 1px solid rgba(68,136,255,0.25);
  margin-top: 4px;
}

.hud-name {
  font-family: 'Bangers', cursive;
  font-size: 1.3rem;
  letter-spacing: 2px;
  white-space: nowrap;
  text-transform: capitalize;
  min-width: 110px;
}

.hp-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.hp-label {
  font-family: 'Bangers', cursive;
  font-size: 1rem;
  color: #888;
  letter-spacing: 1px;
}

.hp-track {
  flex: 1;
  height: 14px;
  background: rgba(0,0,0,0.6);
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: #44dd44;
  border-radius: 7px;
  transition: width 0.5s ease, background 0.3s ease;
}

.hp-num {
  font-weight: 900;
  font-size: 0.8rem;
  color: #e0e0e0;
  min-width: 72px;
  text-align: right;
}

/* ===== BATTLEFIELD ===== */
#battlefield {
  height: 250px;
  position: relative;
  overflow: visible;
  border-radius: 16px;
  border: 2px solid rgba(255,215,0,0.5);
  box-shadow:
    0 0 0 1px rgba(255,215,0,0.08),
    0 0 30px rgba(255,215,0,0.2),
    0 0 60px rgba(120,80,255,0.12),
    inset 0 0 50px rgba(0,0,20,0.5);

  background:
    /* Stars */
    radial-gradient(1px 1px at  5% 11%, rgba(255,255,255,0.95), transparent),
    radial-gradient(1px 1px at 18%  6%, rgba(255,255,255,0.75), transparent),
    radial-gradient(1px 1px at 33% 19%, rgba(255,255,255,0.90), transparent),
    radial-gradient(1px 1px at 47%  8%, rgba(255,255,255,0.65), transparent),
    radial-gradient(1px 1px at 63% 15%, rgba(255,255,255,0.85), transparent),
    radial-gradient(1px 1px at 79%  5%, rgba(255,255,255,0.70), transparent),
    radial-gradient(1px 1px at 92% 22%, rgba(255,255,255,0.90), transparent),
    radial-gradient(1px 1px at 24% 30%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1px 1px at 55% 34%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 86% 40%, rgba(255,255,255,0.60), transparent),
    radial-gradient(1px 1px at 11% 45%, rgba(255,255,255,0.40), transparent),
    /* Bright tinted stars */
    radial-gradient(2px 2px at 70%  7%, rgba(255,240,140,0.90), transparent),
    radial-gradient(2px 2px at  9% 23%, rgba(180,160,255,0.85), transparent),
    radial-gradient(2px 2px at 50% 26%, rgba(140,220,255,0.70), transparent),
    /* P1 blue energy hemisphere — bottom left */
    radial-gradient(ellipse 48% 55% at 12% 90%, rgba(68,136,255,0.30) 0%, rgba(68,136,255,0.08) 45%, transparent 70%),
    /* P2 red energy hemisphere — top right */
    radial-gradient(ellipse 48% 55% at 88% 10%, rgba(255,68,68,0.30) 0%, rgba(255,68,68,0.08) 45%, transparent 70%),
    /* Gold clash glow at center */
    radial-gradient(ellipse 30% 40% at 50% 65%, rgba(255,215,0,0.18) 0%, transparent 70%),
    /* Nebula cloud mid-sky */
    radial-gradient(ellipse 60% 25% at 50% 35%, rgba(80,40,120,0.20) 0%, transparent 70%),
    /* Deep space sky */
    linear-gradient(165deg, #020212 0%, #060528 28%, #0e061c 55%, #0a0310 80%, #040210 100%);
}

/* Perspective arena floor */
#battlefield::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 75px;
  border-radius: 0 0 14px 14px;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg,
      rgba(255,215,0,0.18) 0px, rgba(255,215,0,0.18) 1px,
      transparent 1px, transparent 32px
    ),
    repeating-linear-gradient(0deg,
      rgba(255,215,0,0.14) 0px, rgba(255,215,0,0.14) 1px,
      transparent 1px, transparent 22px
    ),
    linear-gradient(to top, rgba(18,8,55,0.97) 0%, rgba(12,5,40,0.75) 55%, transparent 100%);
  transform: perspective(160px) rotateX(42deg);
  transform-origin: bottom center;
}

/* Central energy beam */
#battlefield::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 15%;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top,
    rgba(255,215,0,0.9) 0%,
    rgba(255,215,0,0.5) 35%,
    rgba(255,215,0,0.15) 65%,
    transparent 100%
  );
  box-shadow:
    0 0 8px  rgba(255,215,0,0.7),
    0 0 20px rgba(255,215,0,0.4),
    0 0 50px rgba(255,215,0,0.15);
  animation: beamPulse 2.2s ease-in-out infinite;
}

@keyframes beamPulse {
  0%, 100% { opacity: 0.5; box-shadow: 0 0 8px rgba(255,215,0,0.6), 0 0 20px rgba(255,215,0,0.3); }
  50%       { opacity: 1;   box-shadow: 0 0 14px rgba(255,215,0,1),  0 0 40px rgba(255,215,0,0.6), 0 0 80px rgba(255,215,0,0.2); }
}

.fighter-wrap {
  position: absolute;
  z-index: 2;
}

.p2-wrap {
  right: 24px;
  top: 16px;
}

.p1-wrap {
  left: 24px;
  bottom: 16px;
}

/* Platform glow under each fighter */
.p1-wrap::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(68,136,255,0.7) 0%, transparent 70%);
  box-shadow: 0 0 18px rgba(68,136,255,0.5), 0 0 40px rgba(68,136,255,0.2);
  animation: platformGlow 1.8s ease-in-out infinite alternate;
  pointer-events: none;
}

.p2-wrap::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,68,68,0.7) 0%, transparent 70%);
  box-shadow: 0 0 18px rgba(255,68,68,0.5), 0 0 40px rgba(255,68,68,0.2);
  animation: platformGlow 1.8s ease-in-out infinite alternate-reverse;
  pointer-events: none;
}

@keyframes platformGlow {
  from { opacity: 0.55; transform: translateX(-50%) scaleX(0.8); }
  to   { opacity: 1;    transform: translateX(-50%) scaleX(1.2); }
}

.fighter-sprite {
  width: 120px;
  height: 120px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6));
}

/* ===== BATTLE BOTTOM ===== */
#battle-bottom {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-top: 8px;
}

#battle-log {
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,215,0,0.18);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
}

#log-text {
  color: #e0e0ff;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.5;
}

#move-panel {
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,215,0,0.18);
  border-radius: 12px;
  padding: 10px;
}

#turn-banner {
  font-family: 'Bangers', cursive;
  font-size: 1.05rem;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-align: center;
  color: #ccc;
}

#moves-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.move-btn:last-child:nth-child(odd) {
  grid-column: span 2;
}

.move-btn {
  padding: 7px 9px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: white;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.move-btn:not(:disabled):hover {
  border-color: #FFD700;
  background: rgba(255,215,0,0.1);
  transform: scale(1.04);
  box-shadow: 0 0 8px rgba(255,215,0,0.2);
}

.move-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.move-name {
  font-weight: 900;
  font-size: 0.8rem;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.move-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}

.move-type {
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: capitalize;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.move-power {
  font-size: 0.68rem;
  color: #FFD700;
  font-weight: 900;
}

/* ===== HIT ANIMATIONS ===== */
@keyframes hitFlash {
  0%   { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)); }
  15%  { filter: brightness(12) saturate(0); }
  35%  { filter: brightness(1); }
  55%  { filter: brightness(8) saturate(0); }
  100% { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)); }
}

.hit-flash {
  animation: hitFlash 0.55s ease-out forwards !important;
}

@keyframes screenShake {
  0%,100% { transform: translate(0,0) rotate(0); }
  10%  { transform: translate(-9px,-3px) rotate(-1deg); }
  20%  { transform: translate(9px, 3px) rotate(1deg); }
  30%  { transform: translate(-7px,-2px) rotate(-0.5deg); }
  40%  { transform: translate(7px, 2px) rotate(0.5deg); }
  50%  { transform: translate(-5px, 0); }
  60%  { transform: translate(5px, 0); }
  70%  { transform: translate(-3px, 0); }
  80%  { transform: translate(3px, 0); }
  90%  { transform: translate(-1px, 0); }
}

.screen-shake {
  animation: screenShake 0.6s ease-out !important;
}

@keyframes floatUp {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  25%  { opacity: 1; transform: translateX(-50%) translateY(-18px) scale(1.25); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-70px) scale(0.7); }
}

.damage-number {
  position: absolute;
  top: 35%;
  left: 50%;
  font-family: 'Bangers', cursive;
  font-size: 2.2rem;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.9), 0 0 10px rgba(255,255,255,0.4);
  pointer-events: none;
  z-index: 200;
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}

.damage-big {
  font-size: 3rem;
  color: #FFD700;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.9), 0 0 20px #FFD700;
}

.damage-immune {
  font-size: 1.4rem;
  color: #aaa;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.9);
}

/* ===== WINNER SCREEN ===== */
#screen-winner.active {
  text-align: center;
  padding: 30px 20px 40px;
}

#winner-content {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

#trophy-text {
  font-family: 'Bangers', cursive;
  font-size: 3.5rem;
  color: #FFD700;
  text-shadow: 0 0 20px #FFD700, 0 0 50px #FF8C00, 3px 3px 0 #8B6914;
  animation: titlePulse 1s ease-in-out infinite;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

#winner-player-label {
  font-family: 'Bangers', cursive;
  font-size: 2.4rem;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

#winner-sprite {
  width: 180px;
  height: 180px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.7)) drop-shadow(0 0 50px rgba(255,215,0,0.3));
  animation: winnerBounce 0.7s ease-in-out infinite alternate;
  display: block;
  margin: 0 auto;
}

@keyframes winnerBounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-18px) scale(1.06); }
}

#winner-pokemon-name {
  font-family: 'Bangers', cursive;
  font-size: 2.8rem;
  color: white;
  letter-spacing: 3px;
  text-transform: capitalize;
  margin: 10px 0 4px;
  text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

#winner-message {
  font-family: 'Bangers', cursive;
  font-size: 1.8rem;
  color: #FF8C00;
  letter-spacing: 2px;
  margin-bottom: 28px;
  text-shadow: 0 0 15px rgba(255,140,0,0.5);
}

#winner-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

#rematch-btn, #new-battle-btn {
  padding: 12px 30px;
  font-family: 'Bangers', cursive;
  font-size: 1.4rem;
  letter-spacing: 2px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid;
}

#rematch-btn {
  background: linear-gradient(135deg, #FF4500, #FF6B00);
  color: white;
  border-color: #FF8C00;
  box-shadow: 0 4px 15px rgba(255,69,0,0.4);
}

#new-battle-btn {
  background: linear-gradient(135deg, #1a1a4a, #2a2a6a);
  color: #FFD700;
  border-color: #FFD700;
  box-shadow: 0 4px 15px rgba(255,215,0,0.2);
}

#rematch-btn:hover    { transform: scale(1.08); box-shadow: 0 6px 25px rgba(255,69,0,0.6); }
#new-battle-btn:hover { transform: scale(1.08); box-shadow: 0 6px 25px rgba(255,215,0,0.4); }

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  #battle-bottom { grid-template-columns: 1fr; }
  .fighter-sprite { width: 96px; height: 96px; }
  #battlefield { height: 190px; }
  .p2-wrap { right: 12px; top: 10px; }
  .p1-wrap { left: 12px; bottom: 10px; }
}
