body {
  margin: 0px;
  overflow: visible !important; /* Allow content to expand on hover */
}

html {
  overflow: visible !important; /* Allow content to expand on hover */
}

#animation_container {
  background-color: transparent; 
  width: 150px; 
  height: 150px;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  transition: width 0.3s ease, height 0.3s ease;
  transform-origin: bottom right;
  /* iOS specific improvements for better touch handling */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y; /* Allow panning for drag */
  /* Ensure container can receive pointer events */
  pointer-events: auto;
}

/* When in iframe, position at bottom-right to align with parent */
/* Override inline styles set by JavaScript when in iframe */
#animation_container {
  /* Default positioning - will be overridden by JS in iframe, but we'll fix it with CSS */
}

/* Ensure container is positioned at bottom-right when absolutely positioned (iframe mode) */
html body #animation_container[style*="absolute"] {
  position: absolute !important;
  top: auto !important;
  left: auto !important;
  bottom: 0 !important;
  right: 0 !important;
  margin: 0 !important;
}
/* Mobile styles - default 150x150 */
@media (max-width: 768px) {
  #animation_container {
    width: 150px !important;
    height: 150px !important;
  }
  
  #animation_container canvas {
    width: 150px !important;
    height: 150px !important;
  }
  
  #dom_overlay_container {
    width: 150px !important;
    height: 150px !important;
  }
}

/* Desktop hover effect only */
@media (hover: hover) and (pointer: fine) {
  /* Regular hover expansion */
  #animation_container:hover {
    width: 250px !important;
    height: 250px !important;
  }
  
  /* Close button scales with banner hover on desktop only */
  #animation_container:hover #closeBtn {
    width: 27px !important;
    height: 27px !important;
    font-size: 29px !important;
    transition: width 0.3s ease, height 0.3s ease, font-size 0.3s ease;
  }
  
  /* Allow hover expansion even when no-hover class is present */
  /* The no-hover class is kept for other purposes but hover expansion is enabled */
  #animation_container.no-hover:hover {
    width: 250px !important;
    height: 250px !important;
    transform: none !important;
  }
  
  #animation_container.no-hover:hover #closeBtn {
    width: 27px !important;
    height: 27px !important;
    font-size: 29px !important;
    transition: width 0.3s ease, height 0.3s ease, font-size 0.3s ease;
  }
  
  #animation_container.no-hover:hover canvas {
    width: 250px !important;
    height: 250px !important;
  }
  
  #animation_container.no-hover:hover #dom_overlay_container {
    width: 250px !important;
    height: 250px !important;
  }
}

#animation_container:active {
  cursor: grabbing;
}

#animation_container canvas {
  position: absolute;
  display: block;
  background-color: transparent;
  width: 150px;
  height: 150px;
  transition: width 0.3s ease, height 0.3s ease;
  /* Canvas needs pointer events for hover detection and dragging */
  pointer-events: auto !important;
}

#dom_overlay_container {
  pointer-events: none;
  /* overflow: hidden; */
  width: 150px;
  height: 150px;
  position: absolute;
  left: 0px;
  top: 0px;
  display: block;
  transition: width 0.3s ease, height 0.3s ease;
}

/* Non-interactive child elements should not block hover */
/* Only disable pointer events on non-interactive elements when hovering */
#animation_container:hover #cta-image {
  pointer-events: none !important;
}

/* Interactive elements must always receive pointer events */
#closeBtn,
#mobileTouchOverlay {
  pointer-events: auto !important;
}

/* General touch improvements */
#closeBtn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* iOS specific improvements */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  transition: transform 0.1s ease, color 0.1s ease, font-size 0.1s ease;
  /* Enhanced touch sensitivity */
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  /* Simple X button styling */
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  font-size: 17.4px !important;
  /* Mobile touch optimization */
  position: relative;
  z-index: 30;
  color: #666666 !important;
}

/* Mobile touch area enhancement */
@media (max-width: 768px) {
  #closeBtn {
    /* Larger touch target for mobile */
    width: 24px !important;
    height: 24px !important;
    font-size: 20px !important;
    /* Enhanced touch area through pseudo-element */
    position: relative;
    /* Move up 4px and right 3px on mobile only */
    top: 4px !important;
    right: 3px !important;
  }
  
  #closeBtn::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    /* Creates larger invisible touch area */
    background: transparent;
    z-index: -1;
    border-radius: 50%;
  }
  
  /* Visual feedback on touch */
  #closeBtn:active {
    transform: scale(0.9);
    background: rgba(255, 107, 107, 0.2) !important;
    border-radius: 50% !important;
    transition: transform 0.1s ease, background 0.1s ease;
  }
}

/* Ensure close button is always accessible */
#closeBtn:hover,
#closeBtn:active,
#closeBtn:focus {
  color: #ff6b6b !important;
  transform: scale(1.2);
  transition: transform 0.1s ease, color 0.1s ease;
}

/* Moved to desktop-only media query above */

/* iOS-specific optimizations */
.ios-device {
  -webkit-overflow-scrolling: touch;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.ios-device#closeBtn {
  /* Enhanced touch sensitivity without changing size */
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  /* Better touch response */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  /* Improved touch area through pseudo-element */
  position: relative;
}

.ios-device#closeBtn::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  /* Invisible but creates larger touch area */
  background: transparent;
  z-index: -1;
}

/* Android-specific optimizations */
.android-device {
  /* Better touch handling for Android */
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  touch-action: manipulation;
}

.android-device#animation_container {
  /* Ensure proper touch event handling on Android */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

/* Touch support indicator */
.touch-supported #animation_container {
  /* Additional optimizations when touch is supported */
  cursor: grab;
}

.touch-supported #animation_container:active {
  cursor: grabbing;
}
