/* ========== Keyframes ========== */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes fadeInModal {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes popInBonus {
  0% { opacity: 0; transform: translateY(-4px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes swirl {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}


/* ========== Global Styles ========== */
html, body {
  overflow: hidden;
  height: 100%;
  touch-action: none; /* Optional: disables swipe-to-scroll in some mobile browsers */
}


body {
  -webkit-user-select: none;
    background: radial-gradient(circle at center, #fdebd4 0%, #e0e0e0 100%);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 2.2vw, 18px);
  margin: 0;
  max-width: 100vw;
  overflow-x: hidden;
  padding: 10px;
  text-align: center;
  touch-action: manipulation;
  user-select: none;
  overscroll-behavior: none;
}

h1 {
  font-size: clamp(20px, 5vw, 28px);
  margin: 10px 0;
}

h3 {
  font-size: clamp(14px, 2.5vw, 18px);
  margin: 12px 0 6px;
}

/* ========== Classes ========== */
.butterfly_wrapper {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  transform-origin: top left;
  pointer-events: none;
}

.bar-bg {
  background: #eee;
  border-radius: 999px;
  height: 16px;
  margin: 0 auto 12px;
  max-width: 300px;
  overflow: hidden;
  width: 100%;
}

.bar-fill {
  background: linear-gradient(to right, #4caf50, #81c784);
  border-radius: 999px;
  height: 100%;
  transition: width 1s ease-in-out;
  width: 0%;
}

.bar-label {
  align-items: center;
  color: #555;
  display: flex;
  font-size: 14px;
  justify-content: space-between;
  margin: 6px auto 4px;
  max-width: 300px;
}

.bar-label span {
  font-weight: bold;
}

.button {
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: bold;
  max-width: 280px;
  min-width: 140px;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(to right, #4f9cf9, #4364f7);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.25s ease;
}

.button:hover {
  background: linear-gradient(to right, #4364f7, #4f9cf9);
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.button:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.butterfly_container {
  width: 60px;
  height: auto;
  margin: 0 auto 20px;
  z-index: 10;
}

.butterfly svg.wing {
  width: 100%;
  height: auto;
  display: block;
}


#grassBanner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: auto;
  z-index: 0;
  pointer-events: none;
}

.submit-button {
  display: block !important;
  width: 100%;
  max-width: 280px;
  box-sizing: border-box;

  background: linear-gradient(to right, #ff66cc, #cc66ff);
  color: white;
  font-weight: bold;
  font-size: clamp(14px, 2.5vw, 18px);
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.25s ease;
  margin: 0 auto;
}

#bonusContainer {
  font-size: 1.2em;
}

.submit-button:hover {
  background: linear-gradient(to right, #cc66ff, #ff66cc);
  transform: scale(1.05);
}

.submit-button:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.highscore-input {
  display: block !important;
  width: 100%;
  max-width: 280px;
  padding: 10px 16px;
  font-size: 16px;
  line-height: 1.2;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin: 0 auto 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  text-align: center;
  box-sizing: border-box;
}



.highscore-input:focus {
  outline: none;
  box-shadow: none;
}



.highscore-entry {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 2px;
}

.highscore-entry input,
.highscore-entry button {
  margin-bottom: 12px;
}

.highscore-entry button:last-child {
  margin-bottom: 0;
}



.highscore-entry > .submit-button {
  margin-top: 0;
}



.secondary-button {
  background: linear-gradient(to right, #4f9cf9, #6a9cff);
  font-size: 90%;
  padding: 12px 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.secondary-button:hover {
  background: linear-gradient(to right, #6a9cff, #4f9cf9);
  transform: scale(1.04);
}


.button-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.icon-button {
  width: 54px;
  height: 54px;
  min-width: unset;
  font-size: 22px;
  border-radius: 14px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e0e0e0;
  color: #333;
  border: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  transition: background 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
  background: #d0d0d0;
  transform: scale(1.05);
}



.copy-tooltip {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.copy-tooltip.show {
  opacity: 1;
}


.hidden {
  display: none !important;
}



.color-box {
  width: 100%;
  aspect-ratio: 1;
  box-sizing: border-box;
  height: 100%; /* ✅ ensures they always match grid height */
  display: block;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}


.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: row;
  gap: 12px;
  margin: 20px auto;
  max-width: 500px;
  width: 100%;
}

.controls button {
  height: 48px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, background 0.25s ease;
  width: 100%;
}

.undo-button,
.reset-button {
  flex: 1;
  background: #ccc;
  color: #333;
}

.undo-button:hover,
.reset-button:hover {
  background: #bbb;
  transform: scale(1.03);
}

.undo-button:active,
.reset-button:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}


.pig-leaderboard {
  position: absolute;
  top: 10px;
  right: 0px;
  width: 120px;
  z-index: 2;
  pointer-events: none;
}

@media (max-width: 500px) {
  .pig-leaderboard {
    width: 100px;
    top: 10px;
    right: 10px;
  }
}



.final-score {
  animation: popIn 0.5s ease forwards;
  font-size: 48px;
  font-weight: bold;
  margin-top: 20px;
  opacity: 0;
}

.hidden {
  display: none !important;
}

.mix-button {
  background: linear-gradient(270deg, #ff8a00, #e52e71, #4f9cf9, #43e97b, #ff8a00);


  background-size: 1000% 1000%;
  animation: swirl 6s ease infinite;

  color: white;
  font-weight: bold;
  font-size: clamp(16px, 2.5vw, 20px);
  padding: 16px 32px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s ease;
  width: 100%;
  max-width: 320px;
}


.mix-button:hover {
    background: linear-gradient(270deg, #ff8a00, #e52e71, #4f9cf9, #43e97b, #ff8a00);
  background-size: 1000% 1000%;
  animation: swirl 6s ease infinite;
  transform: scale(1.05);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.mix-button:disabled {
  background: #aaa;
  box-shadow: none;
  cursor: not-allowed;
}


.result-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.result-buttons .button {
  flex: 1;
  height: 48px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, background 0.25s ease;
  width: 100%;
}

/* Edit button = neutral grey */
.edit-button {
  background: #ccc;
  color: #333;
}

.edit-button:hover {
  background: #bbb;
  transform: scale(1.03);
}

.edit-button:active {
  transform: scale(0.98);
}

/* New button = primary blue (reuse your existing style if you want) */
.new-button {
  background: linear-gradient(to right, #4f9cf9, #4364f7);
  color: white;
}

.new-button:hover {
  background: linear-gradient(to right, #4364f7, #4f9cf9);
  transform: scale(1.03);
}


.modal {
  align-items: center;
  background: rgba(0,0,0,0.6);
  display: flex;
  height: 100%;
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 999;
}

.modal:not(.hidden) {
  display: flex;
}

.modal * {
  touch-action: manipulation;
}

.modal.hidden {
  display: none;
}

.reset-button {
  flex: 1;               /* takes 1 share */
  background: #ccc;
  color: #333;
}

.reset-button:hover {
  background: #bbb;
  transform: scale(1.03);
}


.reset-button:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}




.undo-button {
  flex: 1;
}


.modal-content input {
  width: 12ch;
  max-width: 80%;
  padding: 10px;
  font-size: 16px;
  text-align: center;
}


#nameEntryModal .modal-content {
  max-width: 360px;
  padding: 24px;
  width: 90%;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  background: white;
  animation: popIn 0.5s ease forwards;
  box-sizing: border-box;
}

#nameEntryModal input {
  display: block;
  width: 100%;
  max-width: 280px;
  padding: 10px 16px;
  font-size: 16px;
  margin: 12px auto;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  font-family: 'Nunito';
}

#roundWinnerText {
  font-size: 20px;
  font-weight: bold;
  margin-top: 12px;
}


#startGameButton {
  display: block;
  margin: 20px auto 0;
  padding: 14px 24px;
  width: 100%;
  max-width: 280px;
  font-size: 16px;
  font-weight: bold;
  color: white;
  border: none;
  border-radius: 12px;
  background: linear-gradient(to right, #4f9cf9, #4364f7);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

#startGameButton:hover {
  transform: scale(1.03);
  background: linear-gradient(to right, #4364f7, #4f9cf9);
}

#startGameButton:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.speed-bonus {
  animation: popInBonus 0.5s ease forwards;
}

.swatch {
  flex: 1;
  height: 80px;
  position: relative;
}

.swatch-label {
  color: white;
  font-size: 14px;
  pointer-events: none;
  position: absolute;
  text-shadow: 0 0 2px rgba(0,0,0,0.5);
  top: 6px;
}

.swatch-label.center {
  left: 50%;
  text-align: center;
  transform: translateX(-50%);
}

.swatch-label.left {
  left: 8px;
  text-align: left;
}

.swatch-label.right {
  right: 8px;
  text-align: right;
}

.swatch-row {
  display: flex;
  justify-content: space-between;
  margin: 16px auto;
  max-width: 500px;
  width: 100%;
}

/* ========== IDs ========== */
#accuracyLabel,
#timeLabel {
  opacity: 0;
  transition: opacity 1s ease;
}

#baseColors {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  max-width: 500px;
  width: 100%;
  box-sizing: border-box;
  padding: 0 4px;
  margin: 0 auto;
}



#mixButton:disabled {
  background-color: #888;
  cursor: not-allowed;
}

#resultModal .swatch {
  flex: 1;
  height: 80px;
  position: relative;
}

#resultModal .swatch-label {
  color: white;
  font-size: 14px;
  position: absolute;
  text-shadow: 0 0 2px rgba(0,0,0,0.6);
  top: 6px;
}

#resultModal .swatch-row {
  display: flex;
  gap: 0;
  justify-content: space-between;
  margin-bottom: 16px;
  margin-inline: auto;
  max-width: 500px;
  width: 100%;
}

#resultModal h2 {
  align-items: center;
  display: flex;
  font-size: 28px;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

#scoreOutput {
  font-size: 16px;
  margin-top: 10px;
}

#targetColor {
  background: #ccc;
  border-radius: 10px;
  height: 60px;
  margin: 20px auto;
  max-width: 500px;
  width: 100%;
}

#timer {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}

#timeProgressBar {
  background: linear-gradient(to right, #f39c12, #e74c3c);
  height: 100%;
  transition: width 1s linear;
  width: 0%;
}

#timeProgressContainer {
  background: #ddd;
  border-radius: 5px;
  height: 10px;
  margin: 12px auto 10px;
  max-width: 500px;
  overflow: hidden;
  width: 100%;
}

#turnModal .modal-content {
  max-width: 360px;
  padding: 24px;
  width: 90%;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  background: var(--playerColor, #ffffff); /* keep dynamic background */
  animation: popIn 0.5s ease forwards;
  box-sizing: border-box;
  color: #000;
}

#turnModal h2 {
  animation: bounce 1.5s infinite;
}

#userMix {
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  max-width: 240px;
  position: relative;
  width: 100%;
}

#volumeCanvas {
  height: 200px;
}

/* ========== Media Queries ========== */

@media (max-height: 680px) {
  #grassBanner,
  #butterfly {
    display: none !important;
  }
}



@media (max-width: 480px) {
  body {
    font-size: 14px;
    padding: 8px;
  }

  h1 {
    font-size: 20px;
    margin: 6px 0;
  }

  h3 {
    font-size: 16px;
    margin: 10px 0 5px;
  }


  #targetColor {
    height: 60px;
    margin: 20px auto;
  }

  #userMix {
    margin-bottom: 20px;
    max-width: 200px;
  }

  #volumeCanvas {
    height: 160px;
  }

  .color-box {
    border-width: 2px;
  }

  .modal-content {
    padding: 20px 15px;
  }
}



#backHome {
  position: fixed;
  top: 16px;
  left: 16px;
  background: #444;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: background 0.2s ease;
}

#backHome:hover {
  background: #222;
}



#finalResultsScreen {
  z-index: 9999 !important;
  pointer-events: auto !important;
}

#finalResultsScreen .modal-content {
  pointer-events: auto !important;
}


.paint-full {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  transition: height 1s ease;
}

.paint-used {
  opacity: 0.15;
  border-radius: inherit;
}

#spectrumOverlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px; /* ✅ Prevent canvas from hitting the edges */
  background: rgba(0, 0, 0, 0.6);
  position: fixed;
  inset: 0;
  z-index: 9999;
  box-sizing: border-box;
}


#spectrumOverlay.hidden {
  display: none;
}

#spectrumCanvas {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  box-shadow: 0 0 16px rgba(0,0,0,0.2);
  touch-action: none;
  box-sizing: border-box;
  padding: 12px; /* ✅ Add visual breathing room */
  background: #fff; /* Optional: prevent transparent padding revealing overlay */
}




#magnifier {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 10000;
  pointer-events: none;
  display: none;
}

#magnifier canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

body.spectrum-open {
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}












@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

#milestoneMessage {
  display: block;
  font-size: 18px;
  line-height: 1.4;
  margin: 12px 0;
}



.pig-floating {
  position: absolute;
  top: -90px;
  right: -20px;
  width: 120px;
  pointer-events: none;
  z-index: 10;
}

#nameEntryModal.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6); /* dim background like the others */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}




@keyframes shakeFast {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-3px); }
  20% { transform: translateX(3px); }
  30% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  50% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  90% { transform: translateX(-1px); }
}


@keyframes popBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  80% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}


.sprinkle-button.selected {
  background-color: #f0f0f0;
  border: 2px solid #aaa;
  box-shadow: inset 0 0 4px #ccc;
}




.sprinkle-pot {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.2), 0 2px 5px rgba(0,0,0,0.15);
  background: radial-gradient(white, silver);
  animation: glitterPulse 2s infinite ease-in-out;
}

.sprinkle-pot::after {
  content: "✨";
  position: absolute;
  font-size: 22px;
  right: 6px;
  bottom: 4px;
  opacity: 0.6;
}

@keyframes glitterPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

.color-box.glitter {
  background: linear-gradient(135deg, #ffffff, #cccccc);
  position: relative;
}





.sprinkle-pots {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  max-width: 500px;
  margin: 10px auto;
}



.color-box.empty-pot {
  background: none;
  border: none;
  pointer-events: none;
}


.color-box.test-tube {
  border-left: 1px solid #999;
  border-right: 1px solid #999;
  border-bottom: 1px solid #999;
  border-top: none;
  border-radius: 0 0 6px 6px;
}



/* Inner highlight stripe for glass effect */
.color-box.test-tube::after {
  content: "";
  position: absolute;
  top: 12%;
  left: 15%;
  width: 3px;
  height: 60%;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
}



.sidekick-pig {
  height: 180px;
  width: auto;
  margin-right: -100px;
  margin-left: -20px;
  transform: scaleX(-1);
  position: relative;   /* ✅ allows z-index to apply */
  z-index: 10;           /* ✅ put above canvas and pot */
}


@media (max-width: 500px) {
  .sidekick-pig {
    height: 160px;      /* Smaller pig */
    margin-right: -90px;
    margin-left: -20px;
  }
}

.color-box.empty-pot {
  background: none;
  border: none;
  pointer-events: none;
}

#finalResultsContainer {
  margin-top: 50px;
}

.final-pig {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  pointer-events: none;
  z-index: 2;
}

.turn-pig {
  position: absolute;
  width: 100px;
  top: -50px;
  pointer-events: none;
  z-index: 2;
}

.turn-pig.left {
  left: 0;
}

.turn-pig.right {
  right: 0;
}

#turnPigLeft.flipped {
  transform: scaleX(-1);
}


.modal-content {
  position: relative;
}


#openLeaderboard {
  position: fixed;
  top: 16px;
  right: 16px;
  background: #444;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: background 0.2s ease;
}

#openLeaderboard:hover {
  background: #222;
}


@keyframes rotating {
  0% {
    -webkit-transform: rotate3d(0, 0, 0, 0deg);
    -moz-transform: rotate3d(0, 0, 0, 0deg);
    -ms-transform: rotate3d(0, 0, 0, 0deg);
    -o-transform: rotate3d(0, 0, 0, 0deg);
    transform: rotate3d(0, 0, 0, 0deg);
  }
  100% {
    -webkit-transform: rotate3d(0, 1, 0, 720deg);
    -moz-transform: rotate3d(0, 1, 0, 720deg);
    -ms-transform: rotate3d(0, 1, 0, 720deg);
    -o-transform: rotate3d(0, 1, 0, 720deg);
    transform: rotate3d(0, 1, 0, 720deg);
  }
}
@keyframes rotatingY {
  100% {
    -webkit-transform: rotateY(-360deg);
    -moz-transform: rotateY(-360deg);
    -ms-transform: rotateY(-360deg);
    -o-transform: rotateY(-360deg);
    transform: rotateY(-360deg);
  }
}
@keyframes fluttering {
  0%,
  25%,
  50%,
  75%,
  100% {
    -webkit-transform: translate3d(0, 0, 0);
    -moz-transform: translate3d(0, 0, 0);
    -ms-transform: translate3d(0, 0, 0);
    -o-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
  10%,
  60% {
    -webkit-transform: translate3d(0, 150px, 0);
    -moz-transform: translate3d(0, 150px, 0);
    -ms-transform: translate3d(0, 150px, 0);
    -o-transform: translate3d(0, 150px, 0);
    transform: translate3d(0, 150px, 0);
  }
  30%,
  80% {
    -webkit-transform: translate3d(0, 50px, 0);
    -moz-transform: translate3d(0, 50px, 0);
    -ms-transform: translate3d(0, 50px, 0);
    -o-transform: translate3d(0, 50px, 0);
    transform: translate3d(0, 50px, 0);
  }
}
@keyframes left-wing-flap {
  0% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -o-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
  }
  50% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, -70deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, -70deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, -70deg);
    -o-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, -70deg);
    transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, -70deg);
  }
  100% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    -o-transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
    transform: translate3d(0, 0, 0) scaleX(1) rotate3d(0, 1, 0, 60deg);
  }
}
@keyframes right-wing-flap {
  0% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -o-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
  }
  50% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, -70deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, -70deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, -70deg);
    -o-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, -70deg);
    transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, -70deg);
  }
  100% {
    -webkit-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -moz-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -ms-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    -o-transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
    transform: translate3d(0, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 60deg);
  }
}

.butterfly_container {
  width: 100px;
  height: 100px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
.butterfly_container var {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 100px;
  height: 100px;
  margin-left: -50px;
  margin-top: -50px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
.butterfly_container var.rotate3d {
  -webkit-transform: rotate3d(1, 0.5, 0, 50deg);
  -moz-transform: rotate3d(1, 0.5, 0, 50deg);
  -ms-transform: rotate3d(1, 0.5, 0, 50deg);
  -o-transform: rotate3d(1, 0.5, 0, 50deg);
  transform: rotate3d(1, 0.5, 0, 50deg);
}
.butterfly_container var.translate3d {
  -webkit-animation: fluttering 10s ease-in-out infinite;
  -moz-animation: fluttering 10s ease-in-out infinite;
  -ms-animation: fluttering 10s ease-in-out infinite;
  -o-animation: fluttering 10s ease-in-out infinite;
  animation: fluttering 10s ease-in-out infinite;
}
.butterfly_container figure.butterfly {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100px;
  height: 100px;
  margin-left: -50px;
  margin-top: -50px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform-origin: 50% 50%;
  -moz-transform-origin: 50% 50%;
  -ms-transform-origin: 50% 50%;
  -o-transform-origin: 50% 50%;
  transform-origin: 50% 50%;
}
.butterfly_container figure.butterfly .wing {
  position: absolute;
  width: 50px;
  height: 100px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform-origin: 50% 50%;
  -moz-transform-origin: 50% 50%;
  -ms-transform-origin: 50% 50%;
  -o-transform-origin: 50% 50%;
  transform-origin: 50% 50%;
  -webkit-transform: translate3d(0, 0, 0) rotate3d(1, 0.5, 0, 45deg);
  -moz-transform: translate3d(0, 0, 0) rotate3d(1, 0.5, 0, 45deg);
  -ms-transform: translate3d(0, 0, 0) rotate3d(1, 0.5, 0, 45deg);
  -o-transform: translate3d(0, 0, 0) rotate3d(1, 0.5, 0, 45deg);
  transform: translate3d(0, 0, 0) rotate3d(1, 0.5, 0, 45deg);
}
.butterfly_container figure.butterfly .wing.right {
  -webkit-transform-origin: 50px 50px;
  -moz-transform-origin: 50px 50px;
  -ms-transform-origin: 50px 50px;
  -o-transform-origin: 50px 50px;
  transform-origin: 50px 50px;
  -webkit-transform: translate3d(0px, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 45deg);
  -moz-transform: translate3d(0px, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 45deg);
  -ms-transform: translate3d(0px, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 45deg);
  -o-transform: translate3d(0px, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 45deg);
  transform: translate3d(0px, 0, 0) scaleX(-1) rotate3d(0, 1, 0, 45deg);
  -webkit-animation: right-wing-flap 1s ease-in-out infinite;
  -moz-animation: right-wing-flap 1s ease-in-out infinite;
  -ms-animation: right-wing-flap 1s ease-in-out infinite;
  -o-animation: right-wing-flap 1s ease-in-out infinite;
  animation: right-wing-flap 1s ease-in-out infinite;
  filter: FlipH;
  -ms-filter: "FlipH";
}
.butterfly_container figure.butterfly .wing.left {
  -webkit-transform-origin: 50px 50px;
  -moz-transform-origin: 50px 50px;
  -ms-transform-origin: 50px 50px;
  -o-transform-origin: 50px 50px;
  transform-origin: 50px 50px;
  -webkit-animation: left-wing-flap 1s ease-in-out infinite;
  -moz-animation: left-wing-flap 1s ease-in-out infinite;
  -ms-animation: left-wing-flap 1s ease-in-out infinite;
  -o-animation: left-wing-flap 1s ease-in-out infinite;
  animation: left-wing-flap 1s ease-in-out infinite;
}
.butterfly_container figure.butterfly .wing use {
  display: block;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  fill: url(#image);
}
