:root {
  color-scheme: dark;
  --accent: #f6f7fb;
  --accent-rgb: 246, 247, 251;
  --ink: #f7f8ff;
  --muted: rgba(247, 248, 255, .55);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }

body {
  background: #090b13;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
}

.spinner {
  position: relative;
  display: grid;
  width: 100vw;
  height: 100svh;
  min-height: 420px;
  place-items: center;
  isolation: isolate;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(var(--accent-rgb), .12), transparent 32%),
    linear-gradient(145deg, #111525 0%, #070911 58%, #111323 100%);
  transition: background .45s ease;
}

.spinner::before {
  content: "";
  position: absolute;
  inset: -45%;
  z-index: -3;
  background: conic-gradient(from 20deg, transparent, rgba(var(--accent-rgb), .2), transparent 24%, transparent 70%, rgba(var(--accent-rgb), .13), transparent);
  animation: drift 16s linear infinite;
}

.spinner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: .12;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.ambient {
  position: absolute;
  z-index: -2;
  width: min(68vw, 780px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .14;
  background: var(--accent);
  transition: background .45s ease, transform 1s cubic-bezier(.2,.8,.2,1);
}
.ambient-one { top: -38%; left: -18%; }
.ambient-two { right: -26%; bottom: -44%; }

.dots { position: absolute; inset: 0; z-index: -1; }
.dot {
  position: absolute;
  width: clamp(120px, 22vw, 300px);
  aspect-ratio: 1;
  border: clamp(10px, 1.5vw, 20px) solid rgba(255,255,255,.07);
  border-radius: 50%;
  box-shadow: inset 0 0 60px rgba(255,255,255,.035);
}
.dot-red { background: rgba(255,45,70,.055); left: -8%; top: 12%; }
.dot-blue { background: rgba(45,138,255,.055); right: 4%; top: -10%; transform: scale(.72); }
.dot-yellow { background: rgba(255,211,42,.055); right: -7%; bottom: 3%; }
.dot-green { background: rgba(48,209,88,.055); left: 8%; bottom: -18%; transform: scale(.8); }

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 3.5vh, 34px);
  width: min(92vw, 1050px);
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: clamp(.7rem, 1.4vw, .95rem);
  font-weight: 800;
  letter-spacing: .38em;
  text-indent: .38em;
}

.limb-wrap { display: flex; flex-direction: column; line-height: .83; }
.side, .limb {
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: -.06em;
  text-shadow: 0 0 55px rgba(var(--accent-rgb), .14);
}
.side { color: var(--accent); font-size: clamp(4.2rem, 15vw, 11rem); }
.limb { color: var(--ink); font-size: clamp(3.3rem, 12vw, 8.5rem); }

.color-row { display: flex; align-items: center; justify-content: center; gap: clamp(13px, 2vw, 24px); }
.color-orb {
  width: clamp(28px, 5vw, 54px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(var(--accent-rgb), .1), 0 0 48px rgba(var(--accent-rgb), .65);
}
.color-name {
  color: var(--accent);
  font-size: clamp(1.7rem, 5vw, 3.6rem);
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.hint {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(255,255,255,.38);
  font-size: clamp(.75rem, 2vw, .95rem);
  font-weight: 650;
  letter-spacing: .08em;
  transition: opacity .35s ease;
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at var(--tap-x, 50%) var(--tap-y, 50%), rgba(var(--accent-rgb), .34), transparent 42%);
}

.spinner.spinning .result { animation: result-pop .56s cubic-bezier(.2,.9,.2,1); }
.spinner.spinning .flash { animation: flash .52s ease-out; }
.spinner.spinning .ambient-one { transform: translate(20%, 15%) scale(1.15); }
.spinner.spinning .ambient-two { transform: translate(-18%, -12%) scale(.88); }
.spinner.has-spun .hint { opacity: 0; }

@keyframes result-pop {
  0% { opacity: .15; transform: scale(.78) rotate(-1.5deg); filter: blur(8px); }
  60% { opacity: 1; transform: scale(1.035) rotate(.3deg); filter: blur(0); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes flash { 0% { opacity: 0; } 24% { opacity: 1; } 100% { opacity: 0; } }
@keyframes drift { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .result { gap: 22px; }
  .side { font-size: clamp(4rem, 22vw, 7rem); }
  .limb { font-size: clamp(3rem, 17vw, 5.5rem); }
  .dot { opacity: .7; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
