:root {
  color-scheme: dark;
  --bg: #020207;
  --panel: rgba(5, 8, 18, 0.78);
  --panel-border: rgba(201, 226, 255, 0.2);
  --text: #eef2ff;
  --muted: #b2b8dd;
  --accent: #50ecff;
  --accent-2: #a771ff;
  --danger: #ff4d8d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  --mx: 50%;
  --my: 50%;
  background: radial-gradient(circle at 22% 10%, #12185a 0, transparent 36%),
    radial-gradient(circle at 80% 20%, #4a145f 0, transparent 40%),
    radial-gradient(circle at 52% 84%, #0a4564 0, transparent 34%), var(--bg);
  background-size: 130% 130%;
  animation: ambientShift 18s ease-in-out infinite;
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-bg-theme='nebula'] {
  --bg: #020207;
  --panel: rgba(5, 8, 18, 0.78);
  --panel-border: rgba(201, 226, 255, 0.2);
  --accent: #50ecff;
  --accent-2: #a771ff;
  --danger: #ff4d8d;
}

body[data-bg-theme='sunset'] {
  --bg: #1a0814;
  --panel: rgba(26, 10, 25, 0.76);
  --panel-border: rgba(255, 203, 164, 0.28);
  --accent: #ff9f5d;
  --accent-2: #ff5fa2;
  --danger: #ff4d8d;
  background: radial-gradient(circle at 12% 12%, #4f113d 0, transparent 37%),
    radial-gradient(circle at 86% 16%, #933417 0, transparent 42%),
    radial-gradient(circle at 52% 86%, #3f173a 0, transparent 38%), var(--bg);
}

body[data-bg-theme='matrix'] {
  --bg: #030f0a;
  --panel: rgba(3, 20, 13, 0.8);
  --panel-border: rgba(125, 255, 180, 0.24);
  --accent: #4dff9f;
  --accent-2: #30d2be;
  --danger: #7dffb4;
  background: radial-gradient(circle at 15% 10%, #0f532f 0, transparent 37%),
    radial-gradient(circle at 80% 18%, #0d4538 0, transparent 42%),
    radial-gradient(circle at 50% 82%, #07271e 0, transparent 38%), var(--bg);
}

body[data-bg-theme='frost'] {
  --bg: #07111d;
  --panel: rgba(8, 20, 34, 0.78);
  --panel-border: rgba(185, 233, 255, 0.24);
  --accent: #7fd5ff;
  --accent-2: #9fbeff;
  --danger: #7bd8ff;
  background: radial-gradient(circle at 15% 10%, #174a74 0, transparent 37%),
    radial-gradient(circle at 84% 20%, #1d3268 0, transparent 42%),
    radial-gradient(circle at 50% 88%, #0a2e4f 0, transparent 38%), var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1.2rem, 3vw, 2rem);
  position: relative;
  overflow: hidden;
}

.bg-motion-layer {
  position: absolute;
  inset: -35%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background: conic-gradient(
      from 0deg at 25% 32%,
      rgba(80, 236, 255, 0.35),
      rgba(167, 113, 255, 0.18),
      rgba(255, 77, 141, 0.28),
      rgba(94, 255, 181, 0.22),
      rgba(80, 236, 255, 0.35)
    ),
    radial-gradient(circle at 70% 65%, rgba(140, 161, 255, 0.28), transparent 52%);
  filter: blur(50px) saturate(125%);
  transform-origin: 50% 50%;
  animation: bgOrbit 28s linear infinite, bgPulse 12s ease-in-out infinite;
}

.liquid-bg {
  position: absolute;
  width: 120vmax;
  aspect-ratio: 1;
  border-radius: 43% 57% 53% 47% / 40% 46% 54% 60%;
  pointer-events: none;
  filter: blur(22px) saturate(120%);
  opacity: 0.35;
  z-index: 0;
}

.liquid-bg-a {
  top: -35vmax;
  left: -18vmax;
  background: radial-gradient(circle at 30% 30%, rgba(131, 255, 251, 0.5), rgba(80, 236, 255, 0.12) 48%, transparent 70%);
  animation: liquidMorphA 24s ease-in-out infinite;
}

.liquid-bg-b {
  right: -24vmax;
  bottom: -40vmax;
  background: radial-gradient(circle at 56% 52%, rgba(200, 133, 255, 0.42), rgba(255, 77, 141, 0.16) 46%, transparent 70%);
  animation: liquidMorphB 26s ease-in-out infinite;
}

.liquid-bg-c {
  left: 50%;
  top: 50%;
  width: 95vmax;
  transform: translate(-50%, -50%);
  opacity: 0.26;
  background: radial-gradient(circle at 45% 40%, rgba(94, 255, 181, 0.33), rgba(75, 151, 255, 0.1) 44%, transparent 72%);
  animation: liquidMorphC 20s ease-in-out infinite;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 50%, black 35%, transparent 90%);
  pointer-events: none;
  animation: gridDrift 20s linear infinite;
}

body[data-bg-theme='sunset'] .grid-overlay {
  opacity: 0.25;
  background-image: linear-gradient(rgba(255, 196, 170, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 146, 163, 0.1) 1px, transparent 1px);
}

body[data-bg-theme='matrix'] .grid-overlay {
  opacity: 0.4;
  background-image: linear-gradient(rgba(77, 255, 159, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 210, 190, 0.11) 1px, transparent 1px);
}

body[data-bg-theme='frost'] .grid-overlay {
  opacity: 0.34;
  background-image: linear-gradient(rgba(185, 233, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159, 190, 255, 0.1) 1px, transparent 1px);
}

.sparkle-overlay {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1.5px 1.5px at 70% 22%, rgba(146, 228, 255, 0.9), transparent),
    radial-gradient(1.8px 1.8px at 84% 74%, rgba(255, 182, 240, 0.85), transparent),
    radial-gradient(1.2px 1.2px at 42% 80%, rgba(255, 255, 255, 0.6), transparent);
  background-size: 260px 260px, 320px 320px, 360px 360px, 280px 280px;
  animation: sparkleDrift 16s linear infinite;
}

.scanline-overlay {
  position: absolute;
  inset: -15%;
  pointer-events: none;
  opacity: 0.1;
  background-image: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0,
    rgba(255, 255, 255, 0.08) 1px,
    transparent 1px,
    transparent 7px
  );
  mix-blend-mode: soft-light;
  animation: scanlineSlide 8s linear infinite;
}

body[data-bg-theme='frost'] .scanline-overlay {
  opacity: 0.16;
}

.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
  pointer-events: none;
}

.aurora-a {
  width: 370px;
  height: 370px;
  background: #1894ff;
  top: 6%;
  left: 7%;
  animation: floatA 9s ease-in-out infinite;
}

.aurora-b {
  width: 320px;
  height: 320px;
  background: #a24eff;
  bottom: 4%;
  right: 12%;
  animation: floatB 8.5s ease-in-out infinite;
}

body[data-bg-theme='sunset'] .aurora-a {
  background: #ff8d4f;
}

body[data-bg-theme='sunset'] .aurora-b {
  background: #ff4ca8;
}

body[data-bg-theme='matrix'] .aurora-a {
  background: #3df290;
}

body[data-bg-theme='matrix'] .aurora-b {
  background: #1cd2bf;
}

body[data-bg-theme='frost'] .aurora-a {
  background: #6ec6ff;
}

body[data-bg-theme='frost'] .aurora-b {
  background: #8fb4ff;
}

.nebula-ring {
  position: absolute;
  width: min(120vmax, 1400px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(
    from 0deg,
    rgba(80, 236, 255, 0.16),
    rgba(167, 113, 255, 0.07),
    rgba(255, 77, 141, 0.13),
    rgba(80, 236, 255, 0.16)
  );
  filter: blur(2px);
  opacity: 0.7;
  animation: ringSpin 20s linear infinite;
}

@keyframes floatA {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(35px, -24px);
  }
}

@keyframes floatB {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-28px, 35px);
  }
}

.panel {
  position: relative;
  width: min(1160px, 100%);
  border: 1px solid var(--panel-border);
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.12) 0%,
      rgba(255, 255, 255, 0.05) 28%,
      rgba(255, 255, 255, 0.01) 64%
    ),
    var(--panel);
  backdrop-filter: blur(24px) saturate(165%);
  -webkit-backdrop-filter: blur(24px) saturate(165%);
  border-radius: 24px;
  box-shadow: 0 28px 96px rgba(1, 3, 12, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  padding: clamp(1.6rem, 3.2vw, 2.9rem);
  z-index: 1;
  overflow: hidden;
  transform: none;
}

.panel::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(760px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02) 42%, transparent 62%);
  mix-blend-mode: screen;
  opacity: 0.72;
}

.panel::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.config-panel {
  max-height: calc(100vh - 2.4rem);
  overflow-y: auto;
}

.hidden {
  display: none;
}

.eyebrow,
.badge {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.78rem;
}

h1,
h2 {
  margin: 0.6rem 0 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(1.95rem, 4.8vw, 3.6rem);
  line-height: 1.15;
}

.subtitle {
  margin: 0.9rem 0 1.5rem;
  color: var(--muted);
  font-size: 1.08rem;
}

.host-pill {
  margin: 0.75rem 0 0;
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #03141f;
  background: linear-gradient(120deg, var(--accent), #8bf4ff);
  box-shadow: 0 10px 28px rgba(80, 236, 255, 0.35);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 1.04rem;
}

.inline-help {
  margin: -0.3rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.inline-help code {
  color: #d2f8ff;
  word-break: break-word;
}

.inline-help-actions {
  display: block;
  margin: 0.45rem 0 0.5rem;
}

.help-install-btn {
  display: inline-block;
  color: #03141f;
  text-decoration: none;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.45rem 0.72rem;
  background: linear-gradient(120deg, var(--accent), #8bf4ff);
}

.help-install-btn:hover,
.help-install-btn:focus-visible {
  filter: brightness(1.08);
}

input,
select,
textarea {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  font-size: 1.08rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 236, 255, 0.2);
}


textarea {
  resize: vertical;
  min-height: 5.5rem;
  line-height: 1.35;
}

#titlePreview,
.waiting-title {
  white-space: normal;
}

.title-line {
  display: block;
  line-height: 1.08;
}
button {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  cursor: pointer;
}

.waiting-panel {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 1.15rem;
  padding-block: clamp(1.6rem, 3.5vw, 3.2rem);
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #ffd8ea;
  background: rgba(255, 77, 141, 0.16);
  border: 1px solid rgba(255, 77, 141, 0.5);
  border-radius: 999px;
  padding: 0.36rem 0.72rem;
}

.live-chip span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 12px rgba(255, 77, 141, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

.waiting-title {
  max-width: 20ch;
  font-size: clamp(2.9rem, 8vw, 6.4rem);
  line-height: 1.08;
  background: linear-gradient(96deg, #d6ffff, #c9d6ff 40%, #ffc6f4 72%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.countdown-stage {
  margin: 0.6rem 0 0.2rem;
  width: min(88vw, 740px);
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(8px);
  padding: 1.35rem 1.25rem;
}

.timer {
  margin: 0;
  font-size: clamp(3.8rem, 13vw, 8.4rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 0.22em;
  text-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.digit {
  min-width: 0.66em;
  display: inline-grid;
  place-items: center;
  padding: 0.14em 0.08em;
  border-radius: 0.16em;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.32);
}

.colon {
  opacity: 0.88;
  animation: blink 1s steps(1, end) infinite;
}

@keyframes blink {
  0%,
  42% {
    opacity: 0.92;
  }
  52%,
  100% {
    opacity: 0.18;
  }
}

.digit-change {
  animation: flipIn 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes flipIn {
  0% {
    transform: translateY(10px) rotateX(-76deg);
    opacity: 0.3;
    filter: blur(2px);
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(0) rotateX(0deg);
    filter: blur(0);
  }
}

.progress-bar-wrap {
  width: min(90vw, 760px);
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 20px rgba(80, 236, 255, 0.45);
  transition: width 0.35s ease;
}

.ticker {
  margin: 0.2rem 0 0;
  width: min(90vw, 800px);
  color: var(--muted);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(7px);
  border-radius: 12px;
  padding: 0.48rem 0;
  animation: tickerMove 13s linear infinite;
}

.presence-panel {
  width: min(90vw, 820px);
  margin-top: 0.65rem;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: rgba(4, 8, 24, 0.5);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(10px);
}

.presence-hidden {
  display: none;
}

.presence-title,
.presence-status,
.presence-counts {
  margin: 0;
}

.presence-title {
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.presence-status {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.96rem;
}

.presence-counts {
  margin-top: 0.3rem;
  font-size: 0.98rem;
}

.presence-events {
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  max-height: 180px;
  overflow: auto;
}

.presence-events li {
  padding: 0.36rem 0.52rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.95rem;
}

@keyframes tickerMove {
  0% {
    transform: translateX(6%);
  }
  50% {
    transform: translateX(-6%);
  }
  100% {
    transform: translateX(6%);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.72);
    opacity: 0.62;
  }
}

@keyframes ambientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes bgOrbit {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.08);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes bgPulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.72;
  }
}

@keyframes gridDrift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(22px, 16px, 0);
  }
}

@keyframes ringSpin {
  0% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.04) rotate(180deg);
  }
  100% {
    transform: scale(1) rotate(360deg);
  }
}

@keyframes sparkleDrift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-40px, -30px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes scanlineSlide {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(24px);
  }
}

@keyframes liquidMorphA {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    border-radius: 43% 57% 53% 47% / 40% 46% 54% 60%;
  }
  50% {
    transform: translate3d(6vmax, 4vmax, 0) rotate(180deg) scale(1.08);
    border-radius: 58% 42% 45% 55% / 54% 40% 60% 46%;
  }
}

@keyframes liquidMorphB {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    border-radius: 51% 49% 37% 63% / 56% 40% 60% 44%;
  }
  50% {
    transform: translate3d(-8vmax, -4vmax, 0) rotate(-180deg) scale(1.09);
    border-radius: 37% 63% 55% 45% / 42% 58% 42% 58%;
  }
}

@keyframes liquidMorphC {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    border-radius: 54% 46% 58% 42% / 45% 55% 45% 55%;
  }
  50% {
    transform: translate(calc(-50% + 5vmax), calc(-50% - 3vmax)) rotate(160deg) scale(1.12);
    border-radius: 38% 62% 43% 57% / 62% 38% 62% 38%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 580px) {
  .panel {
    border-radius: 16px;
  }

  .subtitle,
  .ticker {
    font-size: 0.88rem;
  }
}
