#farmErrorBubble {
  position: absolute;
  z-index: 8;
  width: max-content;
  max-width: min(276px, calc(100vw - 30px));
  padding: 11px 15px;
  transform: translate(-50%, -100%);
  border: 2px solid #e4f0f5;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 4px 12px #243c2440;
  color: #3e4544;
  font:
    14px/1.35 Arial,
    sans-serif;
  text-align: left;
  overflow-wrap: anywhere;
  pointer-events: none;
}

#farmErrorBubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 17px;
  height: 17px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 2px solid #e4f0f5;
  border-bottom: 2px solid #e4f0f5;
  background: #fff;
}

.farm-error-enter {
  animation: farm-error-pop 180ms ease-out both;
}

@keyframes farm-error-pop {
  from {
    opacity: 0;
    translate: 0 5px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

#xpTrack {
  overflow: visible;
}

#xpGain {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -2px;
  color: #f8fff0;
  font:
    bold 12px/1 Arial,
    sans-serif;
  text-shadow:
    0 1px 2px #285a2d,
    0 0 3px #285a2d;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.xp-gain-rise {
  animation: xp-gain-rise 920ms ease-out both;
}

@keyframes xp-gain-rise {
  0% {
    transform: translate(-50%, 0) scale(0.92);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  72% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -34px) scale(1.04);
    opacity: 0;
  }
}

#levelUpDialog {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  width: min(520px, calc(100vw - 30px));
  height: auto;
  max-height: calc(100dvh - 32px);
  padding: 10px;
  overflow: auto;
  border: 5px solid #e5e2cb;
  border-radius: 20px;
  background: #fffef5;
  box-shadow:
    0 16px 45px #20391c66,
    inset 0 0 0 2px #fff;
  color: #444;
}

#levelUpDialog::backdrop {
  background: #20341d75;
  backdrop-filter: none;
}

.level-up-frame {
  min-height: 0;
  padding: 12px 22px 15px;
  border: 2px solid #dedbbd;
  border-radius: 12px;
  background: linear-gradient(145deg, #fffef7, #f9f7e9);
}

.level-up-frame h2 {
  margin: 0 0 14px;
  color: #59584b;
  font:
    24px/1.3 Arial,
    sans-serif;
  text-align: center;
}

#levelUpNumber {
  color: #d84d42;
}

.level-up-content {
  min-height: 0;
  padding: 10px 16px;
  border-radius: 9px;
  background: #fff;
  font:
    16px/1.35 Arial,
    sans-serif;
}

.level-up-content p {
  margin: 0 0 8px;
}
.level-up-content p:last-child {
  margin-bottom: 0;
}
.level-up-congrats {
  font-weight: 700;
}
#levelUpReward {
  color: #4b7539;
}

.level-up-frame footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.level-up-mascot {
  width: 58px;
  height: 58px;
  margin: -8px 0 -4px;
  object-fit: contain;
}

.level-up-frame footer button {
  min-width: 112px;
  min-height: 42px;
  padding: 8px 18px;
  border: 1px solid #aaa;
  border-radius: 5px;
  background: linear-gradient(#fff, #e8e8e8);
  color: #565656;
  font:
    16px Arial,
    sans-serif;
  box-shadow: 0 2px 4px #0002;
}

.level-up-frame footer #levelUpShare {
  border-color: #5a8e27;
  background: linear-gradient(#8fc742, #68a721);
  color: #fff;
  font-weight: 700;
}

@media (max-width: 600px) {
  .level-up-frame {
    min-height: 0;
    padding: 12px 10px 14px;
  }
  .level-up-frame h2 {
    margin-bottom: 15px;
    font-size: 21px;
  }
  .level-up-content {
    min-height: 0;
    padding: 15px;
    font-size: 16px;
  }
  .level-up-frame footer {
    gap: 9px;
    margin-top: 10px;
  }
  .level-up-mascot {
    width: 48px;
    height: 48px;
    margin-left: -5px;
  }
  .level-up-frame footer button {
    min-width: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .farm-error-enter,
  .xp-gain-rise {
    animation-duration: 1ms;
  }
}
