:root {
  color-scheme: dark;
  font-family: "Microsoft JhengHei", system-ui, sans-serif;
  color: #f8f0fa;
  background: #181421;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

#stage {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #4a324c, #211927 64%, #181421);
}

#avatar {
  display: block;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

#heard {
  position: absolute;
  inset-block-start: max(4%, env(safe-area-inset-top));
  inset-inline-start: 4%;
  display: grid;
  justify-items: start;
  gap: .3rem;
  max-width: min(50%, 26rem);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
  font-size: clamp(12px, 2.4vw, 17px);
  line-height: 1.4;
}
#heard li {
  display: flex;
  align-items: baseline;
  gap: .45em;
  max-width: 100%;
  padding: .36em .65em;
  border-radius: .55em;
  background: #231829ea;
  color: #fff5fc;
}
.heard-speaker {
  flex: 0 1 auto;
  max-width: 38%;
  color: #ffc3e9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heard-text {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
body[data-song="true"] #heard {
  inset-block-start: max(15%, calc(env(safe-area-inset-top) + 4rem));
}

@media (max-width: 580px) {
  #heard { max-width: 75%; }
}
@media (max-height: 260px) {
  .heard-text { -webkit-line-clamp: 1; }
  body[data-song="true"] #heard { inset-block-start: max(18%, 36px); }
}

#caption, #lyrics {
  position: absolute;
  inset-inline: 5%;
  bottom: max(5%, env(safe-area-inset-bottom));
  text-align: center;
  overflow-wrap: anywhere;
  font-size: clamp(18px, 4vw, 42px);
  font-weight: 750;
  line-height: 1.45;
  text-shadow: 0 2px 4px #171020, 0 0 12px #171020;
  pointer-events: none;
}

#caption { white-space: pre-wrap; }
body[data-karaoke="true"] #caption, body[data-song="true"] #caption {
  bottom: auto;
  top: max(3%, env(safe-area-inset-top));
  font-size: clamp(15px, 3vw, 28px);
}
#lyrics {
  isolation: isolate;
  bottom: max(4%, env(safe-area-inset-bottom));
}
#lyrics::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -22% -4% -65%;
  background: radial-gradient(ellipse at 50% 45%, #24172bd9 0%, #21172880 52%, transparent 76%);
}
#lyric-current {
  display: inline-block;
  max-width: 100%;
  color: #ffe6a3;
  font-weight: 850;
  line-height: 1.26;
}
#lyric-current:empty, #lyric-next:empty { display: none; }
@supports (background-clip: text) {
  #lyric-current {
    background: linear-gradient(100deg, #ffe89a, #ff9abf) left / var(--lyric-progress, 0%) 100% no-repeat,
                linear-gradient(#fff1fa, #fff1fa);
    background-clip: text;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 2px 3px #180f22);
  }
}
#lyric-next {
  color: #f5dfef;
  opacity: .72;
  font-size: .70em;
  line-height: 1.32;
  margin-top: .28em;
}

@media (max-height: 260px) {
  #lyrics { font-size: clamp(13px, 5vw, 20px); }
  body[data-song="true"] #caption {
    inset-inline: 4% 59%;
    text-align: left;
    font-size: clamp(10px, 3.2vw, 15px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

#connection {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  pointer-events: none;
  padding: 24px;
}
#notice { margin: 0; font-size: clamp(15px, 3.2vw, 22px); }
#retry {
  pointer-events: auto;
  margin-top: 16px;
  padding: 8px 16px;
  border: 1px solid #ab7eaa;
  border-radius: 8px;
  background: #533b58;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
