* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: #000;
  overflow: hidden;
}

#canvas {
  display: none;
}

/* Cards section */
.cards-section {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* Cards container */
.cards-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  z-index: 2;
  position: relative;
}

/* Individual card */
.card {
  width: 220px;
  height: 300px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 24px;
  transition: transform 0.3s ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.card:hover {
  transform: translateY(-12px) scale(1.02);
}

.card:hover .card-image {
  transform: scale(1.08);
}

/* Card background image */
.card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
  z-index: 0;
}

/* Card gradient overlay */
.card-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  z-index: 1;
  pointer-events: none;
}

/* Disable transitions during GSAP animations */
.card.no-transition {
  transition: none !important;
}

/* Dark overlay on images */
.card-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
}

/* Active glow overlay - lights up card from bottom when playing */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  mix-blend-mode: soft-light;
}

.card.active-glow::before {
  opacity: 1;
}

.card-green::before {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.9) 0%, rgba(168, 230, 207, 0.5) 25%, transparent 55%);
}

.card-yellow::before {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.9) 0%, rgba(255, 217, 61, 0.5) 25%, transparent 55%);
}

.card-red::before {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.9) 0%, rgba(255, 107, 107, 0.5) 25%, transparent 55%);
}

/* Card colors - gradient overlays */
.card-green .card-gradient {
  background: linear-gradient(to top, rgba(168, 230, 207, 0.7) 0%, rgba(168, 230, 207, 0.5) 10%, transparent 60%);
}

.card-yellow .card-gradient {
  background: linear-gradient(to top, rgba(255, 217, 61, 0.7) 0%, rgba(255, 217, 61, 0.5) 10%, transparent 60%);
}

.card-red .card-gradient {
  background: linear-gradient(to top, rgba(255, 107, 107, 0.7) 0%, rgba(255, 107, 107, 0.5) 10%, transparent 60%);
}

/* Card icon shapes - white icons over gradient */
.card-icon {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 2;
}

.shape-square {
  width: 36px;
  height: 36px;
}

.shape-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.shape-diamond {
  width: 32px;
  height: 32px;
  transform: rotate(45deg);
}

.card-label {
  position: absolute;
  top: 14px;
  left: 16px;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  z-index: 2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Slot container - top position set by JS for responsiveness */
.slot-container {
  opacity: 0;
  position: fixed;
  top: 100%;
  left: 0;
  width: 100%;
  height: 0;
  overflow: visible;
}

/* Single slot bar - fully rounded */
.slot-bar {
  width: 240px;
  height: 8px;
  position: absolute;
  left: 50%;
  margin-left: -120px;
  top: 0;
  background: #0a0a0a;
  border-radius: 4px;
  z-index: 6;
}

/* Gradient slot bar - always visible */
.slot-bar-gradient {
  width: 240px;
  height: 8px;
  position: absolute;
  left: 50%;
  margin-left: -120px;
  top: 0;
  background: linear-gradient(to right, #aaa 0%, #d9d9d9 3.4%, #d9d9d9 50%, #d9d9d9 98%, #aaa 100%);
  border-radius: 4px;
  z-index: 7;
}

/* Glow emanating from slot - behind card, beam shape with progressive blur */
.slot-glow {
  position: fixed;
  width: 343px;
  height: 119px;
  left: 50%;
  margin-left: -171.5px;
  top: 0; /* Set dynamically by JS */
  opacity: 0;
  pointer-events: none;
  z-index: 1; /* Behind everything except white background */
  visibility: hidden;
  --glow-opacity: 1;
  color: var(--glow-color, #a8e6cf);
}

/* Base glow layer styles - SVG */
.glow-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Bottom layer - heavy blur (50px), visible at bottom */
.glow-layer-blur {
  filter: blur(40px);
  opacity: calc(1 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, white 0%, white 50%, transparent 80%);
  mask-image: linear-gradient(to top, white 0%, white 50%, transparent 80%);
}

/* Middle layer - medium blur (25px), visible in middle */
.glow-layer-mid {
  filter: blur(20px);
  opacity: calc(0.8 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, transparent 10%, white 30%, white 70%, transparent 90%);
  mask-image: linear-gradient(to top, transparent 10%, white 30%, white 70%, transparent 90%);
}

/* Top layer - light blur (8px), fades out at top */
.glow-layer-sharp {
  filter: blur(8px);
  opacity: calc(0.5 * var(--glow-opacity, 1));
  -webkit-mask-image: linear-gradient(to top, transparent 30%, white 50%, transparent 85%);
  mask-image: linear-gradient(to top, transparent 30%, white 50%, transparent 85%);
}

.slot-glow.visible {
  opacity: 1;
  visibility: visible;
  display: none; /* TEMP: hidden for testing */
}

/* Glow colors */
.slot-glow.glow-green {
  --glow-color: #4ade80;
}

.slot-glow.glow-yellow {
  --glow-color: #facc15;
}

.slot-glow.glow-red {
  --glow-color: #f87171;
}

/* The void below - full width white mask, top position set by JS */
.slot-void {
  width: 100vw;
  height: 100vh;
  background: #fff;
  position: fixed;
  top: 100%;
  left: 0;
  z-index: 4;
}

/* Card when inserting - fixed position to escape stacking context */
.card.inserting {
  position: fixed;
  z-index: 3;
}

/* Card with no shadow when inserted */
.card.inserting {
  box-shadow: none !important;
}

/* Card at top position after insertion - raise above void */
.card.inserted {
  z-index: 7;
}

/* Anime speed lines - top position set by JS */
.speed-lines {
  position: fixed;
  top: 100%;
  left: 50%;
  margin-left: -120px;
  width: 240px;
  height: 4px;
  z-index: 7;
  pointer-events: none;
}

.speed-line {
  position: absolute;
  top: 0;
  width: 80px;
  height: 3px;
  background: transparent;
  overflow: hidden;
}

.speed-line.left {
  right: 100%;
  margin-right: 2px;
}

.speed-line.left.top {
  transform: rotate(-12deg);
  transform-origin: right center;
}

.speed-line.left.bottom {
  transform: rotate(12deg);
  transform-origin: right center;
}

.speed-line.right {
  left: 100%;
  margin-left: 2px;
}

.speed-line.right.top {
  transform: rotate(12deg);
  transform-origin: left center;
}

.speed-line.right.bottom {
  transform: rotate(-12deg);
  transform-origin: left center;
}

/* The moving segment inside the line */
.speed-line::after {
  content: '';
  position: absolute;
  top: 0;
  height: 100%;
  width: 25px;
  border-radius: 2px;
}

.speed-line.left::after {
  right: -25px;
  background: linear-gradient(to left, transparent 0%, #0a0a0a 40%, #0a0a0a 60%, transparent 100%);
}

.speed-line.right::after {
  left: -25px;
  background: linear-gradient(to right, transparent 0%, #0a0a0a 40%, #0a0a0a 60%, transparent 100%);
}

/* Animation - segment shoots outward */
@keyframes speedLineTravelLeft {
  0% {
    right: -25px;
    opacity: 1;
  }
  100% {
    right: 80px;
    opacity: 0;
  }
}

@keyframes speedLineTravelRight {
  0% {
    left: -25px;
    opacity: 1;
  }
  100% {
    left: 80px;
    opacity: 0;
  }
}

.speed-lines.active .speed-line.left::after {
  animation: speedLineTravelLeft 0.25s ease-out forwards;
}

.speed-lines.active .speed-line.right::after {
  animation: speedLineTravelRight 0.25s ease-out forwards;
}

/* Back button */
.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 20;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  color: #333;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: background 0.2s ease, opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-button:hover {
  background: rgba(0, 0, 0, 0.08);
}

.back-button.visible {
  opacity: 1;
  visibility: visible;
}

/* Mute button */
.mute-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transition: background 0.2s ease, opacity 0.3s ease, visibility 0.3s ease, width 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  width: 40px;
}

.mute-button:hover {
  background: rgba(0, 0, 0, 0.08);
}

.mute-button.visible {
  opacity: 1;
  visibility: visible;
}

/* Mute toggle button inside container */
.mute-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.mute-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
}

.mute-button .mute-icon-off {
  display: none;
}

.mute-button.muted .mute-icon-on {
  display: none;
}

.mute-button.muted .mute-icon-off {
  display: block;
}

/* Volume slider */
.volume-slider {
  --volume: 100;
  width: 0;
  height: 4px;
  margin: 0 8px 0 0;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to right,
    #333 0%,
    #333 calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) 100%
  );
  border-radius: 2px;
  transition: width 0.25s ease, opacity 0.25s ease;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #333;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.volume-slider::-moz-range-track {
  height: 4px;
  background: linear-gradient(
    to right,
    #333 0%,
    #333 calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) calc(var(--volume) * 1%),
    rgba(0, 0, 0, 0.15) 100%
  );
  border-radius: 2px;
}

/* Desktop hover: expand to show slider */
@media (hover: hover) and (pointer: fine) {
  .mute-button:hover {
    width: 140px;
  }
  
  .mute-button:hover .volume-slider {
    width: 80px;
    opacity: 1;
  }
}

/* Music visualizer - positioned inside the selected card */
.visualizer {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.visualizer.visible {
  opacity: 1;
  visibility: visible;
}

.visualizer-bar {
  width: 3px;
  height: 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 1.5px;
  transform-origin: bottom;
  transition: transform 0.05s ease-out, background 0.2s ease;
}

.visualizer.muted .visualizer-bar {
  background: rgba(239, 68, 68, 0.9);
}

/* Game content area */
.game-content {
  position: fixed;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
}

.game-content.visible {
  opacity: 1;
  visibility: visible;
}

/* Game canvas fills the game content area */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Touch-friendly active states (fallback for hover) */
@media (hover: none) {
  .card:active {
    transform: translateY(-6px) scale(1.01);
  }

  .card:hover {
    transform: none;
  }

  .back-button:active {
    background: #e8e8e8;
  }
}

/* Tablet and below */
@media (max-width: 768px) {
  .cards-container {
    gap: 24px;
  }

  .card {
    width: 200px;
    height: 270px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 210px;
    margin-left: -105px;
  }

  .speed-lines {
    width: 210px;
    margin-left: -105px;
  }

  .card-icon {
    width: 32px;
    height: 32px;
  }

  .shape-circle {
    width: 36px;
    height: 36px;
  }

  .shape-diamond {
    width: 26px;
    height: 26px;
  }

  .card-label {
    font-size: 12px;
    top: 12px;
    left: 14px;
  }

  .back-button {
    padding: 12px 20px;
    font-size: 16px;
  }
}

/* Mobile phones */
@media (max-width: 600px) {
  .cards-container {
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 20px 40px;
    width: 100%;
    justify-content: flex-start;
  }

  /* Hide scrollbar but keep functionality */
  .cards-container::-webkit-scrollbar {
    display: none;
  }
  .cards-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  /* When inserting, allow card to escape container clipping */
  .cards-container.card-inserting {
    overflow: visible;
  }

  .card {
    flex-shrink: 0;
    scroll-snap-align: center;
    width: 195px;
    height: 260px;
  }

  .card-icon {
    width: 32px;
    height: 32px;
  }

  .shape-circle {
    width: 36px;
    height: 36px;
  }

  .shape-diamond {
    width: 26px;
    height: 26px;
  }

  .card-label {
    font-size: 12px;
  }

  .card {
    padding-bottom: 20px;
  }

  /* Narrower slot for mobile */
  .slot-bar,
  .slot-bar-gradient {
    width: 210px;
    margin-left: -105px;
  }

  .speed-lines {
    width: 210px;
    margin-left: -105px;
  }

  .back-button {
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
  }

  .mute-button {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
  }

  .game-content {
    top: 80px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .cards-container {
    padding: 20px 30px;
    gap: 12px;
  }

  .card {
    width: 175px;
    height: 230px;
    padding-bottom: 18px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 190px;
    margin-left: -95px;
  }

  .speed-lines {
    width: 190px;
    margin-left: -95px;
  }

  .card-icon {
    width: 28px;
    height: 28px;
  }

  .shape-circle {
    width: 32px;
    height: 32px;
  }

  .shape-diamond {
    width: 22px;
    height: 22px;
  }

  .card-label {
    font-size: 11px;
    top: 10px;
    left: 12px;
  }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .cards-container {
    gap: 16px;
    padding: 10px 40px;
  }

  .card {
    width: 140px;
    height: 180px;
    padding-bottom: 14px;
  }

  .slot-bar,
  .slot-bar-gradient {
    width: 160px;
    margin-left: -80px;
  }

  .speed-lines {
    width: 160px;
    margin-left: -80px;
  }

  .card-icon {
    width: 24px;
    height: 24px;
    border-width: 2px;
  }

  .shape-circle {
    width: 28px;
    height: 28px;
  }

  .shape-diamond {
    width: 20px;
    height: 20px;
  }

  .card-label {
    font-size: 10px;
    top: 8px;
    left: 10px;
  }

  .game-content {
    top: 60px;
  }
}
