:root {
  --void: #05050c;
  --cyan: #00f5ff;
  --magenta: #ff2d95;
  --lime: #c8ff00;
  --ink: #eef6ff;
  --muted: #7a8aa8;
  --panel: rgba(5, 5, 12, 0.78);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Chakra Petch", system-ui, sans-serif;
  background: var(--void);
  display: flex;
  align-items: stretch;
  justify-content: center;
  color: var(--ink);
}

.stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  overflow: hidden;
  background: var(--void);
}

.stage-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 12%, rgba(0, 245, 255, 0.14), transparent 42%),
    radial-gradient(ellipse at 12% 88%, rgba(255, 45, 149, 0.12), transparent 38%),
    radial-gradient(ellipse at 88% 78%, rgba(200, 255, 0, 0.08), transparent 40%),
    linear-gradient(180deg, #0a0a18 0%, var(--void) 50%, #020208 100%);
  pointer-events: none;
  z-index: 0;
}

.grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 50% 42%, black 18%, transparent 74%);
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 6;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(255, 255, 255, 0.012) 2px 3px
  );
  opacity: 0.55;
}

canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
  pointer-events: none;
  z-index: 4;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 245, 255, 0.18);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.panel.right {
  align-items: flex-end;
  justify-self: end;
  border-color: rgba(255, 45, 149, 0.22);
}

.panel b {
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 245, 255, 0.55);
}

.song-name {
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b8c8e8;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0.02em;
}

.combo-burst {
  text-align: center;
  min-width: 88px;
  opacity: 0.3;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.combo-burst.on {
  opacity: 1;
  transform: scale(1.1);
}

.combo-burst em {
  display: block;
  font-style: normal;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-size: 36px;
  line-height: 1;
  color: var(--lime);
  text-shadow:
    0 0 18px rgba(200, 255, 0, 0.75),
    0 0 28px rgba(0, 245, 255, 0.45);
}

.combo-burst span {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.lives {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.life {
  width: 10px;
  height: 10px;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
  background: linear-gradient(180deg, var(--magenta), #c01060);
  box-shadow: 0 0 10px rgba(255, 45, 149, 0.65);
}

.life.empty {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.judge-flash {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.6);
  z-index: 5;
  pointer-events: none;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-size: clamp(38px, 11vw, 52px);
  letter-spacing: 0.06em;
  opacity: 0;
  transition: none;
}

.judge-flash.perfect {
  color: var(--lime);
  text-shadow:
    0 0 24px rgba(200, 255, 0, 0.9),
    0 0 48px rgba(0, 245, 255, 0.5);
  animation: judge-pop 0.55s cubic-bezier(0.22, 1.1, 0.36, 1) forwards;
}

.judge-flash.good {
  color: var(--cyan);
  text-shadow:
    0 0 20px rgba(0, 245, 255, 0.85),
    0 0 40px rgba(255, 45, 149, 0.35);
  animation: judge-pop 0.5s cubic-bezier(0.22, 1.05, 0.36, 1) forwards;
}

.judge-flash.miss {
  color: var(--magenta);
  text-shadow:
    0 0 20px rgba(255, 45, 149, 0.85),
    0 0 36px rgba(255, 45, 149, 0.4);
  animation: judge-pop 0.45s ease-out forwards;
}

@keyframes judge-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(0.95);
  }
}

.tap-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  appearance: none;
  border: none;
  height: max(88px, calc(72px + env(safe-area-inset-bottom)));
  padding-bottom: env(safe-area-inset-bottom);
  background:
    linear-gradient(180deg, rgba(5, 5, 12, 0.2) 0%, rgba(5, 5, 12, 0.92) 28%, rgba(8, 8, 22, 0.98) 100%);
  border-top: 2px solid rgba(0, 245, 255, 0.35);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  box-shadow:
    0 -8px 32px rgba(0, 245, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: bar-glow 2.6s ease-in-out infinite;
}

.tap-bar.hidden {
  display: none;
}

.tap-bar-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 245, 255, 0.08) 25%,
    rgba(255, 45, 149, 0.1) 50%,
    rgba(200, 255, 0, 0.08) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: bar-sweep 3s linear infinite;
  pointer-events: none;
}

.tap-bar-scan {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--lime));
  opacity: 0.65;
  animation: bar-scan 2s ease-in-out infinite;
  pointer-events: none;
}

.tap-bar-label {
  position: relative;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: 0.22em;
  color: var(--ink);
  text-shadow:
    0 0 16px rgba(0, 245, 255, 0.6),
    0 0 28px rgba(255, 45, 149, 0.35);
  pointer-events: none;
}

.tap-bar-hint {
  position: relative;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  pointer-events: none;
}

.tap-bar.vibe {
  animation: bar-vibe 0.12s ease-out;
}

.tap-bar.perfect-hit {
  border-top-color: var(--lime);
  box-shadow:
    0 -4px 40px rgba(200, 255, 0, 0.45),
    inset 0 0 40px rgba(200, 255, 0, 0.1);
}

.tap-bar.good-hit {
  border-top-color: var(--cyan);
  box-shadow:
    0 -4px 36px rgba(0, 245, 255, 0.4),
    inset 0 0 30px rgba(0, 245, 255, 0.08);
}

.tap-bar.miss-hit {
  border-top-color: var(--magenta);
  box-shadow:
    0 -4px 32px rgba(255, 45, 149, 0.45),
    inset 0 0 28px rgba(255, 45, 149, 0.1);
}

.tap-bar:active {
  transform: scaleY(0.97);
  filter: brightness(1.08);
}

@keyframes bar-glow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.06);
  }
}

@keyframes bar-sweep {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes bar-scan {
  0%,
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
  20% {
    opacity: 0.8;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes bar-vibe {
  0% {
    transform: scaleY(1);
  }
  40% {
    transform: scaleY(0.96);
  }
  100% {
    transform: scaleY(1);
  }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 8%, rgba(0, 245, 255, 0.18), transparent 38%),
    radial-gradient(circle at 80% 90%, rgba(255, 45, 149, 0.12), transparent 35%),
    linear-gradient(180deg, rgba(5, 5, 12, 0.97), rgba(8, 8, 20, 0.99));
}

.overlay.hidden {
  display: none;
}

.hero-art {
  position: relative;
  width: min(42vw, 168px);
  height: min(42vw, 168px);
  object-fit: cover;
  border-radius: 22px;
  margin-bottom: 10px;
  box-shadow:
    0 0 0 3px rgba(0, 245, 255, 0.3),
    0 0 24px rgba(200, 255, 0, 0.25),
    0 12px 28px rgba(0, 0, 0, 0.55);
}

.badge {
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  color: var(--void);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 8px;
  box-shadow: 0 0 28px rgba(255, 45, 149, 0.45);
}

.badge.soft {
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  box-shadow: 0 0 28px rgba(200, 255, 0, 0.4);
}

h1 {
  position: relative;
  margin: 0;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-weight: 400;
  font-size: clamp(36px, 10vw, 52px);
  color: #fff;
  text-shadow:
    0 0 22px rgba(0, 245, 255, 0.55),
    0 0 44px rgba(255, 45, 149, 0.35);
}

.overlay > p {
  position: relative;
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 15px;
}

.overlay > p b {
  color: var(--cyan);
}

.overlay > p.lead {
  margin: 6px 0 10px;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #b8c8e8;
}

.howto {
  position: relative;
  width: min(100%, 340px);
  margin: 0 0 12px;
  padding: 12px 12px 10px;
  text-align: left;
  border: 1px solid rgba(0, 245, 255, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(0, 245, 255, 0.08), transparent 42%),
    rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 28px rgba(0, 245, 255, 0.1);
}

.howto-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--lime);
}

.howto-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.howto-steps li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: #c5d2ea;
}

.howto-steps .num {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--void);
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
}

.howto-steps .c-cyan {
  color: var(--cyan);
}

.howto-steps .c-mag {
  color: var(--magenta);
}

.howto-steps .c-lime {
  color: var(--lime);
}

.howto-demo {
  position: relative;
  height: 78px;
  margin: 12px 0 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.demo-lane {
  position: absolute;
  left: 10px;
  right: 18px;
  height: 2px;
  background: rgba(0, 245, 255, 0.18);
  top: 18px;
}

.demo-lane.mid {
  top: 38px;
  background: rgba(255, 45, 149, 0.22);
}

.demo-lane:last-of-type {
  top: 58px;
  background: rgba(200, 255, 0, 0.2);
}

.demo-note {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  left: 12px;
  box-shadow: 0 0 10px currentColor;
  animation: demo-slide 1.6s linear infinite;
}

.demo-note.n0 {
  top: 13px;
  color: #00f5ff;
  background: #00f5ff;
  animation-delay: 0s;
}

.demo-note.n1 {
  top: 33px;
  color: #ff2d95;
  background: #ff2d95;
  animation-delay: 0.45s;
}

.demo-note.n2 {
  top: 53px;
  color: #c8ff00;
  background: #c8ff00;
  animation-delay: 0.9s;
}

.demo-judge {
  position: absolute;
  top: 8px;
  bottom: 18px;
  right: 14px;
  width: 3px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.demo-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--lime);
  text-shadow: 0 0 10px rgba(200, 255, 0, 0.45);
}

@keyframes demo-slide {
  0% {
    left: 12px;
    opacity: 0.35;
  }
  10% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    left: calc(100% - 28px);
    opacity: 0.2;
  }
}

.howto-keys {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.howto-keys kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 245, 255, 0.35);
  background: rgba(0, 245, 255, 0.1);
  color: var(--cyan);
  font-family: inherit;
  font-size: 10px;
}

.song-box {
  position: relative;
  width: min(100%, 340px);
  margin-bottom: 12px;
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  box-shadow: 0 0 24px rgba(0, 245, 255, 0.08);
  max-height: 140px;
  display: flex;
  flex-direction: column;
}

.song-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid rgba(0, 245, 255, 0.1);
}

.song-head #pick-label {
  color: #c8d8f8;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-list {
  flex: 1;
  min-height: 0;
  max-height: min(18vh, 110px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  text-align: left;
  padding: 6px;
}

.song-item {
  width: 100%;
  appearance: none;
  border: none;
  background: transparent;
  color: #d0dcf8;
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.song-item:hover,
.song-item.on {
  background: linear-gradient(90deg, rgba(255, 45, 149, 0.22), rgba(0, 245, 255, 0.14));
  box-shadow: inset 2px 0 0 var(--magenta);
}

.song-item .meta {
  color: var(--lime);
  font-size: 11px;
  flex-shrink: 0;
  font-weight: 600;
}

.controls {
  position: relative;
  margin-bottom: 10px;
}

.slide-preview {
  position: relative;
  width: min(260px, 72vw);
  height: 72px;
  margin: 0 auto;
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.slide-preview .lane {
  position: absolute;
  left: 8%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: preview-slide 1.8s ease-in-out infinite;
}

.slide-preview .lane-0 {
  top: 14px;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.7);
  animation-delay: 0s;
}

.slide-preview .lane-1 {
  top: 30px;
  background: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.7);
  animation-delay: 0.35s;
}

.slide-preview .lane-2 {
  top: 46px;
  background: var(--lime);
  box-shadow: 0 0 12px rgba(200, 255, 0, 0.7);
  animation-delay: 0.7s;
}

.slide-preview .judge-mark {
  position: absolute;
  right: 12%;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta), var(--lime));
  box-shadow: 0 0 14px rgba(0, 245, 255, 0.6);
}

@keyframes preview-slide {
  0% {
    left: 8%;
    opacity: 0.4;
    transform: scale(0.85);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    left: 78%;
    opacity: 0.9;
    transform: scale(1.05);
  }
}

.sub {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.btn {
  position: relative;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 42px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--void);
  background: linear-gradient(90deg, var(--magenta), var(--cyan) 55%, var(--lime));
  box-shadow:
    0 6px 0 #0a2840,
    0 0 32px rgba(0, 245, 255, 0.4);
  cursor: pointer;
  margin-top: 4px;
}

.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #0a2840,
    0 0 20px rgba(0, 245, 255, 0.3);
}

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(0, 245, 255, 0.3);
  box-shadow: none;
}

a {
  position: relative;
  margin-top: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

@media (min-width: 520px) {
  body {
    align-items: center;
    background:
      radial-gradient(circle at 50% 18%, rgba(0, 245, 255, 0.12), transparent 42%),
      var(--void);
  }

  .stage {
    height: min(100dvh, 780px);
    border-radius: 22px;
    border: 1px solid rgba(0, 245, 255, 0.15);
    box-shadow:
      0 30px 80px rgba(0, 0, 0, 0.7),
      0 0 60px rgba(255, 45, 149, 0.08);
  }
}
