@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Fredoka One', cursive;
  touch-action: none;
}

/* Wrapper fills screen, canvas scales inside via JS */
#gc {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

canvas {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* width/height set by JS to fit screen */
}

/* HUD — scaled via CSS transform origin top-left, set by JS */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  /* transform-origin and transform set by JS to match canvas scale */
  pointer-events: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
}

#hud::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
  pointer-events: none;
}

.hbadge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 5px 12px;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hbadge .val {
  font-weight: 900;
  font-size: 16px;
}

#lvBadge {
  background: linear-gradient(135deg, rgba(255, 190, 0, 0.25), rgba(255, 100, 0, 0.2));
  border-color: rgba(255, 180, 0, 0.4);
}

#scBadge {
  flex: 1;
  justify-content: center;
  background: linear-gradient(135deg, rgba(100, 200, 255, 0.15), rgba(60, 100, 255, 0.15));
  border-color: rgba(100, 180, 255, 0.3);
}

#cnBadge {
  background: linear-gradient(135deg, rgba(255, 220, 0, 0.2), rgba(200, 150, 0, 0.15));
  border-color: rgba(255, 200, 0, 0.35);
}

#pauseBtn {
  position: relative;
  pointer-events: all;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#livesRow {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.heart {
  font-size: 22px;
  transition: transform .2s, opacity .3s;
}

.heart.lost {
  opacity: 0.25;
  transform: scale(0.8);
}

#comboPop {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  color: #ffe84a;
  text-shadow: 0 0 20px #ff8000;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity .3s;
  white-space: nowrap;
  background-color: #090000;
  padding: 10px;
  border-radius: 20px;
}

#hitFlash {
  position: absolute;
  inset: 0;
  background: rgba(255, 60, 60, 0);
  pointer-events: none;
  z-index: 40;
  transition: background .05s;
}

/* Overlays */
.ov {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.ov-bg {
  background: radial-gradient(ellipse at 50% 30%, rgba(80, 30, 180, 0.7) 0%, rgba(5, 5, 20, 0.88) 100%);
  backdrop-filter: blur(12px);
}

#mainMenu .logo {
  font-size: 42px;
  text-align: center;
  line-height: 1.1;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 16px rgba(255, 120, 0, 0.6));
  color: #fff;
}

#mainMenu .tagline {
  color: rgba(200, 220, 255, 0.8);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  margin-bottom: 28px;
  text-align: center;
}

.gbtn {
  border: none;
  border-radius: 50px;
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
  cursor: pointer;
  letter-spacing: .5px;
  padding: 14px 40px;
  margin: 6px;
  transition: transform .08s;
  user-select: none;
  pointer-events: all;
}

.gbtn:active {
  transform: translateY(3px);
}

.gbtn-yellow {
  background: linear-gradient(180deg, #ffe84a 0%, #f09000 100%);
  color: #4a1f00;
  box-shadow: 0 6px 0 #9a5000, 0 8px 24px rgba(255, 140, 0, 0.4);
}

.gbtn-yellow:active {
  box-shadow: 0 3px 0 #9a5000;
}

.gbtn-blue {
  background: linear-gradient(180deg, #6ad4ff 0%, #1878e0 100%);
  color: #fff;
  box-shadow: 0 6px 0 #0a40a0, 0 8px 24px rgba(30, 100, 255, 0.35);
}

.gbtn-blue:active {
  box-shadow: 0 3px 0 #0a40a0;
}

.panel {
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 16px 28px;
  margin: 8px 0;
  text-align: center;
  min-width: 300px;
}

.panel-title {
  color: rgba(200, 220, 255, 0.9);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-weight: bold;
}

.panel-val {
  color: #fff;
  font-size: 28px;
  text-shadow: 0 0 20px rgba(150, 200, 255, 0.5);
}

.stars-row {
  display: flex;
  gap: 6px;
  margin: 10px 0 16px;
}

.star-item {
  font-size: 46px;
  animation: starPop .45s cubic-bezier(.2, 1.5, .5, 1) backwards;
}

.star-item:nth-child(2) {
  animation-delay: .12s;
}

.star-item:nth-child(3) {
  animation-delay: .24s;
}

@keyframes starPop {
  from {
    transform: scale(0) rotate(-30deg);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.ov-title {
  font-size: 36px;
  color: #fff;
  text-shadow: 0 0 30px rgba(200, 150, 255, 0.7);
  margin-bottom: 6px;
}

.ov-sub {
  font-size: 22px;
  color: #ffe57a;
  margin-bottom: 12px;
}

/* ============ PRELOADER STYLES ============ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at center, #0a0e1a 0%, #040610 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  opacity: 1;
  visibility: visible;
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Explosive particles behind the bomb */
.preloader-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.preloader-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: preParticleFly 2.5s ease-out infinite;
}

@keyframes preParticleFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  70% {
    opacity: 0.6;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* Central bomb container */
.preloader-bomb-wrap {
  position: relative;
  z-index: 2;
  animation: preBombFloat 2s ease-in-out infinite;
}

@keyframes preBombFloat {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  15% {
    transform: translateY(-18px) rotate(-5deg);
  }

  30% {
    transform: translateY(0) rotate(3deg);
  }

  45% {
    transform: translateY(-10px) rotate(-2deg);
  }

  60% {
    transform: translateY(0) rotate(0deg);
  }

  75% {
    transform: translateY(-6px) rotate(1deg);
  }
}

.preloader-bomb {
  font-size: 80px;
  filter: drop-shadow(0 0 30px rgba(255, 180, 30, 0.9)) drop-shadow(0 0 60px rgba(255, 140, 0, 0.6));
  animation: preBombPulse 1.2s ease-in-out infinite;
  line-height: 1;
}

@keyframes preBombPulse {

  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 30px rgba(255, 180, 30, 0.9)) drop-shadow(0 0 60px rgba(255, 140, 0, 0.6));
  }

  50% {
    transform: scale(1.12);
    filter: drop-shadow(0 0 50px rgba(255, 200, 50, 1)) drop-shadow(0 0 90px rgba(255, 160, 20, 0.9));
  }
}

/* Shockwave ring */
.preloader-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid rgba(255, 200, 50, 0.7);
  transform: translate(-50%, -50%) scale(0.6);
  animation: preRingExpand 2s ease-out infinite;
  pointer-events: none;
}

.preloader-ring:nth-child(2) {
  animation-delay: 0.7s;
  border-color: rgba(255, 150, 30, 0.5);
}

.preloader-ring:nth-child(3) {
  animation-delay: 1.4s;
  border-color: rgba(255, 180, 40, 0.3);
}

@keyframes preRingExpand {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(3.5);
    opacity: 0;
  }
}

/* Title text */
.preloader-title {
  position: relative;
  z-index: 2;
  margin-top: 20px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffcc00;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.8), 0 0 50px rgba(255, 150, 20, 0.5), 0 2px 4px rgba(0, 0, 0, 0.6);
  animation: preTitleGlow 2s ease-in-out infinite;
}

@keyframes preTitleGlow {

  0%,
  100% {
    text-shadow: 0 0 20px rgba(255, 200, 50, 0.8), 0 0 50px rgba(255, 150, 20, 0.5);
  }

  50% {
    text-shadow: 0 0 35px rgba(255, 220, 80, 1), 0 0 80px rgba(255, 180, 30, 0.8), 0 0 10px rgba(255, 255, 200, 0.7);
  }
}

/* Loading bar */
.preloader-bar-track {
  position: relative;
  z-index: 2;
  margin-top: 24px;
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.preloader-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(90deg, #ff8c00, #ffcc00, #ffaa00, #ffdd40);
  background-size: 200% 100%;
  animation: preBarShimmer 1.5s linear infinite;
  box-shadow: 0 0 12px rgba(255, 180, 30, 0.8), 0 0 25px rgba(255, 150, 0, 0.5);
  transition: width 0.3s ease-out;
}

@keyframes preBarShimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* Spark emojis orbiting */
.preloader-spark {
  position: absolute;
  z-index: 1;
  font-size: 22px;
  animation: preSparkOrbit 3s linear infinite;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(255, 200, 50, 0.8));
}

@keyframes preSparkOrbit {
  0% {
    transform: rotate(0deg) translateX(70px) rotate(0deg);
  }

  100% {
    transform: rotate(360deg) translateX(70px) rotate(-360deg);
  }
}

/* Subtitle dots */
.preloader-dots {
  position: relative;
  z-index: 2;
  margin-top: 10px;
  color: rgba(200, 220, 255, 0.8);
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 600;
}

.preloader-dots span {
  animation: preDotBlink 1.4s infinite;
  display: inline-block;
}

.preloader-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.preloader-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes preDotBlink {

  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-6px);
  }
}

/* Responsive */
@media (max-width: 480px) {
  .preloader-bomb {
    font-size: 60px;
  }

  .preloader-title {
    font-size: 22px;
    letter-spacing: 1px;
  }

  .preloader-bar-track {
    width: 160px;
    height: 6px;
  }

  .preloader-spark {
    font-size: 16px;
  }
}