:root {
  --bg: #0d1117;
  --panel: rgba(18, 24, 33, 0.92);
  --line: #2a3442;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #2dd4bf;
  --accent2: #f59e0b;
  --danger: #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", system-ui, sans-serif; overflow: hidden; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
body.playing canvas#game { cursor: none; }

.screen { position: fixed; inset: 0; display: none; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 48px 16px; }
.screen.active { display: flex; }
.screen.overlay { background: rgba(5, 8, 12, 0.6); align-items: center; }
#home { background: radial-gradient(ellipse at top, #13303a 0%, var(--bg) 60%); }

.panel { width: 100%; max-width: 720px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; backdrop-filter: blur(6px); }
.panel.narrow { max-width: 440px; text-align: center; }
h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: 0.5px; }
h1 .tag { font-size: 12px; vertical-align: middle; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 999px; padding: 2px 8px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.panel.narrow h2 { margin-top: 12px; }
.sub, .muted { color: var(--muted); }
.sub { margin: 0 0 20px; }

input[type=text], input[type=number] { width: 100%; background: #0a0e14; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; }
input[type=number] { width: 90px; padding: 6px 8px; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

button { font: inherit; color: var(--text); background: #1c2430; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: wait; }
button.primary { background: var(--accent); color: #062421; border-color: var(--accent); font-weight: 700; }
button.big { font-size: 18px; padding: 14px; }
button.ghost { background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button.on { background: #24303f; color: var(--accent); }

.status { min-height: 1.4em; color: var(--accent2); margin: 12px 0 0; }
.status.err { color: var(--danger); }

.library { display: grid; gap: 10px; }
.card { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line);
  border-radius: 12px; background: #111821; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; }
.card .info { flex: 1; min-width: 0; }
.card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .del { background: transparent; border: 0; color: var(--muted); padding: 6px 10px; }
.card .del:hover { color: var(--danger); }

.settings { margin-top: 24px; color: var(--muted); }
.settings summary { cursor: pointer; }
.settings label { display: block; margin: 12px 0; }
.settings small { display: block; margin-top: 4px; }
.help { margin-top: 20px; padding: 14px 18px; border-radius: 12px;
  background: rgba(245, 158, 11, 0.10); border: 1px solid rgba(245, 158, 11, 0.55); color: var(--text); font-size: 15px; }
.help-title { color: var(--accent2); font-weight: 700; margin-bottom: 6px; }
.help ul { margin: 0; padding-left: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; }
.help b { color: var(--accent2); }
.help .k { display: inline-block; min-width: 1.6em; text-align: center; padding: 1px 7px; border-radius: 6px;
  background: #2a2112; border: 1px solid var(--accent2); border-bottom-width: 3px; color: #fde68a; font-weight: 700; font-size: 13px; }

.thumb { width: 100%; border-radius: 10px; aspect-ratio: 16/9; object-fit: cover; }
.best { color: var(--accent2); min-height: 1.2em; }
.rank { font-size: 72px; font-weight: 800; color: var(--accent); line-height: 1; }
.score { font-size: 36px; font-weight: 700; margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; text-align: left; color: var(--muted); }
.stats b { color: var(--text); float: right; font-variant-numeric: tabular-nums; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1c2430;
  border: 1px solid var(--accent); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; }
select { font: inherit; color: var(--text); background: #0a0e14; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.settings button { padding: 6px 12px; margin-left: 6px; }
.player { float: right; color: var(--muted); font-size: 14px; }
.player b { color: var(--accent); }
.libhead { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.libhead h2 { margin: 0; }
.player a { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* "your song is ready" notices */
.notices { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.notice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #111822; font-size: 14px; }
.notice b { flex: 1 1 auto; min-width: 0; }
.notice.ready { border-color: var(--accent); background: rgba(45, 212, 191, 0.08); }
.notice.err { border-color: var(--danger); }
.notice.wait { color: var(--muted); }
.notice button { padding: 6px 12px; }
