@font-face {
  font-family: "GameFont";
  src: url("../assets/gameFont.ttf") format("truetype");
  font-display: swap;
}

body {
  margin: 0;
  overflow: hidden;
  background: #0b0b0b;
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
}

#game {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: none;
  background:
    linear-gradient(rgba(8, 8, 12, 0.58), rgba(8, 8, 12, 0.58)),
    var(--stage-bg, url('../assets/images/ocean.jpeg')) center / cover no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
}

#game.devito-mode {
  background:
    linear-gradient(rgba(8, 8, 12, 0.42), rgba(8, 8, 12, 0.42)),
    url('../assets/images/devito.jpeg') center / cover no-repeat !important;
}

#game.menu-mode #icePathCanvas,
#game.menu-mode #hudTop,
#game.menu-mode #bossUI,
#game.menu-mode #bossAmbience,
#game.menu-mode #deathScreen,
#game.menu-mode .orb,
#game.menu-mode .enemy,
#game.menu-mode .power,
#game.menu-mode .kirk,
#game.menu-mode .bonix,
#game.menu-mode .drake,
#game.menu-mode .boss,
#game.menu-mode .boss-bullet,
#game.menu-mode #shieldRing,
#game.menu-mode #kirkShieldRing,
#game.menu-mode #player {
  display: none !important;
}

#game.devito-mode .enemy,
#game.devito-mode .orb,
#game.devito-mode .power,
#game.devito-mode .kirk,
#game.devito-mode .bonix,
#game.devito-mode .drake,
#game.devito-mode .boss-bullet {
  background-image: url('../assets/images/devito.jpeg') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

#game.devito-mode .enemy::before,
#game.devito-mode .enemy::after,
#game.devito-mode .orb::before,
#game.devito-mode .orb::after,
#game.devito-mode .power::before,
#game.devito-mode .power::after,
#game.devito-mode .kirk::before,
#game.devito-mode .kirk::after,
#game.devito-mode .bonix::before,
#game.devito-mode .bonix::after,
#game.devito-mode .drake::before,
#game.devito-mode .drake::after {
  content: none !important;
}

#game.paused-mode > *:not(#pauseMenu) {
  filter: blur(4px) brightness(0.55);
  transition: filter 180ms ease;
}

#game.death-mode > *:not(#deathScreen) {
  filter: blur(2.6px) brightness(0.68) saturate(0.94);
  transition: filter 260ms ease;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 21000;
  opacity: 1;
  transform: scale(1);
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.menu-overlay.hidden {
  opacity: 0;
  transform: scale(0.985);
  visibility: hidden;
  pointer-events: none;
}

.menu-overlay.entering {
  animation: menuIn 300ms cubic-bezier(.2,.72,.2,1) both;
}

.menu-overlay.exiting {
  animation: menuOut 240ms cubic-bezier(.4,0,.2,1) both;
}

#startMenu {
  flex-direction: column;
  gap: 16px;
}

.pause-overlay {
  background: rgba(8, 10, 16, 0.35);
  backdrop-filter: blur(8px) brightness(0.72);
}

.pause-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: min(360px, 88vw);
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

#confettiLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 22025;
}

.confetti-piece {
  position: absolute;
  border-radius: 1px;
  opacity: 0;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
  animation: confettiDrop linear forwards;
}

.highscore-display {
  color: #f2fbff;
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
  font-size: clamp(0.92rem, 2.2vw, 1.1rem);
  letter-spacing: 0.8px;
  text-shadow: 0 0 14px rgba(163, 220, 255, 0.5), 0 6px 18px rgba(0, 0, 0, 0.58);
  animation: highscoreFloat 2.1s ease-in-out infinite;
  transform: translateY(3px);
}

.highscore-display span {
  color: #ffffff;
}

.menu-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(280px, 76vw);
  min-height: 58px;
  padding: 0 22px;
  line-height: 1;
  text-align: center;
  vertical-align: middle;
  border-radius: 999px;
  border: 1px solid rgba(190, 230, 255, 0.72);
  background: linear-gradient(180deg, rgba(218, 239, 255, 0.24), rgba(120, 176, 214, 0.13));
  color: #f6fbff;
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
  font-size: clamp(1rem, 2.6vw, 1.22rem);
  letter-spacing: 0.6px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 140ms ease, box-shadow 140ms ease, background 160ms ease, opacity 160ms ease;
}

.menu-btn .btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 1em;
  transform: translateY(6px);
  will-change: transform;
}

.menu-btn:hover {
  transform: translateY(-1px) scale(1.01);
  background: linear-gradient(180deg, rgba(226, 246, 255, 0.3), rgba(139, 192, 226, 0.18));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42), 0 0 24px rgba(155, 219, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.menu-btn:active {
  transform: translateY(0);
}

.menu-btn.secondary {
  border-color: rgba(255, 196, 196, 0.72);
  background: linear-gradient(180deg, rgba(255, 213, 213, 0.24), rgba(214, 120, 120, 0.14));
}

.menu-btn.secondary:hover {
  background: linear-gradient(180deg, rgba(255, 223, 223, 0.32), rgba(224, 136, 136, 0.2));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42), 0 0 24px rgba(255, 157, 157, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.menu-overlay.entering .menu-btn {
  animation: buttonIn 320ms cubic-bezier(.2,.72,.2,1) both;
}

.menu-overlay.entering .menu-btn:nth-child(2) {
  animation-delay: 50ms;
}

#game.starting-game > *:not(#startMenu):not(#pauseMenu) {
  animation: gameReveal 340ms ease both;
}

#game.exiting-to-home > *:not(#pauseMenu):not(#startMenu) {
  animation: gameToMenu 240ms ease both;
}

#player {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.95));
  animation: playerAura 1.4s ease-in-out infinite, playerHover 1.1s ease-in-out infinite;
  transition: width 0.1s, height 0.1s;
}

.orb {
  position: absolute;
  width: 22px;
  height: 22px;
  background: url('../assets/images/Food/Waffles.png') center / cover no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 10px rgba(255, 183, 88, 0.9));
  border-radius: 50%;
  transform-origin: center;
  animation: orbFloat 1.25s ease-in-out infinite, orbPulse 1.3s ease-in-out infinite;
}

.orb::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 147, 0.86);
  opacity: 0.75;
  animation: orbHalo 1.5s ease-out infinite;
}

.orb::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 148, 0.34) 0%, rgba(201, 138, 58, 0.11) 56%, rgba(110, 71, 30, 0) 72%);
  animation: orbAura 1.65s ease-in-out infinite;
  pointer-events: none;
}

.enemy {
  position: absolute;
  width: 32px;
  height: 32px;
  background-image: url('../assets/images/enemy.png');
  background-repeat: no-repeat;
  background-size: 128px 32px;
  background-position: 0 0;
  image-rendering: pixelated;
  filter: hue-rotate(-58deg) saturate(1.58) contrast(1.18) brightness(1.22) drop-shadow(0 0 16px rgba(255, 28, 28, 1));
  animation: enemyFly 0.6s steps(4) infinite, enemyHover 0.95s ease-in-out infinite, enemyGlow 1.1s ease-in-out infinite;
  animation-delay: var(--enemy-fly-delay, 0s), var(--enemy-hover-delay, 0s), var(--enemy-glow-delay, 0s);
  border-radius: 6px;
  outline: 1px solid rgba(255, 220, 220, 0.34);
  outline-offset: -1px;
  transition: transform 120ms linear, filter 120ms linear;
}

.enemy::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 80, 80, 0.74);
  opacity: 0.72;
  pointer-events: none;
}

.enemy.spawn-safe {
  opacity: 0.66;
  filter: hue-rotate(-58deg) saturate(0.92) brightness(1.24) drop-shadow(0 0 12px rgba(255, 236, 132, 0.95));
}

.enemy.jack-minion {
  background-image: url('../assets/images/jackenemy.jpeg');
  background-size: cover;
  background-position: center;
  filter: saturate(1.2) contrast(1.1) brightness(1.18) drop-shadow(0 0 16px rgba(72, 166, 255, 0.95));
  outline-color: rgba(170, 220, 255, 0.42);
}

.enemy.spawn-safe::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 239, 154, 0.92);
  animation: enemySpawnShield 0.24s linear infinite;
  pointer-events: none;
}

.orb.spawn-in {
  animation:
    orbSpawnIn 260ms ease-out forwards,
    orbFloat 1.25s ease-in-out infinite 260ms,
    orbPulse 1.3s ease-in-out infinite 260ms;
}

.enemy.spawn-in {
  animation:
    enemySpawnIn 260ms ease-out forwards,
    enemyFly 0.6s steps(4) infinite 260ms,
    enemyHover 0.95s ease-in-out infinite 260ms,
    enemyGlow 1.1s ease-in-out infinite 260ms;
}

.power,
.kirk,
.bonix,
.drake {
  position: absolute;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  image-rendering: auto;
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 0 16px var(--pu-glow, rgba(255, 255, 255, 0.85));
  filter: saturate(1.08) contrast(1.07);
  animation: powerupPulse 1.2s ease-in-out infinite;
}

.power::before,
.kirk::before,
.bonix::before,
.drake::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed var(--pu-ring, rgba(255, 255, 255, 0.85));
  animation: powerupRing 1.1s linear infinite;
  pointer-events: none;
}

.power::after,
.kirk::after,
.bonix::after,
.drake::after {
  content: "+";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.92);
  color: #f7fbff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
  font-size: 11px;
  line-height: 13px;
  text-align: center;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.power {
  width: 40px;
  height: 40px;
  background-image:
    linear-gradient(rgba(9, 10, 15, 0.08), rgba(9, 10, 15, 0.08)),
    url('../assets/images/devito.jpeg');
  --pu-glow: rgba(255, 215, 98, 0.92);
  --pu-ring: rgba(255, 224, 147, 0.9);
}

.kirk {
  width: 40px;
  height: 40px;
  background-image:
    linear-gradient(rgba(9, 10, 15, 0.1), rgba(9, 10, 15, 0.1)),
    url('../assets/images/kirk.jpeg');
  --pu-glow: rgba(128, 0, 255, 0.92);
  --pu-ring: rgba(191, 130, 255, 0.9);
}

.bonix {
  width: 36px;
  height: 36px;
  background-image:
    linear-gradient(rgba(9, 10, 15, 0.08), rgba(9, 10, 15, 0.08)),
    url('../assets/images/nix.jpeg');
  --pu-glow: rgba(255, 140, 0, 0.92);
  --pu-ring: rgba(255, 198, 121, 0.9);
}

.drake {
  width: 38px;
  height: 38px;
  background-image:
    linear-gradient(rgba(9, 10, 15, 0.08), rgba(9, 10, 15, 0.08)),
    url('../assets/images/drake.jpeg');
  --pu-glow: rgba(70, 130, 255, 0.9);
  --pu-ring: rgba(161, 204, 255, 0.88);
}

#icePathCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1600;
}

.boss {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 14px;
  object-fit: cover;
  image-rendering: pixelated;
  filter: saturate(1.2) contrast(1.15) drop-shadow(0 0 18px rgba(255, 60, 60, 0.95));
  z-index: 9000;
  transition: transform 120ms linear, left 100ms linear, top 100ms linear;
}

.boss.jack-boss {
  width: 168px;
  height: 168px;
  border-radius: 18px;
  filter: saturate(1.22) contrast(1.15) drop-shadow(0 0 24px rgba(70, 170, 255, 0.95));
}

.boss-bullet {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd7d7, #ff2d2d 62%, #840b0b);
  box-shadow: 0 0 16px rgba(255, 55, 55, 0.9);
  z-index: 8990;
  transition: transform 90ms linear;
}

.boss-bullet.jack-freeze {
  width: 16px;
  height: 16px;
  background: url('../assets/images/jackfreeze.jpeg') center / cover no-repeat, radial-gradient(circle at 35% 35%, #eaf7ff, #4aaeff 60%, #1553b8);
  box-shadow: 0 0 15px rgba(76, 164, 255, 0.95);
}

.boss-bullet.jack-freeze.parried {
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.95), 0 0 28px rgba(112, 190, 255, 0.96);
  transform: scale(1.16);
}

#hudTop {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  z-index: 12015;
  background: linear-gradient(180deg, rgba(225, 244, 255, 0.14), rgba(112, 166, 204, 0.1));
  border: 1px solid rgba(196, 233, 255, 0.45);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(7px) saturate(1.1);
}

#ui,
#uiTime {
  position: static;
  min-width: 122px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #f4faff;
  background: linear-gradient(180deg, rgba(8, 16, 34, 0.38), rgba(8, 12, 24, 0.28));
  padding: 9px 14px 5px;
  border-radius: 999px;
  border: 1px solid rgba(195, 231, 255, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  font-family: "GameFont", "Segoe UI", "Trebuchet MS", Tahoma, sans-serif;
  font-weight: 500;
  letter-spacing: 0.4px;
  line-height: 1.18;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

#ui span,
#uiTime span {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(187, 226, 255, 0.5);
}

.hud-text {
  display: block;
  transform: translateY(4px);
}

#hudTop.score-pop #ui {
  animation: hudScorePop 280ms cubic-bezier(.22,.72,.2,1);
}

#shieldRing {
  position: absolute;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  pointer-events: none;
  display: none;
  z-index: 12010;
  background: conic-gradient(from 0deg, rgba(255,190,70,0.0), rgba(255,140,30,0.95), rgba(255,220,130,0.55), rgba(255,150,35,0.95), rgba(255,190,70,0.0));
  filter: drop-shadow(0 0 14px rgba(255,155,35,0.95)) drop-shadow(0 0 26px rgba(255,112,20,0.7));
  animation: shieldSpin 1.15s linear infinite, shieldPulse 1.4s ease-in-out infinite;
}

#shieldRing::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.64);
}

#kirkShieldRing {
  position: absolute;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  pointer-events: none;
  display: none;
  z-index: 12011;
  background: conic-gradient(from 0deg, rgba(80,185,255,0.0), rgba(45,140,255,0.95), rgba(175,232,255,0.62), rgba(45,140,255,0.95), rgba(80,185,255,0.0));
  filter: drop-shadow(0 0 15px rgba(60,160,255,0.95)) drop-shadow(0 0 30px rgba(50,125,255,0.7));
  animation: shieldSpin 0.95s linear infinite, shieldPulse 1.25s ease-in-out infinite;
}

#kirkShieldRing::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
}

#bossUI {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 84vw);
  color: #ffe7e7;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 110, 110, 0.45);
  border-radius: 8px;
  padding: 8px 10px;
  display: none;
  z-index: 12000;
  transition: width 260ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

#bossTop {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

#bossTop span {
  transform: translateY(4px);
}

#bossBar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

#bossFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff8c8c, #ff2e2e);
  box-shadow: 0 0 10px rgba(255, 70, 70, 0.8);
  transition: width 0.18s linear;
}

#bossUI.jack-ui {
  width: min(720px, 94vw);
  border-color: rgba(113, 188, 255, 0.62);
  box-shadow: 0 0 26px rgba(52, 150, 255, 0.44);
  padding-bottom: 32px;
}

#bossUI.jack-ui #bossTop {
  justify-content: flex-end;
  position: relative;
}

#bossUI.jack-ui #bossName {
  position: absolute;
  left: 50%;
  top: 32px;
  transform: translate(-50%, 0);
  text-align: center;
  white-space: nowrap;
}

#bossUI.jack-ui #bossHpText {
  position: absolute;
  right: 0;
  top: 0;
  transform: translateY(0);
}

#bossUI.jack-ui #bossBar {
  height: 16px;
}

#bossUI.jack-ui #bossFill {
  background: linear-gradient(90deg, #8ad0ff, #2c7df5);
  box-shadow: 0 0 12px rgba(80, 164, 255, 0.95);
}

#game.boss-mode {
  filter: contrast(1.08) saturate(1.12);
}

#game.cutscene-mode .enemy,
#game.cutscene-mode .orb,
#game.cutscene-mode .power,
#game.cutscene-mode .kirk,
#game.cutscene-mode .bonix,
#game.cutscene-mode .drake,
#game.cutscene-mode .boss-bullet,
#game.cutscene-mode #icePathCanvas,
#game.cutscene-mode #shieldRing,
#game.cutscene-mode #kirkShieldRing {
  visibility: hidden !important;
  animation: none !important;
}

#game.perf-lite .enemy,
#game.perf-lite .orb,
#game.perf-lite .boss-bullet,
#game.perf-lite .power,
#game.perf-lite .kirk,
#game.perf-lite .bonix,
#game.perf-lite .drake {
  animation: none !important;
  box-shadow: none !important;
  filter: none !important;
}

#player.frozen-player {
  filter: saturate(0.78) hue-rotate(18deg) drop-shadow(0 0 20px rgba(144, 224, 255, 0.98));
  animation: frozenPulse 0.6s ease-in-out infinite;
}

#player.gold-ascended {
  filter: saturate(1.38) hue-rotate(-26deg) brightness(1.18) drop-shadow(0 0 20px rgba(255, 228, 112, 0.98)) drop-shadow(0 0 38px rgba(255, 194, 32, 0.84));
  animation: goldAura 1.1s ease-in-out infinite, playerHover 1.1s ease-in-out infinite;
}

.slash-sweep {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 3px solid rgba(170, 231, 255, 0.95);
  transform: translate(-50%, -50%) scale(0.4) rotate(-16deg);
  opacity: 0;
  pointer-events: none;
  z-index: 13080;
  box-shadow: 0 0 20px rgba(149, 218, 255, 0.95), inset 0 0 22px rgba(220, 246, 255, 0.75);
  transition: transform 220ms cubic-bezier(.15,.8,.2,1), opacity 220ms ease;
}

.slash-sweep::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  border-top: 4px solid rgba(255, 255, 255, 0.95);
  border-right: 4px solid rgba(176, 230, 255, 0.88);
  border-bottom: 4px solid rgba(130, 198, 255, 0.35);
  border-left: 4px solid transparent;
  transform: rotate(-20deg);
}

.slash-sweep.live {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.05) rotate(34deg);
}

#bossAmbience {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 8500;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 22, 22, 0.12), rgba(0, 0, 0, 0) 55%),
    linear-gradient(180deg, rgba(20, 0, 0, 0.3), rgba(0, 0, 0, 0.18));
  animation: bossPulse 2.4s ease-in-out infinite;
}

@keyframes bossPulse {
  0% { opacity: 0.45; }
  50% { opacity: 0.8; }
  100% { opacity: 0.45; }
}

@keyframes shieldSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes frozenPulse {
  0% { transform: translateY(0) scale(0.98); }
  50% { transform: translateY(0) scale(1.02); }
  100% { transform: translateY(0) scale(0.98); }
}

@keyframes goldAura {
  0% { opacity: 0.95; }
  50% { opacity: 1; }
  100% { opacity: 0.95; }
}

@keyframes shieldPulse {
  0% { opacity: 0.75; }
  50% { opacity: 1; }
  100% { opacity: 0.75; }
}

@keyframes orbFloat {
  0% { transform: translateY(0) scale(0.98); }
  50% { transform: translateY(-2px) scale(1.03); }
  100% { transform: translateY(0) scale(0.98); }
}

@keyframes orbPulse {
  0% { filter: drop-shadow(0 0 8px rgba(255, 171, 80, 0.78)); }
  50% { filter: drop-shadow(0 0 16px rgba(255, 214, 116, 0.98)); }
  100% { filter: drop-shadow(0 0 8px rgba(255, 171, 80, 0.78)); }
}

@keyframes orbHalo {
  0% { transform: scale(0.9); opacity: 0.82; }
  70% { transform: scale(1.3); opacity: 0.1; }
  100% { transform: scale(1.3); opacity: 0; }
}

@keyframes orbAura {
  0% { transform: scale(0.88); opacity: 0.28; }
  50% { transform: scale(1.08); opacity: 0.52; }
  100% { transform: scale(0.88); opacity: 0.28; }
}

@keyframes enemyFly {
  from { background-position-x: 0; }
  to { background-position-x: -128px; }
}

@keyframes enemyHover {
  0% { transform: translateY(0); }
  50% { transform: translateY(-1.5px); }
  100% { transform: translateY(0); }
}

@keyframes enemyGlow {
  0% { filter: hue-rotate(-58deg) saturate(1.45) contrast(1.12) brightness(1.14) drop-shadow(0 0 12px rgba(255, 48, 48, 0.88)); }
  50% { filter: hue-rotate(-58deg) saturate(1.74) contrast(1.2) brightness(1.28) drop-shadow(0 0 21px rgba(255, 25, 25, 1)); }
  100% { filter: hue-rotate(-58deg) saturate(1.45) contrast(1.12) brightness(1.14) drop-shadow(0 0 12px rgba(255, 48, 48, 0.88)); }
}

@keyframes orbSpawnIn {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes enemySpawnIn {
  0% { transform: scale(0.55); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes enemySpawnShield {
  0% { transform: rotate(0deg) scale(1); opacity: 0.9; }
  100% { transform: rotate(360deg) scale(1.03); opacity: 0.48; }
}

@keyframes menuIn {
  0% { opacity: 0; transform: scale(0.97); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes menuOut {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.985); }
}

@keyframes buttonIn {
  0% { opacity: 0; transform: translateY(8px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes deathItemIn {
  0% { opacity: 0; transform: translateY(12px) scale(0.97); filter: blur(2px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes deathBtnIn {
  0% { opacity: 0; transform: translateY(14px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes deathSubIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.985); filter: blur(1.5px); }
  100% { opacity: 0.92; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes highscoreFloat {
  0% { transform: translateY(2px); opacity: 0.88; }
  50% { transform: translateY(-1px); opacity: 1; }
  100% { transform: translateY(2px); opacity: 0.88; }
}

@keyframes confettiDrop {
  0% {
    opacity: 0;
    transform: translate(0, -6vh) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift, 0px), 112vh) rotate(var(--spin, 360deg));
  }
}

@keyframes newRecordPulse {
  0% { transform: translateY(10px) scale(0.98); filter: brightness(1); }
  40% { transform: translateY(0) scale(1.06); filter: brightness(1.28); }
  100% { transform: translateY(0) scale(1); filter: brightness(1.08); }
}

@keyframes gameReveal {
  0% { filter: blur(3px) brightness(0.55); opacity: 0.85; }
  100% { filter: blur(0) brightness(1); opacity: 1; }
}

@keyframes gameToMenu {
  0% { filter: blur(0) brightness(1); opacity: 1; }
  100% { filter: blur(5px) brightness(0.45); opacity: 0.8; }
}

@keyframes hudScorePop {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.09); filter: brightness(1.22); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes powerupPulse {
  0% {
    transform: scale(0.98);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.35),
      0 0 12px var(--pu-glow, rgba(255, 255, 255, 0.85));
  }
  50% {
    transform: scale(1.04);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.35),
      0 0 22px var(--pu-glow, rgba(255, 255, 255, 0.95));
  }
  100% {
    transform: scale(0.98);
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.35),
      0 0 12px var(--pu-glow, rgba(255, 255, 255, 0.85));
  }
}

@keyframes powerupRing {
  0% { transform: rotate(0deg); opacity: 0.95; }
  100% { transform: rotate(360deg); opacity: 0.45; }
}

@keyframes boNixDustDrift {
  0% { transform: translate3d(0, 0, 0); opacity: 0.25; }
  15% { opacity: 0.9; }
  100% { transform: translate3d(var(--dust-drift, 180px), var(--dust-rise, -12px), 0); opacity: 0; }
}

@keyframes playerAura {
  0% {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(179, 226, 255, 0.98));
  }
  100% {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
  }
}

@keyframes playerHover {
  0% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

#deathScreen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.985);
  width: min(560px, 88vw);
  display: grid;
  gap: 12px;
  justify-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 22020;
  transition: opacity 260ms ease, transform 300ms cubic-bezier(.2,.72,.2,1), visibility 260ms ease;
}

#deathScreen.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

#deathScore,
#deathTime {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #eef7ff;
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0.6px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.98);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.72), 0 0 18px rgba(175, 217, 255, 0.32);
}

#newHighScoreText {
  font-family: "GameFont", "Segoe UI", Tahoma, sans-serif;
  font-size: clamp(1.02rem, 2.8vw, 1.35rem);
  color: #fff4c8;
  letter-spacing: 1.4px;
  text-shadow: 0 0 18px rgba(255, 225, 133, 0.95), 0 8px 20px rgba(0, 0, 0, 0.62);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
}

#newHighScoreText.show {
  opacity: 1;
  visibility: visible;
  animation: deathItemIn 300ms cubic-bezier(.2,.72,.2,1) both, highscoreFloat 1.8s ease-in-out infinite;
}

#deathHighScore {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
}

#deathScreen.show #deathHighScore {
  opacity: 1;
  visibility: visible;
  animation: deathSubIn 340ms cubic-bezier(.2,.72,.2,1) both;
}

#deathScore {
  max-width: min(540px, 90vw);
  min-height: 40px;
  font-size: clamp(1.45rem, 4.6vw, 2.25rem);
  padding: 2px 4px 0;
  transform-origin: center;
}

#deathTime {
  max-width: min(500px, 88vw);
  min-height: 32px;
  font-size: clamp(0.96rem, 2.45vw, 1.26rem);
  padding: 1px 6px 0;
  opacity: 0.92;
}

#playAgain,
#deathExitMenu {
  position: static;
  width: min(380px, 80vw);
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
}

#playAgain {
  margin-top: 6px;
}

#deathExitMenu {
  width: min(430px, 84vw);
}

#deathScore.show {
  opacity: 1;
  visibility: visible;
  animation: deathItemIn 360ms cubic-bezier(.2,.72,.2,1) both;
}

#deathScore.new-record {
  color: #fff5cf;
  text-shadow: 0 0 24px rgba(255, 223, 125, 0.92), 0 9px 24px rgba(0, 0, 0, 0.64);
  animation: newRecordPulse 580ms cubic-bezier(.2,.72,.2,1) both;
}

#deathTime.show {
  opacity: 1;
  visibility: visible;
  animation: deathSubIn 430ms cubic-bezier(.2,.72,.2,1) both;
}

#playAgain.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  animation: deathBtnIn 460ms cubic-bezier(.2,.72,.2,1) both;
}

#deathExitMenu.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  animation: deathBtnIn 540ms cubic-bezier(.2,.72,.2,1) both;
}
