:root {
  --bg: #08070c;
  --panel: #131019;
  --panel-2: #17131f;
  --panel-border: #262032;
  --ink: #ece7f5;
  --ink-dim: #948aa8;
  --ink-faint: #574f68;
  --accent: #b990ff;
  --accent-dim: #8c5fe0;
  --accent-glow: rgba(185, 144, 255, 0.2);
  --amber: #ffb454;
  --amber-glow: rgba(255, 180, 84, 0.18);
  --discord: #5865F2;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Space Grotesk', sans-serif;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  perspective: 1200px;
}

#fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.55; }

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(185, 144, 255, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, black, transparent 85%);
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 90% at 50% 30%, transparent 30%, rgba(0,0,0,0.4) 100%);
}

.back-link {
  position: fixed;
  top: 24px; left: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  transition: color 0.2s, border-color 0.2s, transform 0.2s, opacity 0.3s, visibility 0.3s;
}
.back-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.back-link:hover { color: var(--accent); border-color: var(--accent-dim); transform: translateX(-3px); }
.back-link.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

main {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
}

.redirect-main { display: none; }

body.redirecting .invite-main { display: none; }
body.redirecting .redirect-main { display: flex; }

.invite-shield-stage {
  position: relative;
  width: 220px; height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 34px;
}
.mega-shield {
  width: 92px; height: 92px;
  fill: var(--accent-glow);
  stroke: var(--accent);
  stroke-width: 1.6;
  filter: drop-shadow(0 0 28px var(--accent-glow));
  position: relative;
  z-index: 3;
}
.mega-shield .check {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: draw-check 0.6s ease 1.1s forwards;
}
@keyframes draw-check { to { stroke-dashoffset: 0; } }

.orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
}
.ring-1 { width: 160px; height: 160px; animation: spin 22s linear infinite; }
.ring-2 { width: 210px; height: 210px; border-style: dashed; border-color: rgba(185,144,255,0.16); animation: spin 32s linear infinite reverse; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.ring-particles span {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  top: 50%; left: 50%;
}

.invite-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px;
  opacity: 0;
}
.invite-eyebrow .dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

h1 {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
  margin-bottom: 20px;
  opacity: 0;
}
h1 .accent { color: var(--accent); }

.invite-desc {
  color: var(--ink-dim);
  font-size: 15.5px;
  max-width: 460px;
  line-height: 1.65;
  margin-bottom: 40px;
  opacity: 0;
}

.invite-cta {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--discord);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  border: none;
  padding: 17px 32px;
  border-radius: 15px;
  margin-bottom: 30px;
  cursor: pointer;
  font-family: var(--display);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s;
  box-shadow: 0 10px 34px -8px rgba(88, 101, 242, 0.5);
  opacity: 0;
}
.invite-cta:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 16px 42px -6px rgba(88, 101, 242, 0.65); }
.invite-cta:active { transform: translateY(-1px) scale(0.99); }
.discord-mark { width: 22px; height: 22px; fill: currentColor; }
.cta-arrow { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.5; transition: transform 0.25s; }
.invite-cta:hover .cta-arrow { transform: translateX(4px); }
.cta-glow {
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-20deg);
  animation: sweep 3s ease-in-out infinite;
}
@keyframes sweep { 0% { left: -60%; } 35%, 100% { left: 130%; } }

.invite-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
  margin-bottom: 70px;
  opacity: 0;
}
.perm-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  padding: 7px 14px;
  border-radius: 20px;
}

.invite-steps {
  display: flex;
  gap: 20px;
  max-width: 900px;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}
.step {
  flex: 1 1 240px;
  max-width: 280px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  display: flex;
  gap: 14px;
  opacity: 0;
  transition: border-color 0.25s, transform 0.25s;
}
.step:hover { border-color: var(--accent-dim); transform: translateY(-4px); }
.step-num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  width: 30px; height: 30px;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-glow);
  flex-shrink: 0;
}
.step-text h3 { font-size: 15px; margin-bottom: 6px; }
.step-text p { font-size: 12.5px; color: var(--ink-dim); line-height: 1.6; }
.step-text code {
  font-family: var(--mono);
  background: rgba(185,144,255,0.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11.5px;
}

.redirect-main {
  align-items: center;
  justify-content: center;
}

.redirect-box {
  background: linear-gradient(165deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  padding: 44px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 50px -20px rgba(185, 144, 255, 0.25), 0 10px 30px rgba(0,0,0,0.4);
  transform-style: preserve-3d;
  transition: transform 0.1s;
  opacity: 0;
  animation: popIn 0.7s var(--ease-spring) forwards;
  width: 100%;
  max-width: 440px;
}
.card-content { transform: translateZ(30px); }
@keyframes popIn { to { opacity: 1; } }

.icon-circle {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--accent-dim);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 24px var(--accent-glow);
}
.icon-circle svg {
  width: 28px; height: 28px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.redirect-box h2 {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink);
}

.status-message {
  font-size: 14px;
  color: var(--ink-dim);
  margin-bottom: 28px;
  font-family: var(--mono);
}

.progress-bar-container {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 50px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  width: 0%;
  border-radius: 50px;
  transition: width 0.05s linear;
  box-shadow: 0 0 10px var(--accent-glow);
}
.progress-text {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--mono);
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
  margin-top: 28px;
}
.info-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--amber); stroke-width: 2; flex-shrink: 0; }
.info-content p { margin: 0; font-size: 12.5px; color: var(--ink-dim); line-height: 1.6; }

.redirecting-message {
  margin-top: 22px;
  font-style: italic;
  color: var(--ink-faint);
  font-size: 12px;
  font-family: var(--mono);
  opacity: 0;
  transition: opacity 0.3s;
}
.redirecting-message.show { opacity: 1; }

@media (max-width: 640px) {
  h1 { font-size: 32px; }
  main { padding: 100px 20px 60px; }
  .mega-shield { width: 70px; height: 70px; }
  .invite-shield-stage { width: 170px; height: 170px; }
  .ring-1 { width: 120px; height: 120px; }
  .ring-2 { width: 160px; height: 160px; }
  .redirect-box { padding: 32px 22px; }
  .redirect-box h2 { font-size: 1.5rem; }
}