: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% 15%, rgba(0, 245, 255, 0.14), transparent 42%),
    radial-gradient(ellipse at 15% 85%, rgba(255, 45, 149, 0.12), transparent 38%),
    radial-gradient(ellipse at 85% 75%, 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% 45%, black 20%, transparent 72%);
  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: 42%;
  transform: translate(-50%, -50%) scale(0.6);
  z-index: 5;
  pointer-events: none;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-size: clamp(42px, 12vw, 56px);
  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-pad {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(12% + env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  width: min(220px, 58vw);
  height: min(220px, 58vw);
  appearance: none;
  border: none;
  border-radius: 50%;
  background: rgba(5, 5, 12, 0.55);
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 2px rgba(0, 245, 255, 0.35),
    0 0 32px rgba(0, 245, 255, 0.15),
    inset 0 0 40px rgba(0, 245, 255, 0.06);
  animation: pad-glow 2.4s ease-in-out infinite;
}

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

.tap-pad::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--void), var(--void)) padding-box,
    linear-gradient(135deg, var(--cyan), var(--magenta), var(--lime), var(--cyan)) border-box;
  opacity: 0.55;
  animation: border-spin 4s linear infinite;
  pointer-events: none;
}

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

.tap-pad.perfect-hit {
  box-shadow:
    0 0 0 3px var(--lime),
    0 0 48px rgba(200, 255, 0, 0.55),
    inset 0 0 50px rgba(200, 255, 0, 0.12);
}

.tap-pad.good-hit {
  box-shadow:
    0 0 0 3px var(--cyan),
    0 0 40px rgba(0, 245, 255, 0.5),
    inset 0 0 40px rgba(0, 245, 255, 0.1);
}

.tap-pad.miss-hit {
  box-shadow:
    0 0 0 3px var(--magenta),
    0 0 36px rgba(255, 45, 149, 0.5),
    inset 0 0 30px rgba(255, 45, 149, 0.1);
}

.tap-ring {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 2px dashed rgba(0, 245, 255, 0.35);
  pointer-events: none;
}

.tap-label {
  position: relative;
  font-family: "Bagel Fat One", "Chakra Petch", cursive;
  font-size: clamp(28px, 8vw, 36px);
  letter-spacing: 0.14em;
  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-pad:active {
  transform: translateX(-50%) scale(0.94);
}

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

@keyframes pad-vibe {
  0% {
    transform: translateX(-50%) scale(1);
  }
  40% {
    transform: translateX(calc(-50% + 2px)) scale(0.97);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes border-spin {
  to {
    transform: rotate(360deg);
  }
}

.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: 50%;
  margin-bottom: 10px;
  box-shadow:
    0 0 0 3px rgba(0, 245, 255, 0.35),
    0 0 28px rgba(255, 45, 149, 0.45),
    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(38px, 11vw, 54px);
  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: 72px;
  margin: 12px 0 8px;
  display: grid;
  place-items: center;
}

.demo-ring {
  position: absolute;
  border-radius: 50%;
  border-style: solid;
  pointer-events: none;
}

.demo-ring.outer {
  width: 64px;
  height: 64px;
  border-width: 3px;
  border-color: var(--magenta);
  box-shadow: 0 0 16px rgba(255, 45, 149, 0.55);
  animation: demo-shrink 1.4s ease-in-out infinite;
}

.demo-ring.target {
  width: 28px;
  height: 28px;
  border-width: 3px;
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 245, 255, 0.65);
}

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

@keyframes demo-shrink {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  55% {
    transform: scale(0.48);
    opacity: 1;
  }
  70% {
    transform: scale(0.44);
    opacity: 1;
  }
}

.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;
}

.pulse-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(200px, 55vw);
  margin: 0 auto;
  height: 48px;
}

.pulse-preview i {
  display: block;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 14px rgba(0, 245, 255, 0.45);
  animation: preview-pulse 1.2s ease-in-out infinite;
}

.pulse-preview i:nth-child(1) {
  width: 44px;
  height: 44px;
  animation-delay: 0s;
}

.pulse-preview i:nth-child(2) {
  width: 28px;
  height: 28px;
  border-color: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.5);
  animation-delay: 0.15s;
}

.pulse-preview i:nth-child(3) {
  width: 16px;
  height: 16px;
  border-color: var(--lime);
  box-shadow: 0 0 10px rgba(200, 255, 0, 0.5);
  animation-delay: 0.3s;
}

@keyframes preview-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.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);
  }
}
