/* Cylon Defense: The battlefield: drones and their bolts, the raptor, the missiles and the nuke.
 * One of the stylesheets index.html links in order; the order is the cascade (README.md, "Stylesheets"). */
/* —— Ambush battlefield (document-grounded; scrolls with the page) —— */
.cylon-battlefield {
  position: absolute;
  inset: 0; /* sized by in-flow body content — never JS scrollHeight */
  width: auto;
  max-width: 100%;
  z-index: 1060;
  pointer-events: none;
  overflow: hidden; /* keep off-screen marches from widening the page */
}


.cylon-bot {
  position: absolute;
  width: 44px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  pointer-events: auto;
  cursor: crosshair;
  /* Above the dodge pip’s former layer; second finger taps hostiles while dragging */
  z-index: 1061;
  touch-action: manipulation;
  transform-origin: 50% 80%;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
  transition: left 0.9s linear, top 0.9s linear;
}


.cylon-bot.is-hiding {
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) brightness(0.75);
  opacity: 0.92;
}


.cylon-bot.is-emerging {
  animation: botEmerge 0.55s ease-out forwards;
}


.cylon-bot.is-marching .cylon-bot-legs span:first-child {
  animation: marchLeg 0.28s ease-in-out infinite alternate;
}


.cylon-bot.is-marching .cylon-bot-legs span:last-child {
  animation: marchLeg 0.28s ease-in-out infinite alternate-reverse;
}


.cylon-bot:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}


.cylon-bot-body {
  position: absolute;
  inset: 10px 8px 6px;
  background:
    linear-gradient(160deg, #6a7384 0%, #2a313c 45%, #151920 100%);
  border: 1px solid #8a93a3;
  border-radius: 4px 4px 3px 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}


.cylon-bot-body::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 18%;
  height: 22%;
  background: #0a0c10;
  border: 1px solid #4a5568;
  border-radius: 2px;
  box-shadow: inset 0 0 6px rgba(255, 0, 0, 0.35);
}


.cylon-bot-body::after {
  /* red slit eye */
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 24%;
  height: 10%;
  background: linear-gradient(90deg, #660000, #ff2222 45%, #fff 50%, #ff2222 55%, #660000);
  border-radius: 1px;
  box-shadow: 0 0 6px 1px rgba(255, 0, 0, 0.85);
  animation: botEyePulse 0.9s ease-in-out infinite alternate;
}


.cylon-bot-legs {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 10px;
  display: flex;
  justify-content: space-between;
}


.cylon-bot-legs span {
  width: 7px;
  height: 100%;
  background: linear-gradient(180deg, #5a6575, #1a1f28);
  border-radius: 1px;
  border: 1px solid #7a8494;
}


.cylon-bot.is-ko {
  pointer-events: none;
  animation: botKo 0.55s ease-in forwards;
}


.cylon-bolt {
  position: absolute;
  width: 10px;
  height: 3px;
  margin-left: -5px;
  margin-top: -1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffaaaa, #ff0000 40%, #ffffff 50%, #ff0000 60%, #aa0000);
  box-shadow:
    0 0 6px 2px rgba(255, 40, 40, 0.95),
    0 0 14px 4px rgba(255, 0, 0, 0.55);
  pointer-events: none;
  z-index: 1062;
  transform-origin: center center;
}


.cylon-impact {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1062;
  background: radial-gradient(circle, #fff 0%, #ff4444 35%, transparent 70%);
  animation: impactPop 0.28s ease-out forwards;
}


/* Abstract transport strike (Raptor-inspired silhouette) */
.cylon-raptor {
  position: fixed;
  inset: 0;
  z-index: 1950;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}


.cylon-raptor.is-inbound {
  visibility: visible;
  opacity: 1;
}


.cylon-raptor-skyflash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(ellipse 80% 45% at 50% 20%, rgba(180, 220, 255, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 45%);
}


.cylon-raptor.is-inbound .cylon-raptor-skyflash {
  animation: raptorSkyFlash 1.85s ease-out forwards;
}


.cylon-raptor-ground {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 55%;
  opacity: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 100%, rgba(255, 120, 40, 0.45), transparent 70%),
    linear-gradient(180deg, transparent 0%, rgba(255, 60, 20, 0.12) 40%, rgba(40, 10, 0, 0.35) 100%);
  filter: blur(1px);
}


.cylon-raptor.is-inbound .cylon-raptor-ground {
  animation: raptorGroundBloom 1.85s ease-out forwards;
}


.cylon-raptor-ship {
  position: absolute;
  top: 18%;
  left: -24%;
  width: 190px;
  height: 52px;
  filter:
    drop-shadow(0 0 14px rgba(160, 210, 255, 0.55))
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  z-index: 2;
}


.cylon-raptor.is-inbound .cylon-raptor-ship {
  animation: raptorFly 1.85s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}


.cylon-raptor-fuselage {
  position: absolute;
  left: 16%;
  top: 28%;
  width: 58%;
  height: 42%;
  background: linear-gradient(180deg, #e8eef8 0%, #8a96a8 40%, #2a313c 100%);
  border: 1px solid #f2f6ff;
  border-radius: 2px 10px 5px 2px;
  transform: skewX(-12deg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}


.cylon-raptor-wing {
  position: absolute;
  top: 14%;
  width: 36%;
  height: 24%;
  background: linear-gradient(180deg, #c5d0e0, #3d4654);
  border: 1px solid #dce5f2;
  box-shadow: 0 0 8px rgba(140, 180, 255, 0.25);
}


.cylon-raptor-wing-l {
  left: 6%;
  transform: skewX(-28deg);
}


.cylon-raptor-wing-r {
  right: 4%;
  top: 46%;
  transform: skewX(-18deg) scaleY(0.85);
}


.cylon-raptor-engine {
  position: absolute;
  right: 2%;
  top: 30%;
  width: 18%;
  height: 36%;
  background: radial-gradient(circle, #fff 0%, #9cf 25%, #3af 55%, transparent 75%);
  box-shadow:
    0 0 16px 6px rgba(100, 200, 255, 0.85),
    0 0 40px 14px rgba(40, 120, 255, 0.45);
  border-radius: 50%;
}


.cylon-raptor.is-inbound .cylon-raptor-engine {
  animation: raptorEnginePulse 0.12s ease-in-out infinite alternate;
}


.cylon-raptor-cannon {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd080 40%, #ff4010 70%, transparent 80%);
  box-shadow:
    0 0 10px 3px rgba(255, 160, 60, 0.95),
    0 0 22px 8px rgba(255, 60, 20, 0.55);
  opacity: 0;
  z-index: 3;
}


.cylon-raptor-cannon-l {
  left: 34%;
  top: 78%;
}


.cylon-raptor-cannon-r {
  left: 52%;
  top: 72%;
}


.cylon-raptor.is-inbound .cylon-raptor-cannon {
  animation: raptorMuzzle 1.85s linear forwards;
}


.cylon-raptor-beam {
  position: absolute;
  top: 85%;
  width: 7px;
  height: 0;
  border-radius: 4px;
  opacity: 0;
  transform-origin: top center;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 210, 120, 0.9) 18%,
    rgba(255, 80, 30, 0.75) 55%,
    rgba(255, 40, 10, 0.15) 100%
  );
  box-shadow:
    0 0 10px 3px rgba(255, 180, 80, 0.95),
    0 0 28px 8px rgba(255, 60, 20, 0.55),
    0 40px 50px 12px rgba(255, 40, 0, 0.25);
  z-index: 1;
}


.cylon-raptor-beam-l {
  left: 36%;
}


.cylon-raptor-beam-r {
  left: 54%;
}


.cylon-raptor-beam-core {
  position: absolute;
  left: 42%;
  top: 80%;
  width: 14px;
  height: 0;
  border-radius: 6px;
  opacity: 0;
  transform-origin: top center;
  background: linear-gradient(
    180deg,
    #fff 0%,
    #ffe9a0 25%,
    rgba(255, 120, 40, 0.85) 70%,
    transparent 100%
  );
  box-shadow:
    0 0 18px 6px rgba(255, 220, 160, 1),
    0 0 48px 16px rgba(255, 80, 20, 0.65);
  z-index: 1;
}


.cylon-raptor.is-inbound .cylon-raptor-beam,
.cylon-raptor.is-inbound .cylon-raptor-beam-core {
  animation: raptorBeam 1.85s linear forwards;
}


.cylon-raptor-strafe {
  position: absolute;
  inset: 12% -5% 0;
  opacity: 0;
  z-index: 0;
  background:
    repeating-linear-gradient(
      98deg,
      transparent 0,
      transparent 26px,
      rgba(255, 240, 200, 0.05) 26px,
      rgba(255, 120, 40, 0.22) 29px,
      rgba(255, 40, 10, 0.35) 31px,
      transparent 34px
    ),
    linear-gradient(
      180deg,
      transparent 0%,
      rgba(255, 180, 80, 0.08) 35%,
      rgba(255, 60, 20, 0.18) 70%,
      rgba(20, 0, 0, 0.25) 100%
    );
  mix-blend-mode: screen;
}


.cylon-raptor.is-inbound .cylon-raptor-strafe {
  animation: raptorStrafe 1.85s ease-out forwards;
}


.cylon-raptor-impacts {
  position: absolute;
  inset: 0;
  z-index: 1;
}


.cylon-raptor-impact {
  position: absolute;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle, #fff 0%, #ffe08a 18%, #ff6020 42%, rgba(255, 40, 0, 0.35) 62%, transparent 72%);
  box-shadow:
    0 0 20px 8px rgba(255, 140, 40, 0.85),
    0 0 50px 18px rgba(255, 40, 0, 0.4);
  animation: raptorImpact 0.55s ease-out forwards;
}


@keyframes raptorFly {
  /* Enter high, dive into a low attack run early, then climb out */
  0% {
    left: -28%;
    top: 6%;
    transform: rotate(-18deg) scale(0.8);
  }
  12% {
    left: 8%;
    top: 28%;
    transform: rotate(-12deg) scale(0.95);
  }
  22% {
    left: 22%;
    top: 42%;
    transform: rotate(-4deg) scale(1.05);
  }
  45% {
    left: 48%;
    top: 44%;
    transform: rotate(0deg) scale(1.08);
  }
  68% {
    left: 72%;
    top: 36%;
    transform: rotate(6deg) scale(1.02);
  }
  100% {
    left: 112%;
    top: 12%;
    transform: rotate(14deg) scale(0.9);
  }
}


@keyframes raptorEnginePulse {
  from {
    filter: brightness(1);
    transform: scale(1);
  }
  to {
    filter: brightness(1.45);
    transform: scale(1.15);
  }
}


@keyframes raptorMuzzle {
  0%,
  8% {
    opacity: 0;
    transform: scale(0.4);
  }
  12%,
  70% {
    opacity: 1;
    transform: scale(1.15);
  }
  16%,
  24%,
  32%,
  40%,
  48%,
  56%,
  64% {
    opacity: 1;
    transform: scale(1.45);
  }
  20%,
  28%,
  36%,
  44%,
  52%,
  60% {
    opacity: 0.55;
    transform: scale(0.85);
  }
  82%,
  100% {
    opacity: 0;
    transform: scale(0.3);
  }
}


@keyframes raptorBeam {
  0%,
  8% {
    opacity: 0;
    height: 0;
    filter: brightness(1);
  }
  14% {
    opacity: 1;
    height: 48vh;
    filter: brightness(1.4);
  }
  22%,
  38%,
  54% {
    opacity: 0.95;
    height: 52vh;
    filter: brightness(1.8);
  }
  30%,
  46% {
    opacity: 0.7;
    height: 40vh;
    filter: brightness(1.1);
  }
  66% {
    opacity: 0.85;
    height: 46vh;
  }
  82%,
  100% {
    opacity: 0;
    height: 12vh;
    filter: brightness(0.6);
  }
}


@keyframes raptorStrafe {
  0%,
  8% {
    opacity: 0;
    transform: translateX(-10%);
  }
  14% {
    opacity: 0.95;
    transform: translateX(-4%);
  }
  40% {
    opacity: 1;
    transform: translateX(0%);
  }
  65% {
    opacity: 0.7;
    transform: translateX(5%);
  }
  100% {
    opacity: 0;
    transform: translateX(12%);
  }
}


@keyframes raptorSkyFlash {
  0%,
  6% {
    opacity: 0;
  }
  12% {
    opacity: 0.9;
  }
  28% {
    opacity: 0.3;
  }
  42% {
    opacity: 0.65;
  }
  100% {
    opacity: 0;
  }
}


@keyframes raptorGroundBloom {
  0%,
  8% {
    opacity: 0;
  }
  16% {
    opacity: 0.95;
  }
  55% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
  }
}


@keyframes raptorImpact {
  0% {
    transform: scale(0.25);
    opacity: 1;
  }
  55% {
    transform: scale(1.35);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.1);
    opacity: 0;
  }
}


/* Nuke warhead in flight (launched from the eye, seeks the cursor) */
.cylon-nuke-missile {
  position: fixed;
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1995;
  opacity: 0;
  visibility: hidden;
  background:
    radial-gradient(circle at 35% 35%, #fff 0%, #ffe08a 28%, #ff5a00 60%, #800000 100%);
  box-shadow:
    0 0 10px 4px rgba(255, 160, 40, 0.95),
    0 0 28px 10px rgba(255, 60, 0, 0.55);
}


.cylon-nuke-missile.is-flying {
  opacity: 1;
  visibility: visible;
}


.cylon-nuke-missile.is-flying::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 8px;
  margin: -4px 0 0 -22px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 180, 80, 0.85), transparent);
  transform: rotate(var(--nuke-heading, 0deg));
  transform-origin: right center;
  filter: blur(1px);
}


.cylon-small-missile {
  position: fixed;
  width: 28px;
  height: 6px;
  margin: -3px 0 0 -14px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 1940;
  opacity: 0;
  visibility: hidden;
  background: linear-gradient(90deg, rgba(255, 160, 60, 0.15), #ff9020 40%, #fff6c8 100%);
  box-shadow: 0 0 10px 3px rgba(255, 120, 40, 0.75);
  transform-origin: center center;
}


.cylon-small-missile.is-flying {
  opacity: 1;
  visibility: visible;
}


.cylon-small-missile.is-tracker {
  height: 8px;
  margin-top: -4px;
  background: linear-gradient(90deg, rgba(80, 220, 255, 0.2), #ff40c8 45%, #e8ffff 100%);
  box-shadow:
    0 0 12px 4px rgba(255, 60, 200, 0.85),
    0 0 22px 8px rgba(60, 200, 255, 0.45);
  animation: trackerPulse 0.18s ease-in-out infinite alternate;
}


.cylon-small-missile.is-tracker::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 2px;
  border: 1.5px solid rgba(255, 80, 220, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(80, 220, 255, 0.8);
}


.cylon-missile-blast {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1063;
  background: radial-gradient(circle, rgba(255, 220, 160, 0.9) 0%, rgba(255, 100, 40, 0.55) 40%, transparent 70%);
  animation: grenadeBlast 0.4s ease-out forwards;
}


@media (prefers-reduced-motion: reduce) {
  .cylon-small-missile.is-tracker {
    animation: none;
  }
}


/* BSG-style nuclear flash */
.cylon-nuke {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}


.cylon-nuke.is-detonating {
  visibility: visible;
  animation: nukeScreen 2.4s ease-out forwards;
}


.cylon-nuke-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
}


.cylon-nuke.is-detonating .cylon-nuke-flash {
  animation: nukeFlash 2.4s ease-out forwards;
}


.cylon-nuke-ball {
  position: absolute;
  left: var(--nuke-x, 50%);
  top: var(--nuke-y, 42%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, #fff 0%, #ffe9a8 18%, #ff8a1a 42%, #ff2a00 62%, rgba(40, 0, 0, 0) 72%);
  opacity: 0;
  transform: scale(0.2);
  filter: blur(0.5px);
  box-shadow:
    0 0 40px 20px rgba(255, 220, 160, 0.85),
    0 0 120px 60px rgba(255, 80, 20, 0.55);
}


.cylon-nuke.is-detonating .cylon-nuke-ball {
  animation: nukeBall 2.4s cubic-bezier(0.15, 0.7, 0.25, 1) forwards;
}


.cylon-nuke-ring {
  position: absolute;
  left: var(--nuke-x, 50%);
  top: var(--nuke-y, 42%);
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 240, 200, 0.85);
  opacity: 0;
  transform: scale(0.3);
  box-shadow: 0 0 24px 4px rgba(255, 180, 80, 0.55);
}


.cylon-nuke.is-detonating .cylon-nuke-ring {
  animation: nukeRing 1.6s ease-out forwards;
}


body.is-nuke-shake {
  animation: nukeShake 0.55s linear;
}


@keyframes nukeScreen {
  0%,
  100% {
    opacity: 1;
  }
}


@keyframes nukeFlash {
  0% {
    opacity: 0;
  }
  4% {
    opacity: 1;
  }
  18% {
    opacity: 0.92;
  }
  45% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
  }
}


@keyframes nukeBall {
  0% {
    opacity: 0;
    transform: scale(0.15);
  }
  6% {
    opacity: 1;
    transform: scale(1.2);
  }
  35% {
    opacity: 1;
    transform: scale(38);
  }
  100% {
    opacity: 0;
    transform: scale(55);
  }
}


@keyframes nukeRing {
  0% {
    opacity: 0.9;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(70);
  }
}


@keyframes nukeShake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-3px, 2px);
  }
  40% {
    transform: translate(3px, -2px);
  }
  60% {
    transform: translate(-2px, -1px);
  }
  80% {
    transform: translate(2px, 1px);
  }
}


