html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  overflow: hidden !important;
  overflow-x: hidden !important;
  touch-action: manipulation !important;
  -ms-touch-action: manipulation !important;
  overscroll-behavior: none !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  -webkit-text-size-adjust: 100%;
}

#root {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  overflow: hidden !important;
  overflow-x: hidden !important;
}

:root {
  --accent: #7c5bf5;
  --bg: #08080f;
}

@media (hover: hover) and (pointer: fine) {
  html.custom-cursor * { cursor: none !important; }
  
  .cursor, .cursor-follower, .cursor-dot {
    display: none;
  }

  html.custom-cursor .cursor {
    display: block;
    position: fixed;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 99999;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.5s ease;
    mix-blend-mode: difference;
  }
  html.custom-cursor .cursor-follower {
    display: block;
    position: fixed;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 25%, transparent) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 99998;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }
  html.custom-cursor .cursor-dot {
    display: block;
    position: fixed;
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 99999;
    box-shadow: 0 0 8px var(--accent), 0 0 20px color-mix(in srgb, var(--accent) 50%, transparent);
    transition: background 0.5s ease, box-shadow 0.5s ease;
  }
}

@media (hover: none) and (pointer: coarse) {
  .cursor, .cursor-follower, .cursor-dot { display: none !important; }
}

.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg, #08080f);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  overflow: hidden;
  opacity: 1;
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
  perspective: 1000px;
}

.preloader::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse 60% 40% at 30% 30%, color-mix(in srgb, var(--accent) 15%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 70% 70%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
  pointer-events: none;
  animation: preloaderAmbient 8s ease-in-out infinite alternate;
}

@keyframes preloaderAmbient {
  0% { opacity: 0.5; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.05); }
}

.preloader-content {
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
  position: relative;
  z-index: 2;
}

.preloader.hidden {
  opacity: 0;
  pointer-events: none;
}

#matrix-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  animation: fadeIn 0.8s ease 0.3s forwards;
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.loader-text {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, #ec4899) 50%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glow-pulse 3s ease-in-out infinite, fadeIn 0.8s ease 0.5s forwards;
  filter: drop-shadow(0 0 25px var(--accent));
  opacity: 0;
  transform: translateZ(50px);
  font-family: 'Inter', -apple-system, sans-serif;
}

@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 25px var(--accent)); }
  50% { filter: drop-shadow(0 0 45px var(--accent)); }
}

.loader-bar {
  width: 70vw;
  max-width: 260px;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin: 28px auto 0;
  opacity: 0;
  animation: fadeIn 0.8s ease 0.7s forwards;
  transform: translateZ(30px);
}

.loader-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #ec4899), #3b82f6);
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
}

.welcome-text {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 22px;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(16px) translateZ(40px);
  transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Inter', -apple-system, sans-serif;
}

.welcome-text.visible {
  opacity: 1;
  transform: translateY(0) translateZ(40px);
}

.gyro-permission {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateZ(60px);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px 28px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, sans-serif;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.gyro-permission.show {
  opacity: 1;
  pointer-events: all;
}

.gyro-permission:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(-50%) translateZ(60px) translateY(-2px);
}

.gyro-permission:active {
  transform: translateX(-50%) translateZ(60px) scale(0.96);
}

.particle {
  position: fixed;
  width: 3px;
  height: 3px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 8px var(--accent);
  z-index: 99997;
}