/**
 * Global reset and base styles
 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/**
 * Body styling - main canvas setup
 */
body {
  background-color: #7ab5a0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  transition: background-color 2s ease;
}

/**
 * Main container for creature and effects
 */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  position: relative;
}

/**
 * Main creature styles
 */
.creature {
  width: 400px;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease, filter 0.5s ease;
  cursor: pointer;
  position: relative;
  z-index: 10;
  animation: float 4s ease-in-out infinite;
  /* Disable mobile touch highlighting and selection */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Prevent dragging */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  draggable: false;
}

/* Electric border effects for different storm levels */
.creature.storm-level-1 {
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 5px rgba(100, 150, 255, 0.3));
}

.creature.storm-level-2 {
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 8px rgba(100, 150, 255, 0.5));
  animation: float 4s ease-in-out infinite, electricPulse 2s ease-in-out infinite;
}

.creature.storm-level-3 {
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 12px rgba(100, 150, 255, 0.7)) drop-shadow(0 0 3px rgba(255, 255, 255, 0.8));
  animation: float 4s ease-in-out infinite, electricPulse 1.5s ease-in-out infinite;
}

.creature.storm-level-4 {
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 15px rgba(100, 150, 255, 0.8)) drop-shadow(0 0 5px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 2px rgba(200, 220, 255, 1));
  animation: float 4s ease-in-out infinite, electricPulse 1s ease-in-out infinite, electricCrackle 0.8s ease-in-out infinite;
}

.creature.storm-level-5 {
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 20px rgba(100, 150, 255, 1)) drop-shadow(0 0 8px rgba(255, 255, 255, 1)) drop-shadow(0 0 4px rgba(200, 220, 255, 1)) drop-shadow(0 0 1px rgba(255, 255, 255, 1));
  animation: float 4s ease-in-out infinite, electricPulse 0.6s ease-in-out infinite, electricCrackle 0.4s ease-in-out infinite, dangerPulse 0.3s ease-in-out infinite;
}

.creature:hover {
  transform: scale(1.05);
}

/**
 * Floating animation for creature and sticker
 */
@keyframes float {

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

  50% {
    transform: translateY(-10px);
  }
}

/**
 * Spore sprite styles
 */
.spore {
  position: absolute;
  width: 76px;
  height: 50px;
  pointer-events: none;
  z-index: 5;
  /* Prevent dragging */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  draggable: false;
}

/**
 * Spore explosion animation
 */
@keyframes explode {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rotation)) scale(0.3);
    opacity: 0;
  }
}

/**
 * Dev Panel styles
 */
.dev-panel {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 20px;
  border-radius: 10px;
  width: 200px;
  z-index: 100;
}

.dev-panel.hidden {
  display: none;
}

.dev-panel h3 {
  margin-bottom: 15px;
  font-size: 16px;
  color: #4A90E2;
}

.toggle {
  display: block;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14px;
}

.toggle input {
  margin-right: 8px;
}

.toggle span {
  user-select: none;
}

#clearAll {
  width: 100%;
  padding: 8px;
  margin-top: 15px;
  background: #4A90E2;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
}

#clearAll:hover {
  background: #357ABD;
}

/**
 * Spore Sticker - positioned bottom-right of creature, floating with it
 */
.spore-sticker {
  position: absolute;
  width: 120px;
  height: 120px;
  bottom: calc(50% - 200px + 80px);
  /* Moved way up closer to creature */
  right: calc(50% - 200px - 20px);
  /* Position to the right of the creature */
  z-index: 20;
  animation: floatWithRotation 4s ease-in-out infinite;
  /* Custom animation with rotation */
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
  transition: transform 0.3s ease;
  cursor: pointer;
  /* Disable mobile touch highlighting and selection */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Prevent dragging */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  draggable: false;
}

.spore-sticker:hover {
  transform: rotate(15deg) scale(1.1);
}

/**
 * Float animation with rotation for the sticker
 */
@keyframes floatWithRotation {

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

  50% {
    transform: translateY(-10px) rotate(15deg);
  }
}

/**
 * Storm Effects
 */
.storm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(40, 40, 70, 0.8) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(60, 60, 90, 0.6) 0%, transparent 50%),
    radial-gradient(ellipse at 40% 80%, rgba(30, 30, 60, 0.7) 0%, transparent 50%),
    linear-gradient(180deg, rgba(20, 20, 40, 0.9) 0%, rgba(40, 40, 70, 0.5) 100%);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 2s ease;
  animation: cloudMovement 20s ease-in-out infinite;
}

.lightning-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.9) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 60%, rgba(200, 220, 255, 0.7) 0%, transparent 50%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 60;
  opacity: 1;
}

.lightning-flash.final-reset {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.4) 100%);
}

@keyframes cloudMovement {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-20px);
  }
}

@keyframes lightningFlash {
  0% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes electricPulse {

  0%,
  100% {
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 5px rgba(100, 150, 255, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 15px rgba(100, 150, 255, 0.8));
  }
}

@keyframes electricCrackle {

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

  25% {
    transform: translateY(-1px) translateX(1px);
  }

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

  75% {
    transform: translateY(-1px) translateX(1px);
  }
}

@keyframes dangerPulse {

  0%,
  100% {
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 20px rgba(100, 150, 255, 1)) drop-shadow(0 0 8px rgba(255, 255, 255, 1));
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 30px rgba(255, 255, 100, 1)) drop-shadow(0 0 15px rgba(255, 255, 255, 1));
  }
}

/**
 * Mobile responsiveness
 */
@media (max-width: 768px) {
  .creature {
    width: 300px;
    height: auto;
  }

  .dev-panel {
    left: 10px;
    padding: 15px;
    width: 160px;
  }

  .spore-sticker {
    width: 90px;
    height: 90px;
    bottom: calc(50% - 150px + 60px);
    right: calc(50% - 150px - 15px);
  }
}

@media (max-width: 480px) {
  .creature {
    width: 250px;
    height: auto;
  }

  .dev-panel {
    font-size: 12px;
    width: 140px;
  }

  .spore-sticker {
    width: 70px;
    height: 70px;
    bottom: calc(50% - 125px + 50px);
    right: calc(50% - 125px - 10px);
  }
}