* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  /* iOS 直向/橫向切換時會自動放大字級,這裡固定住,交給下面的 clamp() 自己控制 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.captions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 1.2vh;
  padding: 4vh 4vw;
  padding-bottom: max(4vh, env(safe-area-inset-bottom));
  min-height: 100vh;
  /* dvh 會隨手機瀏覽器網址列收合即時調整,比 vh 更準;不支援的瀏覽器就退回 vh */
  min-height: 100dvh;
}

.captions > .line {
  width: 100%;
  /* 螢幕很寬(超寬投影幕)時,字幕不要整行拉滿到邊緣,維持適中的閱讀行寬 */
  max-width: min(92vw, 1400px);
  /* flex column 底下的子項目預設 min-width:auto,會被內容的「不換行寬度」撐開,
     導致文字明明有 max-width 限制卻還是整行溢出畫面。這裡強制允許縮小,文字才會真的換行。 */
  min-width: 0;
}

.line {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

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

.line.old {
  opacity: 0.35;
}

.line .en,
.line .zh {
  overflow-wrap: break-word;
  word-break: break-word;
}

.line .en {
  color: #9aa0a6;
  font-size: clamp(16px, 2vw, 28px);
  line-height: 1.3;
  margin-bottom: 0.3em;
}

.line .zh {
  color: #ffffff;
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.status {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  font-size: clamp(11px, 1.4vw, 14px);
  color: #666;
  font-family: monospace;
  z-index: 10;
}

.status.connected {
  color: #2ecc71;
}

.status.disconnected {
  color: #e74c3c;
}

.mic-indicator {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  width: clamp(20px, 3vw, 28px);
  height: clamp(20px, 3vw, 28px);
  color: #4a4d52;
  opacity: 0.55;
  z-index: 10;
  line-height: 0;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.mic-indicator svg {
  width: 100%;
  height: 100%;
}

.mic-indicator.active {
  color: #2ecc71;
  opacity: 1;
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 rgba(46, 204, 113, 0.7));
  }
  50% {
    transform: scale(1.18);
    filter: drop-shadow(0 0 7px rgba(46, 204, 113, 0.85));
  }
}
