:root {
  --neon-cyan: #00f5ff;
  --neon-pink: #ff00e5;
  --neon-lime: #39ff14;
  --neon-yellow: #ffea00;
  --neon-purple: #b026ff;
  --bg-0: #05010f;
  --bg-1: #0a0326;
  --ink: #e8e6ff;
  --ink-dim: #9a93c4;
  --glass: rgba(20, 12, 45, 0.55);
  --glass-brd: rgba(120, 90, 255, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--ink);
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

/* ---------- animated backdrop ---------- */
body {
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(176, 38, 255, 0.28), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(0, 245, 255, 0.20), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(255, 0, 229, 0.18), transparent 60%),
    var(--bg-0);
}

.bg-grid {
  position: fixed;
  inset: -50%;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 0, 229, 0.07) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(500px) rotateX(58deg) translateY(-8%);
  animation: gridflow 18s linear infinite;
  opacity: 0.55;
}
@keyframes gridflow {
  from { background-position: 0 0; }
  to   { background-position: 0 60px; }
}

.bg-orb {
  position: fixed;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  z-index: 0;
  mix-blend-mode: screen;
  pointer-events: none;
}
.orb-1 { background: var(--neon-purple); top: -12%; left: -8%; animation: drift1 22s ease-in-out infinite; }
.orb-2 { background: var(--neon-cyan);  bottom: -15%; right: -10%; animation: drift2 26s ease-in-out infinite; }
.orb-3 { background: var(--neon-pink);  top: 30%; right: 20%; animation: drift3 30s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(8vw,6vh) scale(1.15); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-7vw,-5vh) scale(1.1); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(0.9); } 50% { transform: translate(-5vw,7vh) scale(1.2); } }

#sparkle {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.9;
}

/* ---------- layout ---------- */
.stage {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.hidden { display: none !important; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 0 60px rgba(0, 245, 255, 0.08), inset 0 0 40px rgba(176, 38, 255, 0.06);
}

/* ---------- login ---------- */
.login-card {
  width: min(440px, 92vw);
  padding: 44px 38px;
  border-radius: 22px;
  animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(34px, 7vw, 56px);
  letter-spacing: 2px;
  margin: 0 0 6px;
  text-align: center;
  background: linear-gradient(100deg, var(--neon-cyan), var(--neon-pink) 45%, var(--neon-lime));
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: hue 6s linear infinite;
  filter: drop-shadow(0 0 18px rgba(0, 245, 255, 0.35));
}
.title span { color: transparent; }
@keyframes hue { to { background-position: 220% 0; } }

.tagline {
  text-align: center;
  color: var(--ink-dim);
  font-size: 15px;
  margin: 0 0 30px;
  letter-spacing: 0.4px;
}
.tagline em { color: var(--neon-cyan); font-style: normal; }

.field { display: block; margin-bottom: 22px; }
.field span {
  display: block;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: rgba(5, 1, 15, 0.6);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.15), 0 0 24px rgba(0, 245, 255, 0.25);
}

.neon-btn {
  position: relative;
  width: 100%;
  padding: 15px 22px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
  color: #04010a;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(100deg, var(--neon-cyan), var(--neon-pink), var(--neon-lime));
  background-size: 220% 100%;
  box-shadow: 0 0 26px rgba(0, 245, 255, 0.45);
  transition: transform 0.15s, box-shadow 0.2s;
  animation: hue 5s linear infinite;
}
.neon-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 0 42px rgba(255, 0, 229, 0.6); }
.neon-btn:active { transform: translateY(0) scale(0.99); }

.live-count {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-dim);
  font-size: 13px;
  letter-spacing: 1px;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--neon-lime);
  box-shadow: 0 0 10px var(--neon-lime);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- chat ---------- */
#chat { padding: 16px; gap: 14px; }

.topbar {
  width: min(1080px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-radius: 16px;
  animation: slideDown 0.5s ease both;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 24px;
  color: var(--neon-cyan);
  text-shadow: 0 0 14px var(--neon-cyan);
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
  margin: 0;
  background: linear-gradient(100deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.stats { display: flex; align-items: center; gap: 18px; }
.stat { text-align: center; }
.stat-num {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  color: var(--neon-lime);
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.5);
}
.stat-lbl { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-dim); }

.avatars { display: flex; }
.avatar {
  width: 32px; height: 32px;
  margin-left: -8px;
  border-radius: 50%;
  border: 2px solid var(--bg-0);
  display: grid;
  place-items: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #04010a;
  cursor: pointer;
  transition: transform 0.15s;
  animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.avatar:hover { transform: translateY(-4px) scale(1.12); z-index: 5; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.me-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--glass-brd);
  background: rgba(5, 1, 15, 0.5);
}

/* messages */
.messages {
  flex: 1;
  width: min(1080px, 100%);
  overflow-y: auto;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--neon-cyan), var(--neon-pink));
  border-radius: 8px;
}
.messages::-webkit-scrollbar-track { background: transparent; }

.msg {
  display: flex;
  gap: 12px;
  max-width: 78%;
  animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.msg.self { align-self: flex-end; flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  background: rgba(15, 9, 35, 0.7);
  border: 1px solid rgba(120, 90, 255, 0.25);
}
.msg .name {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.msg .text { font-size: 16px; }
.msg.self .bubble {
  background: rgba(0, 245, 255, 0.08);
  border-color: rgba(0, 245, 255, 0.35);
}

/* system / join / leave lines */
.system {
  align-self: center;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink-dim);
  padding: 4px 14px;
  border-radius: 20px;
  background: rgba(5, 1, 15, 0.4);
  animation: msgIn 0.4s ease both;
}
.system.leave { color: var(--neon-pink); }
.system.join  { color: var(--neon-lime); }

/* composer */
.composer {
  width: min(1080px, 100%);
  padding: 12px;
  border-radius: 16px;
  animation: slideUp 0.5s ease both;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.typing {
  height: 18px;
  font-size: 13px;
  color: var(--neon-cyan);
  padding: 0 6px;
  opacity: 0;
  transition: opacity 0.2s;
}
.typing.show { opacity: 1; }

#msg-form { display: flex; gap: 10px; }
#text {
  flex: 1;
  padding: 14px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: rgba(5, 1, 15, 0.6);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#text:focus {
  border-color: var(--neon-pink);
  box-shadow: 0 0 0 3px rgba(255, 0, 229, 0.15), 0 0 24px rgba(255, 0, 229, 0.25);
}
#msg-form .neon-btn {
  width: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
}

/* connection banner */
.conn-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  text-align: center;
  padding: 6px;
  font-size: 13px;
  letter-spacing: 1px;
  background: rgba(255, 45, 85, 0.9);
  transform: translateY(-100%);
  transition: transform 0.3s;
}
.conn-banner.show { transform: none; }
