:root {
  --bg: #07070f;
  --panel: rgba(16, 18, 34, 0.86);
  --border: rgba(120, 140, 255, 0.25);
  --text: #e8eaf6;
  --muted: #8a8fb0;
  --red: #ff3b4e;
  --blue: #3aa0ff;
  --accent: #7c9cff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

#menu {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 24px 16px 60px;
  background: radial-gradient(ellipse at top, rgba(30, 20, 70, 0.6), rgba(5, 5, 12, 0.82) 60%);
  backdrop-filter: blur(3px);
}
#menu.hidden { display: none; }

.top { text-align: center; margin-bottom: 20px; }
.top h1 { margin: 0; font-size: clamp(32px, 6vw, 56px); letter-spacing: 1px; font-weight: 900; }
.top .red { color: var(--red); text-shadow: 0 0 18px rgba(255, 59, 78, 0.6); }
.top .blue { color: var(--blue); text-shadow: 0 0 18px rgba(58, 160, 255, 0.6); }
.tag { color: var(--muted); margin: 6px 0 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 12px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.drop span { color: var(--muted); font-size: 14px; }
.drop.over, .drop:hover { border-color: var(--accent); background: rgba(124, 156, 255, 0.08); }

.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.row input[type="text"], .row input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 15px;
}

.btn {
  border: 1px solid var(--accent);
  background: rgba(124, 156, 255, 0.18);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.btn:hover:not(:disabled) { background: rgba(124, 156, 255, 0.32); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 20px; font-size: 17px; flex: 1; }
.btn.vr { border-color: var(--blue); background: linear-gradient(90deg, rgba(255, 59, 78, 0.35), rgba(58, 160, 255, 0.35)); }

.chips { gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}
.chip.active, .chip:hover { border-color: var(--accent); background: rgba(124, 156, 255, 0.2); }

.results { list-style: none; padding: 0; margin: 10px 0 0; max-height: 380px; overflow-y: auto; }
.results li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.results li:hover { background: rgba(124, 156, 255, 0.12); }
.results img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex: none; background: #222; }
.results .r-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-meta { color: var(--muted); font-size: 12px; }
.results li > div { min-width: 0; }

.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.song-head { display: flex; gap: 14px; align-items: center; }
.song-head img { width: 110px; height: 110px; border-radius: 10px; object-fit: cover; background: #222; flex: none; }
.song-title { font-size: 22px; font-weight: 800; word-break: break-word; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; margin-top: 6px; }

.diffs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.diff {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}
.diff[data-d="Easy"] { color: #4cdf8f; }
.diff[data-d="Normal"] { color: #59b0f4; }
.diff[data-d="Hard"] { color: #ff9d3a; }
.diff[data-d="Expert"] { color: #ff4d5e; }
.diff[data-d="ExpertPlus"] { color: #c46cff; }
.diff.active { background: rgba(124, 156, 255, 0.25); border-color: var(--accent); }

.play-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.range { display: block; margin: 12px 0; }
.range output { float: right; color: var(--muted); }
.range input { width: 100%; margin-top: 6px; }
.colors label { display: flex; gap: 6px; align-items: center; margin-right: 12px; }
.colors input { width: 42px; height: 28px; border: none; background: none; padding: 0; }
.help { margin-top: 12px; color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; color: var(--text); }
.help ul { padding-left: 18px; }

.result { max-width: 1200px; margin: 16px auto 0; text-align: center; }
.result .rank { font-size: 48px; font-weight: 900; }
.result .stats { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; color: var(--muted); }

.status {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: rgba(10, 12, 28, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  display: none;
}
.status.show { display: block; }
.status.error { border-color: var(--red); color: #ffb3bb; }

#spectator { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; }
#spectator[hidden] { display: none; }
#spectator-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 32px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(10, 12, 28, 0.75);
  border: 1px solid var(--border);
  font-size: 14px;
}
#spectator-bar[hidden] { display: none; }
#spectator-bar span { margin-right: 4px; }
#spectator-bar .hint { color: var(--muted); font-size: 12px; }
#spectator-bar button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
#spectator-bar button.active, #spectator-bar button:hover { border-color: var(--accent); background: rgba(124, 156, 255, 0.25); }
.select { display: block; margin: 12px 0; }
.select select {
  width: 100%;
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 14px;
}

.results.small { max-height: 220px; }
.results.small img { width: 36px; height: 36px; }
.vr-menu { width: 100%; margin-top: 12px; }
.calib { margin: -4px 0 8px; padding: 10px; border: 1px dashed var(--border); border-radius: 10px; }
.calib .row { margin-top: 0; }
.calib .tap { flex: 1; }
.calib .tap.flash { background: rgba(124, 156, 255, 0.6); }

.model-row { margin-top: -4px; }
.model-row .small-text { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
