:root {
  --c0: #ff4d9a;
  --c1: #ffc14d;
  --c2: #00e8ff;
  --c3: #b44dff;
  --ink: #f4f7ff;
  --muted: #9aa8c7;
  --panel: rgba(6, 8, 20, 0.72);
}

* {
  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: "Jua", system-ui, sans-serif;
  background: #03040a;
  display: flex;
  align-items: stretch;
  justify-content: center;
  color: var(--ink);
}

.stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  overflow: hidden;
  background: #05060f;
}

.stage-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(160, 80, 255, 0.38), transparent 42%),
    radial-gradient(ellipse at 18% 88%, rgba(255, 77, 154, 0.22), transparent 40%),
    radial-gradient(ellipse at 82% 86%, rgba(0, 232, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #0a0c1c, #05060f 55%, #020308);
  pointer-events: none;
  z-index: 0;
}

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(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.panel.right {
  align-items: flex-end;
  justify-self: end;
}

.panel b {
  font-size: 18px;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

.song-name {
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b8c4ff;
  font-size: 13px;
}

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

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

.combo-burst em {
  display: block;
  font-style: normal;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-size: 34px;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 18px rgba(255, 77, 154, 0.8),
    0 0 28px rgba(0, 232, 255, 0.5);
}

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

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

.life {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff8ab5, #ff4d9a);
  box-shadow: 0 0 8px rgba(255, 77, 154, 0.7);
}

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

.lane-pads {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: max(112px, calc(18% + env(safe-area-inset-bottom)));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 8px max(10px, env(safe-area-inset-bottom));
  z-index: 5;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55) 30%, rgba(0, 0, 0, 0.82));
}

.lane-pads.hidden {
  display: none;
}

.lane-pad {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
  width: min(78px, 20vw);
  max-height: 100%;
  justify-self: center;
  align-self: center;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.22);
}

.lane-pad span {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.9;
  box-shadow:
    0 0 18px currentColor,
    inset 0 0 12px currentColor;
}

.lane-pad.c0 {
  color: var(--c0);
  border-color: rgba(255, 77, 154, 0.75);
  background: radial-gradient(circle at 50% 40%, rgba(255, 77, 154, 0.45), rgba(255, 77, 154, 0.1));
}
.lane-pad.c1 {
  color: var(--c1);
  border-color: rgba(255, 193, 77, 0.75);
  background: radial-gradient(circle at 50% 40%, rgba(255, 193, 77, 0.45), rgba(255, 193, 77, 0.1));
}
.lane-pad.c2 {
  color: var(--c2);
  border-color: rgba(0, 232, 255, 0.75);
  background: radial-gradient(circle at 50% 40%, rgba(0, 232, 255, 0.45), rgba(0, 232, 255, 0.1));
}
.lane-pad.c3 {
  color: var(--c3);
  border-color: rgba(180, 77, 255, 0.75);
  background: radial-gradient(circle at 50% 40%, rgba(180, 77, 255, 0.45), rgba(180, 77, 255, 0.1));
}

.lane-pad:active,
.lane-pad.flash {
  transform: translateY(3px);
  filter: brightness(1.35);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.2),
    0 0 24px currentColor;
}

.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% 10%, rgba(140, 90, 255, 0.35), transparent 40%),
    linear-gradient(180deg, rgba(5, 6, 16, 0.96), rgba(8, 10, 24, 0.98));
}

.overlay.hidden {
  display: none;
}

.hero-art {
  position: relative;
  width: min(46vw, 176px);
  height: min(46vw, 176px);
  object-fit: cover;
  border-radius: 28px;
  margin-bottom: 8px;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.5),
    0 0 0 3px rgba(180, 100, 255, 0.35),
    0 0 28px rgba(255, 77, 154, 0.35);
}

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

.badge {
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, #ff4d9a, #7a5cff);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  box-shadow: 0 0 24px rgba(255, 77, 154, 0.45);
}

.badge.soft {
  background: linear-gradient(90deg, #00e8ff, #b44dff);
  color: #041018;
  box-shadow: 0 0 24px rgba(0, 232, 255, 0.4);
}

h1 {
  position: relative;
  margin: 0;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-weight: 400;
  font-size: clamp(36px, 10vw, 52px);
  color: #fff;
  text-shadow:
    0 0 20px rgba(122, 92, 255, 0.55),
    0 0 40px rgba(255, 77, 141, 0.35);
}

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

.overlay > p b {
  color: #fff;
}

.song-box {
  position: relative;
  width: min(100%, 340px);
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

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

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

.song-list {
  max-height: min(28vh, 180px);
  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: #d7e0ff;
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.song-item:hover,
.song-item.on {
  background: linear-gradient(90deg, rgba(255, 77, 141, 0.28), rgba(122, 92, 255, 0.22));
}

.song-item .bpm {
  color: #ffc14d;
  font-size: 11px;
  flex-shrink: 0;
}

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

.pad-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(260px, 70vw);
  margin: 0 auto;
}

.pad-preview i {
  display: block;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.pad-preview .c0 { background: rgba(255, 77, 154, 0.45); }
.pad-preview .c1 { background: rgba(255, 193, 77, 0.45); }
.pad-preview .c2 { background: rgba(0, 232, 255, 0.45); }
.pad-preview .c3 { background: rgba(180, 77, 255, 0.45); }

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

.btn {
  position: relative;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  font: inherit;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(90deg, #ff4d8d, #7a5cff 55%, #4db8ff);
  box-shadow:
    0 8px 0 #4a2fb0,
    0 0 28px rgba(122, 92, 255, 0.45);
  cursor: pointer;
  margin-top: 4px;
}

.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 4px 0 #4a2fb0,
    0 0 18px rgba(122, 92, 255, 0.35);
}

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.28);
  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% 20%, rgba(122, 92, 255, 0.2), transparent 40%),
      #03040a;
  }

  .stage {
    height: min(100dvh, 780px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
  }
}
