:root {
  --bg: #05060a;
  --bg2: #0a0d16;
  --ink: #eef1f8;
  --muted: #7d84a3;
  --accent: #6c8cff;
  --accent2: #b46bff;
  --danger: #ff5c7a;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 100% at 50% 0%, #0d1120 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
}
::selection { background: var(--accent); color: #05060a; }

#stars { position: fixed; inset: 0; z-index: 0; }

.aura {
  position: fixed;
  top: 40%; left: 50%;
  width: 70vmax; height: 70vmax;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(closest-side, rgba(108,140,255,.18), transparent 70%),
    radial-gradient(closest-side, rgba(180,107,255,.14), transparent 70%);
  filter: blur(20px);
  z-index: 0;
  animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .8; }
  50% { transform: translate(-50%, -52%) scale(1.12); opacity: 1; }
}

.grid-floor {
  position: fixed;
  inset: 55% -20% -20% -20%;
  background-image:
    linear-gradient(rgba(108,140,255,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,140,255,.16) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(340px) rotateX(62deg);
  transform-origin: top center;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  z-index: 0;
  animation: floor 12s linear infinite;
}
@keyframes floor { from { background-position: 0 0; } to { background-position: 0 46px; } }

.wrap {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 32px;
  max-width: 640px;
}

/* 404 */
.code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 18px);
  font-weight: 700;
  font-size: clamp(6rem, 26vw, 15rem);
  line-height: 1;
  letter-spacing: -.03em;
  position: relative;
}
.code .d {
  background: linear-gradient(180deg, #fff, #9aa6d8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: glitch 4.5s steps(1) infinite;
  text-shadow: 0 0 40px rgba(108,140,255,.35);
}
.code .d:last-child { animation-delay: 2.25s; }

@keyframes glitch {
  0%, 92%, 100% { transform: translate(0,0); filter: none; }
  93% { transform: translate(-3px, 1px); filter: drop-shadow(2px 0 var(--danger)) drop-shadow(-2px 0 var(--accent)); }
  95% { transform: translate(3px, -1px); filter: drop-shadow(-2px 0 var(--danger)) drop-shadow(2px 0 var(--accent)); }
  97% { transform: translate(-2px, 0); filter: none; }
}

.o {
  position: relative;
  width: clamp(4.4rem, 19vw, 11rem);
  height: clamp(4.4rem, 19vw, 11rem);
  display: inline-grid;
  place-items: center;
}
.planet {
  position: relative;
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #aab6ff, #5f79ff 45%, #3a2a8c 100%);
  box-shadow:
    inset -10px -12px 30px rgba(0,0,0,.55),
    0 0 44px rgba(108,140,255,.55);
  animation: spin 14s linear infinite;
}
.planet .ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 175%;
  height: 46%;
  border: 3px solid rgba(180,177,255,.7);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  box-shadow: 0 0 24px rgba(180,107,255,.35);
}
.planet .moon {
  position: absolute;
  top: 50%; left: 50%;
  width: 12px; height: 12px;
  margin: -6px;
  border-radius: 50%;
  background: #eef1f8;
  box-shadow: 0 0 12px rgba(255,255,255,.8);
  transform-origin: -46px 6px;
  animation: orbit 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbit { to { transform: rotate(360deg); } }

.title {
  margin-top: clamp(18px, 4vh, 34px);
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -.01em;
  opacity: 0;
  animation: rise .8s cubic-bezier(.19,1,.22,1) .2s forwards;
}
.sub {
  margin: 14px auto 0;
  max-width: 30rem;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1rem;
  opacity: 0;
  animation: rise .8s cubic-bezier(.19,1,.22,1) .35s forwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

.home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(24px, 5vh, 40px);
  padding: 14px 26px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  border: 1px solid rgba(238,241,248,.16);
  background: rgba(238,241,248,.03);
  backdrop-filter: blur(8px);
  overflow: hidden;
  position: relative;
  opacity: 0;
  animation: rise .8s cubic-bezier(.19,1,.22,1) .5s forwards;
  transition: color .35s, border-color .35s, transform .35s;
}
.home::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: translateX(-101%);
  transition: transform .4s cubic-bezier(.19,1,.22,1);
  z-index: -1;
}
.home:hover { color: #fff; border-color: transparent; transform: translateY(-2px); }
.home:hover::before { transform: translateX(0); }
.home i { transition: transform .35s; }
.home:hover i { transform: translateX(5px); }

.ref {
  margin-top: 34px;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  color: var(--muted);
  opacity: 0;
  animation: rise .8s ease .65s forwards;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .title, .sub, .home, .ref { opacity: 1 !important; }
}
