:root {
  color-scheme: dark;
  --bg: #020305;
  --panel: rgba(10, 14, 20, 0.74);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f8fbff;
  --muted: #8d98a8;
  --live: #f02d42;
  --accent: #69d6ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
}

.live-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(105, 214, 255, 0.13), transparent 46%),
    radial-gradient(ellipse at 12% 0%, rgba(240, 45, 66, 0.08), transparent 38%),
    linear-gradient(180deg, #050810 0%, #020305 58%);
}

.live-topbar {
  position: fixed;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.live-back {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.live-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.language-select {
  min-height: 26px;
  max-width: 128px;
  border: 0;
  border-radius: 999px;
  padding: 0 28px 0 10px;
  background: rgba(2, 3, 5, 0.72);
  color: var(--text);
  font: inherit;
  outline: none;
}

.language-select:focus-visible {
  box-shadow: 0 0 0 2px rgba(105, 214, 255, 0.5);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(240, 45, 66, 0.16);
  border: 1px solid rgba(240, 45, 66, 0.38);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 0 32px rgba(240, 45, 66, 0.28);
  animation: livePulse 1.6s ease-in-out infinite;
}

.live-badge[hidden] {
  display: none;
}

.live-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--live);
  box-shadow: 0 0 16px rgba(240, 45, 66, 0.9);
}

.connection-state,
.fullscreen-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.fullscreen-button {
  color: var(--text);
}

.subtitle-stage {
  position: relative;
  min-height: 100dvh;
  height: 100dvh;
  padding: clamp(102px, 15vh, 150px) clamp(18px, 6vw, 90px) clamp(42px, 11vh, 118px);
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  isolation: isolate;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.subtitle-stage::-webkit-scrollbar {
  width: 8px;
}

.subtitle-stage::-webkit-scrollbar-track {
  background: transparent;
}

.subtitle-stage::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.subtitle-feed {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: clamp(14px, 2.2vh, 28px);
  min-height: 100%;
  width: min(100%, 1180px);
  margin: 0 auto;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 720ms ease,
    transform 720ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.live-shell.is-waiting .subtitle-feed {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

.subtitle-line {
  width: min(100%, 24ch);
  margin: 0;
  color: var(--text);
  font-size: clamp(2.35rem, 9vw, 7.4rem);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(22px) scale(0.985);
  filter: blur(8px);
  transition:
    color 420ms ease,
    opacity 420ms ease,
    transform 420ms ease,
    filter 420ms ease,
    font-size 420ms ease;
  animation: subtitleIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.subtitle-line.is-current {
  color: var(--text);
  text-shadow: 0 12px 42px rgba(0, 0, 0, 0.52);
}

.subtitle-line.is-history {
  width: min(100%, 38ch);
  color: rgba(248, 251, 255, 0.44);
  font-size: clamp(1.16rem, 4.6vw, 3.1rem);
  font-weight: 800;
  line-height: 1.16;
  transform: translateY(-2px) scale(0.992);
  filter: none;
}

.subtitle-line.is-complete {
  filter: none;
}

.subtitle-text {
  white-space: pre-wrap;
}

.typing-caret {
  display: inline-block;
  width: 0.08em;
  height: 0.86em;
  margin-left: 0.08em;
  border-radius: 999px;
  vertical-align: -0.08em;
  background: currentColor;
  animation: caretBlink 850ms ease-in-out infinite;
}

.typing-caret[hidden] {
  display: none;
}

.waiting-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: clamp(116px, 16vh, 158px) clamp(22px, 7vw, 96px) clamp(42px, 10vh, 96px);
  text-align: center;
  pointer-events: none;
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity 760ms ease,
    visibility 0s linear 0s,
    transform 760ms cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.waiting-state::before {
  content: "";
  position: absolute;
  inset: -18%;
  background:
    linear-gradient(115deg, transparent 0 24%, rgba(105, 214, 255, 0.09) 42%, transparent 61%),
    linear-gradient(245deg, transparent 0 36%, rgba(240, 45, 66, 0.06) 53%, transparent 74%);
  filter: blur(22px);
  opacity: 0.9;
  transform: translate3d(-2%, 1%, 0) scale(1.04);
  animation: waitingAtmosphere 18s ease-in-out infinite alternate;
}

.waiting-state::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 3, 5, 0.04), rgba(2, 3, 5, 0.72)),
    radial-gradient(ellipse at center, transparent 0 36%, rgba(0, 0, 0, 0.42) 100%);
}

.live-shell.is-live .waiting-state {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-18px) scale(0.985);
  transition:
    opacity 680ms ease,
    visibility 0s linear 680ms,
    transform 680ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.waiting-ambient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.8;
}

.waiting-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(92vw, 780px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.82);
  animation: waitingRing 6.8s ease-in-out infinite;
}

.waiting-line-two {
  width: min(112vw, 980px);
  border-color: rgba(105, 214, 255, 0.08);
  animation-delay: -2.8s;
}

.waiting-content {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: clamp(14px, 2.4vh, 24px);
  width: min(100%, 760px);
  max-width: calc(100vw - 44px);
  transform: translateY(clamp(8px, 3vh, 28px));
}

.waiting-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(105, 214, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(248, 251, 255, 0.72);
  font-size: clamp(0.74rem, 2.6vw, 0.86rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(16px);
}

.waiting-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 20px rgba(105, 214, 255, 0.85);
  animation: waitingSignal 2.4s ease-in-out infinite;
}

.waiting-title {
  margin: 0;
  width: min(100%, 14ch);
  color: rgba(248, 251, 255, 0.96);
  font-size: clamp(2.35rem, 11vw, 6.8rem);
  font-weight: 900;
  line-height: 1.02;
  text-wrap: balance;
  overflow-wrap: break-word;
  letter-spacing: 0;
  text-shadow: 0 18px 58px rgba(0, 0, 0, 0.72);
  animation: waitingTextBreath 4.8s ease-in-out infinite;
}

.waiting-subtitle {
  margin: 0;
  width: min(100%, 42ch);
  color: rgba(248, 251, 255, 0.58);
  font-size: clamp(1rem, 3.8vw, 1.32rem);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.waiting-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 54px;
  margin-top: clamp(6px, 1.8vh, 14px);
  opacity: 0.7;
}

.waiting-wave span {
  width: 4px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(105, 214, 255, 0.28), rgba(248, 251, 255, 0.74), rgba(240, 45, 66, 0.24));
  transform: scaleY(0.34);
  transform-origin: center;
  animation: waitingWave 2.4s ease-in-out infinite;
}

.waiting-wave span:nth-child(2) {
  animation-delay: -2.12s;
}

.waiting-wave span:nth-child(3) {
  animation-delay: -1.86s;
}

.waiting-wave span:nth-child(4) {
  animation-delay: -1.58s;
}

.waiting-wave span:nth-child(5) {
  animation-delay: -1.3s;
}

.waiting-wave span:nth-child(6) {
  animation-delay: -1.02s;
}

.waiting-wave span:nth-child(7) {
  animation-delay: -0.74s;
}

.waiting-wave span:nth-child(8) {
  animation-delay: -0.46s;
}

.waiting-wave span:nth-child(9) {
  animation-delay: -0.18s;
}

.waiting-wave span:nth-child(10) {
  animation-delay: 0.1s;
}

.waiting-wave span:nth-child(11) {
  animation-delay: 0.38s;
}

.waiting-state[aria-hidden="true"] {
  pointer-events: none;
}

@keyframes subtitleIn {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes caretBlink {
  0%,
  100% {
    opacity: 0.22;
  }
  50% {
    opacity: 1;
  }
}

@keyframes waitingAtmosphere {
  from {
    opacity: 0.72;
    transform: translate3d(-3%, 1%, 0) scale(1.04);
  }
  to {
    opacity: 1;
    transform: translate3d(3%, -2%, 0) scale(1.08);
  }
}

@keyframes waitingRing {
  0%,
  100% {
    opacity: 0.26;
    transform: translate(-50%, -50%) scale(0.78);
  }
  50% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes waitingSignal {
  0%,
  100% {
    opacity: 0.42;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes waitingTextBreath {
  0%,
  100% {
    opacity: 0.86;
    text-shadow: 0 18px 58px rgba(0, 0, 0, 0.72);
  }
  50% {
    opacity: 1;
    text-shadow: 0 22px 72px rgba(105, 214, 255, 0.16), 0 18px 58px rgba(0, 0, 0, 0.72);
  }
}

@keyframes waitingWave {
  0%,
  100% {
    opacity: 0.38;
    transform: scaleY(0.32);
  }
  48% {
    opacity: 0.95;
    transform: scaleY(1);
  }
}

@keyframes livePulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(240, 45, 66, 0);
  }
  50% {
    box-shadow: 0 0 34px rgba(240, 45, 66, 0.38);
  }
}

@media (prefers-reduced-motion: reduce) {
  .subtitle-stage {
    scroll-behavior: auto;
  }

  .subtitle-line,
  .live-badge,
  .typing-caret,
  .waiting-state::before,
  .waiting-line,
  .waiting-kicker::before,
  .waiting-title,
  .waiting-wave span {
    animation: none;
    transition: none;
  }

  .subtitle-line,
  .waiting-state {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

html:fullscreen .live-topbar {
  opacity: 0.18;
  transform: translateY(-2px);
  transition: opacity 180ms ease, transform 180ms ease;
}

html:fullscreen .live-topbar:hover,
html:fullscreen .live-topbar:focus-within {
  opacity: 0.96;
  transform: translateY(0);
}

html:fullscreen .subtitle-stage {
  padding-top: clamp(84px, 12vh, 128px);
  padding-bottom: clamp(54px, 13vh, 142px);
}

@media (max-width: 720px) {
  .live-topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    overflow: hidden;
    border-radius: 24px;
    align-items: flex-start;
    flex-direction: column;
  }

  .live-status-group {
    align-self: stretch;
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, max-content);
    align-items: center;
    gap: 8px;
  }

  .language-picker {
    grid-column: 1 / -1;
    flex: 0 1 auto;
    min-width: 0;
    width: auto;
    max-width: 100%;
  }

  .language-select {
    width: 134px;
    max-width: min(134px, calc(100vw - 132px));
    min-width: 0;
  }

  .live-badge,
  .connection-state,
  .fullscreen-button {
    min-width: 0;
  }

  .connection-state {
    max-width: 100%;
  }

  .subtitle-stage {
    padding: 154px clamp(16px, 5vw, 28px) clamp(34px, 9vh, 82px);
  }

  .waiting-state {
    padding: 170px clamp(20px, 6vw, 28px) 48px;
  }

  .waiting-content {
    transform: translateY(2vh);
  }

  .waiting-title {
    width: min(100%, 10.5ch);
    font-size: clamp(2.15rem, 10.4vw, 3.65rem);
  }

  .waiting-subtitle {
    width: min(100%, 28ch);
  }

  .subtitle-line {
    width: min(100%, 13ch);
    font-size: clamp(2.15rem, 12vw, 4.75rem);
    line-height: 1.08;
  }

  .subtitle-line.is-history {
    width: min(100%, 21ch);
    font-size: clamp(1.08rem, 5.6vw, 2.15rem);
  }
}
