/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #070709;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Nixie One font */
.nixie-one-regular {
  font-family: "Nixie One", system-ui, sans-serif;
  font-weight: 600;
  font-style: normal;
}

/* Divergence Meter */
.divergence-meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0 2.25rem;
}

.divergence-meter-stage {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  -webkit-box-reflect: below 0rem
    linear-gradient(
      to bottom,
      rgba(5, 5, 6, 0) 0%,
      rgba(5, 5, 6, 0.008) 8%,
      rgba(5, 5, 6, 0.025) 22%,
      rgba(5, 5, 6, 0.06) 42%,
      rgba(5, 5, 6, 0.12) 62%,
      rgba(5, 5, 6, 0.2) 82%,
      rgba(5, 5, 6, 0.28) 100%
    );
}

/* Nixie Stack */
.nixie-stack {
  --nixie-tube-w: 2.75rem;
  --nixie-tube-h: 4.75rem;
  display: flex;
  align-items: flex-end;
  gap: 0;
}

.nixie-tube-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 3px;
}

.nixie-tube-rim {
  width: var(--nixie-tube-w);
  height: 4px;
  background: linear-gradient(
    90deg,
    rgba(45, 42, 38, 0.55),
    rgba(120, 110, 98, 0.35) 40%,
    rgba(160, 150, 135, 0.28) 50%,
    rgba(120, 110, 98, 0.35) 60%,
    rgba(45, 42, 38, 0.55)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.nixie-tube-rim--bottom {
  height: 5px;
  background: linear-gradient(
    90deg,
    rgba(35, 32, 28, 0.6),
    rgba(90, 84, 76, 0.32) 42%,
    rgba(130, 120, 108, 0.22) 50%,
    rgba(90, 84, 76, 0.32) 58%,
    rgba(35, 32, 28, 0.6)
  );
}

.nixie-tube-glass {
  position: relative;
  width: var(--nixie-tube-w);
  min-height: var(--nixie-tube-h);
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  isolation: isolate;
  transform: translateZ(0);
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.03) 38%, transparent 52%),
    linear-gradient(262deg, rgba(255, 255, 255, 0.07) 0%, transparent 40%),
    rgba(42, 40, 38, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Top, Bottom Glass, Central Chamber Gradient */
.nixie-tube-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 253, 250, 0.15) 0%,
    rgba(225, 218, 210, 0.1) 5%,
    rgba(175, 168, 160, 0.07) 9%,
    rgba(120, 113, 106, 0.055) 12%,
    rgba(78, 72, 66, 0.08) 15%,
    rgba(52, 45, 40, 0.18) 18%,
    rgba(36, 29, 24, 0.38) 21%,
    rgba(24, 17, 12, 0.62) 24%,
    rgba(17, 11, 7, 0.82) 27%,
    rgba(13, 8, 5, 0.93) 30%,
    rgba(11, 7, 5, 0.97) 34%,
    rgba(11, 7, 5, 0.98) 40%,
    rgba(11, 7, 5, 0.98) 60%,
    rgba(11, 7, 5, 0.97) 66%,
    rgba(13, 8, 5, 0.93) 70%,
    rgba(18, 12, 8, 0.82) 73%,
    rgba(28, 21, 16, 0.62) 76%,
    rgba(42, 35, 30, 0.4) 79%,
    rgba(62, 55, 49, 0.22) 82%,
    rgba(95, 88, 82, 0.12) 85%,
    rgba(140, 133, 126, 0.08) 88%,
    rgba(195, 188, 180, 0.09) 92%,
    rgba(235, 230, 222, 0.12) 96%,
    rgba(255, 252, 248, 0.14) 100%
  );
}

/* Texture */
.nixie-tube-glass::after {
  content: "";
  position: absolute;
  left: 6%; right: 6%; top: 6%; bottom: 6%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.42;
  -webkit-mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.18) 5%, rgba(0,0,0,0.5) 10%,
    rgba(0,0,0,0.85) 15%, #000 22%, #000 78%,
    rgba(0,0,0,0.85) 85%, rgba(0,0,0,0.5) 90%,
    rgba(0,0,0,0.18) 95%, transparent 100%
  );
  mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.18) 5%, rgba(0,0,0,0.5) 10%,
    rgba(0,0,0,0.85) 15%, #000 22%, #000 78%,
    rgba(0,0,0,0.85) 85%, rgba(0,0,0,0.5) 90%,
    rgba(0,0,0,0.18) 95%, transparent 100%
  );
  background-image:
    repeating-linear-gradient(58deg,  transparent 0 1px, rgba(120, 70, 40, 0.2)  1px 2px),
    repeating-linear-gradient(-52deg, transparent 0 1px, rgba(90,  55, 32, 0.16) 1px 2px),
    repeating-linear-gradient(0deg,   rgba(55, 38, 24, 0.14) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg,  rgba(45, 32, 20, 0.1)  0 1px, transparent 1px 5px),
    radial-gradient(
      ellipse 100% 85% at 50% 48%,
      rgba(255, 110, 50, 0.14) 0%,
      rgba(60,  35,  18, 0.45) 45%,
      rgba(20,  12,   8, 0.75) 100%
    );
  mix-blend-mode: soft-light;
}

.nixie-tube-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.06) 10%, transparent 18%,
      transparent 82%, rgba(0,0,0,0.06) 90%, rgba(0,0,0,0.2) 100%),
    linear-gradient(180deg,
      rgba(0,0,0,0.07) 0%, rgba(0,0,0,0.02) 14%, transparent 26%,
      transparent 74%, rgba(0,0,0,0.02) 86%, rgba(0,0,0,0.07) 100%);
  pointer-events: none;
  z-index: 3;
}

.nixie-tube-mesh {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg, transparent 0, transparent 2px, rgba(255,130,90,0.045) 2px, rgba(255,130,90,0.045) 3px),
    repeating-linear-gradient(0deg,  transparent 0, transparent 2px, rgba(255,150,100,0.04)  2px, rgba(255,150,100,0.04)  3px);
  mix-blend-mode: soft-light;
  opacity: 0.52;
  pointer-events: none;
  z-index: 4;
  -webkit-mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.1) 5%, rgba(0,0,0,0.32) 11%,
    rgba(0,0,0,0.62) 16%, rgba(0,0,0,0.9) 21%, #000 26%,
    #000 74%, rgba(0,0,0,0.9) 79%, rgba(0,0,0,0.62) 84%,
    rgba(0,0,0,0.32) 89%, rgba(0,0,0,0.1) 95%, transparent 100%
  );
  mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.1) 5%, rgba(0,0,0,0.32) 11%,
    rgba(0,0,0,0.62) 16%, rgba(0,0,0,0.9) 21%, #000 26%,
    #000 74%, rgba(0,0,0,0.9) 79%, rgba(0,0,0,0.62) 84%,
    rgba(0,0,0,0.32) 89%, rgba(0,0,0,0.1) 95%, transparent 100%
  );
}

.nixie-tube-inner-glow {
  position: absolute;
  inset: 5% 9%;
  background: radial-gradient(
    ellipse 98% 92% at 50% 50%,
    rgba(255, 130, 70, 0.18) 0%,
    rgba(100,  48, 22, 0.35) 48%,
    rgba( 25,  14,  8, 0.55) 72%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
  -webkit-mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.35) 10%, rgba(0,0,0,0.75) 18%,
    #000 24%, #000 76%, rgba(0,0,0,0.75) 82%,
    rgba(0,0,0,0.35) 90%, transparent 100%
  );
  mask-image: linear-gradient(
    180deg,
    transparent 0%, rgba(0,0,0,0.35) 10%, rgba(0,0,0,0.75) 18%,
    #000 24%, #000 76%, rgba(0,0,0,0.75) 82%,
    rgba(0,0,0,0.35) 90%, transparent 100%
  );
}

.nixie-stack-chars {
  position: relative;
  z-index: 5;
  width: 100%;
  min-height: var(--nixie-tube-h);
  padding: 0.2rem 0;
  overflow: hidden;
}

.nixie-face-clip {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.nixie-face-clip--chaos { isolation: isolate; }

/* Scramble afterimage */
.nixie-face-trail {
  grid-area: 1 / 1;
  font-size: clamp(2.2rem, 9.4vw, 3.15rem);
  line-height: 1;
  text-align: center;
  color: #f0d48a;
  pointer-events: none;
  user-select: none;
}

.nixie-face-trail--near {
  z-index: 2;
  opacity: 0.32;
  filter: blur(0.9px);
  text-shadow:
    0 0 6px  rgba(255, 100, 50, 0.55),
    0 0 14px rgba(255,  50, 25, 0.35);
}

.nixie-face-trail--mid {
  z-index: 1;
  opacity: 0.16;
  filter: blur(2px);
  text-shadow:
    0 0 10px rgba(255, 60, 30, 0.4),
    0 0 22px rgba(200, 30, 15, 0.22);
}

.nixie-face-trail--deep {
  z-index: 0;
  opacity: 0.075;
  filter: blur(3.5px);
  text-shadow:
    0 0 14px rgba(255, 40, 20, 0.35),
    0 0 28px rgba(180, 20, 10, 0.15);
}

.nixie-face--chaos-top { position: relative; z-index: 3; }

.nixie-silhouettes {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 0;
}

.nixie-silhouette {
  grid-area: 1 / 1;
  font-size: clamp(2.25rem, 9.6vw, 3.25rem);
  line-height: 1;
  color: #ffaa77;
  opacity: 0.055;
  user-select: none;
}

.nixie-bloom {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  font-size: clamp(2.35rem, 10vw, 3.35rem);
  line-height: 1;
  color: #ff4a10;
  filter: blur(4px);
  opacity: 0.35;
  transform: translate(-50%, -50%) scale(1.14);
  user-select: none;
  pointer-events: none;
}

.nixie-face {
  grid-area: 1 / 1;
  font-size: clamp(2.2rem, 9.4vw, 3.15rem);
  line-height: 1;
  color: #f0d48a;
  text-align: center;
  text-shadow:
    0 0 1px  rgba( 40,  28, 12, 0.55),
    0 0 3px  rgba(255, 245, 210, 0.75),
    0 0 7px  rgba(255, 200, 110, 0.65),
    0 0 13px rgba(240, 150,  55, 0.45),
    0 0 22px rgba(210,  95,  30, 0.25),
    0 0 34px rgba(170,  55,  20, 0.12);
  user-select: none;
  pointer-events: none;
  will-change: opacity, filter;
}

.nixie-face--dot {
  font-size: clamp(1.95rem, 8.2vw, 2.8rem);
  transform: translateY(0.06em);
}

.nixie-tube-shell:has(.nixie-face--dot) .nixie-bloom {
  font-size: clamp(2.1rem, 9vw, 3rem);
  transform: translate(-50%, calc(-50% + 0.06em)) scale(1.14);
}

/* Digit Transition Animations */
@keyframes nixie-digit-enter {
  from { opacity: 0.25; filter: blur(2px); }
  to   { opacity: 1;    filter: blur(0px); }
}

@keyframes nixie-digit-exit {
  from {
    opacity: 1; filter: blur(0px); color: #f0d48a;
    text-shadow:
      0 0 1px rgba(40,28,12,0.55), 0 0 3px rgba(255,245,210,1),
      0 0 8px rgba(255,200,110,0.98), 0 0 16px rgba(240,150,55,0.85);
  }
  to {
    opacity: 0; filter: blur(3px); color: #ff2200;
    text-shadow:
      0 0 14px rgba(255, 50,  0, 1),
      0 0 28px rgba(255,  0,  0, 0.55),
      0 0 40px rgba(200,  0,  0, 0.3);
  }
}

.nixie-face--entering {
  animation: nixie-digit-enter 0.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.nixie-face--exiting {
  position: absolute !important;
  animation: nixie-digit-exit 0.12s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}
