:root {
  --ink: rgba(255,255,255,.92);
  --ink-2: rgba(255,255,255,.55);
  --line: rgba(255,255,255,.28);
  --pane: rgba(10,10,14,.38);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body { font: 500 13px/1.3 -apple-system, "SF Pro Text", "PingFang TC", "Noto Sans TC", system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* 開始 */
#start { position: fixed; left: 50%; top: 50%; width: clamp(84px, 16vmin, 132px); aspect-ratio: 1; transform: translate(-50%, -50%); opacity: 0; transition: opacity .5s, transform .25s cubic-bezier(.2,.8,.2,1); }
.ready #start { opacity: 1; }
#start svg { width: 100%; height: 100%; display: block; overflow: visible; }
#start .track { fill: var(--pane); stroke: var(--line); stroke-width: 1.2; }
#start .prog { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--p, 0)); transform: rotate(-90deg); transform-origin: 50% 50%; opacity: 0; transition: stroke-dashoffset .25s; }
#start .tri { fill: var(--ink); transition: transform .25s cubic-bezier(.2,.8,.2,1); transform-origin: 50% 50%; }
#start:hover .tri { transform: scale(1.08); }
#start:active { transform: translate(-50%, -50%) scale(.94); }
#start[data-state=loading] .prog { opacity: 1; }
#start[data-state=loading] .tri { transform: scale(.7); opacity: .5; }
#start[data-state=done] { opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(1.5); }
#start[data-state=error] .track { stroke: #ff6b6b; }

/* 曲名 */
#meta { position: fixed; left: calc(18px + var(--safe-l)); bottom: calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 2px; pointer-events: none; opacity: 0; transition: opacity .6s; }
.ready #meta { opacity: 1; }
#title { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
#cat { font-size: 12px; color: var(--ink-2); }

/* 播放／暫停 */
#play { position: fixed; right: calc(14px + var(--safe-r)); top: calc(14px + var(--safe-t)); width: 40px; height: 40px; border-radius: 50%; background: var(--pane); border: 1px solid var(--line); display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .4s, transform .15s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#start[data-state=done] ~ #play { opacity: 1; pointer-events: auto; }
#play:active { transform: scale(.9); }
#play svg { width: 18px; height: 18px; fill: var(--ink); }
#play .resume { display: none; }
body:not(.playing) #play .pause { display: none; }
body:not(.playing) #play .resume { display: block; }

/* 速度軌：只在觸控裝置出現 */
#rail { position: fixed; right: calc(14px + var(--safe-r)); bottom: calc(22px + var(--safe-b)); width: 44px; height: min(46vh, 260px); display: none; touch-action: none; }
#rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--line); border-radius: 1px; }
#rail::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 2px; margin-left: -1px; height: calc(var(--v, .27) * 100%); background: var(--ink); border-radius: 1px; }
#rail i { position: absolute; left: 50%; bottom: calc(var(--v, .27) * 100%); width: 22px; height: 22px; margin: 0 0 -11px -11px; border-radius: 50%; background: var(--ink); }
@media (pointer: coarse) { #start[data-state=done] ~ #rail { display: block; } }
@media (pointer: coarse) and (orientation: landscape) { #rail { height: min(64vh, 240px); bottom: 50%; transform: translateY(50%); } }

/* 手勢示範：動過就消失 */
#hint { position: fixed; left: 50%; bottom: 22%; width: 120px; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .5s; }
#start[data-state=done] ~ #hint { opacity: .9; }
.used #hint { opacity: 0 !important; }
#hint .arc { fill: none; stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 3 5; stroke-linecap: round; }
#hint .dot { fill: var(--ink); offset-path: path("M20 40 Q60 5 100 40"); animation: sweep 2.2s cubic-bezier(.5,0,.5,1) infinite alternate; }
@keyframes sweep { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@media (prefers-reduced-motion: reduce) { #hint .dot { animation: none; offset-distance: 50%; } }
body.capture #meta { opacity: 1; }
