/* ============ 设计令牌 ============ */
:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --bg-2: #111827;
  --panel: rgba(23, 31, 51, 0.86);
  --panel-solid: #161e33;
  --line: rgba(120, 150, 220, 0.18);
  --line-strong: rgba(120, 150, 220, 0.36);
  --text: #e8edf7;
  --text-dim: #9aa8c4;
  --text-mute: #6d7a96;
  --brand: #4f8cff;
  --brand-2: #22d3ee;
  --accent: #a855f7;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(4, 8, 20, 0.55);
  --header-bg: rgba(9, 13, 22, 0.82);
  --nav-bg: rgba(9, 13, 22, 0.94);
  --surface: rgba(8, 12, 22, 0.72);
  --board-chrome: rgba(8, 12, 22, 0.6);
  --toast-bg: rgba(18, 24, 40, 0.96);
  --meter-track: rgba(255, 255, 255, 0.08);
  --header-h: 62px;
  --bottom-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(79, 140, 255, 0.22), transparent 60%),
    radial-gradient(800px 480px at 92% 0%, rgba(168, 85, 247, 0.18), transparent 62%),
    radial-gradient(700px 520px at 50% 110%, rgba(34, 211, 238, 0.12), transparent 60%);
  background-attachment: fixed;
}

a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 10px; line-height: 1.3; }
p { margin: 0 0 10px; color: var(--text-dim); line-height: 1.65; }
button { font-family: inherit; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.4);
}

.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }

.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.nav-link:hover { color: var(--text); background: rgba(120, 160, 255, 0.1); }
.nav-link.active { color: #fff; background: linear-gradient(135deg, rgba(79, 140, 255, 0.9), rgba(168, 85, 247, 0.85)); }

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.user-btn:hover { border-color: var(--brand); }

/* ============ 布局 ============ */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; }
.wrap.narrow { max-width: 880px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 6px 0 0; font-size: 14px; }

.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.game { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); align-items: start; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel + .panel { margin-top: 16px; }
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}
.panel-title small { color: var(--text-mute); font-weight: 400; font-size: 12px; }

/* ============ 首页 ============ */
.hero {
  padding: 40px 30px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.16), rgba(168, 85, 247, 0.12) 55%, rgba(34, 211, 238, 0.1));
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.hero h1 { font-size: 32px; letter-spacing: 0.5px; }
.hero .sub { color: var(--text-dim); font-size: 15px; max-width: 640px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card .ico { font-size: 26px; }
.card h3 { font-size: 18px; margin: 0; }
.card p { font-size: 13.5px; margin: 0; }
.card .go { margin-top: auto; color: var(--brand); font-size: 13px; font-weight: 600; }

/* ============ 按钮 / 控件 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--brand); background: rgba(79, 140, 255, 0.14); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--accent)); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(248, 113, 113, 0.5); color: #ffd9d9; }
.btn.danger:hover { background: rgba(248, 113, 113, 0.16); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

.seg { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.04); padding: 5px; border-radius: 12px; border: 1px solid var(--line); }
.seg button {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.seg button.active { background: linear-gradient(135deg, rgba(79, 140, 255, 0.95), rgba(168, 85, 247, 0.9)); color: #fff; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--text-dim); }
.input, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="file"] { font-size: 13px; color: var(--text-dim); }

/* ============ 统计 / 标签 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 10px; }
.stat { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.stat-value { font-size: 19px; font-weight: 700; }
.stat-label { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(79, 140, 255, 0.16);
  border: 1px solid rgba(79, 140, 255, 0.35);
  color: #cfe0ff;
}
.tag.warn { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.36); color: #ffe9b5; }
.tag.ok { background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.36); color: #c5f7e2; }
.tag.mute { background: rgba(255, 255, 255, 0.05); border-color: var(--line); color: var(--text-dim); }

.meter { height: 7px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.meter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.meter-row > span:first-child { width: 78px; color: var(--text-dim); flex: none; }
.meter-row .meter { flex: 1; }

table.rank { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rank th, table.rank td { padding: 8px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.rank th { color: var(--text-mute); font-weight: 500; font-size: 12px; }
table.rank td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.rank tr.me td { color: #cfe0ff; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.list-row .meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.empty { padding: 18px; text-align: center; color: var(--text-mute); font-size: 13px; }

.kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
}

/* ============ 棋盘 / 画布 ============ */
.board-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--board-chrome);
  overflow: hidden;
}
.board-wrap canvas { display: block; width: 100%; height: auto; touch-action: manipulation; }
.turn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.turn-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 7px; vertical-align: -1px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12); }
.turn-dot.black { background: #1b2233; border: 1px solid #5a6b90; }
.turn-dot.white { background: #f2f5ff; }

/* ============ 音游 ============ */
.rhythm-stage {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 9, 18, 0.96), rgba(14, 20, 38, 0.96));
  overflow: hidden;
}
.rhythm-stage canvas { display: block; width: 100%; touch-action: none; }

.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.hud .score { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud .combo { font-size: 13px; color: var(--text-dim); }
.hud .acc { font-size: 13px; color: var(--brand-2); font-variant-numeric: tabular-nums; }

.touch-zones { position: absolute; inset: 0; display: flex; pointer-events: none; }
.touch-zones > div { flex: 1; border-right: 1px dashed rgba(120, 160, 255, 0.08); }
.touch-zones > div:last-child { border-right: none; }

.chart-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.chart-row:hover { border-color: var(--line-strong); }
.chart-row .info { flex: 1; min-width: 0; }
.chart-row .title { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-row .meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-badge {
  flex: none;
  min-width: 46px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line-strong);
}
.diff-EZ { background: rgba(52, 211, 153, 0.18); color: #b8f5df; border-color: rgba(52, 211, 153, 0.4); }
.diff-HD { background: rgba(79, 140, 255, 0.2); color: #cfe0ff; border-color: rgba(79, 140, 255, 0.45); }
.diff-IN { background: rgba(168, 85, 247, 0.22); color: #eddcff; border-color: rgba(168, 85, 247, 0.45); }
.diff-AT { background: rgba(248, 113, 113, 0.22); color: #ffd9d9; border-color: rgba(248, 113, 113, 0.45); }

.result-card { text-align: center; padding: 20px; }
.result-card .rank-big { font-size: 46px; font-weight: 800; letter-spacing: 2px; background: linear-gradient(135deg, var(--brand-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.judge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.judge-grid .stat-value { font-size: 16px; }

.overlay-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 18, 0.86);
  backdrop-filter: blur(6px);
  z-index: 5;
  padding: 18px;
}

/* ============ 提示 / 模态 ============ */
#mcc-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  z-index: 90;
  max-width: min(88vw, 460px);
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--toast-bg);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}
#mcc-toast.show { opacity: 1; transform: translate(-50%, 0); }
#mcc-toast.error { border-color: rgba(248, 113, 113, 0.6); }
#mcc-toast.ok { border-color: rgba(52, 211, 153, 0.55); }

.mcc-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(4, 7, 14, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.mcc-modal {
  width: min(94vw, 420px);
  padding: 22px;
  border-radius: 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
.mcc-modal h3 { font-size: 17px; }
.mcc-modal-desc { font-size: 13px; }
.mcc-modal-input {
  width: 100%;
  padding: 11px 13px;
  margin: 6px 0 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.mcc-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ============ 移动端底部导航 ============ */
.bottom-nav { display: none; }

/* ============ 响应式 ============ */
@media (max-width: 1020px) {
  .grid.game { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --header-h: 54px; }
  html.is-mobile .topbar { gap: 10px; padding: 0 12px; height: var(--header-h); }
  html.is-mobile .nav { display: none; }
  html.is-mobile .brand { font-size: 15px; }
  html.is-mobile .brand .logo { width: 26px; height: 26px; font-size: 13px; }
  html.is-mobile .user-btn { padding: 6px 10px; font-size: 12px; }
  html.is-mobile .wrap { padding: 16px 12px calc(24px + var(--bottom-h) + var(--safe-bottom)); }
  html.is-mobile .page-head h1 { font-size: 21px; }
  html.is-mobile .hero { padding: 24px 18px; }
  html.is-mobile .hero h1 { font-size: 23px; }
  html.is-mobile .grid.cols-3, html.is-mobile .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  html.is-mobile .panel { padding: 14px; border-radius: 12px; }
  html.is-mobile .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    height: calc(var(--bottom-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  html.is-mobile .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-mute);
  }
  html.is-mobile .bottom-nav a .bi { font-size: 19px; line-height: 1; }
  html.is-mobile .bottom-nav a.active { color: var(--brand); }
  html.is-mobile .judge-grid { grid-template-columns: repeat(2, 1fr); }
  html.is-mobile .hud { flex-wrap: wrap; gap: 6px; }
  html.is-mobile .hud .score { font-size: 18px; }
  html.is-mobile .stage-actions { position: sticky; bottom: calc(var(--bottom-h) + 8px); }
  html.is-mobile #mcc-toast { bottom: calc(var(--bottom-h) + 22px + var(--safe-bottom)); }
}

@media (min-width: 861px) {
  .desktop-only { display: initial; }
}
@media (max-width: 860px) {
  html.is-mobile .desktop-only { display: none !important; }
}

/* ============ 浅色主题 ============ */
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7;
  --bg-2: #e5eaf3;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --line: rgba(24, 44, 96, 0.13);
  --line-strong: rgba(24, 44, 96, 0.28);
  --text: #1a2334;
  --text-dim: #46536e;
  --text-mute: #7c879c;
  --brand: #2f6fe0;
  --brand-2: #0891b2;
  --accent: #7c4dd8;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 18px 40px rgba(30, 45, 80, 0.14);
  --header-bg: rgba(255, 255, 255, 0.84);
  --nav-bg: rgba(255, 255, 255, 0.95);
  --surface: #ffffff;
  --board-chrome: rgba(255, 255, 255, 0.6);
  --toast-bg: rgba(30, 38, 54, 0.97);
  --meter-track: rgba(20, 34, 66, 0.1);
}

[data-theme="light"] body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(79, 140, 255, 0.12), transparent 60%),
    radial-gradient(800px 480px at 92% 0%, rgba(124, 77, 216, 0.1), transparent 62%),
    radial-gradient(700px 520px at 50% 110%, rgba(8, 145, 178, 0.08), transparent 60%);
}

[data-theme="light"] .topbar { box-shadow: 0 1px 0 rgba(24, 44, 96, 0.06); }
[data-theme="light"] .nav-link.active { color: #fff; }
[data-theme="light"] .user-btn { background: rgba(20, 34, 66, 0.03); }
[data-theme="light"] .btn { background: rgba(20, 34, 66, 0.04); }
[data-theme="light"] .btn.ghost { background: transparent; }
[data-theme="light"] .btn.danger { color: #b91c1c; }
/* 浅色模式下 .btn 的浅底色会盖掉 .btn.primary 的蓝色渐变，只留下白字看不见；此处还原 primary 的渐变底色（含 hover） */
[data-theme="light"] .btn.primary { background: linear-gradient(135deg, var(--brand), var(--accent)); border-color: transparent; }
[data-theme="light"] .btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--brand), var(--accent)); border-color: transparent; }
/* 浅色模式下所有“重新开始 / 开始新对局”按钮统一黑底白字
   （这些按钮为 btn primary / btn ghost，浅色块里的 [data-theme="light"] .btn 会覆盖 primary 的渐变底色却保留白字，导致浅底白字看不清） */
[data-theme="light"] #ms-restart,
[data-theme="light"] #btn-start,
[data-theme="light"] #rh-retry { background: #111; border-color: transparent; color: #fff; }
[data-theme="light"] #ms-restart:hover:not(:disabled),
[data-theme="light"] #btn-start:hover:not(:disabled),
[data-theme="light"] #rh-retry:hover:not(:disabled) { background: #1c2230; border-color: transparent; filter: none; }
[data-theme="light"] .seg { background: rgba(20, 34, 66, 0.05); }
[data-theme="light"] .stat { background: rgba(20, 34, 66, 0.04); }
[data-theme="light"] .list-row { background: rgba(20, 34, 66, 0.03); }
[data-theme="light"] .chart-row { background: rgba(20, 34, 66, 0.03); }
[data-theme="light"] .kbd { background: rgba(20, 34, 66, 0.06); }
[data-theme="light"] .hero {
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.1), rgba(124, 77, 216, 0.07) 55%, rgba(8, 145, 178, 0.06));
}

/* 浅色模式下提示条仍是深色底（--toast-bg），但文字继承的是浅色主题的深色 --text，黑底黑字看不见；此处只固定文字色，不碰边框（.error/.ok 的红绿边框要保持） */
[data-theme="light"] #mcc-toast { color: #f2f5ff; }

[data-theme="light"] .tag { color: #1d4ed8; background: rgba(79, 140, 255, 0.12); border-color: rgba(79, 140, 255, 0.3); }
[data-theme="light"] .tag.warn { color: #92400e; background: rgba(217, 119, 6, 0.12); border-color: rgba(217, 119, 6, 0.3); }
[data-theme="light"] .tag.ok { color: #047857; background: rgba(5, 150, 105, 0.12); border-color: rgba(5, 150, 105, 0.3); }
[data-theme="light"] .tag.mute { color: var(--text-dim); background: rgba(20, 34, 66, 0.05); }
[data-theme="light"] table.rank tr.me td { color: #1d4ed8; }

[data-theme="light"] .diff-EZ { background: rgba(5, 150, 105, 0.14); color: #065f46; border-color: rgba(5, 150, 105, 0.35); }
[data-theme="light"] .diff-HD { background: rgba(47, 111, 224, 0.14); color: #1e40af; border-color: rgba(47, 111, 224, 0.35); }
[data-theme="light"] .diff-IN { background: rgba(124, 77, 216, 0.14); color: #6d28d9; border-color: rgba(124, 77, 216, 0.35); }
[data-theme="light"] .diff-AT { background: rgba(220, 38, 38, 0.14); color: #b91c1c; border-color: rgba(220, 38, 38, 0.35); }

/* 音游舞台与遮罩为固定暗色“演出面”，文字固定浅色，不随站点主题变化 */
.rhythm-stage, .overlay-panel { color: #e8edf7; }
.rhythm-stage .hud .score, .overlay-panel h2 { color: #e8edf7; }
.rhythm-stage .hud .combo { color: #9aa8c4; }
.rhythm-stage .hud .acc { color: #22d3ee; }
.overlay-panel p { color: #b9c4dc; }

/* 主题切换按钮 */
.theme-btn { padding: 7px 11px; font-size: 15px; line-height: 1; }

/* ============ 音游视觉增强（Phigros 风格演出面） ============ */
.rhythm-stage {
  border-color: rgba(90, 160, 255, 0.22);
  box-shadow: inset 0 0 90px rgba(79, 140, 255, 0.06), var(--shadow);
}

.hud {
  letter-spacing: 0.4px;
  background: linear-gradient(180deg, rgba(10, 16, 30, 0.92), rgba(12, 19, 36, 0.85));
}
.hud .score {
  font-size: 24px;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(79, 140, 255, 0.55);
}
.hud .acc { text-shadow: 0 0 12px rgba(34, 211, 238, 0.5); }

.chart-row {
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.chart-row:hover {
  border-color: rgba(90, 160, 255, 0.45);
  box-shadow: 0 6px 22px rgba(4, 8, 20, 0.4);
  transform: translateX(2px);
}

.result-card .rank-big {
  text-shadow: 0 0 34px rgba(34, 211, 238, 0.45);
}

.overlay-panel {
  background: rgba(5, 8, 16, 0.9);
  backdrop-filter: blur(10px);
}

/* ============ 界面美化增强（全站统一） ============ */

/* 背景：加强纵深的多层光晕 */
body {
  background-image:
    radial-gradient(1000px 560px at 10% -12%, rgba(79, 140, 255, 0.24), transparent 62%),
    radial-gradient(880px 520px at 94% -4%, rgba(168, 85, 247, 0.20), transparent 64%),
    radial-gradient(760px 560px at 50% 112%, rgba(34, 211, 238, 0.14), transparent 62%),
    radial-gradient(520px 520px at 82% 78%, rgba(79, 140, 255, 0.10), transparent 60%);
}

html { scroll-behavior: smooth; }

/* 顶栏：玻璃拟态 + 立体感 */
.topbar {
  box-shadow: 0 8px 30px rgba(4, 8, 20, 0.35);
  border-bottom-color: rgba(120, 150, 220, 0.22);
}
.brand { transition: opacity 0.15s ease; }
.brand:hover { opacity: 0.92; }
.brand .logo {
  border-radius: 11px;
  background: linear-gradient(135deg, #4f8cff, #a855f7 58%, #22d3ee);
  box-shadow: 0 8px 22px rgba(79, 140, 255, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand:hover .logo {
  transform: rotate(-6deg) scale(1.06);
  box-shadow: 0 10px 26px rgba(79, 140, 255, 0.6);
}
.nav-link { position: relative; }
.nav-link.active {
  box-shadow: 0 8px 22px rgba(79, 140, 255, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* 英雄区：更强渐变 + 流动光泽 */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border-color: rgba(120, 160, 255, 0.28);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.2), rgba(168, 85, 247, 0.14) 55%, rgba(34, 211, 238, 0.12));
}
.hero::after {
  content: '';
  position: absolute;
  inset: -40% -20%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.14) 50%, transparent 58%);
  transform: translateX(-60%);
  animation: mcc-sheen 7.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes mcc-sheen {
  0%, 58% { transform: translateX(-60%); opacity: 0; }
  68% { opacity: 0.85; }
  100% { transform: translateX(60%); opacity: 0; }
}
.hero h1 {
  background: linear-gradient(120deg, #eaf2ff, #bcd4ff 45%, #d8c4ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
[data-theme="light"] .hero h1 {
  background: linear-gradient(120deg, #1a2334, #2f6fe0 50%, #7c4dd8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* 卡片：图标徽章 + 悬停辉光 */
.card { border-radius: 18px; }
.card .ico {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 23px;
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.22), rgba(168, 85, 247, 0.18));
  border: 1px solid rgba(120, 160, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.card:hover {
  border-color: rgba(120, 170, 255, 0.5);
  box-shadow: 0 22px 48px rgba(4, 8, 20, 0.6), 0 0 0 1px rgba(120, 170, 255, 0.18);
}
.card .go { display: inline-block; transition: transform 0.18s ease; }
.card:hover .go { transform: translateX(3px); }

/* 面板：顶部高光细线 */
.panel { position: relative; border-radius: 16px; }
.panel::before {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 180, 255, 0.45), transparent);
  pointer-events: none;
}

/* 按钮：聚焦环与按下反馈 */
.btn { border-radius: 10px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.32); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { box-shadow: 0 8px 22px rgba(79, 140, 255, 0.32); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 10px 28px rgba(110, 120, 255, 0.46); }

/* 输入框：聚焦光晕 */
.input:focus, .select:focus { box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22); }

/* 分段控件 / 标签 / 统计卡 */
.seg button.active { box-shadow: 0 6px 16px rgba(79, 140, 255, 0.32); }
.tag { backdrop-filter: blur(6px); }
.stat { border-radius: 12px; }
.stat-value { letter-spacing: 0.3px; }

/* 移动端底部导航：激活项辉光 */
html.is-mobile .bottom-nav a.active .bi {
  filter: drop-shadow(0 0 10px rgba(79, 140, 255, 0.75));
}

/* 文本选中与滚动条 */
::selection { background: rgba(79, 140, 255, 0.35); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: rgba(120, 150, 220, 0.4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(120, 150, 220, 0.42), rgba(168, 85, 247, 0.38));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(120, 150, 220, 0.62), rgba(168, 85, 247, 0.58));
  background-clip: padding-box;
}

/* 尊重「减少动效」偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero::after { animation: none; opacity: 0; }
}

/* ============ 音游全屏沉浸（Phigros 风格，自研绘制） ============ */

body.rhythm-app {
  height: 100vh;
  height: 100dvh; /* 移动端地址栏收放时 100vh 与实际可视高度不一致，用 dvh 兜底 */
  overflow: hidden;
  background: #05070f;
  color: #e8edf7;
}

.rh-app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  /* 横屏刘海/挖孔：顶栏、HUD、操作条一律让开安全区（背景另见 .rh-bg 的 fixed） */
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* 沉浸式演出面：禁止双指缩放与双击缩放（iOS Safari 忽略 user-scalable，故手势拦截在 ui.js） */
.rh-app, .rh-app * { touch-action: manipulation; }
.rh-app canvas, .rh-app input[type="range"] { touch-action: none; }

/* iOS Safari 聚焦 font-size < 16px 的输入框时会自动放大整页，固定全屏层被放大后缩不回去，
   这正是「误触缩放、无法还原」的主要来源。音游页的文本输入口（曲库搜索框 + 昵称弹窗输入框）
   统一抬到 16px 即可从源头杜绝。 */
.rh-app .input,
.rh-app input[type="text"],
.rh-app input[type="search"],
body.rhythm-app .mcc-modal-input { font-size: 16px; }

/* ---------- 背景 ---------- */
.rh-bg {
  position: fixed; /* 相对视口定位，才能铺满横屏下 .rh-app 让出的安全区，不留黑边 */
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 18% -8%, rgba(79, 140, 255, 0.16), transparent 60%),
    radial-gradient(1000px 640px at 88% 6%, rgba(168, 85, 247, 0.14), transparent 62%),
    radial-gradient(900px 700px at 50% 110%, rgba(34, 211, 238, 0.10), transparent 60%),
    linear-gradient(180deg, #05070f, #0a1022 55%, #0d1530);
}
.rh-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, #000 30%, transparent 78%);
}
#rh-bg-stars { position: absolute; inset: 0; width: 100%; height: 100%; }
.rh-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}
.rh-bg-orb.orb-1 { width: 46vw; height: 46vw; left: -10vw; top: -14vw; background: radial-gradient(circle, rgba(79,140,255,0.55), transparent 68%); animation: rh-float 16s ease-in-out infinite; }
.rh-bg-orb.orb-2 { width: 40vw; height: 40vw; right: -12vw; top: -8vw; background: radial-gradient(circle, rgba(168,85,247,0.45), transparent 68%); animation: rh-float 20s ease-in-out infinite reverse; }
.rh-bg-orb.orb-3 { width: 42vw; height: 42vw; left: 26vw; bottom: -18vw; background: radial-gradient(circle, rgba(34,211,238,0.35), transparent 68%); animation: rh-float 24s ease-in-out infinite; }
@keyframes rh-float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2vw, -3vh, 0) scale(1.12); }
}

/* ---------- 顶栏 ---------- */
.rh-topbar {
  position: relative;
  z-index: 20;
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: rgba(7, 11, 20, 0.55);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(120, 150, 220, 0.16);
}
.rh-back {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: #e8edf7;
  font-size: 26px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(120, 150, 220, 0.22);
  transition: all 0.16s ease;
}
.rh-back:hover { background: rgba(79, 140, 255, 0.2); border-color: rgba(79, 140, 255, 0.5); }
.rh-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: 0.4px; }
.rh-logo {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #4f8cff, #a855f7 58%, #22d3ee);
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.45);
}
.rh-top-spacer { flex: 1; }
.rh-ico-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(120, 150, 220, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #e8edf7;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.rh-ico-btn:hover { border-color: rgba(79, 140, 255, 0.6); background: rgba(79, 140, 255, 0.14); }
.rh-ico-emoji { font-size: 15px; line-height: 1; }
.rh-nick-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 主容器 ---------- */
.rh-main {
  position: relative;
  flex: 1;
  min-height: 0;
  z-index: 5;
}
.rh-view { position: absolute; inset: 0; }

/* ---------- 选曲视图 ---------- */
.rh-select {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(320px, 1fr);
  gap: 18px;
  padding: 18px;
}
.rh-lib {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 16px;
  border-radius: 18px;
  background: rgba(10, 16, 30, 0.55);
  border: 1px solid rgba(120, 150, 220, 0.16);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(2, 5, 12, 0.45);
}
.rh-lib-head { display: flex; flex-direction: column; gap: 10px; flex: none; }
.rh-search { display: flex; gap: 8px; }
.rh-search .input { flex: 1; }
.rh-count { font-size: 12px; color: #8ea0c4; padding-top: 2px; }
.rh-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-right: 4px;
}
.rh-list .chart-row { border-radius: 13px; }
.rh-cover-thumb {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.35);
}
.rh-play-ico { flex: none; padding: 7px 12px; }

/* ---------- 详情 ---------- */
.rh-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 26px;
  border-radius: 18px;
  background: rgba(10, 16, 30, 0.55);
  border: 1px solid rgba(120, 150, 220, 0.16);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(2, 5, 12, 0.45);
  overflow: hidden;
  position: relative;
}
.rh-detail-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #7c89a8; text-align: center; }
.rh-detail-empty-ico { font-size: 54px; color: #3f4f75; }
.rh-detail-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; text-align: center; }
.rh-detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(120, 150, 220, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: #cdd6e8;
  cursor: pointer;
  display: none;
}
.rh-cover {
  width: min(46%, 220px);
  aspect-ratio: 1;
  border-radius: 20px;
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.rh-cover::after {
  content: '';
  position: absolute;
  inset: -40% -20%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.16) 50%, transparent 58%);
  transform: translateX(-60%);
  animation: mcc-sheen 7.5s ease-in-out infinite;
}
.rh-cover span {
  position: relative;
  z-index: 1;
  font-size: 86px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.45);
}
.rh-detail-meta { display: flex; flex-direction: column; gap: 4px; }
.rh-title { font-size: 22px; font-weight: 700; line-height: 1.25; }
.rh-sub { font-size: 13px; color: #9aa8c4; }
.rh-diff { margin-top: 2px; }
.rh-stats { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 8px; width: 100%; margin-top: 4px; }
.rh-stats .stat-value { font-size: 17px; }
.rh-best { font-size: 13px; color: #8fd0ff; min-height: 18px; }
.rh-best b { color: #dceaff; }
.rh-detail-actions { justify-content: center; width: 100%; margin-top: 2px; }
.rh-detail-foot { font-size: 12px; color: #6d7a96; margin-top: 4px; }

/* ---------- 游玩视图 ---------- */
.rh-play { display: flex; flex-direction: column; }
.rh-hud {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 26px 10px;
  pointer-events: none;
}
.rh-hud-left { display: flex; flex-direction: column; }
.rh-hud-score {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 24px rgba(79, 140, 255, 0.5);
}
.rh-hud-combo { font-size: 14px; color: #9aa8c4; letter-spacing: 1px; margin-top: 6px; }
.rh-hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.rh-hud-acc { font-size: 22px; font-weight: 700; color: #22d3ee; font-variant-numeric: tabular-nums; text-shadow: 0 0 16px rgba(34, 211, 238, 0.45); }
.rh-hud-time { font-size: 13px; color: #8ea0c4; font-variant-numeric: tabular-nums; }
.rh-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.rh-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.rh-pause {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(10px);
  z-index: 6;
  padding: 18px;
}
.rh-pause-card { text-align: center; max-width: 460px; }
.rh-pause-card h2 { font-size: 24px; color: #e8edf7; }
.rh-pause-card p { font-size: 13.5px; color: #b9c4dc; margin: 8px 0 18px; }
.rh-controls {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px 18px;
}

/* ---------- 结算视图 ---------- */
.rh-result { display: grid; place-items: center; padding: 20px; }
.rh-result-card {
  width: min(94vw, 520px);
  padding: 34px 30px;
  border-radius: 22px;
  text-align: center;
  background: rgba(10, 16, 30, 0.7);
  border: 1px solid rgba(120, 150, 220, 0.22);
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 70px rgba(2, 5, 12, 0.6);
}
.rh-rank {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: 3px;
  line-height: 1;
  background: linear-gradient(135deg, #22d3ee, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(34, 211, 238, 0.3);
}
.rh-result-score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 8px; }
.rh-result-line { font-size: 14px; color: #9aa8c4; margin-top: 6px; }
.rh-judges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.rh-judge { padding: 12px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(120, 150, 220, 0.14); }
.rh-judge b { display: block; font-size: 22px; font-weight: 700; }
.rh-judge span { font-size: 11.5px; color: #8ea0c4; }
.rh-result-extra { font-size: 13px; color: #8fd0ff; margin-top: 16px; min-height: 18px; }

/* ---------- 抽屉 ---------- */
.rh-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(92vw, 420px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 28, 0.96);
  border-left: 1px solid rgba(120, 150, 220, 0.2);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
  animation: rh-drawer-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  /* .rh-drawer 是 fixed，不受 .rh-app 的 padding 影响，横屏右侧刘海需自行让位 */
  padding-right: var(--safe-right);
}
@keyframes rh-drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.rh-drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(120, 150, 220, 0.16);
}
.rh-drawer-title { font-size: 17px; font-weight: 700; }
.rh-drawer-body { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.rh-panel { padding: 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(120, 150, 220, 0.14); }
.rh-panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14.5px; font-weight: 600; margin-bottom: 10px; }
.rh-panel-title small { color: #8ea0c4; font-weight: 400; font-size: 12px; }
.rh-note { font-size: 12px; color: #7c89a8; line-height: 1.6; margin-top: 10px; }
.rh-mask { position: fixed; inset: 0; z-index: 55; background: rgba(3, 6, 12, 0.55); backdrop-filter: blur(2px); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .rh-topbar { padding: 0 12px; height: 56px; gap: 8px; }
  .rh-brand-name, .rh-nick-label { display: none; }
  .rh-select { grid-template-columns: 1fr; padding: 12px; gap: 0; }
  .rh-lib { padding: 12px; border-radius: 16px; }
  .rh-detail {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: min(78vh, 620px);
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
    z-index: 10;
  }
  .rh-has-chart .rh-detail { transform: translateY(0); }
  .rh-detail-close { display: block; }
  .rh-hud { padding: 12px 16px 6px; }
  .rh-hud-score { font-size: 30px; }
  .rh-hud-acc { font-size: 18px; }
  .rh-controls { padding: 10px 12px 14px; }
  .rh-cover { width: min(42%, 160px); }
  .rh-cover span { font-size: 60px; }
  .rh-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rh-result-card { padding: 26px 20px; }
  .rh-rank { font-size: 56px; }
}

/* ---------- 横屏（手机旋转后可视高度只有 300~420px） ----------
   上面那条 max-width: 860px 断点是为竖屏写的：横屏 844px 也会命中它，于是选曲被压成单列、
   详情变底部抽屉，横向空间全浪费；这里按 orientation + 矮视口单独回收。 */
@media (orientation: landscape) and (max-height: 560px) {
  /* 顶栏：非游玩时压到 46px，游玩时整条隐藏（暂停/重开/退出已在操作条里，顶栏只会白占高度） */
  .rh-topbar { height: 46px; padding: 0 14px; gap: 8px; }
  .rh-brand-name, .rh-nick-label { display: none; }
  .rh-logo { width: 28px; height: 28px; border-radius: 9px; font-size: 14px; }
  .rh-back { width: 32px; height: 32px; font-size: 22px; }
  .rh-ico-btn { padding: 6px 10px; font-size: 12.5px; }
  body.rh-playing .rh-topbar { display: none; }

  /* 选曲：保持左右两栏（详情不做底部抽屉），并把左侧库的头部压成两行：
     搜索框一行，两个分段控件并排一行 */
  .rh-select { grid-template-columns: minmax(250px, 1.05fr) minmax(250px, 1fr); gap: 10px; padding: 10px; }
  .rh-lib { padding: 10px; }
  .rh-lib-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 8px;
    align-items: center;
  }
  .rh-search, .rh-count { grid-column: 1 / -1; }
  .rh-count { padding-top: 0; font-size: 11.5px; }
  .rh-search .input { padding: 8px 10px; }
  .rh-search .btn { padding: 7px 10px; font-size: 12.5px; }
  .rh-lib-head .seg { padding: 4px; }
  .rh-lib-head .seg button { padding: 6px 4px; font-size: 12px; }

  /* 曲库行：图片与内边距一起收，同样高度能多显示两行 */
  .rh-list { gap: 6px; margin-top: 8px; }
  .rh-list .chart-row { padding: 8px 10px; gap: 8px; }
  .rh-cover-thumb { width: 38px; height: 38px; border-radius: 9px; font-size: 16px; }
  .rh-app .chart-row .title { font-size: 13.5px; }
  .rh-app .chart-row .meta { font-size: 11px; margin-top: 2px; }
  .rh-play-ico { padding: 5px 9px; }

  /* 详情：竖排内容在 240px 高的右栏里放不下（底部的「开始游玩」会被裁掉），
     横屏改为「封面在左、信息在右」的网格排布，并留出滚动兜底 */
  .rh-detail {
    position: static;
    height: auto;
    transform: none;
    border-radius: 18px;
    padding: 14px;
    justify-content: flex-start;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(2, 5, 12, 0.45);
  }
  .rh-detail-close { display: none; }
  .rh-detail-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "cover meta"
      "cover diff"
      "stats stats"
      "best best"
      "actions actions"
      "foot foot";
    gap: 6px 12px;
    align-items: center;
    text-align: left;
  }
  .rh-cover { grid-area: cover; width: 88px; border-radius: 14px; }
  .rh-cover span { font-size: 32px; }
  .rh-detail-meta { grid-area: meta; }
  .rh-diff { grid-area: diff; margin-top: 0; }
  .rh-stats { grid-area: stats; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 0; }
  .rh-stats .stat { padding: 6px 8px; }
  .rh-stats .stat-value { font-size: 14px; }
  .rh-stats .stat-label { font-size: 10.5px; }
  .rh-best { grid-area: best; min-height: 0; font-size: 12px; }
  .rh-detail-actions { grid-area: actions; justify-content: flex-start; margin-top: 0; }
  .rh-detail-actions .btn { padding: 7px 12px; font-size: 12.5px; }
  .rh-detail-foot { grid-area: foot; margin-top: 0; font-size: 11px; }
  .rh-title { font-size: 17px; }
  .rh-sub { font-size: 12px; }
  .rh-detail-empty-ico { font-size: 34px; }

  /* 游玩：HUD 压成单行（分数 · 连击 / 准度 · 时间），操作条同步收窄，高度全留给舞台 */
  .rh-hud { padding: 4px 14px; align-items: center; }
  .rh-hud-left { flex-direction: row; align-items: baseline; gap: 8px; }
  .rh-hud-right { flex-direction: row; align-items: baseline; gap: 10px; }
  .rh-hud-score { font-size: 22px; }
  .rh-hud-combo { margin-top: 0; font-size: 12px; }
  .rh-hud-acc { font-size: 15px; }
  .rh-hud-time { font-size: 11.5px; }
  .rh-controls { padding: 4px 12px 6px; gap: 6px; }
  .rh-controls .btn { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
  .rh-pause-card h2 { font-size: 20px; }
  .rh-pause-card p { font-size: 12.5px; margin: 6px 0 12px; }
  .rh-pause .btn-group { gap: 6px; }

  /* 结算 / 抽屉 */
  .rh-result { padding: 10px; }
  .rh-result-card { width: min(86vw, 460px); padding: 16px 20px; }
  .rh-rank { font-size: 42px; }
  .rh-result-score { font-size: 28px; margin-top: 4px; }
  .rh-result-line { font-size: 12.5px; margin-top: 4px; }
  .rh-judges { gap: 8px; margin-top: 10px; }
  .rh-judge { padding: 8px 4px; }
  .rh-judge b { font-size: 18px; }
  .rh-result-extra { margin-top: 10px; }
  .rh-drawer { width: min(62vw, 400px); }
  .rh-drawer-head { padding: 12px 16px; }
  .rh-drawer-body { padding: 12px 14px; gap: 12px; }
  .rh-panel { padding: 12px; }
  .rh-panel-title { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .rh-bg-orb, .rh-cover::after { animation: none; }
  .rh-drawer { animation: none; }
}

/* ---------- 音游内复用组件的暗色适配 ----------
   音游是常暗演出面（body.rhythm-app + .rh-app 固定深色底），而 .btn / .input / .seg /
   .stat / .empty / .chart-row / table.rank 这些公共组件用的是主题变量（--text / --surface /
   --text-dim / --text-mute）。站点切到浅色主题时，这些变量变成深色，落在深色舞台底上就成了
   「透明底 + 黑字」（.btn.ghost 本身还是全透明），暂停 / 退出 / 继续 / 点赞 / 下载等按钮与
   统计卡、曲库行文字全部看不清。此块只按 .rh-app 作用域强制一套深色面板配色，与站点深浅色解耦；
   因追加在文件末尾，与 [data-theme="light"] 选择器同权重时按顺序覆盖，另有 .rh-app #rh-retry
   用于压过浅色块里的 ID 级规则。 */
.rh-app .btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(120, 150, 220, 0.34);
  color: #e8edf7;
}
.rh-app .btn:hover:not(:disabled) {
  background: rgba(79, 140, 255, 0.22);
  border-color: rgba(79, 140, 255, 0.62);
  color: #fff;
}
.rh-app .btn.primary,
.rh-app .btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border-color: transparent;
  color: #fff;
}
.rh-app .btn.ghost { background: rgba(255, 255, 255, 0.06); }
.rh-app .btn.ghost:hover:not(:disabled) { background: rgba(79, 140, 255, 0.22); }
.rh-app .btn.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.55);
  color: #ffd9d9;
}
.rh-app .btn.danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.24); color: #fff; }
.rh-app #rh-retry {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(120, 150, 220, 0.34);
  color: #e8edf7;
  filter: none;
}
.rh-app #rh-retry:hover:not(:disabled) {
  background: rgba(79, 140, 255, 0.22);
  border-color: rgba(79, 140, 255, 0.62);
  color: #fff;
}

.rh-app .input,
.rh-app .select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(120, 150, 220, 0.3);
  color: #e8edf7;
}
.rh-app .input::placeholder { color: #6d7a96; }
.rh-app .input:focus,
.rh-app .select:focus { border-color: rgba(79, 140, 255, 0.7); }
.rh-app input[type="file"] { color: #9aa8c4; }
.rh-app input[type="range"] { accent-color: #4f8cff; }
.rh-app .field label { color: #9aa8c4; }
.rh-app .field label small { color: #8ea0c4; font-weight: 400; }

.rh-app .seg {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(120, 150, 220, 0.2);
}
.rh-app .seg button { color: #b9c4dc; }
.rh-app .seg button:hover { color: #e8edf7; }
.rh-app .seg button.active {
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.95), rgba(168, 85, 247, 0.9));
  color: #fff;
}

.rh-app .stat {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(120, 150, 220, 0.18);
}
.rh-app .stat-value { color: #e8edf7; }
.rh-app .stat-label { color: #8ea0c4; }
.rh-app .empty { color: #7c89a8; }

.rh-app .chart-row {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(120, 150, 220, 0.18);
  color: #e8edf7;
}
.rh-app .chart-row:hover { border-color: rgba(90, 160, 255, 0.5); }
.rh-app .chart-row .title { color: #e8edf7; }
.rh-app .chart-row .meta { color: #8ea0c4; }

.rh-app table.rank th,
.rh-app table.rank td { border-bottom-color: rgba(120, 150, 220, 0.16); color: #dbe3f2; }
.rh-app table.rank th { color: #8ea0c4; }
.rh-app table.rank tr.me td { color: #8fd0ff; }

/* ---------- 移动端输入框防聚焦缩放（全站） ----------
   iOS Safari 聚焦 font-size < 16px 的输入框时会自动放大整页，页面（尤其吸顶/固定布局）被放大后
   不会自动缩回，看起来就是「误触缩放、无法还原」。全站的文本输入控件原本是 14~15px
   （.input 14px、.mcc-modal-input 15px，用于五子棋口令/聊天、扫雷自定义雷区、音游搜索、昵称弹窗），
   触屏设备上一律抬到 16px 从源头消除。range / file / checkbox 不会触发聚焦缩放，不在此列。 */
@media (hover: none) and (pointer: coarse) {
  .input,
  .select,
  .mcc-modal-input,
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  input[type="url"] { font-size: 16px; }
}
