:root {
    --bg: #0c0a16; --card: #16122a; --line: #2c2650; --text: #f2f0ff; --dim: #a8a4c8;
    --pink: #ff78dc; --cyan: #78c8ff; --yellow: #ffe678; --green: #78ffaa; --red: #ff6e6e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: radial-gradient(1200px 600px at 20% -10%, #2a1450 0%, transparent 60%),
                radial-gradient(900px 500px at 100% 0%, #10305a 0%, transparent 55%), var(--bg);
    color: var(--text); font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    font-size: 15px; line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#home { max-width: 1320px; margin: 0 auto; padding: 20px 16px 40px; }
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.logo { font-weight: 900; font-size: 34px; letter-spacing: 2px; text-shadow: 0 0 18px rgba(255, 120, 220, .6); }
.logo span { color: var(--pink); }
.tagline { color: var(--dim); margin: 0; flex: 1; min-width: 160px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { background: rgba(120, 200, 255, .12); border: 1px solid var(--cyan); border-radius: 999px; padding: 7px 16px; font-weight: 700; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px; color: var(--dim); }
.ghost:hover, .chip:hover { border-color: var(--pink); color: var(--text); }
.primary { background: var(--pink); color: #1a0828; border: 0; border-radius: 12px; padding: 12px 34px; font-weight: 900; font-size: 18px; }
.primary:hover { filter: brightness(1.1); }
.primary:disabled { opacity: .45; cursor: default; }

.grid { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.25fr) minmax(260px, .8fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid { grid-template-columns: 1fr 1fr; } #feedCard { grid-column: 1 / -1; } }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head.slim { margin: 14px 0 8px; }
h2 { margin: 0; font-size: 20px; } h3 { margin: 0 0 6px; font-size: 20px; } h4 { margin: 0; font-size: 15px; color: var(--dim); }
.tabs, .seg { display: inline-flex; background: #0f0c20; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button, .seg button { background: transparent; border: 0; border-radius: 8px; padding: 5px 12px; color: var(--dim); font-size: 14px; }
.tabs button.on, .seg button.on { background: var(--line); color: var(--text); font-weight: 700; }

.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li, .me-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.rank-list li.me, .me-row { background: rgba(255, 230, 120, .08); border-radius: 10px; border-bottom-color: transparent; }
.me-row { margin-top: 10px; border: 1px dashed var(--yellow); }
.rank-list .no { font-weight: 900; text-align: center; color: var(--dim); }
.rank-list li:nth-child(1) .no { color: var(--yellow); font-size: 20px; }
.rank-list li:nth-child(2) .no { color: #d8d8e8; font-size: 18px; }
.rank-list li:nth-child(3) .no { color: #ffb070; font-size: 17px; }
.who { min-width: 0; }
.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small, .dim { color: var(--dim); font-size: 13px; }
.pts { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.pts small { display: block; color: var(--dim); font-weight: 400; }
.rank-list.small li { padding: 5px 6px; font-size: 14px; }
.empty { color: var(--dim); padding: 18px 6px; text-align: center; }
.grade { font-weight: 900; margin-right: 6px; }
.grade.S { color: #ffdc50; } .grade.A { color: #78ffc8; } .grade.B { color: #78b4ff; } .grade.C { color: #dcdcdc; } .grade.D { color: var(--red); }

#songSearch, .register input, .dlg input:not([type=checkbox]):not([type=range]), .dlg select {
    width: 100%; background: #0f0c20; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
#songSearch:focus, .register input:focus, .dlg input:focus, .dlg select:focus { border-color: var(--cyan); }
.song-list { list-style: none; margin: 10px 0; padding: 0; max-height: 56vh; overflow: auto; }
.song-list li { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; cursor: pointer; }
.song-list li:hover { background: rgba(255, 255, 255, .05); }
.song-list li.busy { cursor: default; opacity: .7; }
.song-list img { width: 96px; height: 54px; object-fit: cover; border-radius: 8px; background: #000; }
.song-list .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-list .go { color: var(--pink); font-weight: 900; }
.register { display: flex; gap: 8px; }
.register button { background: var(--line); border: 0; border-radius: 10px; padding: 0 18px; font-weight: 700; white-space: nowrap; }
.register button:hover { background: var(--cyan); color: #06182a; }
.msg { min-height: 20px; margin: 8px 2px 0; font-size: 13px; color: var(--yellow); }
.msg.err { color: var(--red); } .msg.ok { color: var(--green); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .05); font-size: 14px; }
.feed li b { color: var(--cyan); }
.feed .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }

.dlg { background: var(--card); color: var(--text); border: 1px solid var(--pink); border-radius: 20px; padding: 22px; width: min(640px, 94vw); max-height: 92vh; }
.dlg.narrow { width: min(420px, 94vw); }
.dlg::backdrop { background: rgba(5, 0, 20, .72); }
.dlg .close { position: absolute; right: 12px; top: 8px; background: none; border: 0; font-size: 28px; color: var(--dim); }
.dlg label { display: block; margin: 12px 0; color: var(--dim); font-size: 14px; }
.dlg label.row { display: flex; gap: 8px; align-items: center; color: var(--text); }
.dlg label input, .dlg label select { margin-top: 4px; color: var(--text); }
.song-head { display: flex; gap: 14px; align-items: center; margin-right: 24px; }
.song-head img { width: 160px; height: 90px; object-fit: cover; border-radius: 10px; background: #000; }
.diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.diffs button { background: #0f0c20; border: 2px solid var(--line); border-radius: 14px; padding: 12px 6px; text-align: center; }
.diffs button b { display: block; font-size: 18px; }
.diffs button small { color: var(--dim); display: block; }
.diffs button.on { border-color: var(--yellow); background: rgba(255, 230, 120, .08); }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.center { text-align: center; margin: 10px 0 0; }

#loading { position: fixed; inset: 0; background: rgba(8, 4, 24, .9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 30; font-size: 18px; text-align: center; padding: 20px; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--pink); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 20; display: block; background: #0c0a16; }
.rank-list li.empty, .feed li.empty, .song-list li.empty { display: block; cursor: default; border-bottom: 0; }
.song-list { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
