:root {
  --bg: #050712;
  --text: #e9efff;
  --glow-cyan: rgba(71, 214, 255, 0.7);
  --glow-violet: rgba(168, 97, 255, 0.58);
  --glow-magenta: rgba(255, 95, 229, 0.5);
  --glow-gold: rgba(255, 190, 75, 0.54);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 20%, #18104a 0%, #090b18 34%, #04060d 70%, #020207 100%);
  color: var(--text);
  overflow: hidden;
}
body {
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.viewport {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
}

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #03040a;
  box-shadow: 0 0 80px rgba(83, 0, 160, 0.35), 0 0 160px rgba(0, 91, 255, 0.08);
}

.bg-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: saturate(1.05) contrast(1.02);
}

.ambient-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 66%, rgba(5, 8, 24, 0.18) 0 9%, rgba(5, 8, 24, 0.44) 9% 28%, rgba(5, 8, 24, 0) 34%),
    radial-gradient(circle at 50% 61%, rgba(0, 0, 0, 0.24) 0, rgba(0,0,0,0.0) 42%),
    linear-gradient(to bottom, rgba(5, 6, 16, 0.05), rgba(6, 7, 18, 0.13));
  pointer-events: none;
}

.portal-links {
  position: absolute;
  inset: 0;
}

.portal {
  --outline: rgba(102, 190, 255, 0.9);
  --glow: var(--glow-cyan);
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  min-width: 180px;
  height: calc(var(--h) * 1%);
  min-height: 76px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #f4f7ff;
  isolation: isolate;
  transition: transform 180ms ease, filter 180ms ease;
}

.portal::before,
.portal::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(5% 0, 95% 0, 100% 16%, 100% 84%, 95% 100%, 5% 100%, 0 84%, 0 16%);
  border-radius: 2px;
}

.portal::before {
  background: linear-gradient(to bottom, rgba(8, 10, 22, 0.82), rgba(5, 7, 16, 0.92));
  border: 1.6px solid var(--outline);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    inset 0 0 22px rgba(0,0,0,0.55),
    0 0 0 1px rgba(0,0,0,0.25),
    0 0 16px var(--glow),
    0 0 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px) saturate(1.1);
}

.portal::after {
  inset: 6px;
  border: 1px solid color-mix(in srgb, var(--outline) 65%, transparent);
  background: linear-gradient(to bottom, rgba(255,255,255,0.03), rgba(255,255,255,0));
  opacity: 0.9;
}

.portal .label {
  position: relative;
  z-index: 2;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(10px, 0.95vw, 16px);
  letter-spacing: 0.02em;
  text-shadow: 0 0 8px rgba(255,255,255,0.18), 0 0 18px var(--glow);
}

.sigil {
  position: absolute;
  top: 0;
  left: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -58%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(255,255,255,0.12), rgba(9, 12, 24, 0.94));
  border: 1.5px solid var(--outline);
  box-shadow:
    0 0 10px var(--glow),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  z-index: 3;
}

.sigil svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: white;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px var(--glow));
}

.sigil.human svg { stroke-width: 3.5; }

.portal:hover,
.portal:focus-visible {
  transform: translate(-50%, -50%) scale(1.035);
  filter: brightness(1.08);
  outline: none;
}
.portal:hover::before,
.portal:focus-visible::before {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    inset 0 0 26px rgba(0,0,0,0.55),
    0 0 20px var(--glow),
    0 0 44px var(--glow),
    0 0 0 1px rgba(255,255,255,0.05);
}

.gold { --outline: rgba(255, 188, 86, 0.95); --glow: var(--glow-gold); }
.cyan { --outline: rgba(69, 211, 255, 0.95); --glow: var(--glow-cyan); }
.violet { --outline: rgba(191, 117, 255, 0.95); --glow: var(--glow-violet); }
.magenta { --outline: rgba(236, 106, 255, 0.95); --glow: var(--glow-magenta); }

.page-glow {
  position: fixed;
  inset: -10%;
  background:
    radial-gradient(circle at 50% 50%, rgba(51, 111, 255, 0.09), transparent 28%),
    radial-gradient(circle at 20% 15%, rgba(177, 97, 255, 0.08), transparent 18%),
    radial-gradient(circle at 85% 22%, rgba(204, 82, 255, 0.06), transparent 20%);
  pointer-events: none;
}

#cursorGlow {
  position: fixed;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(142, 225, 255, 0.55) 0, rgba(115, 175, 255, 0.2) 35%, rgba(132, 75, 255, 0.05) 65%, transparent 75%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(2px);
  opacity: 0.82;
  z-index: 999;
}

@media (max-aspect-ratio: 16/9) {
  .stage {
    width: 100vw;
    height: calc(100vw * 9 / 16);
  }
}

@media (max-width: 1024px) {
  .portal {
    min-width: 0;
    min-height: 0;
  }
  .portal .label {
    font-size: clamp(8px, 1.2vw, 13px);
  }
  .sigil {
    width: 44px;
    height: 44px;
  }
  .sigil svg {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 720px) {
  html, body { overflow: auto; background: #05060f; }
  .viewport {
    min-height: 100vh;
    padding: 24px 12px 40px;
    display: block;
  }
  .stage {
    width: 100%;
    aspect-ratio: auto;
    min-height: calc(100vh - 64px);
    height: auto;
    overflow: hidden;
    border-radius: 20px;
  }
  .bg-art {
    height: 100%;
    object-fit: cover;
    filter: blur(2px) brightness(0.62) saturate(1.02);
    transform: scale(1.08);
  }
  .ambient-overlay {
    background: linear-gradient(to bottom, rgba(3,4,10,0.22), rgba(5,6,12,0.74) 35%, rgba(5,6,12,0.88));
  }
  .portal-links {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 180px 16px 40px;
  }
  .portal {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: 84px;
    transform: none;
  }
  .portal:hover,
  .portal:focus-visible {
    transform: scale(1.02);
  }
  .wide { width: 100%; }
}
