/* 歌词字体：均为 SIL OFL 1.1，按 scripts/charset.txt 子集化；许可全文见 assets/fonts/OFL-*.txt */
@font-face { font-family: "NFJ Noto Serif"; src: url("../assets/fonts/NotoSerifSC-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "NFJ Han Serif Light"; src: url("../assets/fonts/SourceHanSerifSC-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "NFJ WenKai"; src: url("../assets/fonts/LXGWWenKai.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NFJ ZhenKai"; src: url("../assets/fonts/LXGWZhenKai.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NFJ ChienChia"; src: url("../assets/fonts/ChienChia.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NFJ LongCang"; src: url("../assets/fonts/LongCang.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NFJ Qiji"; src: url("../assets/fonts/Qiji.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --gold: #f2c46d; --gold-2: #ffe7b0; --gold-dim: rgba(242, 196, 109, .38); --ink: #f6ead2; --ink-dim: rgba(246, 234, 210, .62);
  --glass: rgba(14, 9, 5, .72); --glass-2: rgba(30, 20, 10, .78); --line: rgba(242, 196, 109, .22);
  --panel-w: 372px; --ui: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "NFJ Noto Serif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #050302; color: var(--ink); font: 14px/1.5 var(--ui); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
code { font-size: .92em; color: var(--gold-2); }

#stage { position: fixed; inset: 0; transition: right .35s ease, bottom .35s ease; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#tap { position: absolute; inset: 0; cursor: default; }
body:not(.hud-on).playing #tap { cursor: none; }

/* —— 封面 —— */
#cover { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; transition: opacity 1.2s ease, visibility 1.2s; text-align: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 0, rgba(0,0,0,.25) 55%, rgba(0,0,0,.6) 100%); }
body:not(.cover) #cover { opacity: 0; visibility: hidden; pointer-events: none; }
.cover-inner { padding: 24px; max-width: 640px; }
.cover-title { font: 700 clamp(40px, 9vmin, 92px)/1.1 var(--serif); letter-spacing: .32em; margin: 0 0 .1em .32em; color: transparent;
  background: linear-gradient(180deg, #fff5d6 10%, #f2c46d 60%, #b9772b 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 22px rgba(255, 190, 90, .45)); }
.cover-sub { font: 400 clamp(16px, 2.8vmin, 24px) var(--serif); letter-spacing: 1.2em; margin: 0 0 3.2em 1.2em; color: var(--ink-dim); }
.enter { font: 700 20px var(--serif); letter-spacing: .6em; padding: 16px 44px 16px 56px; border-radius: 999px; cursor: pointer; color: #2a1606;
  border: 1px solid #ffe7b0; background: linear-gradient(180deg, #ffe9b8, #e9b257 55%, #c98a35); box-shadow: 0 0 0 6px rgba(242,196,109,.12), 0 0 48px rgba(255,180,80,.55);
  transition: transform .2s, box-shadow .3s; }
.enter:hover, .enter:focus-visible { transform: translateY(-1px) scale(1.02); box-shadow: 0 0 0 8px rgba(242,196,109,.16), 0 0 72px rgba(255,180,80,.75); outline: none; }
.enter-test { display: block; margin: 26px auto 0; background: none; border: 0; color: var(--ink-dim); cursor: pointer; font-size: 13px; text-decoration: underline; text-decoration-color: var(--gold-dim); text-underline-offset: 4px; }
.enter-test small { display: block; font-size: 11px; opacity: .7; text-decoration: none; margin-top: 2px; }
.cover-note { font-size: 12px; color: var(--ink-dim); opacity: .75; margin-top: 28px; min-height: 1.5em; }

/* —— 控制栏 —— */
.hud { position: fixed; left: 0; right: 0; z-index: 20; transition: opacity .6s ease, transform .6s ease; padding-left: calc(18px + var(--safe-l)); padding-right: calc(18px + var(--safe-r)); }
body.panel-open .hud { right: var(--panel-w); }
body:not(.hud-on) .hud, body.cover .hud { opacity: 0; pointer-events: none; }
body:not(.hud-on) #top { transform: translateY(-8px); } body:not(.hud-on) #bottom { transform: translateY(8px); }
#top { top: 0; padding-top: calc(14px + var(--safe-t)); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0)); padding-bottom: 36px; }
#bottom { bottom: 0; padding-bottom: calc(12px + var(--safe-b)); background: linear-gradient(0deg, rgba(0,0,0,.65), rgba(0,0,0,0)); padding-top: 40px; }
.now { min-width: 0; }
.now-line { font-size: 12px; color: var(--ink-dim); letter-spacing: .08em; display: flex; gap: 8px; align-items: center; }
.now-title { font: 600 17px var(--serif); letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid #ff9b6a; color: #ffc3a3; letter-spacing: .04em; white-space: nowrap; }
.counter { background: none; border: 0; padding: 2px 0; font-size: 12px; color: var(--ink-dim); cursor: pointer; letter-spacing: .1em; }
.counter b { color: var(--gold-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.top-btns { display: flex; gap: 6px; }
.ibtn { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 8px; border-radius: 999px; border: 1px solid transparent; background: rgba(0,0,0,.25); cursor: pointer; color: var(--ink); }
.ibtn:hover, .ibtn:focus-visible { border-color: var(--line); background: rgba(40,26,12,.6); outline: none; }
.ibtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ibtn svg .fill { fill: currentColor; stroke: none; }
.ibtn.small { height: 36px; min-width: 36px; font-size: 12px; }
.ibtn.play { width: 64px; height: 64px; border-color: var(--gold-dim); background: rgba(242,196,109,.12); }
.ibtn.play svg { width: 28px; height: 28px; }
.i-pause { display: none; } body.playing .i-play { display: none; } body.playing .i-pause { display: block; }
.fs-off { display: none; } body.fs .fs-on { display: none; } body.fs .fs-off { display: block; }
body.muted .v-wave { opacity: .15; }
.progress { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; }
.tnum { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-dim); min-width: 42px; text-align: center; }
.ctrls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; max-width: 1100px; margin: 6px auto 0; gap: 8px; }
.transport { display: flex; align-items: center; gap: 18px; }
.vol { display: flex; align-items: center; gap: 6px; justify-self: end; }
#btn-mode { justify-self: start; padding: 0 14px; letter-spacing: .1em; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 28px; cursor: pointer; flex: 1; min-width: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gold) var(--p, 0%), rgba(255,255,255,.18) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255,255,255,.18); }
input[type=range]::-moz-range-progress { height: 3px; background: var(--gold); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--gold-2); box-shadow: 0 0 10px rgba(255,200,110,.8); border: 0; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold-2); border: 0; box-shadow: 0 0 10px rgba(255,200,110,.8); }
#vol { width: 110px; flex: none; }

/* —— 播单抽屉 —— */
#drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(380px, 92vw); z-index: 25; background: var(--glass); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .35s ease; display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 16px calc(14px + var(--safe-b)) calc(16px + var(--safe-l)); }
body.drawer-open #drawer { transform: none; }
.drawer-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-head h2, .panel-head h2 { font: 600 17px var(--serif); letter-spacing: .3em; margin: 0; color: var(--gold-2); }
.pl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.chip { border: 1px solid var(--line); background: rgba(0,0,0,.2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--ink-dim); }
.chip.on { color: #2a1606; background: linear-gradient(180deg, #ffe3a6, #e2a94e); border-color: transparent; }
.chip.test { border-color: rgba(255,155,106,.55); }
.pl-desc { font-size: 12px; color: var(--ink-dim); margin: 6px 0 10px; min-height: 1.4em; }
.tracks { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.tracks li { display: grid; grid-template-columns: 28px 1fr; gap: 4px 8px; padding: 10px 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.tracks li:hover { background: rgba(255,255,255,.04); }
.tracks li.on { border-color: var(--line); background: rgba(242,196,109,.08); }
.tracks .n { color: var(--ink-dim); font-variant-numeric: tabular-nums; text-align: right; padding-top: 1px; }
.tracks .tt { font: 600 15px var(--serif); letter-spacing: .04em; }
.tracks .sub { grid-column: 2; font-size: 12px; color: var(--ink-dim); }
.tracks .empty { display: block; cursor: default; color: var(--ink-dim); font-size: 13px; line-height: 1.7; border: 1px dashed var(--line); }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.btn { border: 1px solid var(--line); background: rgba(242,196,109,.08); color: var(--ink); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; }
.btn:hover { background: rgba(242,196,109,.16); }
.btn.primary { background: linear-gradient(180deg, #ffe3a6, #e2a94e); color: #2a1606; border-color: transparent; }
.btn.warn { border-color: rgba(255,130,100,.4); color: #ffc3a3; }
.btn.mini { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.hint { font-size: 12px; color: var(--ink-dim); margin: 8px 0 0; }

/* —— 设计 / 调试面板 —— */
#panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); z-index: 26; background: var(--glass-2); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--line); transform: translateX(102%); transition: transform .35s ease, opacity .2s; display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) 0 var(--safe-b) 0; }
body.panel-open #panel { transform: none; }
body.panel-open #stage { right: var(--panel-w); }
#panel.peek { opacity: .28; }
#panel.peek .row.active { opacity: 1; }
.panel-head { padding: 0 14px; }
.fps { font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; margin-left: auto; }
.meter { width: calc(100% - 28px); margin: 10px 14px 4px; height: 76px; border-radius: 8px; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 6px 10px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { background: none; border: 0; padding: 8px 9px; cursor: pointer; color: var(--ink-dim); white-space: nowrap; border-bottom: 2px solid transparent; font-size: 13px; letter-spacing: .1em; }
.tabs button.on { color: var(--gold-2); border-bottom-color: var(--gold); }
.panel-body { flex: 1; overflow: auto; padding: 6px 14px 30px; overscroll-behavior: contain; }
.panel-note { font-size: 12px; color: #9fe0a8; padding: 0 14px 6px; min-height: 18px; }
.panel-note.bad { color: #ffb19a; }
.grp { font: 600 12px var(--ui); color: var(--gold); letter-spacing: .2em; margin: 16px 0 4px; padding-top: 10px; border-top: 1px solid rgba(242,196,109,.12); }
.row { display: grid; grid-template-columns: 1fr 1.25fr 46px; align-items: center; gap: 8px; padding: 3px 0; min-height: 34px; }
.row label { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row label.edited::after { content: ' ●'; color: var(--gold); font-size: 9px; vertical-align: middle; }
.row .val { font-size: 11px; color: var(--ink-dim); text-align: right; font-variant-numeric: tabular-nums; cursor: pointer; }
.row .val:hover { color: var(--gold-2); }
.row select, .row input[type=text], .row input[type=number], .tl input, .field input, .field select { width: 100%; background: rgba(0,0,0,.35); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font: 13px var(--ui); }
.row input[type=color] { width: 100%; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.row .desc { grid-column: 1 / -1; font-size: 11px; color: var(--ink-dim); margin: -4px 0 4px; line-height: 1.45; }
.switch { position: relative; width: 40px; height: 22px; justify-self: start; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,.14); transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #ddd; transition: transform .2s; }
.switch input:checked + span { background: var(--gold); } .switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: rgba(0,0,0,.2); }
.card h3 { margin: 0 0 4px; font: 600 15px var(--serif); letter-spacing: .1em; color: var(--gold-2); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card p { margin: 0 0 8px; font-size: 12px; color: var(--ink-dim); }
.card .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.card.on { border-color: var(--gold); }
.info { font-size: 12px; color: var(--ink-dim); line-height: 1.6; margin: 8px 0; }
.info b { color: var(--ink); font-weight: 600; }
.field { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; font-size: 12px; margin: 6px 0; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.tl td { padding: 2px 2px; }
.tl tr.cur td { background: rgba(242,196,109,.14); }
.tl input { padding: 3px 4px; font-size: 12px; }
.tl .ix { color: var(--ink-dim); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.tl .t input { width: 64px; font-variant-numeric: tabular-nums; }
.tap { width: 100%; padding: 14px; font: 600 15px var(--serif); letter-spacing: .2em; border-radius: 10px; border: 1px solid var(--gold); background: rgba(242,196,109,.12); color: var(--gold-2); cursor: pointer; touch-action: none; user-select: none; }
.tap.down { background: var(--gold); color: #2a1606; }

#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%) translateY(10px); z-index: 40; background: rgba(20,12,6,.88); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* —— 窄屏 / 手机 —— */
@media (max-width: 760px) {
  :root { --panel-w: 100vw; }
  #panel { top: auto; height: 56vh; height: 56dvh; width: 100%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; transform: translateY(102%); padding-top: 10px; }
  body.panel-open #stage { right: 0; bottom: 56vh; bottom: 56dvh; }
  body.panel-open .hud { right: 0; }
  body.panel-open #bottom { display: none; }
  .meter { height: 56px; }
  .ctrls { grid-template-columns: auto 1fr auto; }
  .transport { justify-self: center; gap: 10px; }
  #vol { width: 72px; }
  .vol { gap: 0; }
  #btn-mode { padding: 0 8px; font-size: 11px; letter-spacing: 0; }
  .now-title { font-size: 15px; max-width: 52vw; }
  .row { grid-template-columns: 1fr 1.3fr 42px; min-height: 40px; }
}
@media (max-width: 400px) { .vol input { display: none; } }
@media (prefers-reduced-motion: reduce) { .hud, #drawer, #panel, #cover { transition-duration: .01s; } }
