/* ================= 我的音符 · 样式 ================= */
:root {
  --bg: #07080f;
  --panel: rgba(19, 22, 36, 0.66);
  --panel-line: rgba(255, 255, 255, 0.08);
  --text: #e9edf7;
  --muted: #8b93ab;
  --cyan: #22d3ee;
  --violet: #a855f7;
  --pink: #f472b6;
  --lime: #a3e635;
  --danger: #fb7185;
  --lane-1: #22d3ee;
  --lane-2: #a855f7;
  --lane-3: #f472b6;
  --lane-4: #fbbf24;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

.bg-grid {
  position: fixed; inset: -10%;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(600px) rotateX(52deg) translateY(10%);
  transform-origin: center 70%;
  pointer-events: none;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(60vw 40vh at 12% 8%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(55vw 45vh at 88% 92%, rgba(168, 85, 247, 0.18), transparent 62%),
    radial-gradient(45vw 35vh at 70% 10%, rgba(244, 114, 182, 0.10), transparent 65%);
  filter: blur(6px);
}

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity .28s ease, transform .28s ease;
  transform: scale(.99);
  z-index: 1;
}
.screen.active { opacity: 1; visibility: visible; transform: none; }
.screen.center { align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }

.glass {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; letter-spacing: .02em;
  border-radius: 12px; padding: 12px 20px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease, opacity .16s;
  user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(120deg, var(--cyan), var(--violet));
  color: #05060d;
  box-shadow: 0 12px 28px -12px rgba(34, 211, 238, .8);
}
.btn-primary:hover { background: linear-gradient(120deg, #38e0f8, #b76bff); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--panel-line); }
.btn-block { width: 100%; display: block; margin-top: 10px; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; }
.btn-row .btn { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--panel-line);
  border-radius: 11px; color: var(--text); cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- 登录 ---------- */
.auth-card { width: min(400px, 100%); padding: 30px 26px 24px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand-mark {
  width: 58px; height: 58px; margin: 0 auto 14px;
  display: grid; place-items: center;
  font-size: 30px; border-radius: 18px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #05060d;
  box-shadow: 0 16px 36px -14px rgba(168, 85, 247, .9);
}
.brand h1 { margin: 0; font-size: 25px; letter-spacing: .04em; }
.brand p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 4px;
  margin-bottom: 20px;
}
.tabs .tab {
  position: relative; z-index: 1; appearance: none; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 0; cursor: pointer; border-radius: 9px; transition: color .2s;
}
.tabs .tab.active { color: #05060d; }
.tab-indicator {
  position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px);
  border-radius: 9px; background: linear-gradient(120deg, var(--cyan), var(--violet));
  transition: transform .26s cubic-bezier(.4, 1.4, .6, 1);
}
.tabs[data-active="register"] .tab-indicator { transform: translateX(100%); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; letter-spacing: .04em; }
.field input {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 15px;
  color: var(--text); background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-line); border-radius: 12px; outline: none;
  transition: border-color .2s, background .2s;
}
.field input:focus { border-color: rgba(34, 211, 238, .65); background: rgba(34, 211, 238, .06); }
.field input::placeholder { color: #5b6480; }
.form-error { min-height: 18px; margin: 4px 0 6px; font-size: 12.5px; color: var(--danger); }
.auth-foot { text-align: center; font-size: 11.5px; color: #5b6480; margin: 16px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; flex-shrink: 0;
}
.logo { font-weight: 700; letter-spacing: .05em; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.logo span {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
  background: linear-gradient(135deg, var(--cyan), var(--violet)); color: #05060d; font-size: 17px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-line);
  color: #cfd6e6; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 主区 ---------- */
.home {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 380px 1fr;
  gap: 18px; padding: 0 22px 22px;
}
.panel { padding: 20px; display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.count {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: rgba(255, 255, 255, 0.07); padding: 2px 8px; border-radius: 999px;
}
.hint { font-size: 11.5px; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); }
.head-actions { display: flex; gap: 8px; }

.dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px; padding: 26px 16px; text-align: center;
  cursor: pointer; transition: all .2s ease; outline: none;
  background: rgba(255, 255, 255, 0.02);
}
.dropzone:hover, .dropzone:focus-visible { border-color: rgba(34, 211, 238, .6); background: rgba(34, 211, 238, .06); }
.dropzone.drag { border-color: var(--cyan); background: rgba(34, 211, 238, .12); transform: scale(1.01); }
.dz-icon {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px;
  display: grid; place-items: center; color: var(--cyan);
  background: rgba(34, 211, 238, .12); border: 1px solid rgba(34, 211, 238, .25);
}
.dropzone p { margin: 0 0 6px; font-size: 14px; }
.dropzone p b { color: var(--cyan); }
.dropzone small { color: var(--muted); font-size: 11.5px; line-height: 1.6; }

.upload-status { margin-top: 14px; }
.upload-status .bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.upload-status .bar i { display: block; height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .25s ease; }
.upload-status span { display: block; margin-top: 7px; font-size: 11.5px; color: var(--muted); }

.control-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.control-row.wrap { flex-wrap: wrap; gap: 14px; }
.label { font-size: 12px; color: var(--muted); letter-spacing: .05em; flex-shrink: 0; }
.segmented { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 11px; flex: 1; }
.segmented button {
  flex: 1; appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 0; border-radius: 8px; cursor: pointer;
  transition: all .18s ease;
}
.segmented button.active { background: rgba(34, 211, 238, .16); color: var(--cyan); box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .3); }

.inline-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.inline-field.grow { flex: 1; min-width: 190px; }
.inline-field b { color: var(--text); font-size: 12px; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.inline-field select {
  appearance: none; font: inherit; font-size: 12.5px; color: var(--text);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--panel-line);
  border-radius: 9px; padding: 6px 10px; outline: none; cursor: pointer;
}
.inline-field select option { background: #12141f; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; flex: 1;
  background: rgba(255, 255, 255, 0.14); border-radius: 999px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet)); border: 2px solid #0b0d16;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, .5);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #0b0d16;
  background: var(--cyan);
}

/* ---------- 曲库 ---------- */
.song-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.song-list::-webkit-scrollbar { width: 6px; }
.song-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 999px; }
.empty-state {
  margin: auto; text-align: center; color: #56607a; font-size: 13px; padding: 40px 0;
}

.song-item {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  padding: 12px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.035); border: 1px solid transparent;
  transition: all .18s ease;
}
.song-item:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(34, 211, 238, .28); transform: translateX(2px); }
.song-art {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #05060d; overflow: hidden; position: relative;
}
.song-art::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.45), transparent 55%);
}
.song-info { min-width: 0; }
.song-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.song-sub .dot::before { content: '·'; margin-right: 8px; color: #3b4358; }
.song-badges { display: flex; gap: 5px; margin-top: 6px; }
.badge {
  font-size: 10.5px; padding: 2px 7px; border-radius: 6px; letter-spacing: .03em;
  background: rgba(255, 255, 255, 0.06); color: #9aa4bd;
}
.badge.easy { color: #7dd3fc; background: rgba(56, 189, 248, .12); }
.badge.normal { color: #c4b5fd; background: rgba(168, 85, 247, .14); }
.badge.hard { color: #fda4af; background: rgba(251, 113, 133, .14); }
.song-play {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(34, 211, 238, .2), rgba(168, 85, 247, .2));
  border: 1px solid rgba(34, 211, 238, .35); color: var(--cyan); flex-shrink: 0;
}
.song-item:hover .song-play { background: linear-gradient(135deg, var(--cyan), var(--violet)); color: #05060d; }
.song-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.board-btn {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-line);
  color: var(--muted); cursor: pointer; transition: all .18s;
}
.board-btn:hover { color: var(--cyan); border-color: rgba(34, 211, 238, .4); background: rgba(34, 211, 238, .1); }
.song-best {
  font-size: 10.5px; color: var(--lime); font-variant-numeric: tabular-nums;
  min-width: 52px; text-align: right; white-space: nowrap;
}
.song-best.none { color: #46506a; }

/* ---------- 游戏 ---------- */
.screen-game { background: #04050a; }
.game-wrap { position: absolute; inset: 0; overflow: hidden; }
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.game-hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; z-index: 3;
}
.hud-left { text-align: left; }
.hud-score { font-size: 26px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgba(34, 211, 238, .5); }
.hud-acc { font-size: 12px; color: var(--cyan); font-variant-numeric: tabular-nums; }
.hud-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.hud-song { font-size: 11.5px; color: var(--muted); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.combo-box {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 2;
}
.combo-box.show { opacity: 1; }
.combo-num { font-size: 46px; font-weight: 900; line-height: 1; font-style: italic; color: #fff; text-shadow: 0 0 24px rgba(168, 85, 247, .85), 0 0 46px rgba(34, 211, 238, .5); }
.combo-label { font-size: 11px; letter-spacing: .35em; color: rgba(255,255,255,.62); margin-top: 4px; }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 76px; font-weight: 900; color: #fff; z-index: 4; pointer-events: none;
  text-shadow: 0 0 40px rgba(34, 211, 238, .8); opacity: 0;
}
.countdown.tick { animation: cdPop .62s ease-out; }
@keyframes cdPop {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.86); }
}

.pause-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center; padding: 20px;
  background: rgba(4, 5, 10, .78); backdrop-filter: blur(8px);
}
.pause-card { width: min(380px, 100%); padding: 24px; }
.pause-card h3 { margin: 0 0 6px; font-size: 18px; }
.kbd-tip { font-size: 11.5px; color: var(--muted); text-align: center; margin: 14px 0 0; }
.kbd-tip b { color: #cfd6e6; letter-spacing: .1em; }

/* ---------- 结算 ---------- */
.result-card { width: min(430px, 100%); padding: 26px 24px; text-align: center; }
.result-song { margin: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade {
  font-size: 62px; font-weight: 900; line-height: 1.05; font-style: italic;
  margin: 6px 0 0; letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff, #9fb4ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(34, 211, 238, .45));
}
.grade[data-grade="SSS"], .grade[data-grade="SS"] { background: linear-gradient(135deg, #fde68a, #f472b6, #a855f7); -webkit-background-clip: text; background-clip: text; }
.grade[data-grade="S"] { background: linear-gradient(135deg, #a5f3fc, #22d3ee); -webkit-background-clip: text; background-clip: text; }
.grade[data-grade="A"] { background: linear-gradient(135deg, #bbf7d0, #34d399); -webkit-background-clip: text; background-clip: text; }
.grade[data-grade="B"], .grade[data-grade="C"] { background: linear-gradient(135deg, #cbd5e1, #64748b); -webkit-background-clip: text; background-clip: text; }
.score-big { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .01em; margin-top: 2px; }
.result-meta { font-size: 12.5px; color: var(--muted); margin: 8px 0 18px; }

.judge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.judge { padding: 10px 4px; border-radius: 11px; background: rgba(255, 255, 255, 0.04); }
.judge span { display: block; font-size: 9.5px; letter-spacing: .08em; color: var(--muted); }
.judge b { font-size: 17px; font-variant-numeric: tabular-nums; }
.judge.perfect b { color: #67e8f9; }
.judge.great b { color: #c4b5fd; }
.judge.good b { color: #fcd34d; }
.judge.miss b { color: var(--danger); }

.result-tip { font-size: 12px; margin: 16px 0 0; min-height: 17px; color: var(--lime); }
.result-tip.err { color: var(--danger); }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 18px;
  background: rgba(3, 4, 9, .72); backdrop-filter: blur(10px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal-card { width: min(460px, 100%); max-height: 82vh; display: flex; flex-direction: column; padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.board-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.board-tabs button {
  flex: 1; appearance: none; border: 0; cursor: pointer; font: inherit; font-size: 12.5px;
  font-weight: 600; padding: 8px 0; border-radius: 9px; color: var(--muted);
  background: rgba(255, 255, 255, 0.05); transition: all .18s;
}
.board-tabs button.active { background: rgba(34, 211, 238, .16); color: var(--cyan); }
.board-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.board-list::-webkit-scrollbar { width: 6px; }
.board-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 999px; }
.board-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 11px; border-radius: 11px; background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
}
.board-row.me { background: rgba(34, 211, 238, .12); box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .3); }
.board-row .rk { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.board-row:nth-child(1) .rk { color: #fcd34d; }
.board-row:nth-child(2) .rk { color: #e2e8f0; }
.board-row:nth-child(3) .rk { color: #fb923c; }
.board-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .nm small { display: block; font-size: 10.5px; color: #66708a; margin-top: 2px; }
.board-row .sc { font-variant-numeric: tabular-nums; font-weight: 700; }
.board-empty { text-align: center; color: #56607a; font-size: 13px; padding: 30px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b));
  transform: translate(-50%, 20px); z-index: 50;
  padding: 11px 20px; border-radius: 12px; font-size: 13px;
  background: rgba(20, 23, 38, .96); border: 1px solid var(--panel-line);
  box-shadow: 0 18px 40px -18px #000;
  opacity: 0; pointer-events: none; transition: all .28s cubic-bezier(.4, 1.3, .6, 1);
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; gap: 14px; padding: 0 14px calc(14px + var(--safe-b)); overflow-y: auto; align-content: start; }
  .library-panel { min-height: 300px; }
  .topbar { padding: 12px 14px; }
  .panel { padding: 16px; }
  .dropzone { padding: 20px 14px; }
  .hud-score { font-size: 22px; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .combo-box { top: 26%; }
  .combo-num { font-size: 34px; }
}