:root {
  --bg: #12141c;
  --bg2: #1b1f2b;
  --text: #ebebf5;
  --dim: #969bab;
  --accent: #5ac8ff;
  --card: rgba(28, 32, 46, 0.92);
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0c0d12;
  color: #ebebf5;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- 悬浮按钮 ---------- */
.float-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  z-index: 30;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20, 24, 36, 0.7);
  color: #ebebf5;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: none;
}
.float-btn.show { display: block; }

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(120% 120% at 50% 0%, #161a26 0%, #0c0d12 70%);
  overflow-y: auto;
}
.overlay.translucent {
  background: rgba(8, 9, 14, 0.55);
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }

.card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}
.card.wide { max-width: 620px; }
.card.center { text-align: center; }

.title {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #5ac8ff, #b388ff 60%, #ff6f91);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title.sm { font-size: 26px; margin-bottom: 16px; }
.subtitle { margin: 0 0 18px; color: var(--dim); font-size: 14px; }

.howto {
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.9;
  color: #c9cde0;
  margin-bottom: 16px;
}
.howto b { color: #fff; }
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
}
.dot.tap { background: #5ac8ff; }
.dot.hold { background: #78a0dc; }
.dot.catch { background: #f0cd46; }
.dot.flick { background: #ff5f5f; }

.settings-line {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 16px;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.btn-col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin: 8px 0 14px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #ebebf5;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: rgba(90, 200, 255, 0.12); border-color: rgba(90, 200, 255, 0.5); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(90deg, #2f8fff, #5ac8ff);
  border-color: transparent;
  color: #06121f;
}

.hint { color: var(--dim); font-size: 12px; margin-top: 14px; }
.hint.center { text-align: center; }
/* 移动端隐藏键盘按键提示 */
.touch .pc-hint { display: none; }

/* ---------- 选谱列表 ---------- */
.chart-list { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.chart-item {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
}
.chart-item:active { transform: scale(0.99); }
.chart-item.selected {
  border-color: rgba(90, 200, 255, 0.8);
  background: rgba(90, 200, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(90, 200, 255, 0.4) inset;
}
.chart-name { font-size: 16px; font-weight: 700; color: #fff; }
.chart-name .diff { color: var(--accent); font-weight: 600; font-size: 13px; margin-left: 8px; }
.chart-sub { font-size: 12px; color: var(--dim); margin-top: 4px; }

/* ---------- 设置 ---------- */
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}
.setting-row label { width: 72px; font-size: 14px; color: #c9cde0; }
.setting-row input[type="range"] { flex: 1; accent-color: #5ac8ff; }
.setting-row .val { width: 56px; text-align: right; font-size: 14px; color: var(--accent); font-weight: 700; }
.preview {
  width: 100%;
  height: 180px;
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  display: block;
}

/* ---------- 结算 ---------- */
.rating {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  margin: 6px 0 16px;
  text-shadow: 0 0 24px rgba(90, 200, 255, 0.5);
}
.stats {
  text-align: left;
  font-size: 15px;
  line-height: 2;
  color: #d6d9ea;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.stats .c-perfect { color: #ffc83c; }   /* 普通 PERFECT = 金 */
.stats .c-great { color: #c8cdda; }        /* GREAT = 银 */
.stats .c-good { color: #6ee68c; }         /* GOOD = 绿 */
.stats .c-miss { color: #969ba5; }         /* MISS = 灰 */
.stats .c-bad { color: #969ba5; }          /* BAD = 灰（与 MISS 一致） */
.stats .c-miracle { color: #ffffff; text-shadow: 0 0 8px rgba(255,255,255,0.55); }

/* 设置选中行高亮 */
.setting-row.sel { border-color: rgba(90,200,255,0.7); background: rgba(90,200,255,0.08); }
.setting-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: #5ac8ff; cursor: pointer; }

/* 特殊评级 */
.special { margin-bottom: 16px; display: none; }
.special .spec {
  font-size: 18px; font-weight: 800; color: #fff;
  text-shadow: 0 0 18px rgba(90,200,255,0.7);
  margin: 4px 0;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 560px) {
  .title { font-size: 28px; }
  .card { padding: 20px 16px; border-radius: 14px; }
  .howto { font-size: 12px; }
  .btn { padding: 14px 16px; font-size: 16px; }
  .chart-name { font-size: 15px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .card { padding: 14px 18px; }
  .howto { display: none; }
  .title { font-size: 24px; }
}
