:root {
  --bg-void: #05040b;
  --bg-surface: #0b0a17;
  --bg-cabinet: #0d0c1b;
  --text-primary: #f2f5ff;
  --text-secondary: #bcc6e6;
  --text-muted: #7882a6;

  --cyan: #00f0ff;
  --cyan-rgb: 0, 240, 255;
  --magenta: #ff2a9d;
  --magenta-rgb: 255, 42, 157;
  --purple: #9d4edd;
  --purple-rgb: 157, 78, 221;

  --font-display: 'Orbitron', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: 'Chakra Petch', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-void);
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Background: Three.js Canvas + CSS Neon Grid Fallback
   ========================================================================== */

.bg-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% 42%, rgba(88, 28, 135, 0.28) 0%, transparent 65%),
    radial-gradient(circle at 18% 22%, rgba(0, 240, 255, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 82% 28%, rgba(255, 42, 157, 0.14) 0%, transparent 45%),
    var(--bg-void);
}

.bg-fallback__horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: 48%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(var(--cyan-rgb), 0.38) 28%,
    rgba(var(--magenta-rgb), 0.55) 50%,
    rgba(var(--cyan-rgb), 0.38) 72%,
    transparent 100%
  );
  box-shadow:
    0 0 28px rgba(var(--magenta-rgb), 0.45),
    0 0 60px rgba(var(--cyan-rgb), 0.25);
  opacity: 0.85;
  transition: opacity 600ms ease;
}

.bg-fallback__grid {
  position: absolute;
  left: -35%;
  right: -35%;
  top: 48%;
  bottom: -25%;
  transform-origin: 50% 0%;
  transform: perspective(420px) rotateX(68deg);
  background-image:
    linear-gradient(to right, rgba(var(--cyan-rgb), 0.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(var(--magenta-rgb), 0.24) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.45) 55%, transparent 95%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.45) 55%, transparent 95%);
  animation: fallback-grid-scroll 3.6s linear infinite;
  transition: opacity 600ms ease;
}

.bg-fallback__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 48%, transparent 32%, rgba(5, 4, 11, 0.72) 100%);
}

@keyframes fallback-grid-scroll {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 56px;
  }
}

.scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 700ms ease;
}

body.scene-ready .scene-canvas {
  opacity: 1;
}

body.scene-ready .bg-fallback__grid,
body.scene-ready .bg-fallback__horizon {
  opacity: 0;
}

/* ==========================================================================
   Page Shell & Hero Neon Sign
   ========================================================================== */

.page-shell {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(2rem + env(safe-area-inset-top))
    max(1.1rem, env(safe-area-inset-right))
    calc(4.75rem + env(safe-area-inset-bottom))
    max(1.1rem, env(safe-area-inset-left));
}

.hero {
  text-align: center;
  margin-bottom: clamp(1.75rem, 4vw, 3rem);
  max-width: 780px;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.85rem;
  margin-bottom: 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--cyan-rgb), 0.3);
  background: rgba(11, 10, 23, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: rgba(212, 248, 255, 0.88);
  text-transform: uppercase;
}

.hero__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan), 0 0 14px var(--cyan);
  animation: status-pulse 2.4s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.neon-sign {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.14em;
  user-select: none;
}

.neon-sign__line {
  display: block;
}

.neon-sign__line--top {
  font-size: clamp(1.65rem, 6.2vw, 3rem);
  color: #ecfeff;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.9),
    0 0 12px rgba(var(--cyan-rgb), 0.85),
    0 0 28px rgba(var(--cyan-rgb), 0.55),
    0 0 56px rgba(var(--cyan-rgb), 0.3);
}

.neon-sign__line--bottom {
  font-size: clamp(2.3rem, 9.2vw, 4.45rem);
  letter-spacing: 0.11em;
  color: #fff2fa;
  text-shadow:
    0 0 5px rgba(255, 255, 255, 0.92),
    0 0 14px rgba(var(--magenta-rgb), 0.85),
    0 0 34px rgba(var(--magenta-rgb), 0.6),
    0 0 72px rgba(var(--purple-rgb), 0.42);
}

/* Subtle occasional neon tube flicker on one letter */
.neon-flicker {
  display: inline-block;
  animation: neon-tube-flicker 11s infinite;
}

@keyframes neon-tube-flicker {
  0%, 73%, 75%, 77%, 100% {
    opacity: 1;
    text-shadow:
      0 0 5px rgba(255, 255, 255, 0.92),
      0 0 14px rgba(var(--magenta-rgb), 0.85),
      0 0 34px rgba(var(--magenta-rgb), 0.6),
      0 0 72px rgba(var(--purple-rgb), 0.42);
  }
  74% {
    opacity: 0.48;
    text-shadow:
      0 0 2px rgba(255, 255, 255, 0.35),
      0 0 8px rgba(var(--magenta-rgb), 0.35);
  }
  76% {
    opacity: 0.72;
    text-shadow:
      0 0 3px rgba(255, 255, 255, 0.55),
      0 0 12px rgba(var(--magenta-rgb), 0.5);
  }
}

.hero__tagline {
  margin: 0.95rem 0 0;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-shadow: 0 2px 14px rgba(5, 4, 11, 0.9);
}

/* ==========================================================================
   Arcade Floor & Cabinets Grid
   ========================================================================== */

.floor {
  width: 100%;
  max-width: 1080px;
}

.cabinets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(272px, 316px));
  justify-content: center;
  gap: clamp(1.35rem, 3vw, 2rem);
}

/* ==========================================================================
   3D-Tilting Arcade Cabinet Card
   ========================================================================== */

.cabinet {
  --accent: #00f0ff;
  --accent-rgb: 0, 240, 255;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --lift-z: 0px;
  --glare-x: 50%;
  --glare-y: 25%;
  --glare-opacity: 0;

  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.9rem;
  border-radius: 18px 18px 14px 14px;
  background:
    linear-gradient(165deg, rgba(24, 22, 46, 0.92) 0%, rgba(10, 9, 22, 0.96) 55%, rgba(7, 6, 15, 0.98) 100%);
  border: 1.5px solid rgba(var(--accent-rgb), 0.55);
  box-shadow:
    0 22px 48px -14px rgba(0, 0, 0, 0.85),
    0 0 26px -6px rgba(var(--accent-rgb), 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 24px rgba(var(--accent-rgb), 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transform-style: preserve-3d;
  transform: perspective(1000px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) translate3d(0, 0, var(--lift-z));
  transition:
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 220ms ease,
    box-shadow 220ms ease;
  will-change: transform;
}

.cabinet--interactive {
  cursor: pointer;
}

.cabinet--interactive:hover,
.cabinet--interactive:focus-within {
  border-color: rgba(var(--accent-rgb), 0.95);
  box-shadow:
    0 30px 60px -14px rgba(0, 0, 0, 0.92),
    0 0 42px -4px rgba(var(--accent-rgb), 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 0 28px rgba(var(--accent-rgb), 0.14);
}

.cabinet--interactive:active {
  transform: perspective(1000px) scale(0.985);
}

/* Specular glare across cabinet & screen */
.cabinet__glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  opacity: var(--glare-opacity);
  background: radial-gradient(
    circle 210px at var(--glare-x) var(--glare-y),
    rgba(255, 255, 255, 0.2) 0%,
    rgba(var(--accent-rgb), 0.12) 38%,
    transparent 72%
  );
  mix-blend-mode: screen;
  transition: opacity 200ms ease;
}

/* Top Illuminated Marquee */
.cabinet__marquee {
  position: relative;
  padding: 0.68rem 0.8rem;
  margin-bottom: 0.72rem;
  border-radius: 10px 10px 6px 6px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.24) 0%, rgba(var(--accent-rgb), 0.08) 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.65);
  box-shadow:
    inset 0 0 18px rgba(var(--accent-rgb), 0.28),
    0 0 16px rgba(var(--accent-rgb), 0.24);
  overflow: hidden;
}

.cabinet__marquee::before {
  content: "";
  position: absolute;
  inset: 0 10%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
}

.cabinet__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow:
    0 0 8px rgba(var(--accent-rgb), 0.9),
    0 0 18px rgba(var(--accent-rgb), 0.55);
}

/* Recessed CRT Screen */
.cabinet__bezel {
  position: relative;
  padding: 0.45rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #05050c 0%, #090814 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.95),
    0 1px 0 rgba(255, 255, 255, 0.06);
}

.cabinet__screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #03040a;
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.9),
    0 0 14px rgba(var(--accent-rgb), 0.16);
}

.cabinet__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cabinet__scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0px,
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.24) 3px,
    rgba(0, 0, 0, 0.24) 4px
  );
  opacity: 0.72;
}

.cabinet__glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(132deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.02) 28%, transparent 52%),
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.48) 100%);
}

/* Decorative Control Deck Shelf */
.cabinet__deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  margin-top: 0.62rem;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.35) 100%);
  border-top: 1px solid rgba(var(--accent-rgb), 0.28);
  border-bottom: 1px solid rgba(0, 0, 0, 0.6);
}

.cabinet__stick {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cabinet__joystick {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.cabinet__deck-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cabinet__buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cabinet__btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.72);
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.7);
}

.cabinet__btn-dot--alt {
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

/* Description & PLAY CTA */
.cabinet__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding-top: 0.78rem;
  gap: 0.9rem;
}

.cabinet__tagline {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.42;
  color: var(--text-secondary);
  min-height: 2.7em;
}

.cabinet__play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: auto;
  padding: 0.76rem 1.15rem;
  border-radius: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffffff;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.22) 0%, rgba(var(--accent-rgb), 0.08) 100%);
  border: 1.5px solid rgba(var(--accent-rgb), 0.8);
  box-shadow:
    0 0 18px rgba(var(--accent-rgb), 0.25),
    inset 0 0 12px rgba(var(--accent-rgb), 0.12);
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

/* Stretched-link overlay so the whole cabinet AND the PLAY button link cleanly */
.cabinet__play::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
}

.cabinet--interactive:hover .cabinet__play,
.cabinet__play:focus-visible {
  background: var(--accent);
  color: #05040b;
  box-shadow:
    0 0 26px rgba(var(--accent-rgb), 0.75),
    0 0 8px rgba(255, 255, 255, 0.45);
}

.cabinet__play:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
}

.cabinet__arrow {
  display: inline-block;
  transition: transform 180ms ease;
}

.cabinet--interactive:hover .cabinet__arrow {
  transform: translateX(3px);
}

/* ==========================================================================
   Dim "NEXT CABINET" Placeholder
   ========================================================================== */

.cabinet--placeholder {
  --accent: #7f78a8;
  --accent-rgb: 127, 120, 168;
  cursor: default;
  opacity: 0.76;
  border-style: dashed;
  border-color: rgba(var(--accent-rgb), 0.36);
  background:
    linear-gradient(165deg, rgba(16, 15, 30, 0.84) 0%, rgba(8, 7, 16, 0.9) 100%);
  box-shadow:
    0 18px 36px -14px rgba(0, 0, 0, 0.8),
    0 0 22px -8px rgba(var(--accent-rgb), 0.22),
    inset 0 0 24px rgba(var(--accent-rgb), 0.05);
}

.cabinet--placeholder .cabinet__marquee {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.1) 0%, rgba(var(--accent-rgb), 0.03) 100%);
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: inset 0 0 12px rgba(var(--accent-rgb), 0.12);
}

.cabinet--placeholder .cabinet__title {
  color: rgba(206, 202, 232, 0.72);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

.cabinet--placeholder .cabinet__screen-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background:
    radial-gradient(circle at 50% 50%, rgba(127, 120, 168, 0.14) 0%, rgba(5, 4, 11, 0.96) 72%);
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.95),
    0 0 14px rgba(var(--accent-rgb), 0.14);
}

.placeholder-screen__badge {
  padding: 0.26rem 0.65rem;
  border-radius: 4px;
  border: 1px solid rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.08);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(253, 224, 138, 0.85);
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.45);
  animation: construction-glow 3.4s ease-in-out infinite;
}

.placeholder-screen__sub {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(164, 158, 198, 0.56);
}

@keyframes construction-glow {
  0%, 100% {
    opacity: 0.95;
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.22);
  }
  50% {
    opacity: 0.52;
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.08);
  }
}

.cabinet--placeholder .cabinet__joystick {
  background: rgba(var(--accent-rgb), 0.45);
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.18);
}

.cabinet--placeholder .cabinet__btn-dot {
  background: rgba(var(--accent-rgb), 0.32);
  box-shadow: none;
}

.cabinet--placeholder .cabinet__tagline {
  color: var(--text-muted);
}

.cabinet__status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 0.76rem 1.15rem;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(180, 174, 212, 0.62);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(var(--accent-rgb), 0.35);
}

/* ==========================================================================
   Fixed Bottom-Right Semsotai Labs Link
   ========================================================================== */

.labs-badge {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.82rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: rgba(10, 9, 22, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  transition: color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.labs-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  box-shadow: 0 0 8px rgba(var(--cyan-rgb), 0.75);
}

.labs-badge:hover,
.labs-badge:focus-visible {
  color: #ffffff;
  border-color: rgba(var(--cyan-rgb), 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 16px rgba(var(--cyan-rgb), 0.25);
  transform: translateY(-1px);
}

.labs-badge:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ==========================================================================
   Touch Devices & Small Screens
   ========================================================================== */

@media (hover: none), (pointer: coarse) {
  .cabinets-grid {
    grid-template-columns: minmax(0, 380px);
  }

  .cabinet {
    transform: none !important;
    transition: border-color 180ms ease, box-shadow 180ms ease;
  }

  .cabinet__glare {
    display: none;
  }
}

@media (max-width: 640px) {
  .cabinets-grid {
    grid-template-columns: minmax(0, 360px);
    gap: 1.35rem;
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .cabinet {
    padding: 0.82rem;
  }

  .cabinet__tagline {
    min-height: 0;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .neon-flicker,
  .hero__status-dot,
  .bg-fallback__grid,
  .placeholder-screen__badge {
    animation: none !important;
  }

  .cabinet,
  .cabinet__play,
  .cabinet__arrow,
  .labs-badge {
    transition: none !important;
  }

  .cabinet {
    transform: none !important;
  }

  .cabinet__glare {
    display: none;
  }
}
