@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap");

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: visible;
  background: #000000;
  color: #ffffff;
  cursor: default;
}

body {
  position: relative;
  font-family: "Space Grotesk", Arial, sans-serif;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

video {
  position: absolute;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

#preloader {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #020202;
  overflow: hidden;
  transition: opacity 520ms ease;
}

#preloader.is-exit {
  opacity: 0;
  pointer-events: none;
}

#preloader::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0.8px, transparent 1px);
  background-size: 11px 11px;
  opacity: 0.04;
  pointer-events: none;
}

#preloader-visual {
  width: min(680px, 86vw);
  height: min(86vh, 860px);
  position: relative;
  display: grid;
  place-items: center;
  animation: preloader-float 4.8s ease-in-out infinite;
}

#preloader-headphones {
  width: 100%;
  height: 100%;
  display: block;
}

.wire {
  fill: none;
  stroke: url(#dot-fill);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: var(--path-length, 900);
  stroke-dashoffset: var(--path-length, 900);
  opacity: 0.95;
  animation: wire-reveal 2.15s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    wire-breathe 2.7s ease-in-out infinite;
  animation-delay: var(--reveal-delay, 0ms), 2.1s;
}

.wire-a {
  --path-length: 460;
  --reveal-delay: 40ms;
}

.wire-b {
  --path-length: 430;
  --reveal-delay: 120ms;
}

.wire-c {
  --path-length: 980;
  --reveal-delay: 220ms;
}

.wire-d {
  --path-length: 1020;
  --reveal-delay: 340ms;
}

.wire-e {
  --path-length: 1120;
  --reveal-delay: 470ms;
}

.wire-f {
  --path-length: 930;
  --reveal-delay: 620ms;
}

.hardware {
  fill: url(#dot-fill);
  stroke: url(#dot-fill);
  stroke-width: 1.8;
  opacity: 0;
  transform-origin: center;
  animation: hardware-pop 860ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.earbud-stem {
  fill: none;
  stroke: url(#dot-fill);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.earbud-port {
  fill: #020202;
  stroke: #020202;
  stroke-width: 1.2;
  opacity: 0.92;
}

.earbud-crease {
  fill: none;
  stroke: #020202;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.88;
}


.hardware-layer > *:nth-child(1) {
  animation-delay: 860ms;
}

.hardware-layer > *:nth-child(2) {
  animation-delay: 980ms;
}

.hardware-layer > *:nth-child(3) {
  animation-delay: 1060ms;
}

.hardware-layer > *:nth-child(4) {
  animation-delay: 1240ms;
}

.hardware-layer > *:nth-child(5) {
  animation-delay: 1320ms;
}

.hardware-layer > *:nth-child(6) {
  animation-delay: 1400ms;
}

.hardware-layer > *:nth-child(7) {
  animation-delay: 1480ms;
}

@keyframes wire-reveal {
  from {
    stroke-dashoffset: var(--path-length, 900);
    opacity: 0.3;
  }

  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

@keyframes hardware-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes preloader-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes wire-breathe {
  0%,
  100% {
    opacity: 0.92;
  }

  50% {
    opacity: 1;
  }
}

#overlay {
  --cursor-x: 50%;
  --cursor-y: 50%;
  --hover-alpha: 0;
  --grid-size: 48px;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 10, 20, 0.9);
  user-select: none;
  z-index: 20;
  overflow: hidden;
}

#overlay::before {
  content: "";
  position: absolute;
  inset: -3%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M0 0H48M0 0V48' fill='none' stroke='%23ffd84d' stroke-opacity='0.38' stroke-width='1'/%3E%3Ccircle cx='0' cy='0' r='1.1' fill='%23fff0a6' fill-opacity='0.58'/%3E%3C/svg%3E");
  background-size: var(--grid-size) var(--grid-size);
  background-position: center center;
  opacity: 0.64;
  pointer-events: none;
}

#overlay::after {
  content: "";
  position: absolute;
  inset: -3%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M0 0H48M0 0V48' fill='none' stroke='%23f4f8ff' stroke-opacity='0.94' stroke-width='1.45'/%3E%3Cpath d='M0 -4 L4 0 L0 4 L-4 0 Z' fill='%23f4f8ff' fill-opacity='0.99'/%3E%3C/svg%3E");
  background-size: var(--grid-size) var(--grid-size);
  background-position: center center;
  opacity: calc(var(--hover-alpha) * 0.95);
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.26));
  -webkit-mask-image: radial-gradient(circle 120px at var(--cursor-x) var(--cursor-y), rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.98) 22%, rgba(0, 0, 0, 0.55) 40%, rgba(0, 0, 0, 0) 62%);
  mask-image: radial-gradient(circle 120px at var(--cursor-x) var(--cursor-y), rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.98) 22%, rgba(0, 0, 0, 0.55) 40%, rgba(0, 0, 0, 0) 62%);
  pointer-events: none;
}

#overlay-card {
  --receipt-tilt-x: 0deg;
  --receipt-tilt-y: 0deg;
  --receipt-shine-x: 50%;
  --receipt-shine-y: 50%;
  position: relative;
  z-index: 1;
  width: min(390px, 88vw);
  display: grid;
  gap: 10px;
  padding: 20px 20px 14px;
  color: #0a0a0a;
  background: linear-gradient(180deg, #f5f5f5 0%, #ececec 68%, #e3e3e3 100%);
  border: 1px solid #d1d1d1;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(var(--receipt-tilt-x)) rotateY(var(--receipt-tilt-y));
  transition: transform 100ms linear, box-shadow 160ms ease;
  cursor: pointer;
}

#overlay-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--receipt-shine-x) var(--receipt-shine-y), rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0) 54%);
  pointer-events: none;
}

#overlay-eyebrow {
  margin: 0;
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.78;
}

.receipt-barcode {
  height: 44px;
  border: 1px solid #2c2c2c;
  background: repeating-linear-gradient(
    90deg,
    #0e0e0e 0,
    #0e0e0e 2px,
    transparent 2px,
    transparent 4px,
    #0e0e0e 4px,
    #0e0e0e 5px,
    transparent 5px,
    transparent 8px
  );
}

.receipt-title {
  margin: 0;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  font-family: "Times New Roman", Georgia, serif;
  font-style: italic;
}

.receipt-divider {
  border-top: 1px solid rgba(10, 10, 10, 0.35);
}

.receipt-list {
  display: grid;
  gap: 6px;
  font-family: "Space Grotesk", Arial, sans-serif;
}

.receipt-row {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.receipt-row span:first-child {
  opacity: 0.82;
}

.receipt-row span:last-child {
  opacity: 0.95;
}

#begin-btn {
  width: 100%;
  margin-top: 2px;
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f6f6f6;
  background: #0f0f0f;
  border: 1px solid #0f0f0f;
  border-radius: 0;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 100ms ease, opacity 120ms ease, background 140ms ease;
}

#begin-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #1f1f1f;
}

#begin-btn:disabled {
  opacity: 0.64;
  cursor: progress;
}

#overlay-note {
  margin: 0;
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.72;
}

.receipt-tear {
  height: 10px;
  margin-top: 2px;
  background: conic-gradient(from 45deg at 5px 5px, #d8d8d8 90deg, transparent 0) 0 0 / 10px 10px;
  opacity: 0.95;
}

#instruction-receipt {
  position: absolute;
  left: 14px;
  bottom: 98px;
  z-index: 12;
  width: min(340px, calc(100% - 28px));
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

#instruction-receipt.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#instruction-receipt-card {
  display: grid;
  gap: 8px;
  padding: 14px 14px 10px;
  color: #0a0a0a;
  background: linear-gradient(180deg, #f4f4f4 0%, #ebebeb 100%);
  border: 1px solid #d2d2d2;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

#instruction-eyebrow {
  margin: 0;
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.76;
}

.instruction-title {
  font-size: clamp(24px, 4vw, 32px);
}

#instruction-receipt .receipt-list {
  gap: 4px;
}

#instruction-receipt .receipt-row {
  font-size: 9px;
  letter-spacing: 0.05em;
}

#instruction-close-btn {
  width: 100%;
  margin-top: 2px;
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f5f5f5;
  background: #101010;
  border: 1px solid #101010;
  border-radius: 0;
  padding: 8px 10px;
  cursor: pointer;
  transition: opacity 140ms ease, transform 100ms ease;
}

#instruction-close-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

#sound-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: min(220px, calc(100% - 24px));
  display: grid;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(5, 10, 20, 0.45);
  backdrop-filter: blur(2px);
}

.sound-panel-title,
.sound-panel-label {
  margin: 0;
  text-transform: uppercase;
}

.sound-panel-title {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.7);
}

.sound-panel-group {
  display: grid;
  gap: 6px;
}

.sound-panel-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.55);
}

.pv-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
}

.pv-name {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
}

.pv-value {
  font-size: 9px;
  letter-spacing: 0.05em;
  color: rgba(255, 216, 77, 0.95);
}

.pv-track {
  grid-column: 1 / -1;
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.pv-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 216, 77, 0.92), rgba(255, 231, 138, 0.94));
  transition: width 70ms linear;
}

.pv-fill-volume {
  background: linear-gradient(90deg, rgba(255, 216, 77, 0.9), rgba(255, 231, 138, 0.95));
}

.instrument-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.sound-toggle {
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.84);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.sound-toggle.is-active {
  color: #ffd84d;
  border-color: rgba(255, 216, 77, 0.9);
  background: rgba(255, 216, 77, 0.12);
}

.effect-row {
  display: grid;
  gap: 5px;
}

.effect-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.effect-toggle input {
  margin: 0;
  accent-color: #ffd84d;
}

.effect-amount {
  width: 100%;
  margin: 0;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.effect-amount::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffd84d;
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.effect-amount::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffd84d;
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.finger-meter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
}

.finger-meter-name {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.finger-meter-value {
  font-size: 9px;
  letter-spacing: 0.05em;
  color: rgba(255, 216, 77, 0.95);
}

.finger-meter-track {
  grid-column: 1 / -1;
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.finger-meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 216, 77, 0.9), rgba(255, 216, 77, 0.9));
  transition: width 70ms linear;
}

#song-indicator {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 10;
  width: min(560px, calc(100% - 24px));
  display: grid;
  gap: 7px;
  padding: 10px 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(5, 10, 20, 0.48);
  backdrop-filter: blur(2px);
}

#song-controls {
  display: flex;
  gap: 8px;
}

#song-controls button {
  font-family: "Space Grotesk", Arial, sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
}

#song-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#song-title,
#song-time,
#song-hint {
  margin: 0;
}

#song-title {
  font-size: 12px;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#upload-status {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 216, 77, 0.82);
}

#song-progress-track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: visible;
  cursor: pointer;
  touch-action: none;
}

#song-progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ffd84d, #ffd84d);
  position: relative;
}

#song-progress-fill::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffd84d;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
  transform: translate(50%, -50%);
}

#song-time {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.68);
}

#song-hint {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.52);
}

@media (max-width: 820px) {
  #sound-panel {
    top: auto;
    bottom: 152px;
    right: 12px;
    width: min(250px, calc(100% - 24px));
  }

  #instruction-receipt {
    left: 12px;
    bottom: 140px;
    width: min(320px, calc(100% - 24px));
  }
}
