* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #05060a;
}

body {
  min-height: 100svh;
}

.stage {
  --mx: 0deg;
  --my: 0deg;

  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;

  background:
    radial-gradient(circle at 50% 43%, rgba(24, 28, 48, 0.92) 0%, rgba(9, 10, 17, 0.98) 44%, #040509 78%),
    #040509;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -5;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(circle at center, #000 0 30%, transparent 72%);
  mask-image: radial-gradient(circle at center, #000 0 30%, transparent 72%);
}

.noise {
  position: absolute;
  inset: -50%;
  z-index: 20;
  pointer-events: none;
  opacity: 0.025;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  animation: noiseShift 0.45s steps(2) infinite;
}

.aurora {
  position: absolute;
  z-index: -4;
  width: min(62vw, 850px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.17;
  pointer-events: none;
}

.aurora-a {
  left: -21%;
  top: -34%;
  background: #7367ff;
  animation: auroraA 13s ease-in-out infinite alternate;
}

.aurora-b {
  right: -22%;
  bottom: -38%;
  background: #00d8ff;
  animation: auroraB 15s ease-in-out infinite alternate;
}

.clock-scene {
  position: relative;
  width: min(68vw, 510px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  perspective: 900px;
  transform:
    rotateX(var(--my))
    rotateY(var(--mx))
    translateZ(0);
  transition: transform 180ms ease-out;
  animation: levitate 6s ease-in-out infinite;
  will-change: transform;
}

.halo {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.halo-outer {
  inset: -11%;
  background:
    conic-gradient(
      from 30deg,
      transparent 0 8%,
      rgba(103, 93, 255, 0.58) 14%,
      transparent 25% 42%,
      rgba(0, 220, 255, 0.47) 50%,
      transparent 61% 78%,
      rgba(186, 92, 255, 0.38) 86%,
      transparent 96%
    );
  filter: blur(42px);
  opacity: 0.68;
  animation: spin 12s linear infinite;
}

.halo-inner {
  inset: -3%;
  border: 1px solid rgba(124, 143, 255, 0.08);
  box-shadow:
    0 0 70px rgba(83, 104, 255, 0.11),
    inset 0 0 70px rgba(0, 222, 255, 0.035);
  animation: pulseHalo 4s ease-in-out infinite;
}

.clock {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.115);

  background:
    radial-gradient(circle at 37% 29%, rgba(255, 255, 255, 0.09), transparent 26%),
    radial-gradient(circle at 58% 61%, rgba(62, 82, 136, 0.08), transparent 35%),
    linear-gradient(145deg, rgba(25, 28, 42, 0.98), rgba(7, 8, 13, 0.99));

  box-shadow:
    0 48px 95px rgba(0, 0, 0, 0.66),
    0 0 80px rgba(83, 99, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -45px 80px rgba(0, 0, 0, 0.28);
}

.clock::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 15;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(
      123deg,
      rgba(255, 255, 255, 0.085) 0%,
      rgba(255, 255, 255, 0.02) 17%,
      transparent 34% 69%,
      rgba(255, 255, 255, 0.02) 100%
    );
}

.rim {
  position: absolute;
  inset: 3.3%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.045);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.34),
    inset 0 0 28px rgba(255, 255, 255, 0.012);
}

.inner-ring {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.027);
}

.sweep-ring {
  position: absolute;
  inset: 8.5%;
  border-radius: 50%;
  border-top: 1px solid rgba(75, 207, 255, 0.12);
  border-right: 1px solid transparent;
  border-bottom: 1px solid rgba(122, 93, 255, 0.07);
  border-left: 1px solid transparent;
  animation: spin 20s linear infinite;
}

.ticks {
  position: absolute;
  inset: 0;
}

.tick-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  top: 6.3%;
  left: 50%;
  width: 1px;
  height: 1.45%;
  min-height: 4px;
  border-radius: 20px;
  transform: translateX(-50%);
  background: rgba(235, 241, 255, 0.25);
}

.tick.major {
  top: 5.1%;
  width: 2px;
  height: 3%;
  min-height: 8px;
  background: rgba(245, 248, 255, 0.82);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  z-index: 7;
  transform-origin: 50% 100%;
  border-radius: 999px;
  will-change: transform;
}

.hour {
  width: clamp(5px, 1.25%, 7px);
  height: 23%;
  transform: translateX(-50%);
  background:
    linear-gradient(
      90deg,
      rgba(214, 220, 244, 0.72),
      #ffffff 52%,
      rgba(190, 199, 232, 0.76)
    );
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.09),
    0 7px 18px rgba(0, 0, 0, 0.35);
}

.minute {
  width: clamp(3px, 0.78%, 4px);
  height: 34%;
  transform: translateX(-50%);
  background:
    linear-gradient(
      90deg,
      rgba(194, 204, 239, 0.62),
      #ffffff 55%,
      rgba(182, 193, 232, 0.73)
    );
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.32);
}

.second-system {
  position: absolute;
  inset: 0;
  z-index: 9;
  transform-origin: 50% 50%;
  will-change: transform;
}

.second {
  bottom: 50%;
  width: 2px;
  height: 39.5%;
  transform: translateX(-50%);
  background: linear-gradient(to top, #7468ff, #30e6ff);
  box-shadow:
    0 0 7px rgba(91, 123, 255, 0.95),
    0 0 18px rgba(48, 230, 255, 0.55);
}

.second-tail {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 12.5%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(to bottom, #7468ff, rgba(116, 104, 255, 0));
  box-shadow: 0 0 12px rgba(116, 104, 255, 0.3);
}

.pin {
  position: absolute;
  z-index: 13;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 5.2%;
  aspect-ratio: 1;
  min-width: 21px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.19);
  background: rgba(7, 9, 15, 0.94);
  box-shadow:
    0 0 26px rgba(77, 145, 255, 0.53),
    inset 0 0 12px rgba(255, 255, 255, 0.075);
}

.pin span {
  width: 31%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e8fdff;
  box-shadow:
    0 0 8px #ffffff,
    0 0 18px rgba(65, 224, 255, 0.92);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes levitate {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

@keyframes pulseHalo {
  0%, 100% { opacity: 0.52; scale: 0.99; }
  50% { opacity: 0.9; scale: 1.015; }
}

@keyframes auroraA {
  to { transform: translate(16vw, 11vh) scale(1.18); }
}

@keyframes auroraB {
  to { transform: translate(-13vw, -14vh) scale(1.15); }
}

@keyframes noiseShift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2%, -1%, 0); }
  50% { transform: translate3d(-1%, 2%, 0); }
  75% { transform: translate3d(1%, 1%, 0); }
  100% { transform: translate3d(-2%, -1%, 0); }
}

@media (max-width: 700px) {
  .clock-scene {
    width: min(84vw, 480px);
  }

  .aurora {
    width: 88vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .clock-scene,
  .halo,
  .sweep-ring,
  .aurora,
  .noise {
    animation: none;
  }

  .clock-scene {
    transition: none;
  }
}
