.guitar-companion {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 12000;
  display: grid;
  width: 126px;
  height: 158px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.guitar-companion.is-dragging { cursor: grabbing; }

.guitar-motion-emote[hidden] { display: none; }

.guitar-motion-emote {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 5, 18, 0.86);
  opacity: 0;
  backdrop-filter: blur(8px);
  transition: opacity 220ms ease;
}

.guitar-motion-emote.is-visible { opacity: 1; }

.guitar-motion-emote-shell {
  position: relative;
  width: min(360px, calc(100vw - 36px));
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  transform: translateY(70px) scale(0.48);
  transition: transform 460ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease;
}

.guitar-motion-emote.is-visible .guitar-motion-emote-shell {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.guitar-motion-emote-animation {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  filter: drop-shadow(0 26px 28px rgba(0, 0, 0, 0.55));
}

.guitar-motion-emote-message {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  background: rgba(16, 13, 31, 0.88);
  color: #fff;
  font: 900 clamp(0.9rem, 2.4vw, 1.25rem)/1.3 system-ui, sans-serif;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.guitar-motion-emote-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(16, 13, 31, 0.82);
  color: #fff;
  font: 800 0.76rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.guitar-companion.is-celebrating {
  left: 50% !important;
  top: 52% !important;
  right: auto !important;
  bottom: auto !important;
  width: 270px;
  height: 238px;
  cursor: default;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.guitar-companion-stage {
  position: relative;
  display: block;
  width: 118px;
  height: 154px;
  background: transparent;
}

.guitar-companion-duo,
.guitar-companion-note,
.guitar-companion-spark {
  position: absolute;
  pointer-events: none;
}

.guitar-companion-duo {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 14px rgba(4, 3, 16, 0.5));
  transform-origin: 50% 80%;
}

.guitar-companion-note { opacity: 0; color: #fff3a8; font-size: 1.1rem; font-weight: 900; }
.guitar-companion-note.note-one { top: 4px; right: 14px; }
.guitar-companion-note.note-two { top: 20px; left: 10px; }

.guitar-companion-spark {
  color: #ffd166;
  font-size: 1rem;
  font-weight: 900;
  opacity: 0;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.9);
}

.spark-one { top: 8%; left: 10%; }
.spark-two { top: 2%; right: 12%; }
.spark-three { bottom: 17%; left: 3%; }
.spark-four { right: 2%; bottom: 22%; }

.guitar-companion-message {
  position: absolute;
  right: 2px;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(230px, calc(100vw - 30px));
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px 14px 4px 14px;
  background: rgba(20, 16, 34, 0.96);
  box-shadow: 0 12px 28px rgba(5, 4, 14, 0.32);
  color: #fff;
  font: 800 0.74rem/1.35 system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
}

.guitar-companion:hover .guitar-companion-message,
.guitar-companion:focus-visible .guitar-companion-message,
.guitar-companion.is-playing .guitar-companion-message,
.guitar-companion.is-speaking .guitar-companion-message,
.guitar-companion.is-celebrating .guitar-companion-message {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.guitar-companion.is-celebrating .guitar-companion-stage {
  width: 260px;
  height: 220px;
}

.guitar-companion.is-celebrating .guitar-companion-message {
  right: 50%;
  bottom: calc(100% + 4px);
  max-width: min(330px, calc(100vw - 28px));
  padding: 12px 17px;
  border-radius: 16px;
  font-size: 0.92rem;
  text-align: center;
  translate: 50% 0;
}

.guitar-companion.is-complete:is(.is-playing, .is-celebrating) .guitar-companion-note {
  animation: ots-music-note 1.05s ease-out 4;
}

.guitar-companion.is-complete:is(.is-playing, .is-celebrating) .note-two { animation-delay: 180ms; }

.guitar-companion.is-celebrating .guitar-companion-spark {
  animation: ots-celebration-spark 900ms ease-out 4;
}

.guitar-companion.is-celebrating .spark-two { animation-delay: 120ms; }
.guitar-companion.is-celebrating .spark-three { animation-delay: 240ms; }
.guitar-companion.is-celebrating .spark-four { animation-delay: 360ms; }

@keyframes ots-duo-idle {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1deg); }
}

@keyframes ots-emote-victory-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  12% { transform: translateY(5px) scale(1.06, 0.93); }
  48% { transform: translateY(-34px) rotate(3deg) scale(0.98, 1.04); }
  72% { transform: translateY(-10px) rotate(-2deg); }
}

@keyframes ots-emote-guitar-solo {
  0%, 100% { transform: translateY(0) rotate(-3deg) scale(1); }
  35% { transform: translateY(-8px) rotate(7deg) scale(1.06); }
  70% { transform: translateY(1px) rotate(-6deg) scale(1.02); }
}

@keyframes ots-emote-riff-dance {
  0%, 100% { transform: translateX(0) translateY(0) rotate(0); }
  25% { transform: translateX(-22px) translateY(-8px) rotate(-7deg); }
  50% { transform: translateX(0) translateY(2px) rotate(0); }
  75% { transform: translateX(22px) translateY(-8px) rotate(7deg); }
}

@keyframes ots-emote-power-spin {
  0% { transform: translateY(0) rotate(0) scale(1); }
  35% { transform: translateY(-24px) rotate(150deg) scale(1.05); }
  70% { transform: translateY(-10px) rotate(300deg) scale(1.02); }
  100% { transform: translateY(0) rotate(360deg) scale(1); }
}

@keyframes ots-emote-stage-bow {
  0%, 100% { transform: translateY(0) rotate(0) scaleY(1); }
  30% { transform: translateY(4px) rotate(-1deg) scaleY(0.93); }
  58% { transform: translateY(15px) rotate(7deg) scaleY(0.82); }
  78% { transform: translateY(-7px) rotate(-3deg) scaleY(1.03); }
}

@keyframes ots-music-note {
  0% { opacity: 0; transform: translateY(8px) scale(0.7); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) translateX(8px) scale(1.15); }
}

@keyframes ots-celebration-spark {
  0% { opacity: 0; transform: scale(0.3) rotate(0); }
  35% { opacity: 1; transform: scale(1.35) rotate(80deg); }
  100% { opacity: 0; transform: translateY(-28px) scale(0.55) rotate(180deg); }
}

@media (max-width: 780px) {
  .guitar-motion-emote { padding: 10px; }
  .guitar-motion-emote-shell {
    width: min(300px, calc(100vw - 20px));
  }
  .guitar-motion-emote-message {
    right: 10px;
    bottom: 10px;
    left: 10px;
    padding: 10px 12px;
  }
  .guitar-motion-emote-close { top: 9px; right: 9px; }
  .guitar-companion {
    right: 12px;
    bottom: calc(102px + env(safe-area-inset-bottom));
    width: 94px;
    height: 124px;
  }
  .guitar-companion-stage { width: 90px; height: 120px; }
  .guitar-companion-message { max-width: min(210px, calc(100vw - 24px)); }
  .guitar-companion.is-celebrating {
    top: 48% !important;
    width: 210px;
    height: 190px;
  }
  .guitar-companion.is-celebrating .guitar-companion-stage {
    width: 202px;
    height: 176px;
  }
  .guitar-companion.is-celebrating .guitar-companion-message {
    max-width: min(300px, calc(100vw - 24px));
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guitar-companion * { animation: none !important; transition: none !important; }
  .guitar-motion-emote,
  .guitar-motion-emote-shell { transition: none !important; }
}
