/* Kimi Logo Piano — 深色底 + 白键 / 琥珀金高亮（Moonshot 钢琴 logo 调性） */
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-800.woff2") format("woff2");
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  --bg: #0c0c10;
  --panel: rgba(22, 22, 29, 0.92);
  --line: #2a2a34;
  --ink: #ece8dd;
  --dim: #9a97a3;
  --amber: #f2a541;
  --amber2: #ffc66e;
  --crit: #ffd75e;
  --perf: #f2a541;
  --great: #7fd8c9;
  --good: #93a5b7;
  --miss: #e05454;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: auto;
  gap: 12px;
}
.hidden { display: none !important; }

/* 面板类界面在短视口（手机横屏）下可滚动：flex 居中会上下对称裁掉超高内容，
   改为 flex-start + 子级 margin:auto（有空间时居中、超高时自然顶齐可滚） */
#screen-settings, #screen-howto, #screen-results {
  justify-content: flex-start; overflow-y: auto;
}
#screen-settings, #screen-howto { padding-top: 74px; }
#screen-results { padding: 24px 0; }
#screen-settings .panel, #screen-howto .panel, #screen-results .panel {
  margin: auto; flex: none;
}
/* 短视口主菜单：副标题让位、标题上移、按钮区收紧（月亮收小见 menu.js） */
@media (max-height: 480px) {
  .menu-title { top: 3vh; }
  .menu-title .subtitle { display: none; }
  #screen-menu { padding-bottom: 2vh; }
}

/* ---------- 主菜单 ---------- */
#screen-menu { justify-content: flex-end; padding-bottom: 5vh; z-index: 2; pointer-events: none; }
#screen-menu nav, #screen-menu footer { pointer-events: auto; }
.menu-title {
  position: absolute; top: 9vh; left: 50%; transform: translateX(-50%);
  text-align: center; width: 100%;
}
.menu-title h1 {
  margin: 0; font-size: clamp(28px, 4.6vw, 56px);
  letter-spacing: 0.18em; font-weight: 700;
  text-shadow: 0 2px 24px rgba(242, 238, 227, 0.22);
}
.menu-title .amber { color: var(--amber); }
.subtitle { color: var(--dim); letter-spacing: 0.3em; font-size: 13px; margin-top: 10px; }
.menu-buttons { display: flex; gap: 18px; z-index: 2; }
.menu-footer { color: var(--dim); font-size: 12px; letter-spacing: 0.2em; margin-top: 18px; }

/* ---------- 通用控件 ---------- */
.btn {
  background: linear-gradient(180deg, #1d1d26, #14141b);
  border: 1px solid var(--line); color: var(--ink);
  padding: 12px 34px; font-size: 16px; letter-spacing: 0.25em;
  border-radius: 8px; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.btn:hover { border-color: #f2eee3; color: #f2eee3; box-shadow: 0 0 18px rgba(242,238,227,.22); }
.btn.big { font-size: 20px; padding: 16px 52px; border-color: #f2eee3; color: #f2eee3; }
.btn.small { padding: 6px 14px; font-size: 13px; letter-spacing: .1em; }

/* ---------- 导航 chrome：全局统一的返回/暂停/关闭件 ----------
   40×40 圆角方块（与 panel 圆角同族），半透明底 + 细边，hover 泛琥珀。
   字形全部纯 CSS 绘制（Inter 无对应字形，且避免各平台渲染漂移）。 */
.chip {
  width: 40px; height: 40px; flex: none; padding: 0; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(22, 22, 29, .6); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color .15s, background .15s;
  font-family: inherit;
}
.chip:hover { border-color: var(--amber2); background: rgba(22, 22, 29, .85); }
.chip::before, .chip::after { content: ""; }
/* 返回 ‹（左+下边框旋转 45°，微调光学中心） */
.chip-back::before {
  width: 10px; height: 10px; border-radius: 1px;
  border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(45deg) translate(1.5px, -1.5px);
}
/* 暂停 ‖ */
.chip-pause { gap: 5px; }
.chip-pause::before, .chip-pause::after {
  width: 4px; height: 16px; background: var(--ink); border-radius: 2px;
}
/* 关闭 ×（两条旋转细条，绝对定位居中） */
.chip-close::before, .chip-close::after {
  position: absolute; width: 2px; height: 16px; background: var(--ink); border-radius: 1px;
}
.chip-close::before { transform: rotate(45deg); }
.chip-close::after { transform: rotate(-45deg); }

.bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.bar h2 { margin: 0; font-size: 18px; letter-spacing: .2em; font-weight: 600; }

/* 即兴卡的现场生成徽标（第三类，与常规曲/变奏并列） */
.live-tag {
  font-size: 10px; letter-spacing: .18em; color: var(--amber2);
  border: 1px solid rgba(242, 165, 65, .4); border-radius: 4px;
  padding: 1px 5px; vertical-align: 2px;
}
/* 预览资源加载角标（采样预载时带百分比） */
.song-card { position: relative; }
.p-load {
  position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--amber2);
  letter-spacing: .08em; animation: pload-pulse 1s infinite; pointer-events: none;
}
@keyframes pload-pulse { 50% { opacity: .45; } }

/* ---------- 排行榜 ---------- */
.lb-panel { display: flex; flex-direction: column; gap: 12px; width: min(94vw, 560px); position: relative; }
.lb-panel .chip-close { position: absolute; top: 14px; right: 14px; }
.lb-panel h3 { margin: 0; letter-spacing: .2em; }
.lb-sub { color: var(--dim); font-size: 13px; }
.lb-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.lb-row {
  display: grid; grid-template-columns: 36px 1fr 84px 64px 48px 88px;
  gap: 8px; font-size: 13px; padding: 5px 8px;
  background: rgba(245,242,234,.03); border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.lb-row.lb-head { color: var(--dim); background: none; font-size: 12px; }
.lb-empty { color: var(--dim); text-align: center; padding: 24px 0; }
.lb-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--amber2); font-size: 12px; cursor: pointer; padding: 1px 7px;
  margin-left: 8px; flex: none;
}
.lb-btn:hover { border-color: var(--amber); }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 34px; max-width: min(92vw, 620px);
  backdrop-filter: blur(6px);
}

/* ---------- 选曲 ---------- */
#screen-select { padding-top: 74px; justify-content: flex-start; }
.diff-switch { margin-left: auto; display: flex; gap: 6px; }
.diff-btn {
  border: 1px solid var(--line); background: #14141b; color: var(--dim);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.diff-btn.on { border-color: var(--amber); color: var(--amber2); box-shadow: 0 0 10px rgba(242,165,65,.3); }
/* 选曲页控件区：header（Back+标题+AUTO）与 toolbar（tab/模式/难度分段钮）分区 */
.auto-slot { margin-left: auto; }
.auto-toggle {
  border: 1px solid var(--line); background: rgba(20, 20, 27, .72); color: var(--dim);
  border-radius: 999px; padding: 6px 18px; font-size: 12px; letter-spacing: .1em;
  cursor: pointer; transition: all .12s;
}
.auto-toggle:hover { color: var(--ink); border-color: var(--amber); }
.auto-toggle.on {
  border-color: var(--amber); color: var(--amber2); font-weight: 700;
  background: rgba(242, 165, 65, .12); box-shadow: 0 0 12px rgba(242, 165, 65, .3);
}
.sel-toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 10px; width: min(96vw, 1200px); margin: 0 0 10px;
}
.sel-toolbar-right { display: flex; gap: 10px; flex-wrap: wrap; }
/* 分段控件：所有开关统一语言（tab/5K9K/难度同款胶囊组） */
.seg {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(20, 20, 27, .72); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.seg-item {
  border: none; background: transparent; color: var(--dim);
  border-radius: 999px; padding: 6px 14px; font-size: 12px; letter-spacing: .04em;
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.seg-item:hover { color: var(--ink); }
.seg-item.on {
  background: rgba(242, 165, 65, .14); color: var(--amber2); font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(242, 165, 65, .45);
}
.seg-count { opacity: .5; font-size: 11px; margin-left: 7px; font-variant-numeric: tabular-nums; }
.song-grid {
  display: grid; gap: 12px; width: min(96vw, 1200px); overflow: hidden; padding: 10px 4px 8px;
}
.song-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px 12px; cursor: pointer; transition: all .12s; position: relative;
  overflow: hidden; min-height: 0;
}
.song-card:hover { border-color: var(--amber); transform: translateY(-2px); }
.song-card .genre-strip { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.song-card h3 {
  margin: 0 0 6px; font-size: 15px; padding-left: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-card .meta { color: var(--dim); font-size: 12px; padding-left: 8px; display: flex; justify-content: space-between; align-items: center; }
.song-card .best { position: absolute; right: 12px; top: 12px; font-weight: 700; }
.song-card .level { color: var(--amber2); font-weight: 700; }
/* 上下翻页（无滚动条）：悬浮玻璃胶囊锚定屏底，圆钮 ▲▼ + 细字码 + 页点 */
#sel-pager {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 30;
  display: flex; justify-content: center; align-items: center; gap: 22px;
  padding: 8px 20px;
  background: rgba(10, 10, 14, .66); border: 1px solid var(--line);
  border-radius: 999px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
}
.pager-arrow {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(20, 20, 27, .72); color: var(--dim);
  font-size: 11px; cursor: pointer; transition: all .15s;
  display: inline-grid; place-items: center; line-height: 1;
}
.pager-arrow:hover:not(:disabled) {
  color: var(--amber2); border-color: var(--amber);
  box-shadow: 0 0 12px rgba(242, 165, 65, .35), inset 0 0 8px rgba(242, 165, 65, .12);
  transform: translateY(-1px);
}
.pager-arrow:active:not(:disabled) { transform: translateY(0); }
.pager-arrow:disabled { opacity: .2; cursor: default; }
.pager-mid { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pager-num {
  color: var(--dim); font-size: 12px; letter-spacing: .3em; text-indent: .3em;
  font-variant-numeric: tabular-nums;
}
.pager-num i { font-style: normal; opacity: .38; margin: 0 .1em; }
.pager-dots { display: flex; gap: 6px; }
.pager-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--line); transition: all .15s; }
.pager-dots i.on { background: var(--amber); box-shadow: 0 0 6px rgba(242, 165, 65, .65); }

/* ---------- 设置 / 玩法 ---------- */
.settings-panel {
  display: flex; flex-direction: column; gap: 18px;
  width: min(94vw, 560px); max-height: 82vh; overflow-y: auto;
}
.settings-panel label { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.settings-panel label > span:first-child { min-width: 110px; }
.settings-panel label span { text-align: right; color: var(--amber2); }
.settings-panel label span[id$="-val"] { width: 64px; }
.settings-panel input[type=range] { flex: 1; accent-color: var(--amber); }
.settings-panel input[type=text] {
  background: #14141b; border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 6px 10px; font-family: inherit; font-size: 14px;
}
.settings-panel .row input { accent-color: var(--amber); }
.hint { color: var(--dim); font-size: 12px; margin: 0; }
.keybind-section { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.keybind-section h3 { margin: 0; font-size: 13px; color: var(--dim); letter-spacing: .2em; }
.kb-row { display: flex; gap: 6px; flex-wrap: wrap; }
.kb-key {
  min-width: 44px; height: 38px; padding: 0 8px;
  background: #f5f2ea; color: #22222a; border: none; border-radius: 6px;
  font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit;
  box-shadow: 0 3px 0 #b9b6ac; transition: all .1s;
}
.kb-key:hover { transform: translateY(-1px); }
.kb-key.listening { background: var(--amber); color: #3a2c10; box-shadow: 0 0 14px rgba(242,165,65,.6); animation: kbpulse .8s infinite; }
@keyframes kbpulse { 50% { opacity: .65; } }
.howto-panel { line-height: 1.9; font-size: 14px; max-height: 86vh; overflow-y: auto; }
.howto-panel ul { padding-left: 20px; margin: 14px 0 0; }
.howto-panel li { margin-bottom: 6px; color: var(--dim); }
.kbd-diagram { text-align: center; margin: 30px 0 34px; transform: rotate(-15deg); transform-origin: center; }
.kbd-row { display: flex; justify-content: center; gap: 6px; }
.kbd-row.top { margin-bottom: -10px; z-index: 1; position: relative; gap: 18px; }
.kbd-row .gap { width: 40px; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 64px; background: #f5f2ea; color: #22222a;
  border-radius: 4px; font-weight: 700; font-family: inherit;
  box-shadow: 0 3px 0 #b9b6ac;
}
kbd.wide { width: 120px; }
.kbd-row.top kbd { width: 34px; height: 40px; background: #1b1b22; color: var(--amber2); box-shadow: 0 3px 0 #000; margin: 0 3px; }
.kbd-caption { margin: 4px 0 14px; color: var(--dim); font-size: 12px; text-align: center; }
.howto-canvas { width: 100%; height: 220px; border: 1px solid var(--line); border-radius: 10px; }
.j-crit { color: var(--crit); } .j-perf { color: var(--perf); }
.j-great { color: var(--great); } .j-good { color: var(--good); } .j-miss { color: var(--miss); }

/* ---------- 结算 ---------- */
.results-panel { text-align: center; min-width: min(92vw, 480px); }
.grade {
  font-size: 84px; font-weight: 800; color: var(--crit); line-height: 1;
  text-shadow: 0 0 30px rgba(255, 215, 94, .45);
}
.grade.low { color: var(--good); }
.grade.mid { color: var(--amber); }
.res-title { color: var(--dim); margin: 6px 0 2px; letter-spacing: .15em; }
.badges { min-height: 22px; margin-top: 4px; }
.badge {
  display: inline-block; border: 1px solid var(--amber); color: var(--amber2);
  border-radius: 999px; padding: 2px 14px; font-size: 12px; margin: 0 4px; letter-spacing: .2em;
}
.res-score { font-size: 40px; font-weight: 700; margin: 10px 0 16px; font-variant-numeric: tabular-nums; }
.res-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 30px;
  text-align: left; font-size: 14px; color: var(--dim);
  max-width: 320px; margin: 0 auto 22px;
}
.res-grid div:nth-child(even) { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.res-buttons { display: flex; gap: 14px; justify-content: center; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
/* 触屏无 Esc——HUD 内提供暂停入口（导航 chrome 件，样式见 .chip） */
#hud-pause { position: absolute; top: 12px; left: 22px; pointer-events: auto; }
#hud-song {
  position: absolute; top: 16px; left: 74px; font-size: 13px; color: var(--dim);
  letter-spacing: .12em; line-height: 40px;
}
#hud-score {
  position: absolute; top: 12px; right: 24px; font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
#hud-acc {
  position: absolute; top: 46px; right: 24px; font-size: 13px; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
#hud-combo {
  position: absolute; top: 76px; right: 24px;
  font-size: 34px; font-weight: 800; color: var(--amber2);
  text-shadow: 0 0 24px rgba(242,165,65,.5);
  font-variant-numeric: tabular-nums; transition: transform .08s;
}
#hud-combo.pop { transform: scale(1.22); }

/* ---------- 暂停 ---------- */
.overlay { background: rgba(6,6,9,.72); backdrop-filter: blur(4px); z-index: 10; }
.pause-panel { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.pause-panel h2 { margin: 0 0 8px; letter-spacing: .3em; }
.pause-panel .btn { min-width: 220px; text-align: center; }
.res-buttons .btn { min-width: 220px; text-align: center; }

@media (max-width: 640px) {
  .menu-buttons { flex-direction: column; }
  #hud-combo { font-size: 36px; }
}

/* 短视口（手机横屏）：面板取消内部 max-height/滚动，统一由 .screen 单层滚动
   （双滚动套娃难用）。必须放在 .settings-panel/.howto-panel 定义之后——
   同优先级后写生效（此前媒体查询写在前面被覆盖，修复未生效）。 */
@media (max-height: 480px) {
  .settings-panel, .howto-panel { max-height: none; overflow-y: visible; }
}
