:root {
  --bg-1: radial-gradient(
      1200px 600px at 10% 10%,
      rgba(255, 140, 248, 0.1),
      transparent 60%
    ),
    radial-gradient(
      1000px 800px at 90% 20%,
      rgba(102, 217, 255, 0.1),
      transparent 60%
    ),
    radial-gradient(
      900px 700px at 50% 90%,
      rgba(173, 255, 186, 0.1),
      transparent 60%
    );
  --glass: rgba(255, 255, 255, 0.1);
  --glow: rgba(255, 255, 255, 0.35);
  --ink: #e9f1ff;
  --ink-dim: #a8b3c7;
  --accent-a: #a76bff;
  --accent-b: #5be3ff;
  --accent-c: #7bffcc;
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  background: #0b0f16;
  background-image: var(--bg-1);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    "Helvetica Neue", Arial;
  letter-spacing: 0.2px;
}

.wrap {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.hero {
  text-align: center;
  margin-bottom: 20px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
}
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.1;
  background: linear-gradient(
    90deg,
    var(--accent-a),
    var(--accent-b),
    var(--accent-c)
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero h1 span {
  font-weight: 600;
  opacity: 0.8;
}
.tag {
  margin-top: 8px;
  color: var(--ink-dim);
}

.panel {
  width: min(980px, 96vw);
  backdrop-filter: blur(16px) saturate(120%);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.04)
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.mode {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.02)
  );
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.mode::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    600px 80px at var(--x, 50%) 0%,
    rgba(255, 255, 255, 0.22),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
}
.mode:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
}
.mode:hover::after {
  opacity: 1;
}
.mode.active {
  box-shadow: 0 0 24px rgba(167, 107, 255, 0.35),
    inset 0 0 22px rgba(91, 227, 255, 0.15);
  border-color: rgba(167, 107, 255, 0.55);
}

.result-card {
  height: 220px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(
    140% 200% at 50% 0%,
    rgba(167, 107, 255, 0.15),
    rgba(91, 227, 255, 0.08) 40%,
    rgba(255, 255, 255, 0.02) 70%
  );
  box-shadow: inset 0 0 100px rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.result {
  display: flex;
  gap: 10px;
  font-variant-numeric: tabular-nums lining-nums;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}
.placeholder {
  color: var(--ink-dim);
  font-size: clamp(14px, 2vw, 16px);
}

.digit {
  font-size: clamp(36px, 10vw, 80px);
  min-width: 0.6em;
  text-align: center;
  padding: 6px 10px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.35),
    rgba(167, 107, 255, 0.18)
  );
  border: 1px solid rgba(255, 255, 255, 0.45);
  -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.25);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-smooth: always;
  text-shadow: 0 0 10px rgba(167, 107, 255, 0.8),
    0 0 20px rgba(91, 227, 255, 0.6), 0 1px 0 rgba(0, 0, 0, 0.25);
  transform: translateZ(0);
  will-change: transform, filter, opacity;
  animation: float 2.8s ease-in-out infinite both;
  animation-delay: calc(-0.08s * var(--i, 0));
  position: relative;
  overflow: hidden;
  contain: paint;
}

.digit::before {
  content: "";
  position: absolute;
  inset: -20% -30%;
  background: radial-gradient(
    120% 60% at 50% 0%,
    rgba(255, 255, 255, 0.25),
    transparent 60%
  );
  transform: translateY(20%);
  animation: float 2.8s ease-in-out infinite both;
  animation-delay: calc(-0.08s * var(--i, 0));
  pointer-events: none;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .digit,
  .ball {
    animation: none;
    filter: brightness(1.2) contrast(1.1);
  }
}

@media (prefers-contrast: more) {
  .digit {
    -webkit-text-stroke: 0.75px rgba(255, 255, 255, 0.35);
    text-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
}

.ball {
  font-size: clamp(20px, 6vw, 40px);
  min-width: 2em;
  height: 2em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: radial-gradient(
      circle at 35% 25%,
      rgba(255, 255, 255, 0.65),
      rgba(255, 255, 255, 0.1) 40%
    ),
    linear-gradient(200deg, rgba(167, 107, 255, 0.35), rgba(91, 227, 255, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 26px rgba(91, 227, 255, 0.25),
    inset 0 0 26px rgba(255, 255, 255, 0.18);
  animation: pop 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(0.05s * var(--i, 0));
}
@keyframes pop {
  0% {
    transform: scale(0.6);
    filter: blur(4px);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    filter: blur(0);
    opacity: 1;
  }
}

.controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  justify-content: center;
}
.cta,
.ghost {
  padding: 12px 18px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease,
    background 0.2s ease, color 0.2s ease;
}
.cta {
  color: #0b0f16;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 12px 30px rgba(167, 107, 255, 0.35);
}
.cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.cta:hover {
  transform: translateY(-1px);
}
.ghost {
  color: var(--ink);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.01)
  );
}
.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ghost:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.hint {
  text-align: center;
  color: var(--ink-dim);
  margin: 10px 0 0 0;
}

.foot {
  text-align: center;
  margin-top: 20px;
  color: var(--ink-dim);
  font-size: 12px;
}

/* Canvas overlay pointer events off */
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.wrap {
  position: relative;
  z-index: 1;
}
