:root {
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.35);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.25);
  --glass-hi: rgba(255, 255, 255, 0.5);
  --text: #f4f4f8;
  --text-dim: rgba(244, 244, 248, 0.62);
  --radius: 30px;
  --blur: 26px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: #05060a;
  overflow: hidden;
}

body { position: relative; }

/* ---------- Background ---------- */
.bg-layer { position: fixed; inset: 0; z-index: 0; }
#bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  filter: brightness(0.55) saturate(1.1);
}
.bg-overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.55) 100%),
    linear-gradient(180deg, rgba(5,6,10,0.35), rgba(5,6,10,0.7));
  backdrop-filter: blur(2px);
}

/* ---------- Liquid blobs ---------- */
.blobs { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  mix-blend-mode: screen;
  animation: float 18s ease-in-out infinite;
}
.blob-1 { width: 340px; height: 340px; left: -60px; top: 10%;
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%); }
.blob-2 { width: 300px; height: 300px; right: -40px; bottom: 8%;
  background: radial-gradient(circle at 60% 40%, #3b82f6, transparent 70%); animation-delay: -6s; }
.blob-3 { width: 260px; height: 260px; left: 40%; top: 60%;
  background: radial-gradient(circle at 50% 50%, #ec4899, transparent 70%); animation-delay: -12s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(30px,-40px) scale(1.1); }
  66% { transform: translate(-20px,30px) scale(0.95); }
}

/* ---------- Cursor glow ---------- */
.cursor-glow {
  position: fixed; z-index: 2; width: 500px; height: 500px;
  border-radius: 50%; pointer-events: none; left: 0; top: 0;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent-soft), transparent 60%);
  opacity: 0; transition: opacity 0.4s;
}

/* ---------- Entrance ---------- */
.entrance {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: rgba(5,6,10,0.5);
  backdrop-filter: blur(14px);
  transition: opacity 0.7s ease, visibility 0.7s;
}
.entrance.hidden { opacity: 0; visibility: hidden; }
.entrance-text {
  font-size: 15px; letter-spacing: 0.35em; text-transform: uppercase;
  color: var(--text-dim);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ---------- Stage / floating profile ---------- */
.stage {
  position: relative; z-index: 10;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.stage.show { opacity: 1; transform: translateY(0); }

.profile {
  position: relative;
  width: min(440px, 100%);
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  gap: 18px;
  padding-bottom: 8px;
}

.username {
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 550;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
.username.glow { text-shadow: 0 0 16px var(--username-glow), 0 2px 20px rgba(0,0,0,0.5); }

/* glitch effect — the real text itself jitters/slices, plus RGB ghosts */
.username.glitch {
  position: relative;
  display: inline-block;
  text-shadow: 0 0 16px var(--username-glow), 0 2px 20px rgba(0,0,0,0.5);
  animation: glitch-main 2.4s infinite steps(1);
}
.username.glitch::before,
.username.glitch::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  pointer-events: none;
  text-shadow: none;
  background: transparent;
}
.username.glitch::before {
  color: #ff2d5e;
  z-index: 2;
  opacity: 0.85;
  animation: glitch-r 0.85s infinite steps(1) alternate-reverse;
}
.username.glitch::after {
  color: #22d3ee;
  z-index: 2;
  opacity: 0.85;
  animation: glitch-c 0.7s infinite steps(1) alternate-reverse;
}

/* the real text: jitter, skew, flicker + horizontal slices */
@keyframes glitch-main {
  0%   { transform: translate(0,0) skewX(0deg); opacity: 1; }
  4%   { transform: translate(-3px,1px) skewX(-8deg); clip-path: inset(20% 0 55% 0); }
  6%   { transform: translate(4px,-2px) skewX(6deg); clip-path: inset(60% 0 15% 0); }
  8%   { transform: translate(0,0) skewX(0deg); clip-path: inset(0 0 0 0); }
  20%  { transform: translate(0,0); opacity: 1; }
  21%  { transform: translate(2px,0); opacity: 0.4; }
  22%  { transform: translate(-2px,0); opacity: 1; }
  40%  { transform: translate(0,0) skewX(0deg); clip-path: inset(0 0 0 0); }
  42%  { transform: translate(5px,-1px) skewX(10deg); clip-path: inset(35% 0 40% 0); }
  44%  { transform: translate(-4px,2px) skewX(-6deg); clip-path: inset(10% 0 70% 0); }
  46%  { transform: translate(0,0) skewX(0deg); clip-path: inset(0 0 0 0); }
  70%  { transform: translate(0,0); opacity: 1; }
  71%  { transform: translate(-3px,0) skewX(5deg); opacity: 0.6; clip-path: inset(50% 0 20% 0); }
  73%  { transform: translate(3px,0) skewX(-5deg); clip-path: inset(15% 0 60% 0); }
  75%  { transform: translate(0,0) skewX(0deg); clip-path: inset(0 0 0 0); opacity: 1; }
  100% { transform: translate(0,0); }
}
@keyframes glitch-r {
  0%   { transform: translate(-5px,0);  clip-path: inset(0 0 82% 0); }
  20%  { transform: translate(-6px,2px);clip-path: inset(30% 0 40% 0); }
  40%  { transform: translate(5px,-2px);clip-path: inset(55% 0 8% 0); }
  60%  { transform: translate(-4px,1px);clip-path: inset(12% 0 65% 0); }
  80%  { transform: translate(4px,0);   clip-path: inset(70% 0 12% 0); }
  100% { transform: translate(-5px,-1px);clip-path: inset(38% 0 35% 0); }
}
@keyframes glitch-c {
  0%   { transform: translate(5px,0);   clip-path: inset(10% 0 70% 0); }
  20%  { transform: translate(6px,-2px);clip-path: inset(65% 0 5% 0); }
  40%  { transform: translate(-5px,2px);clip-path: inset(28% 0 50% 0); }
  60%  { transform: translate(4px,-1px);clip-path: inset(48% 0 28% 0); }
  80%  { transform: translate(-4px,0);  clip-path: inset(5% 0 78% 0); }
  100% { transform: translate(5px,1px); clip-path: inset(72% 0 10% 0); }
}

/* badges — row below username */
.badges { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: -4px; }
.badge { display: grid; place-items: center; transition: transform 0.2s; }
.badge:hover { transform: translateY(-2px) scale(1.12); }
.b-ico {
  width: 22px; height: 22px; display: block;
  background-color: #fff;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.6));
}
.b-img {
  width: 19px; height: 19px; display: block; object-fit: contain;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}

/* bio */
.bio { font-size: clamp(15px, 4vw, 17px); color: rgba(255,255,255,0.78); text-shadow: 0 1px 8px rgba(0,0,0,0.5); }

/* ---------- Discord Spotify pill (liquid glass) ---------- */
.dc-pill {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 380px;
  padding: 12px 14px; text-align: left;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(18px) saturate(1.6) brightness(1.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.6) brightness(1.05);
  box-shadow:
    0 8px 30px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.3),
    inset 0 -6px 18px rgba(0,0,0,0.15);
  overflow: hidden;
  transform-style: flat;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* 3D spin intro: fast → smoothly decelerate, 3 full turns on the Y axis */
.dc-pill.spin-3d {
  animation: pill-spin-3d 2.2s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
  /* drop the live blur while spinning (it re-renders every frame and stutters) */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  /* iOS drops frames when it must re-clip rounded overflow every rotation frame.
     Turn off clipping + box-shadow during the spin so the layer is static & GPU-only. */
  overflow: visible !important;
  box-shadow: none !important;
}
/* hide the sheen pseudo (extra layer) while spinning */
.dc-pill.spin-3d::before { display: none; }
/* During the 3D spin, flatten inner layers (shadows/rounding force per-frame
   re-raster on iOS). Makes the whole pill one cheap GPU texture to rotate. */
.dc-pill.spin-3d .spotify-art,
.dc-pill.spin-3d .dc-avatar { box-shadow: none !important; }
.dc-pill.spin-3d .dc-avatar-dot { display: none !important; }
@keyframes pill-spin-3d {
  0%   { -webkit-transform: perspective(1200px) rotateY(1080deg); transform: perspective(1200px) rotateY(1080deg); opacity: 0; }
  15%  { opacity: 1; }
  100% { -webkit-transform: perspective(1200px) rotateY(0deg); transform: perspective(1200px) rotateY(0deg); opacity: 1; }
}
/* While the pill spins, pause other animations so it gets a full 60fps */
body.spinning .username.glitch,
body.spinning .username.glitch::before,
body.spinning .username.glitch::after { animation-play-state: paused; }
body.spinning .rain-canvas { display: none !important; }
/* also drop the pill's own inner sheen layer while spinning (one less paint) */
body.spinning .dc-pill::before { display: none; }

/* Mobile: keep the full 3-turn spin, just lighten the render (no scale) */
@media (pointer: coarse) {
  @keyframes pill-spin-3d {
    0%   { -webkit-transform: perspective(1000px) rotateY(1080deg); transform: perspective(1000px) rotateY(1080deg); opacity: 0; }
    15%  { opacity: 1; }
    100% { -webkit-transform: perspective(1000px) rotateY(0deg); transform: perspective(1000px) rotateY(0deg); opacity: 1; }
  }

  /* Live backdrop-blur over a playing video is what makes mobile audio stutter.
     Replace it with a static frosted background — looks almost identical, way cheaper. */
  .dc-pill {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: linear-gradient(135deg, rgba(30,30,42,0.72), rgba(16,16,24,0.72)) !important;
  }
  /* full-screen blur over the playing video is a huge constant GPU cost on phones */
  .bg-overlay {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  /* dropping the per-frame video filter + upscale also frees the compositor */
  #bg-video { filter: brightness(0.6) !important; transform: none !important; }

  /* Mobile glitch: still looks broken/glitchy, but transform-only (no clip-path)
     so it stays 60fps on iOS. Jerky RGB split + quick jitter bursts. */
  .username.glitch {
    animation: glitch-main-m 2s infinite steps(1) !important;
  }
  .username.glitch::before {
    animation: glitch-r-m 1.1s infinite steps(1) !important;
  }
  .username.glitch::after {
    animation: glitch-c-m 0.9s infinite steps(1) !important;
  }
}

/* Mobile glitch keyframes — transform + opacity only (GPU-cheap), no clip-path */
@keyframes glitch-main-m {
  0%, 100% { transform: translate(0,0) skewX(0deg); opacity: 1; }
  6%  { transform: translate(-3px,1px) skewX(-6deg); }
  8%  { transform: translate(3px,-1px) skewX(4deg); }
  10% { transform: translate(0,0) skewX(0deg); }
  30% { transform: translate(0,0); opacity: 1; }
  31% { transform: translate(2px,0); opacity: 0.5; }
  32% { transform: translate(-2px,0); opacity: 1; }
  60% { transform: translate(0,0) skewX(0deg); }
  62% { transform: translate(4px,-1px) skewX(7deg); }
  64% { transform: translate(-3px,1px) skewX(-5deg); }
  66% { transform: translate(0,0) skewX(0deg); }
}
@keyframes glitch-r-m {
  0%   { transform: translate(-4px,0); }
  25%  { transform: translate(-5px,2px); }
  50%  { transform: translate(4px,-1px); }
  75%  { transform: translate(-3px,1px); }
  100% { transform: translate(-4px,0); }
}
@keyframes glitch-c-m {
  0%   { transform: translate(4px,0); }
  25%  { transform: translate(5px,-1px); }
  50%  { transform: translate(-4px,1px); }
  75%  { transform: translate(3px,0); }
  100% { transform: translate(4px,0); }
}
.dc-pill::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(120% 80% at 15% -20%, rgba(255,255,255,0.25), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.dc-avatar-wrap { position: relative; flex-shrink: 0; }
.dc-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  object-fit: cover; display: block;
  border: 2px solid rgba(255,255,255,0.2);
}
/* status dot on the pill avatar */
.dc-avatar-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 15px; height: 15px; border-radius: 50%;
  border: 3px solid #14141a;
  background: #80848e;
}
.dc-avatar-dot.online  { background: #23a55a; }
.dc-avatar-dot.idle    { background: #f0b232; }
.dc-avatar-dot.dnd     { background: #f23f43; }
.dc-avatar-dot.offline { background: #80848e; }

/* status view (when no Spotify) */
.dc-status { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 13px; }
.dc-status[hidden] { display: none; }
.last-seen[hidden], .status-text[hidden] { display: none; }
.dc-status .status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #80848e; flex-shrink: 0;
}
.dc-status .status-dot.online  { background: #23a55a; }
.dc-status .status-dot.idle    { background: #f0b232; }
.dc-status .status-dot.dnd     { background: #f23f43; }
.dc-status .status-dot.offline { background: #80848e; }
.status-text { color: rgba(255,255,255,0.85); font-weight: 500; }
.last-seen { color: rgba(255,255,255,0.5); font-size: 12px; }

.dc-info { flex: 1; min-width: 0; }
.dc-name-row { display: flex; align-items: center; gap: 6px; }
.dc-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-tag {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: rgba(255,255,255,0.16); color: #fff; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.tag-badge { width: 14px; height: 14px; object-fit: contain; }
.spotify-line { display: flex; align-items: baseline; gap: 5px; margin-top: 2px; }
.sp-label { font-size: 12px; color: rgba(255,255,255,0.6); flex-shrink: 0; }
.spotify-song { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spotify-sub { font-size: 12px; color: rgba(255,255,255,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spotify-art {
  width: 54px; height: 54px; border-radius: 10px; object-fit: cover;
  flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.activity { font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 2px; }

/* ---------- Socials (white glyphs via mask) ---------- */
.socials { display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; }
.social {
  display: grid; place-items: center; cursor: pointer;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), filter 0.25s;
}
.social:hover { transform: translateY(-4px) scale(1.15); }
.social .ico {
  width: 30px; height: 30px;
  background-color: #fff;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  transition: background-color 0.25s;
}
.social:hover .ico { background-color: var(--accent); filter: drop-shadow(0 4px 10px var(--accent-soft)); }

/* views — left side, aligned with the socials row, no box */
.views {
  position: absolute; z-index: 20; left: 0; bottom: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 550; color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

/* rain effect canvas */
.rain-canvas {
  position: fixed; inset: 0; z-index: 3;
  pointer-events: none;
}

@media (max-width: 480px) {
  .socials { gap: 22px; }
  .profile { gap: 16px; }
}
