:root { --bg:#15161a; --panel:#1e2026; --line:#30333c; --text:#e8e9ee; --sub:#9a9eab; --accent:#4f8cff; }
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); font:16px/1.5 sans-serif; }
button { font:inherit; min-height:48px; min-width:48px; padding:8px 14px; border:0; border-radius:8px; background:var(--line); color:var(--text); touch-action:manipulation; }
button.primary, button.on { background:var(--accent); color:#fff; }
button:disabled { opacity:.35; }
input[type=text], input[type=search] { font:inherit; width:100%; min-height:48px; padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--text); }
input[type=range] { flex:1; min-height:40px; accent-color:var(--accent); }
h1, h2, h3 { margin:0; }
h2 { font-size:18px; }
.row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.row.center { justify-content:center; }
.error { color:#ff8b8b; white-space:pre-wrap; }

#start { max-width:520px; margin:auto; padding:32px 16px; display:flex; flex-direction:column; gap:12px; }

#main { display:flex; flex-direction:column; height:100%; height:100dvh; }
#playerPane { flex:none; max-height:75%; overflow-y:auto; padding:0 10px 6px; border-bottom:1px solid var(--line); }
#stage { position:relative; margin:0 -10px; height:34vh; background:#000; }
#video, #placeholder, #loading { position:absolute; inset:0; width:100%; height:100%; }
#video { object-fit:contain; }
#placeholder, #loading { display:flex; align-items:center; justify-content:center; text-align:center; padding:12px; color:var(--sub); }
#loading { flex-direction:column; gap:10px; background:rgba(0,0,0,.65); color:#fff; pointer-events:none; }
#loadingBar { width:70%; max-width:360px; height:10px; accent-color:var(--accent); }
.spinner, .busy::before { display:inline-block; width:28px; height:28px; border:3px solid rgba(255,255,255,.25); border-top-color:var(--accent); border-radius:50%; animation:spin .9s linear infinite; }
.busy::before { content:''; width:14px; height:14px; border-width:2px; margin-right:8px; vertical-align:-2px; }
@keyframes spin { to { transform:rotate(360deg); } }
button.down { box-shadow:inset 0 -3px #1e8fe0; } button.up { box-shadow:inset 0 -3px #e0761e; }
.keyblock { display:flex; flex-direction:column; align-items:center; gap:6px; width:100%; }
#keyVal { font-size:20px; font-weight:bold; min-width:5.5em; }
.scale { display:flex; gap:2px; width:100%; max-width:480px; }
.scale span { flex:1; min-width:0; text-align:center; font-size:11px; color:var(--sub); border-radius:3px; background:var(--line); }
.scale span.origin { outline:1px solid var(--sub); }
.scale span.fill { color:#fff; } .scale span.now { color:#fff; font-weight:bold; background:var(--accent); }
.scale[data-dir=down] span.fill { background:#245a80; } .scale[data-dir=down] span.now { background:#1e8fe0; }
.scale[data-dir=up] span.fill { background:#80502a; } .scale[data-dir=up] span.now { background:#e0761e; }
#more { width:100%; text-align:center; }
#more summary { padding:10px; color:var(--sub); cursor:pointer; }
#more .ctl { justify-content:center; margin-bottom:8px; }
#more #offsetVal { min-width:12em; }
.offsets { flex-wrap:wrap; }
.hint { margin:4px 0; font-size:12px; color:var(--sub); }
#nowTitle { margin-top:6px; font-weight:bold; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#time { font-size:13px; color:var(--sub); font-variant-numeric:tabular-nums; }
button.big { min-width:76px; font-size:22px; }
#controls { display:flex; flex-wrap:wrap; justify-content:center; gap:8px 16px; margin-top:8px; }
.ctl { display:flex; align-items:center; gap:6px; }
.ctl output { min-width:7.5em; text-align:center; font-size:14px; }
#status, #nextInfo { margin:4px 0 0; font-size:13px; color:var(--sub); white-space:pre-wrap; min-height:0; }
#status.error { color:#ff8b8b; }
#status:empty, #nextInfo:empty { display:none; }

#listPane { flex:1; min-height:0; overflow-y:auto; padding:10px; }
#lists { display:flex; gap:8px; overflow-x:auto; padding-bottom:8px; }
#lists button { flex:none; border-radius:24px; }
.pane-head { display:flex; flex-direction:column; gap:8px; margin:4px 0 8px; }
#songs { list-style:none; margin:0; padding:0; }
#songs li { display:flex; align-items:center; gap:8px; min-height:60px; padding:8px; border-bottom:1px solid var(--line); }
#songs li.playing { background:#25324d; }
#songs li.missing { opacity:.5; }
#songs li.empty { color:var(--sub); }
.song-name { flex:1; min-width:0; overflow-wrap:anywhere; }
.tags { display:block; font-size:12px; color:var(--sub); }
.foot { margin-top:16px; }

#sheet { position:fixed; inset:0; display:flex; align-items:flex-end; justify-content:center; background:rgba(0,0,0,.6); z-index:5; }
#sheetBody { width:100%; max-width:560px; max-height:80%; overflow-y:auto; padding:16px; border-radius:16px 16px 0 0; background:var(--panel); display:flex; flex-direction:column; gap:10px; }
#sheetItems { display:flex; flex-direction:column; gap:8px; }

/* スマホ（幅が狭い画面）：ボタンと映像を小さめにする */
@media (max-width: 520px) {
  body { font-size:14px; }
  button { min-height:44px; min-width:44px; padding:6px 9px; }
  button.big { min-width:60px; }
  #stage { height:28vh; }
  .ctl { gap:4px; }
}
/* スマホの縦画面は全体を 1 本にして、下へスクロールすると曲の一覧が広く見えるようにする */
@media (max-width: 520px) and (orientation: portrait) {
  #main { display:block; height:auto; }
  #playerPane { max-height:none; overflow:visible; }
  #listPane { overflow:visible; }
}
/* 待ち表示の裏の曲名は隠す */
#stage:has(#loading:not([hidden])) #placeholder { visibility:hidden; }

/* 横向き：左に映像と操作、右に曲の一覧 */
@media (orientation: landscape) {
  #main { flex-direction:row; }
  #playerPane { flex:3; max-height:none; min-width:0; overflow-y:auto; border-bottom:0; border-right:1px solid var(--line); }
  #stage { height:auto; aspect-ratio:16/9; max-height:62vh; }
  #listPane { flex:2; }
}
#stage:fullscreen { height:100%; max-height:none; margin:0; }
