:root {
  --void: #05010c;
  --void-deep: #000000;
  --panel: #0d0518;
  --hot-pink: #ff2fd6;
  --cyan: #00fff2;
  --acid: #39ff14;
  --purple: #b026ff;
  --yellow: #faff00;
  --chrome: #eef0ff;
  --grid-line: rgba(0, 255, 242, 0.28);
  --font-title: 'Baloo 2', cursive;
  --font-mono: 'VT323', monospace;
  --font-body: 'Space Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--chrome);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 47, 214, 0.16), transparent 45%),
    radial-gradient(circle at 82% 20%, rgba(0, 255, 242, 0.14), transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(176, 38, 255, 0.14), transparent 55%),
    linear-gradient(180deg, var(--void), var(--void-deep));
  overflow-x: hidden;
  position: relative;
}

/* Tron/Hackers-style perspective grid floor */
.grid-floor {
  position: fixed;
  left: -20%;
  right: -20%;
  bottom: 0;
  height: 46vh;
  pointer-events: none;
  z-index: 0;
  background-image:
    repeating-linear-gradient(0deg, var(--grid-line) 0px 1px, transparent 1px 42px),
    repeating-linear-gradient(90deg, var(--grid-line) 0px 1px, transparent 1px 42px);
  transform: perspective(320px) rotateX(68deg);
  transform-origin: bottom;
  -webkit-mask-image: linear-gradient(to top, black, transparent 88%);
  mask-image: linear-gradient(to top, black, transparent 88%);
  opacity: 0.55;
  animation: gridFlow 5s linear infinite;
}

@keyframes gridFlow {
  from { background-position: 0px 0px, 0px 0px; }
  to { background-position: 0px 42px, 0px 0px; }
}

/* CRT scanlines + vignette */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0px, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.6) 100%);
  mix-blend-mode: overlay;
}

header {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  position: relative;
  z-index: 2;
}

.plate-number {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(0, 255, 242, 0.7);
  margin: 0 0 0.6rem;
}

.glitch-title {
  font-family: var(--font-title);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.5rem, 5vw, 2.9rem);
  letter-spacing: 0.02em;
  margin: 0;
  position: relative;
  display: inline-block;
  color: var(--chrome);
  -webkit-text-stroke: 2px #0a0014;
  background: linear-gradient(120deg, var(--hot-pink), var(--yellow), var(--acid), var(--cyan), var(--purple), var(--hot-pink));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: holoShift 7s ease infinite;
  filter: drop-shadow(0 0 10px rgba(255, 47, 214, 0.45)) drop-shadow(0 0 18px rgba(0, 255, 242, 0.3));
}

@keyframes holoShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.glitch-title::before,
.glitch-title::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  background: transparent;
  -webkit-text-stroke: 0;
  mix-blend-mode: screen;
}

.glitch-title::before {
  color: var(--cyan);
  animation: glitchTop 4.5s infinite linear alternate-reverse;
  clip-path: inset(0 0 60% 0);
}

.glitch-title::after {
  color: var(--hot-pink);
  animation: glitchBottom 3.7s infinite linear alternate-reverse;
  clip-path: inset(60% 0 0 0);
}

@keyframes glitchTop {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-2px, -1px); }
  40% { transform: translate(2px, 1px); }
  60% { transform: translate(-1px, 1px); }
  80% { transform: translate(1px, -1px); }
  100% { transform: translate(0, 0); }
}

@keyframes glitchBottom {
  0% { transform: translate(0, 0); }
  25% { transform: translate(2px, 1px); }
  50% { transform: translate(-2px, -1px); }
  75% { transform: translate(1px, -1px); }
  100% { transform: translate(0, 0); }
}

.tagline {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--acid);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.6);
  margin-top: 0.6rem;
}

.tagline::after {
  content: "_";
  animation: blinkCursor 1s step-end infinite;
}

@keyframes blinkCursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

main.lab {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.tube-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2.2rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
  padding: 2rem 1.5rem 2.4rem;
  position: relative;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.65));
  border: 1px solid var(--grid-line);
  box-shadow: inset 0 0 30px rgba(0, 255, 242, 0.08), 0 0 24px rgba(255, 47, 214, 0.1);
}

/* a rack strip with tube-holder holes along the bottom */
.tube-row::after {
  content: "";
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 0.5rem;
  height: 10px;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.9) 0 3px, transparent 4px);
  background-size: 26px 100%;
  background-repeat: repeat-x;
  background-position: center;
  opacity: 0.85;
  pointer-events: none;
}

.tube-slot {
  --tube-w: 190px;
  --tube-h: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

.tube-label {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hot-pink);
  text-shadow: 0 0 6px rgba(255, 47, 214, 0.6);
}

/* two-layer teapot: the photo is clipped to a plain ellipse sitting in
   the belly (so no spout/handle slivers of the image), and a separate
   stroked SVG (.tube-outline, fill: none) draws the full teapot
   illustration — body/lid/knob/spout/handle — on top, unconstrained
   by whatever the photo needs to look like. */
.tube {
  width: var(--tube-w);
  height: var(--tube-h);
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 0 16px rgba(0, 255, 242, 0.3));
  transition: transform 0.25s ease, filter 0.25s ease;
}

/* liquid line inside the pot, matching the image ellipse's width */
.tube::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 62%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.5;
  z-index: 2;
  pointer-events: none;
}

.tube:hover {
  transform: translateY(-4px) rotate(-1deg);
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 22px rgba(255, 47, 214, 0.35));
}

/* the lid + knob are drawn by .tube-outline now, so the old neck-rim
   bar has no role here */
.tube-rim {
  display: none;
}

/* the teapot illustration: a stroke-only trace of the same
   body/lid/knob/spout/handle path, drawn over the photo */
.tube-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.tube-outline path {
  fill: none;
  stroke: rgba(0, 255, 242, 0.75);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* the photo itself: clipped to a plain ellipse sized to sit inside the
   outline's belly curve, so it stays intact with no cropped slivers */
.tube-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: ellipse(43% 21% at 50% 60%);
  z-index: 1;
  filter: saturate(1.25) contrast(1.05);
}

.tube-bubbles {
  position: absolute;
  inset: 0;
  clip-path: ellipse(43% 21% at 50% 60%);
  z-index: 2;
  pointer-events: none;
}

.tube-bubbles span {
  position: absolute;
  bottom: -20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  animation: bubbleUp 5s infinite ease-in;
}

.tube-bubbles span:nth-child(1) { left: 20%; width: 5px; height: 5px; color: var(--hot-pink); background: var(--hot-pink); animation-delay: 0s; animation-duration: 4.5s; }
.tube-bubbles span:nth-child(2) { left: 45%; width: 8px; height: 8px; color: var(--cyan); background: var(--cyan); animation-delay: 1.1s; animation-duration: 5.5s; }
.tube-bubbles span:nth-child(3) { left: 65%; width: 4px; height: 4px; color: var(--acid); background: var(--acid); animation-delay: 2.3s; animation-duration: 4s; }
.tube-bubbles span:nth-child(4) { left: 30%; width: 6px; height: 6px; color: var(--purple); background: var(--purple); animation-delay: 0.6s; animation-duration: 6s; }
.tube-bubbles span:nth-child(5) { left: 78%; width: 7px; height: 7px; color: var(--yellow); background: var(--yellow); animation-delay: 1.8s; animation-duration: 5s; }
.tube-bubbles span:nth-child(6) { left: 55%; width: 5px; height: 5px; color: var(--hot-pink); background: var(--hot-pink); animation-delay: 2.8s; animation-duration: 4.8s; }

@keyframes bubbleUp {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 0.9; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-240px) scale(0.6); opacity: 0; }
}

.tube-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: rgba(0, 255, 242, 0.7);
  z-index: 4;
  padding: 0.8rem;
  line-height: 1.4;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tube.has-image .tube-placeholder,
.result-tube.has-image .tube-placeholder {
  display: none;
}

.mix-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  min-width: 200px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  align-items: center;
}

.control label {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acid);
  text-shadow: 0 0 5px rgba(57, 255, 20, 0.5);
}

select#blendMode {
  font-family: var(--font-body);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
  color: var(--chrome);
  border: 1.5px solid var(--cyan);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  outline: none;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 255, 242, 0.2);
}

input#accel {
  width: 170px;
  accent-color: var(--hot-pink);
}

button {
  font-family: var(--font-title);
  font-weight: 800;
  text-transform: uppercase;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0.75rem 1.4rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

button:active { transform: scale(0.95); }

.mix-btn {
  background: linear-gradient(135deg, var(--hot-pink), var(--purple), var(--cyan));
  color: #05010c;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(255, 47, 214, 0.55);
}

.mix-btn:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 26px rgba(255, 47, 214, 0.7); }

.accelerate-btn {
  background: linear-gradient(135deg, var(--acid), var(--yellow));
  color: #05010c;
  font-size: 0.85rem;
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
}

.accelerate-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 22px rgba(57, 255, 20, 0.6); }

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.result-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.result-tube {
  --tube-w: 260px;
  --tube-h: 340px;
  filter: drop-shadow(0 0 30px rgba(0, 255, 242, 0.4));
}

.result-tube .tube-outline path {
  stroke: var(--cyan);
  stroke-width: 2.5;
}

.result-tube:hover { transform: none; }

.sparkle-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}

.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  animation: sparklePop 0.9s ease-out forwards;
  pointer-events: none;
}

@keyframes sparklePop {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  60% { transform: scale(1.3) rotate(120deg); opacity: 1; }
  100% { transform: scale(0.3) rotate(200deg) translateY(-20px); opacity: 0; }
}

.result-actions {
  display: flex;
  gap: 0.8rem;
}

.result-actions button {
  background: rgba(0, 0, 0, 0.5);
  color: var(--chrome);
  border: 1.5px solid var(--cyan);
  font-size: 0.8rem;
}

.result-actions button:hover:not(:disabled) {
  background: rgba(0, 255, 242, 0.15);
  transform: translateY(-2px);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(5, 1, 12, 0.95);
  border: 1.5px solid var(--hot-pink);
  color: var(--chrome);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
  box-shadow: 0 0 20px rgba(255, 47, 214, 0.4);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: rgba(0, 255, 242, 0.55);
  position: relative;
  z-index: 2;
}

@media (max-width: 640px) {
  .tube-row { gap: 1.4rem; }
  .tube-slot { --tube-w: 140px; --tube-h: 190px; }
  .result-tube { --tube-w: 190px; --tube-h: 250px; }
}

@media (prefers-reduced-motion: reduce) {
  .grid-floor, .glitch-title, .glitch-title::before, .glitch-title::after, .tagline::after, .tube-bubbles span {
    animation: none;
  }
}
