/* ============================================================
   Virtual Soda Machine — Styles
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #f5a623;
  --accent-glow: rgba(245, 166, 35, 0.4);
  --shadow-color: 0deg 0% 0%;
  --shadow-elevation-low:
    0px 1px 0.8px hsl(var(--shadow-color) / 0.35),
    0px 4.3px 3.4px -4.8px hsl(var(--shadow-color) / 0.18);
  --shadow-elevation-medium:
    0px 1px 0.8px hsl(var(--shadow-color) / 0.33),
    0px 3.7px 2.9px -2.4px hsl(var(--shadow-color) / 0.22),
    0.2px 21.7px 16.9px -4.8px hsl(var(--shadow-color) / 0.12);
  --shadow-elevation-high:
    0px 1px 0.8px hsl(var(--shadow-color) / 0.36),
    0px 3.5px 2.7px -1.2px hsl(var(--shadow-color) / 0.29),
    0.1px 16.4px 12.8px -2.4px hsl(var(--shadow-color) / 0.22),
    0.5px 50.6px 39.5px -3.6px hsl(var(--shadow-color) / 0.15),
    1.1px 117px 91.3px -4.8px hsl(var(--shadow-color) / 0.08);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  color: #fff;
}

html, body { width: 100%; height: 100%; }

/* ---------- Preloader ---------- */
#preloader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #000;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#preloader.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}

.preloader-glass {
  position: relative;
  width: 80px; height: 140px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top: none;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}

.preloader-liquid {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0%;
  background: var(--accent);
  transition: height 0.3s ease-out;
  border-radius: 0 0 13px 13px;
}

.preloader-liquid::after {
  content: '';
  position: absolute; top: -4px; left: 0; right: 0;
  height: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.35), transparent);
}

/* Bubbles inside preloader glass */
.preloader-bubbles {
  position: absolute; bottom: 0; left: 0; right: 0; height: 100%;
  overflow: hidden;
}
.preloader-bubble {
  position: absolute;
  width: 6px; height: 6px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: preloaderBubbleUp 1.5s ease-in infinite;
}
.preloader-bubble:nth-child(1) { left: 20%; animation-delay: 0s; }
.preloader-bubble:nth-child(2) { left: 50%; animation-delay: 0.4s; width: 4px; height: 4px; }
.preloader-bubble:nth-child(3) { left: 70%; animation-delay: 0.8s; width: 5px; height: 5px; }
.preloader-bubble:nth-child(4) { left: 35%; animation-delay: 1.1s; width: 3px; height: 3px; }

@keyframes preloaderBubbleUp {
  0% { bottom: 0; opacity: 0.8; }
  100% { bottom: 100%; opacity: 0; }
}

.preloader-text {
  margin-top: 20px;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}

.preloader-pct {
  font-size: 12px;
  margin-top: 6px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Tap to start overlay */
.tap-to-start {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  z-index: 1;
}
.tap-to-start.visible {
  opacity: 1; visibility: visible;
}
.tap-to-start span {
  font-size: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  animation: tapPulse 1.5s ease-in-out infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ---------- Main App ---------- */
#app {
  display: none;
  width: 100%; height: 100vh; height: 100dvh;
}
#app.visible { display: grid; }

/* Desktop: left parallax square + right panel */
@media (min-width: 769px) {
  #app {
    grid-template-columns: auto 1fr;
    grid-template-rows: 100vh;
    grid-template-rows: 100dvh;
  }
}
/* Ultra-wide: left panel + parallax + right panel */
@media (min-width: 1921px) {
  #app {
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
    grid-template-rows: 100vh;
    grid-template-rows: 100dvh;
  }
}
/* Mobile: stacked */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
  }
}

/* ---------- Parallax Viewport ---------- */
#parallax-viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--accent);
  transition: background 0.5s ease;
}

@media (min-width: 769px) {
  #parallax-viewport {
    height: 100vh;
    height: 100dvh;
    width: 115vh;
    width: 115dvh;
    max-width: 70vw;
    aspect-ratio: auto;
  }
}
@media (max-width: 768px) {
  #parallax-viewport {
    width: 100vw;
    aspect-ratio: 1 / 3;
    max-height: 55dvh;
  }
}

/* Flavor layer group container */
.flavor-group {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.flavor-group.active {
  opacity: 1;
  pointer-events: auto;
}

/* Container entrance animation — quick bouncy scale pop */
@keyframes group-enter {
  0%   { transform: scale(0.85); }
  50%  { transform: scale(1.04); }
  75%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.flavor-group.animate-in {
  animation: group-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Individual layer */
.parallax-layer {
  position: absolute;
  inset: 0;
  will-change: transform;
  overflow: visible;
  pointer-events: none;
}

/* Mirror tiles — 8 copies placed around the center original,
   each offset by 100% and flipped so edges match seamlessly. */
.tile {
  position: absolute;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  top: -1px; left: -1px;
  pointer-events: none;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Positional offsets */
.tile-l  { left: -100%; }
.tile-r  { left:  100%; }
.tile-t  { top:  -100%; }
.tile-b  { top:   100%; }
.tile-tl { top: -100%; left: -100%; }
.tile-tr { top: -100%; left:  100%; }
.tile-bl { top:  100%; left: -100%; }
.tile-br { top:  100%; left:  100%; }

/* Flip transforms — mirror at the shared edge */
.tile-l  img, .tile-r  img { transform: scaleX(-1); }
.tile-t  img, .tile-b  img { transform: scaleY(-1); }
.tile-tl img, .tile-tr img,
.tile-bl img, .tile-br img { transform: scale(-1, -1); }

/* Gentle sine-wave bobbing on layers 1–3 (not background layer 4).
   Each layer has a different duration so they drift out of sync. */
@keyframes bob1 {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -50px; }
}
@keyframes bob2 {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -25px; }
}
@keyframes bob3 {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -12px; }
}
.parallax-layer[data-layer="1"] { animation: bob1 4.0s ease-in-out infinite; }
.parallax-layer[data-layer="2"] { animation: bob2 5.5s ease-in-out infinite; animation-delay: -1.8s; }
.parallax-layer[data-layer="3"] { animation: bob3 7.0s ease-in-out infinite; animation-delay: -3.5s; }

/* ---------- Bubble Layer ---------- */
#bubble-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

/* Individual bubble — canvas-based spherical distortion */
@keyframes bubble-in {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.15); }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}
.bubble {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto;
  cursor: default;
  overflow: hidden;
  z-index: 5;
  will-change: left, top;
}

.bubble canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Mobile: GPU-based frosted glass instead of CPU refraction */
@media (max-width: 768px) {
  .bubble canvas {
    display: none;
  }
  .bubble {
    backdrop-filter: blur(8px) saturate(1.4);
    -webkit-backdrop-filter: blur(8px) saturate(1.4);
  }
}

/* Desktop perf mode: same frosted glass as mobile */
.perf-mode .bubble canvas {
  display: none;
}
.perf-mode .bubble {
  backdrop-filter: blur(8px) saturate(1.4);
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
}

/* Glass overlay elements sit on top of the distortion canvas */
.bubble .glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255,255,255,0.22) 0%,
    rgba(255,255,255,0.04) 40%,
    rgba(255,255,255,0.08) 75%,
    rgba(255,255,255,0.02) 100%
  );
}

/* Thick refractive rim */
.bubble .rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    transparent 50%,
    rgba(255,255,255,0.15) 65%,
    rgba(255,255,255,0.35) 78%,
    rgba(255,255,255,0.1) 90%,
    transparent 100%
  );
}

/* Top-left specular highlight */
.bubble .hl {
  position: absolute;
  width: 50%;
  height: 42%;
  top: 8%;
  left: 12%;
  border-radius: 50% 50% 50% 30%;
  background: radial-gradient(
    ellipse at 45% 45%,
    rgba(255,255,255,0.95) 0%,
    rgba(255,255,255,0.4) 40%,
    transparent 100%
  );
}

/* Bottom-right glint */
.bubble .glint {
  position: absolute;
  width: 16%;
  height: 16%;
  bottom: 16%;
  right: 18%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255,255,255,0.75) 0%,
    transparent 100%
  );
}

/* Chromatic aberration fringe */
.bubble .chroma {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    transparent 55%,
    rgba(100,180,255,0.18) 72%,
    rgba(255,120,80,0.12) 86%,
    transparent 100%
  );
  mix-blend-mode: screen;
}

/* Pop-particle canvas overlay */
#bubble-canvas {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 15;
}

/* ---------- CRT Display Effects ---------- */
.crt-vignette {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  box-shadow:
    inset  60px  0 40px -20px rgba(0,0,0,0.45),
    inset -60px  0 40px -20px rgba(0,0,0,0.45),
    inset 0  30px 25px -15px rgba(0,0,0,0.4),
    inset 0 -30px 25px -15px rgba(0,0,0,0.4);
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.2) 2px,
    rgba(0,0,0,0.2) 4px
  );
  mix-blend-mode: overlay;
}

/* ---------- Control Panel (metal feel) ---------- */
#control-panel,
#panel-left {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 20px;
  overflow: hidden;
  z-index: 20;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.12),
    inset 0 -2px 0 rgba(0,0,0,0.4),
    inset 2px 0 0 rgba(255,255,255,0.06),
    inset -2px 0 0 rgba(0,0,0,0.3),
    inset 0 4px 8px rgba(255,255,255,0.04),
    inset 0 -4px 8px rgba(0,0,0,0.25);
}

#panel-left {
  display: none;
  border-right: 10px solid #0a0a0a;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.06);
}
@media (min-width: 1921px) {
  #panel-left {
    display: flex;
  }
}

/* Brushed metal texture overlay for left panel */
#panel-left::after {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 1px,
      rgba(255,255,255,0.015) 1px,
      rgba(255,255,255,0.015) 2px
    );
  pointer-events: none;
  z-index: 0;
}

/* Heavily blurred label background */
#panel-bg,
#panel-bg-left {
  position: absolute;
  inset: -80px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: url(#vertical-blur) saturate(2.5) brightness(1.0);
  z-index: 0;
  pointer-events: none;
}

/* White light sweep overlay */
@keyframes light-sweep {
  0%   { transform: translateX(-100%); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translateX(200%); opacity: 0; }
}
.panel-sweep {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,0.15) 45%,
    rgba(255,255,255,0.28) 50%,
    rgba(255,255,255,0.15) 55%,
    transparent 70%
  );
  opacity: 0;
  transform: translateX(-100%);
}
.panel-sweep.playing {
  animation: light-sweep 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Brushed metal texture overlay */
#control-panel::after {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 1px,
      rgba(255,255,255,0.015) 1px,
      rgba(255,255,255,0.015) 2px
    );
  pointer-events: none;
  z-index: 0;
}

@media (min-width: 769px) {
  #control-panel {
    min-width: 220px;
    border-left: 10px solid #0a0a0a;
    box-shadow: inset 1px 0 0 rgba(255,255,255,0.06);
  }
}

/* ---------- Mobile Layout ---------- */
@media (max-width: 768px) {
  #control-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 12px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  #control-panel #panel-bg {
    filter: url(#horizontal-blur) saturate(2.5) brightness(1.0);
  }

  /* LCDs span full width, hide label, bigger text */
  #control-panel .lcd-display {
    flex: 0 0 100%;
    max-width: none;
    height: 36px;
  }
  #control-panel .lcd-line-label {
    display: none;
  }
  #control-panel .lcd-line-value {
    font-size: 18px;
  }

  /* Buttons as large as possible — 2 per row, last centered */
  #control-panel .flavor-btn {
    flex: 0 0 calc(50% - 5px);
    width: calc(50% - 5px);
    height: auto;
  }
  #control-panel .flavor-btn img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }
}

/* Pull tab handle — no longer needed */
.pull-tab {
  display: none;
}

/* ---------- Flavor Buttons ---------- */
.flavor-btn {
  position: relative;
  cursor: pointer;
  border: none;
  background: #222;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow:
    var(--shadow-elevation-high),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.5),
    inset 1px 0 0 rgba(255,255,255,0.1),
    inset -1px 0 0 rgba(0,0,0,0.3);
  outline: 2px solid transparent;
  outline-offset: 2px;
  z-index: 1;
}

.flavor-btn.active {
  outline-color: var(--accent);
  box-shadow:
    var(--shadow-elevation-high),
    0 0 12px var(--accent-glow),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.5),
    inset 1px 0 0 rgba(255,255,255,0.12),
    inset -1px 0 0 rgba(0,0,0,0.3);
}

.flavor-btn picture,
.flavor-btn img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

/* Debossed bevel overlay */
.flavor-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
  box-shadow:
    inset 0 3px 6px rgba(0,0,0,0.6),
    inset 0 -2px 0 rgba(255,255,255,0.18),
    inset 3px 0 6px rgba(0,0,0,0.35),
    inset -3px 0 6px rgba(0,0,0,0.35),
    inset 0 -3px 6px rgba(255,255,255,0.06),
    inset 0 6px 12px rgba(0,0,0,0.25);
}

/* Horizontal gloss band — bottom-up default, flips on hover */
.flavor-btn::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(
    0deg,
    rgba(255,255,255,0.38) 0%,
    rgba(255,255,255,0.12) 50%,
    transparent 100%
  );
  border-radius: 0 0 6px 6px;
  z-index: 2;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform: translateY(0);
}

/* Hover: gloss slides up, subtle press */
.flavor-btn:hover {
  transform: scale(0.98) translateY(1px);
  box-shadow:
    var(--shadow-elevation-medium),
    inset 0 1px 0 rgba(255,255,255,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.45),
    inset 1px 0 0 rgba(255,255,255,0.08),
    inset -1px 0 0 rgba(0,0,0,0.25);
}
.flavor-btn:hover::before {
  transform: translateY(-50%);
  opacity: 0.7;
}

/* Click: full press */
.flavor-btn:active {
  transform: scale(0.95) translateY(3px);
  box-shadow:
    var(--shadow-elevation-low),
    inset 0 2px 4px rgba(0,0,0,0.5),
    inset 0 -1px 0 rgba(255,255,255,0.08),
    inset 1px 0 2px rgba(0,0,0,0.3),
    inset -1px 0 0 rgba(255,255,255,0.04);
}
.flavor-btn:active::before {
  transform: translateY(80%);
  opacity: 0.4;
}

/* Desktop button sizing — fill the panel */
@media (min-width: 769px) {
  .flavor-btn {
    width: 100%;
    max-width: 320px;
  }
}

/* Mobile button sizing */
@media (max-width: 768px) {
  .lcd-display {
    width: 100%;
    max-width: none;
    flex-shrink: 0;
  }
}

/* ---------- Accent Color Themes ---------- */
[data-flavor="fratwater"] {
  --accent: #3ec6c9;
  --accent-glow: rgba(62, 198, 201, 0.4);
}
[data-flavor="limewire"] {
  --accent: #7ccf2e;
  --accent-glow: rgba(124, 207, 46, 0.4);
}
[data-flavor="oops"] {
  --accent: #e84560;
  --accent-glow: rgba(232, 69, 96, 0.4);
}
[data-flavor="pigwater"] {
  --accent: #e87cb0;
  --accent-glow: rgba(232, 124, 176, 0.4);
}
[data-flavor="superjuice"] {
  --accent: #f5a623;
  --accent-glow: rgba(245, 166, 35, 0.4);
}

/* ---------- LCD Displays ---------- */
.lcd-display {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 56px;
  background: linear-gradient(180deg, #060e06 0%, #0c1e0c 50%, #081408 100%);
  border-radius: 5px;
  overflow: hidden;
  z-index: 1;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow:
    0 0 4px var(--accent),
    0 0 10px var(--accent-glow),
    0 0 22px var(--accent-glow);
  /* Deep bevel */
  border: 1px solid #000;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.9),
    inset 0 -1px 0 rgba(255,255,255,0.03),
    inset 1px 0 4px rgba(0,0,0,0.6),
    inset -1px 0 4px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.1),
    0 -1px 0 rgba(0,0,0,0.4),
    1px 0 0 rgba(255,255,255,0.05),
    -1px 0 0 rgba(0,0,0,0.3),
    0 2px 4px rgba(0,0,0,0.4);
}

/* Pixel grid overlay */
.lcd-display::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.12) 2px,
      rgba(0,0,0,0.12) 3px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.08) 2px,
      rgba(0,0,0,0.08) 3px
    );
  pointer-events: none;
  z-index: 2;
}

/* Inner bezel highlight */
.lcd-display::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -1px 0 rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 3;
}

.lcd-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 10px;
  overflow: hidden;
}

.lcd-line {
  line-height: 1.3;
  white-space: nowrap;
}

.lcd-line-label {
  font-size: 10px;
  letter-spacing: 3px;
  opacity: 0.45;
}

.lcd-line-value {
  font-size: 16px;
  letter-spacing: 2px;
  overflow: hidden;
  position: relative;
}

/* Top LCD — typewriter ticker */
.lcd-ticker {
  display: inline-block;
  white-space: nowrap;
  transition: transform 1.2s linear;
}
.lcd-ticker::after {
  content: '_';
  animation: lcd-blink 0.6s step-end infinite;
}
@keyframes lcd-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Legacy marquee (unused, kept for fallback) */
.lcd-marquee {
  display: inline-block;
  animation: lcd-scroll 14s linear infinite;
}
@keyframes lcd-scroll {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* Bottom LCD — counter, centered */
.lcd-counter .lcd-inner {
  align-items: center;
}

/* Panel ambient glow — beneath the metal texture */
.panel-glow {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 120px;
  background: radial-gradient(ellipse at top center, var(--accent-glow), transparent 70%);
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 0.5s ease;
  z-index: 0;
}

/* ---------- iOS Gyro Permission Button ---------- */
.gyro-prompt {
  display: none;
  position: fixed;
  bottom: 70px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 100;
}

/* ---------- Score Popup ---------- */
.score-popup {
  position: absolute;
  pointer-events: none;
  font-family: 'Courier New', monospace;
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.9),
    0 4px 8px rgba(0,0,0,0.7),
    0 0 10px rgba(255,255,255,0.4);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: score-float 0.9s ease-out forwards;
  z-index: 60;
}
@keyframes score-float {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  60%  { opacity: 1; transform: translate(-50%, -120%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.9); }
}

/* ---------- Chain Meter ---------- */
.chain-meter {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 12px;
  height: 140px;
  background: rgba(0,0,0,0.5);
  border-radius: 6px;
  overflow: hidden;
  z-index: 55;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
}
.chain-meter-label {
  position: absolute;
  bottom: 16px;
  right: 34px;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  z-index: 55;
  pointer-events: none;
}
.chain-meter-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  border-radius: 4px;
  transition: height 0.15s ease-out;
}

/* ---------- Flavor Challenge Overlay ---------- */
.challenge-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 58;
  text-align: center;
  animation: challenge-flash 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.challenge-overlay span {
  display: block;
  font-family: 'Courier New', monospace;
  font-weight: 900;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}
.challenge-overlay .challenge-label {
  font-size: 18px;
  letter-spacing: 6px;
  opacity: 0.9;
  margin-bottom: 8px;
  text-shadow: 0 0 14px rgba(255,255,255,0.6), 0 2px 4px rgba(0,0,0,0.8);
}
.challenge-overlay .challenge-flavor {
  font-size: 42px;
  letter-spacing: 5px;
  color: #fff;
  -webkit-text-stroke: 2px var(--accent);
  paint-order: stroke fill;
  text-shadow:
    0 0 20px var(--accent-glow),
    0 0 50px var(--accent-glow),
    0 3px 8px rgba(0,0,0,0.9);
}
@keyframes challenge-flash {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-3deg); filter: brightness(4) blur(4px); }
  20%  { opacity: 1; filter: brightness(2) blur(0px); }
  40%  { transform: translate(-50%, -50%) scale(0.92) rotate(1deg); filter: brightness(1.3); }
  60%  { transform: translate(-50%, -50%) scale(1.06) rotate(-0.5deg); filter: brightness(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); filter: brightness(1); }
}

/* Challenge success overlay */
.challenge-success {
  animation: success-slam 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.challenge-success-word {
  font-size: 38px;
  letter-spacing: 6px;
  -webkit-text-stroke: 2px var(--accent);
  paint-order: stroke fill;
  text-shadow:
    0 0 24px var(--accent-glow),
    0 0 60px var(--accent-glow),
    0 3px 8px rgba(0,0,0,0.9);
  margin-bottom: 4px;
}
.challenge-success-mult {
  font-size: 52px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow:
    0 0 30px var(--accent-glow),
    0 0 60px var(--accent-glow),
    0 4px 10px rgba(0,0,0,0.9);
}
@keyframes success-slam {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(3) rotate(5deg); filter: brightness(5) blur(6px); }
  25%  { opacity: 1; filter: brightness(2.5) blur(0px); }
  45%  { transform: translate(-50%, -50%) scale(0.88) rotate(-2deg); filter: brightness(1.2); }
  65%  { transform: translate(-50%, -50%) scale(1.08) rotate(0.5deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); filter: brightness(1); }
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Quality Toggle ---------- */
.quality-toggle {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  opacity: 1;
}
@media (min-width: 769px) {
  .quality-toggle { display: flex; }
}
.qt-label {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.quality-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.qt-track {
  position: relative;
  width: 36px;
  height: 18px;
  background: rgba(255,255,255,0.3);
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.5),
    inset 0 -1px 0 rgba(255,255,255,0.1),
    0 1px 3px rgba(0,0,0,0.4);
  transition: background 0.2s ease;
}
.qt-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, #fff 0%, #ddd 100%);
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow:
    0 1px 3px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.9);
  transition: left 0.2s ease;
}
.quality-toggle input:checked ~ .qt-track {
  background: var(--accent-glow);
}
.quality-toggle input:checked ~ .qt-track .qt-thumb {
  left: 20px;
}
