.space-war-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, #3b82f6 0%, #1d4ed8 22%, #172554 48%, #0b1024 72%, #050814 100%);
  color: #fff;
  user-select: none;
  touch-action: none;
  perspective: 1200px;
  font-family: Inter, system-ui, sans-serif;
}

.space-war-stage * {
  box-sizing: border-box;
}

.space-war-stage #hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 50;
}

.space-war-stage #score {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(255,255,255,.22);
}

.space-war-stage #status {
  margin-top: 4px;
  font-size: 14px;
  opacity: .96;
}

.space-war-stage #combo {
  margin-top: 8px;
  font-size: 18px;
  color: #fef08a;
  font-weight: 800;
  opacity: 0;
  transition: opacity .2s ease;
  text-shadow: 0 0 12px rgba(254,240,138,.45);
}

.space-war-stage #combo.show {
  opacity: 1;
}

.space-war-stage #stars,
.space-war-stage #nebula,
.space-war-stage #enemyLayer,
.space-war-stage #bulletLayer,
.space-war-stage #fxLayer,
.space-war-stage #hitFlash {
  position: absolute;
  inset: 0;
}

.space-war-stage #stars {
  background:
    radial-gradient(circle at 8% 16%, rgba(255,255,255,1) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 18% 48%, rgba(255,255,255,.95) 0 1px, transparent 2px),
    radial-gradient(circle at 32% 22%, rgba(255,244,200,.95) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 44% 78%, rgba(255,255,255,.9) 0 1px, transparent 2px),
    radial-gradient(circle at 58% 32%, rgba(255,255,255,.95) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 72% 16%, rgba(255,240,180,.95) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 82% 52%, rgba(255,255,255,.9) 0 1px, transparent 2px),
    radial-gradient(circle at 92% 26%, rgba(255,255,255,.9) 0 1px, transparent 2px),
    radial-gradient(circle at 86% 84%, rgba(255,255,255,.9) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 22% 88%, rgba(255,255,255,.85) 0 1px, transparent 2px),
    radial-gradient(circle at 66% 70%, rgba(255,255,255,.85) 0 1px, transparent 2px);
  animation: sw-stars 18s linear infinite;
  opacity: 1;
}

.space-war-stage #stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 24%, rgba(255,255,255,.45) 0 3px, transparent 6px),
    radial-gradient(circle at 38% 64%, rgba(255,255,255,.35) 0 2px, transparent 5px),
    radial-gradient(circle at 68% 20%, rgba(255,255,255,.4) 0 3px, transparent 6px),
    radial-gradient(circle at 88% 72%, rgba(255,255,255,.35) 0 2px, transparent 5px);
  animation: sw-twinkle 3s ease-in-out infinite alternate;
}

@keyframes sw-stars {
  from { transform: translateY(0); }
  to { transform: translateY(120px); }
}

@keyframes sw-twinkle {
  from { opacity: .45; }
  to { opacity: 1; }
}

.space-war-stage #nebula {
  background:
    radial-gradient(circle at 18% 22%, rgba(125,211,252,.28) 0%, transparent 32%),
    radial-gradient(circle at 76% 26%, rgba(196,181,253,.22) 0%, transparent 28%),
    radial-gradient(circle at 60% 76%, rgba(244,114,182,.16) 0%, transparent 30%),
    radial-gradient(circle at 36% 72%, rgba(253,224,71,.10) 0%, transparent 24%);
  filter: blur(18px) saturate(1.15);
}

.space-war-stage #player {
  position: absolute;
  left: 50%;
  bottom: 12vh;
  width: 110px;
  height: 132px;
  z-index: 30;
  transform-style: preserve-3d;
}

.space-war-stage .ship {
  position: absolute;
  inset: 0;
}

.space-war-stage .pig-ship {
  position: relative;
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 0%, 72% 22%, 84% 62%, 64% 100%, 36% 100%, 16% 62%, 28% 22%);
  background: linear-gradient(180deg, #fbcfe8 0%, #f472b6 46%, #ec4899 74%, #9d174d 100%);
  border: 2px solid rgba(255,255,255,.32);
  box-shadow:
    inset 0 -8px 0 rgba(0,0,0,.12),
    0 0 30px rgba(244,114,182,.34);
}

.space-war-stage .pig-ship::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: 42px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255,182,193,.95);
  box-shadow:
    -18px 2px 0 -4px rgba(255,182,193,.9),
    18px 2px 0 -4px rgba(255,182,193,.9);
  opacity: .9;
}

.space-war-stage .cockpit {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 30px;
  height: 38px;
  transform: translateX(-50%);
  border-radius: 16px 16px 10px 10px;
  background: linear-gradient(180deg, #eff6ff, #7dd3fc);
  box-shadow: 0 0 18px rgba(125,211,252,.6);
}

.space-war-stage .wing {
  position: absolute;
  top: 44px;
  width: 26px;
  height: 52px;
  background: linear-gradient(180deg, #f9a8d4, #ec4899);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(244,114,182,.2);
}

.space-war-stage .wing.left {
  left: -12px;
  transform: skewY(18deg);
}

.space-war-stage .wing.right {
  right: -12px;
  transform: skewY(-18deg);
}

.space-war-stage .engine {
  position: absolute;
  bottom: -6px;
  width: 16px;
  height: 24px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #64748b, #0f172a);
}

.space-war-stage .engine.left { left: 30px; }
.space-war-stage .engine.right { right: 30px; }

.space-war-stage .engine::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  width: 12px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #fef08a 25%, #fb923c 70%, transparent);
  filter: blur(1px);
  animation: sw-engine .14s infinite alternate;
}

@keyframes sw-engine {
  from { transform: translateX(-50%) scaleY(.8); opacity: .8; }
  to { transform: translateX(-50%) scaleY(1.25); opacity: 1; }
}

.space-war-stage .gun {
  position: absolute;
  top: -6px;
  width: 8px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(180deg, #fff, #cbd5e1);
  box-shadow: 0 0 8px rgba(255,255,255,.35);
}

.space-war-stage .gun.left { left: 30px; }
.space-war-stage .gun.right { right: 30px; }

.space-war-stage .enemy {
  position: absolute;
  width: 88px;
  height: 108px;
  transform: translate(-50%, -50%);
  transition: filter .2s ease;
  z-index: 20;
}

.space-war-stage .enemy.hit {
  filter: brightness(1.9) saturate(1.3);
}

.space-war-stage .enemy-body {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 78% 18%, 90% 56%, 68% 100%, 32% 100%, 10% 56%, 22% 18%);
  background: linear-gradient(180deg, #bfdbfe 0%, #60a5fa 38%, #2563eb 72%, #1d4ed8 100%);
  border: 2px solid rgba(255,255,255,.24);
  box-shadow:
    inset 0 -8px 0 rgba(0,0,0,.12),
    0 0 24px rgba(96,165,250,.24);
}

.space-war-stage .enemy.fire .enemy-body {
  background: linear-gradient(180deg, #fde68a 0%, #f9a8d4 26%, #fb7185 60%, #ef4444 100%);
  box-shadow:
    inset 0 -8px 0 rgba(0,0,0,.10),
    0 0 24px rgba(251,113,133,.28);
}

.space-war-stage .enemy-wing {
  position: absolute;
  top: 34px;
  width: 24px;
  height: 44px;
  background: linear-gradient(180deg, #93c5fd, #2563eb);
  border-radius: 10px;
}

.space-war-stage .enemy.fire .enemy-wing {
  background: linear-gradient(180deg, #fdba74, #fb7185);
}

.space-war-stage .enemy-wing.left {
  left: -12px;
  transform: skewY(18deg);
}

.space-war-stage .enemy-wing.right {
  right: -12px;
  transform: skewY(-18deg);
}

.space-war-stage .enemy-core {
  position: absolute;
  left: 50%;
  top: 22px;
  width: 24px;
  height: 24px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  box-shadow: 0 0 18px rgba(255,255,255,.45);
}

.space-war-stage .enemy.fire .enemy-core {
  background: #fff7ed;
  box-shadow: 0 0 18px rgba(255,237,213,.6);
}

.space-war-stage .bullet {
  position: absolute;
  width: 12px;
  height: 34px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.space-war-stage .bullet.player {
  background: linear-gradient(180deg, #ffffff, #a7f3d0 20%, #67e8f9 55%, #22d3ee 100%);
  box-shadow:
    0 0 16px rgba(34,211,238,.85),
    0 0 28px rgba(103,232,249,.45);
}

.space-war-stage .bullet.player::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translateX(-50%);
  width: 7px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.4), rgba(34,211,238,.22), transparent);
  filter: blur(2px);
}

.space-war-stage .bullet.enemy {
  background: linear-gradient(180deg, #ffffff, #fda4af 24%, #fb7185 60%, #ef4444 100%);
  box-shadow:
    0 0 16px rgba(251,113,133,.75),
    0 0 26px rgba(239,68,68,.35);
}

.space-war-stage .bullet.enemy::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translateX(-50%);
  width: 7px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(239,68,68,.22), transparent);
  filter: blur(2px);
}

.space-war-stage .fx {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.space-war-stage .muzzle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #a7f3d0 25%, #67e8f9 50%, transparent 78%);
  animation: sw-puff 180ms ease-out forwards;
}

.space-war-stage .explosion {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0%, #fde68a 16%, #f9a8d4 34%, #fb7185 56%, rgba(236,72,153,.45) 72%, transparent 100%);
  animation: sw-boom .55s ease-out forwards;
}

@keyframes sw-puff {
  from { transform: scale(.4); opacity: 1; }
  to { transform: scale(1.9); opacity: 0; }
}

@keyframes sw-boom {
  from { transform: scale(.2); opacity: 1; }
  to { transform: scale(5.2); opacity: 0; }
}

.space-war-stage #hitFlash {
  opacity: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.12), rgba(251,113,133,.2), transparent 70%);
  transition: opacity .12s ease;
}

.space-war-stage #hitFlash.show {
  opacity: 1;
}

.space-war-stage .overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(10,14,30,.48);
  backdrop-filter: blur(4px);
  text-align: center;
  padding: 24px;
}

.space-war-stage .overlay.hidden {
  display: none;
}

.space-war-stage .overlay h2 {
  margin: 0;
  font-size: 42px;
  text-shadow: 0 0 20px rgba(255,255,255,.18);
}

.space-war-stage .overlay p {
  margin: 0;
  opacity: .95;
}

.space-war-stage .overlay button {
  border: 0;
  border-radius: 14px;
  padding: 14px 24px;
  background: linear-gradient(180deg, #f472b6, #db2777);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 10px 30px rgba(219,39,119,.28);
}

.space-war-stage .mobile-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  gap: 12px;
  padding: 14px;
}

.space-war-stage .control-btn {
  flex: 1;
  min-height: 62px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(30,41,59,.55);
  color: #fff;
  font-size: 28px;
  backdrop-filter: blur(8px);
}

.space-war-stage .fire-btn {
  max-width: 110px;
  background: linear-gradient(180deg, #fb7185, #e11d48);
}
