html,
body {
  margin: 0;
  padding: 0;
  background: transparent;
  overflow: hidden;
  height: 100%;
  width: 100%;
  font-family: 'DotGothic16', sans-serif;
}

#bubble-container {
  position: fixed;
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  transition: all 0.3s ease;
  /* Default position (will be overridden by message positioning) */
  top: 20px;
  right: 20px;
}

/* Container for bubble with circular image */
.message-with-circle {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease, transform 1s ease;
  position: relative;
}

/* Ensure bubble content aligns with top of circle */
.message-with-circle .bubble-content {
  margin-top: 0;
  align-self: flex-start;
}

.message-with-circle.visible {
  opacity: 1;
  transform: translateY(0);
}

.message-with-circle.fadeout {
  opacity: 0;
  transform: translateY(-20px);
}

/* Container for bubble without circular image */
.message-without-circle {
  position: relative;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease, transform 1s ease;
}

.message-without-circle.visible {
  opacity: 1;
  transform: translateY(0);
}

.message-without-circle.fadeout {
  opacity: 0;
  transform: translateY(-20px);
}

/* Triangle pointer from bubble to avatar */
.message-triangle {
  position: absolute;
  right: -18px;
  top: 15px;
  width: 0;
  height: 0;
  border-left: 15px solid;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  z-index: 6;
}

/* White border for triangle */
.message-triangle::before {
  content: '';
  position: absolute;
  right: 0px;
  top: -15px;
  width: 0;
  height: 0;
  border-left: 18px solid #ffffff;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  z-index: -1;
}

/* Square avatar container inside bubble */
.avatar-image-container {
  width: 180px;
  height: 180px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px #000000;
  align-self: flex-start;
}

/* Avatar image element */
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Adjust bubble width when circle is present */
.bubble.with-circle {
  width: fit-content;
  max-width: 800px;
  min-width: 250px;
  position: relative;
}

/* Progress bar styles */
.progress-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  width: 0%;
  transition: width linear;
  border-radius: 8px 0 0 0;
}

/* Make bubble relative positioned for absolute progress bar */
.bubble {
  position: relative;
  padding: 15px 25px;
  background: #002180;
  color: white;
  border-radius: 6px;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px #000000;
  width: fit-content;
  max-width: 800px;
  min-width: 400px;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow-wrap: break-word;
  font-size: 20px;
  line-height: 1.4;
  box-sizing: border-box;
  display: inline-block;
  display: block;
}

.visible {
  opacity: 1;
  transform: translateY(0);
}

.fadeout {
  opacity: 0;
  transform: translateY(-20px);
}

/* Message wrapper for new structure */
.message-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

/* Horizontal container for text and avatar inside bubble */
.message-horizontal-container {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  width: 100%;
}

/* Content wrapper for text (flex: 1 to take available space) */
.message-horizontal-container > div:first-child {
  flex: 1;
  min-width: 300px;
}

/* External image (not avatar) */
.message-image-external {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px #000000;
}

/* When with circle, align bubble content to circle's top */
.message-with-circle .message-wrapper {
  align-items: flex-start;
  justify-content: flex-start;
}

.message-with-circle .bubble {
  margin-top: 0;
  align-self: flex-start;
}

/* Title outside and above bubble */
.message-title {
  font-weight: bold;
  font-size: 25px;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 4px rgba(0, 0, 0, 0.5);
  padding: 8px 0px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  margin-bottom: 2px;
  width: 100%;
  text-align: center;
}

/* Old title style (now unused) */
.title {
  font-weight: bold;
  font-size: 20px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 5px;
}

/* Content inside bubble */
.content {
  font-size: 28px;
  line-height: 1.4;
  font-family: 'DotGothic16', sans-serif;
  position: relative;
}

/* Invisible placeholder to maintain bubble size */
.content-placeholder {
  visibility: hidden;
  font-size: 28px;
  line-height: 1.4;
  font-family: 'DotGothic16', sans-serif;
}

/* Actual typing text positioned over placeholder */
.content-typing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

/* Typing effect for RPG-style text */
.content .char {
  opacity: 0;
  animation: fadeInChar 0.1s forwards;
  text-shadow: 
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 4px rgba(0, 0, 0, 0.5);
}

@keyframes fadeInChar {
  to {
    opacity: 1;
  }
}

/* Image styles (old - inside bubble) */
.message-image {
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 8px 0;
  display: block;
  object-fit: contain;
}

/* External image styles (left of bubble) */
/* External image styles (left of bubble) */
.message-image-external {
  max-width: 200px;
  max-height: 200px;
  height: auto;
  width: auto;
  border-radius: 8px;
  margin: 0;
  display: block;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

/* Bouncing name in title */
.message-title .bouncing-name {
  display: inline-block;
  margin: 0 2px;
  color: #5eff00;
  font-size: 1.3em;
  font-weight: bold;
  text-shadow: 
    -2px -2px 0 #0f0f0f,
    -1px -1px 0 #0f0f0f,
    2px -2px 0 #4f575e,
    1px -1px 0 #4f575e,
    -2px 2px 0 #12161a,
    -1px 1px 0 #12161a,
    2px 2px 0 #455868,
    1px 1px 0 #455868,
    0 0 12px rgba(252, 252, 252, 0.9),
    0 0 20px rgba(94, 255, 0, 0.6);
}

/* Characters in bouncing name */
.message-title .bouncing-name .char {
  display: inline-block;
  animation: bounce 0.8s ease-in-out infinite;
}

/* Stagger animation for each character in bouncing name */
.message-title .bouncing-name .char:nth-child(1) { animation-delay: 0s; }
.message-title .bouncing-name .char:nth-child(2) { animation-delay: 0.05s; }
.message-title .bouncing-name .char:nth-child(3) { animation-delay: 0.1s; }
.message-title .bouncing-name .char:nth-child(4) { animation-delay: 0.15s; }
.message-title .bouncing-name .char:nth-child(5) { animation-delay: 0.2s; }
.message-title .bouncing-name .char:nth-child(6) { animation-delay: 0.25s; }
.message-title .bouncing-name .char:nth-child(7) { animation-delay: 0.3s; }
.message-title .bouncing-name .char:nth-child(8) { animation-delay: 0.35s; }
.message-title .bouncing-name .char:nth-child(9) { animation-delay: 0.4s; }
.message-title .bouncing-name .char:nth-child(10) { animation-delay: 0.45s; }
.message-title .bouncing-name .char:nth-child(11) { animation-delay: 0.5s; }
.message-title .bouncing-name .char:nth-child(12) { animation-delay: 0.55s; }
.message-title .bouncing-name .char:nth-child(n+13) { animation-delay: 0.6s; }

/* User name below image with bouncing effect - DEPRECATED */
.user-name-label {
  display: none;
}

/* Bounce animation */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.image-only .message-image {
  margin: 0;
  border-radius: 4px;
  width: 100%;
  height: auto;
}

/* Audio styles */
.message-audio {
  display: none;
  /* Completely hide the audio player */
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Hide progress bar for infinite messages */
.bubble.infinite .progress-container {
  display: none;
}

/* Debug info panel (hidden by default) */
#debug-info {
  position: fixed;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px;
  border-radius: 5px;
  font-size: 12px;
  font-family: monospace;
  z-index: 10000;
  display: none;
  /* Set to 'block' for debugging */
  min-width: 200px;
}

#debug-info div {
  margin: 2px 0;
}
