:root {
  --bg: #100818;
  --card: #1c1224;
  --pink: #ff4db8;
  --text: #f8eef6;
  --muted: #b9a0b8;
  --border: rgba(255, 77, 184, 0.35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse 80% 45% at 50% -5%, rgba(255, 77, 184, 0.2), transparent 55%), var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overscroll-behavior: none;
}
.page {
  max-width: 440px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
}
h1 { margin: 0; color: var(--pink); font-size: 1.65rem; letter-spacing: 0.02em; }
.sub { margin: 0.3rem 0 0.7rem; color: var(--muted); font-size: 0.82rem; }
.hud {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.hud strong { color: var(--text); }
.now-playing {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  color: var(--pink);
  font-weight: 700;
}
.now-playing.hidden { display: none; }
.np-meta { color: var(--muted); font-weight: 500; font-size: 0.75rem; }

.stage {
  position: relative;
  display: inline-block;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 12px 36px rgba(0,0,0,0.45);
  touch-action: none;
  background: #0a0610;
  width: min(400px, 100vw - 1.5rem);
}
.bg-video {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}
#board {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  background: transparent;
  vertical-align: top;
  touch-action: none;
}
.overlay {
  position: absolute; inset: 0;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,4,12,0.72);
  padding: 0.75rem;
}
.overlay.hidden { display: none; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  max-width: 300px;
  width: 100%;
}
.card-wide {
  max-width: 340px;
  max-height: min(520px, 85%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card h2 { margin: 0.2rem 0 0.35rem; color: var(--pink); font-size: 1.2rem; }
.card p { margin: 0.3rem 0; font-size: 0.9rem; line-height: 1.4; }
.hint { color: var(--muted); font-size: 0.78rem !important; }
.diff {
  display: flex; flex-direction: column; gap: 0.25rem;
  margin: 0.55rem 0 0.5rem; font-size: 0.8rem; color: var(--muted);
  text-align: left;
}
.diff select {
  font: inherit; color: var(--text);
  background: #120a16; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.4rem;
}

.song-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  text-align: left;
  margin: 0.25rem 0 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.song-btn {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.song-btn:hover, .song-btn:focus-visible {
  background: rgba(255, 77, 184, 0.18);
  border-color: var(--pink);
  outline: none;
}
.song-btn .song-title { font-weight: 700; font-size: 0.92rem; }
.song-btn .song-meta { font-size: 0.72rem; color: var(--muted); }

.btn {
  margin-top: 0.45rem;
  font: inherit; font-weight: 700;
  color: #1a0a14;
  background: linear-gradient(135deg, #ff8ad4, var(--pink));
  border: none; border-radius: 999px;
  padding: 0.55rem 1.4rem; cursor: pointer;
  width: 100%;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-col { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }

.countdown-overlay {
  background: rgba(8, 4, 12, 0.55);
  z-index: 3;
}
.countdown-num {
  font-size: 5.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 24px rgba(255, 77, 184, 0.85), 0 4px 16px rgba(0,0,0,0.6);
  animation: count-pop 0.9s ease;
}
@keyframes count-pop {
  0% { transform: scale(0.6); opacity: 0.3; }
  30% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

kbd {
  font-size: 0.78em; padding: 0.08em 0.35em;
  border-radius: 4px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
}

.touch-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  width: min(400px, 100vw - 1.5rem);
  margin: 0.65rem auto 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.lane-btn {
  appearance: none;
  border: 2px solid var(--lane, #ff4db8);
  background: linear-gradient(180deg, var(--lane, #ff4db8), #120814);
  background: linear-gradient(180deg, color-mix(in srgb, var(--lane) 45%, #1a0a16), #120814);
  border-color: color-mix(in srgb, var(--lane) 70%, #fff);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  border-radius: 14px;
  min-height: 72px;
  padding: 0.85rem 0.25rem;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform 0.05s ease, filter 0.05s ease, box-shadow 0.05s ease;
}
.lane-btn:active,
.lane-btn.pressed {
  transform: translateY(3px) scale(0.97);
  filter: brightness(1.25);
  box-shadow: 0 1px 0 rgba(0,0,0,0.35), inset 0 2px 8px rgba(0,0,0,0.35);
}
.footer { margin-top: 0.75rem; font-size: 0.75rem; color: var(--muted); }

@media (max-height: 720px) {
  .lane-btn { min-height: 58px; font-size: 1.15rem; padding: 0.55rem 0.2rem; }
  h1 { font-size: 1.4rem; }
  .countdown-num { font-size: 4.2rem; }
}
@media (max-height: 600px) {
  .sub { display: none; }
  .lane-btn { min-height: 52px; }
}
