:root {
  --navy: #26305c;
  --sun: #ffd54a;
  --pink: #ff5d8f;
  --ui: "Jua", "Malgun Gothic", sans-serif;
  --word: "Lexend", "Segoe UI", Arial, sans-serif;
  --paper: #fffdf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1a2144; overflow: hidden; font-family: var(--ui); color: var(--navy); }
#wrap { position: fixed; inset: 0; }
#stage { position: absolute; left: 50%; top: 50%; width: 1600px; height: 900px; transform: translate(-50%, -50%) scale(var(--s, 1)); overflow: hidden; background: #2a3366; }
#cv { position: absolute; inset: 0; width: 1600px; height: 900px; }
[hidden] { display: none !important; }
button { font-family: var(--ui); color: var(--navy); cursor: pointer; }
kbd { font-family: var(--word); background: #fff; border: 2px solid var(--navy); border-bottom-width: 4px; border-radius: 8px; padding: 0 8px; font-size: .85em; }

/* 위쪽 */
#hud { position: absolute; left: 20px; right: 20px; top: 12px; display: flex; gap: 10px; align-items: center; z-index: 3; }
.spacer { flex: 1; }
.pill { background: rgba(255, 253, 248, .95); border: 3px solid var(--navy); border-radius: 18px; padding: 4px 16px; font-size: 24px; height: 46px; display: flex; align-items: center; }
.pill.btn { padding: 0 10px; font-size: 22px; }
.pill.btn.off { opacity: .45; }
.pill.progress { width: 300px; padding: 0; overflow: hidden; background: #fff; }
#hudBar { height: 100%; width: 0; background: linear-gradient(90deg, #51cf66, #ffd54a); }
.pill.score { font-family: var(--word); font-weight: 700; color: #e0457b; min-width: 120px; justify-content: flex-end; }
.pill.combo { font-family: var(--word); font-weight: 700; color: #1f8a4c; }
.pill.combo:empty { display: none; }

/* 양손과 자판 */
#play { position: absolute; left: 0; right: 0; top: 486px; height: 400px; z-index: 2; }
.hand { position: absolute; top: 6px; width: 282px; height: 372px; padding: 8px 2px; background: rgba(38, 48, 92, .94); border-radius: 22px; box-shadow: 0 6px 0 rgba(0, 0, 0, .25); }
.hand.left { left: 16px; }
.hand.right { right: 16px; }
.hand svg { width: 100%; height: 100%; overflow: visible; }
.hand .palm { fill: #ffe3c8; stroke: var(--navy); stroke-width: 4; }
.hand .fg rect { stroke: var(--navy); stroke-width: 4; transition: transform .08s; }
.hand .fg { opacity: .4; }
.hand .fg.act { opacity: 1; }
.hand .fg text { font: 700 22px var(--word); fill: #fff; text-anchor: middle; paint-order: stroke; stroke: rgba(38, 48, 92, .55); stroke-width: 3px; }
.hand .fg.next rect { stroke: #fff; stroke-width: 7; filter: drop-shadow(0 0 12px #fff); }
.hand .fg.press rect { filter: brightness(1.25); }

#kbd { position: absolute; left: 310px; top: 6px; width: 980px; height: 372px; background: rgba(38, 48, 92, .94); border-radius: 22px; padding: 12px; box-shadow: 0 6px 0 rgba(0, 0, 0, .25); }
.key { position: absolute; width: 84px; height: 80px; border-radius: 14px; background: #4a5488; color: rgba(255, 255, 255, .45); display: flex; align-items: center; justify-content: center; font: 700 34px var(--word); border-bottom: 6px solid rgba(0, 0, 0, .3); transition: transform .06s; user-select: none; }
.key.act { background: var(--c); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.key.space { font-size: 20px; }
.key.bump::after { content: ""; position: absolute; bottom: 10px; width: 24px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .9); }
.key.next { transform: translateY(-5px) scale(1.1); outline: 6px solid #fff; z-index: 2; box-shadow: 0 0 26px 8px rgba(255, 255, 255, .75); }
.key.press { transform: translateY(4px); border-bottom-width: 2px; filter: brightness(1.2); }
.key.bad { background: #e03131 !important; color: #fff; animation: shake .25s; }
#kbd.blind .key { color: transparent; text-shadow: none; }
#kbd.blind .key.space { color: transparent; }
#kbd.blind .key.next { transform: none; outline: 0; box-shadow: none; }
@keyframes shake { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }

/* 첫 화면 */
.screen { position: absolute; inset: 0; z-index: 4; }
#home { display: grid; grid-template-columns: 540px 1fr; gap: 24px; padding: 26px 30px; background: rgba(20, 28, 70, .35); }
.logo { margin: 0; font: 700 78px/1 var(--word); letter-spacing: -2px; text-shadow: 0 4px 0 var(--navy), 0 0 18px rgba(0, 0, 0, .3); }
.tagline { margin: 8px 0 12px; font-size: 28px; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .7); }
.tagline b { color: var(--sun); font-weight: 400; }
.howto { list-style: none; margin: 0; padding: 10px 18px; background: rgba(255, 253, 248, .93); border: 3px solid var(--navy); border-radius: 20px; font-size: 23px; line-height: 38px; }
.howto b { color: #e0457b; font-weight: 400; }

.board { margin-top: 14px; background: rgba(255, 253, 248, .94); border: 3px solid var(--navy); border-radius: 22px; padding: 10px 18px 8px; }
.board-head { display: flex; align-items: center; gap: 10px; font-size: 25px; }
.board-head b { margin-right: auto; font-weight: 400; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mini-seg { display: flex; border: 2px solid var(--navy); border-radius: 12px; overflow: hidden; flex: none; }
.mini-seg button { border: 0; background: #fff; font-size: 18px; padding: 3px 12px; }
.mini-seg button + button { border-left: 2px solid var(--navy); }
.mini-seg button.on { background: var(--sun); }
.board ol { list-style: none; margin: 6px 0 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 12px; font-size: 21px; line-height: 33px; border-top: 1px dashed #d5d9ea; }
.board li:first-child { border-top: 0; }
.board li b { width: 34px; text-align: center; font-family: var(--word); }
.board li .nm { flex: 1; font-family: var(--word); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .sc { font-family: var(--word); font-weight: 700; color: #e0457b; width: 100px; text-align: right; }
.board li .cp { width: 92px; text-align: right; color: #6b7190; font-size: 18px; }
.board li.me { background: #fff2b8; border-radius: 10px; }
.board li.empty { color: #8b91ad; justify-content: center; }

.card { background: rgba(255, 253, 248, .96); border: 4px solid var(--navy); border-radius: 28px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lessons { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 10px; flex: 1; min-height: 0; }
.lesson { position: relative; display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: #fff; border: 3px solid #cfd4e8; border-radius: 16px; padding: 10px 14px; font-size: 27px; line-height: 1.15; overflow: hidden; }
.lesson .no { font: 700 17px var(--word); color: #8b91ad; }
.lesson .ttl { margin-top: 1px; }
.lesson .keys { margin-top: auto; display: flex; flex-wrap: wrap; gap: 2px; min-height: 26px; }
.lesson .keys i { font: 700 17px/28px var(--word); font-style: normal; width: 28px; height: 28px; border-radius: 7px; background: var(--c); color: #fff; text-align: center; }
.lesson .keys small { font-size: 18px; color: #6b7190; }
.lesson .stars { position: absolute; right: 10px; top: 8px; font-size: 20px; letter-spacing: -2px; color: #d4d8e8; }
.lesson .stars b { color: #f5a800; font-weight: 400; }
.lesson.on { border-color: var(--navy); background: #fff8d6; box-shadow: 0 4px 0 var(--navy); transform: translateY(-2px); }
.tb { display: flex; gap: 10px; align-items: center; }
.tb select { font: 20px var(--ui); color: var(--navy); border: 3px solid var(--navy); border-radius: 12px; padding: 5px 8px; background: #fff; min-width: 0; }
.mixrow select { flex: 1 1 0; }
.mixrow select[hidden] { display: none; }
#intro .mix { margin: -4px 0 8px; font-size: 22px; color: #6b7190; }
#selPub { width: 190px; flex: none; }
#selUnit { flex: 1; }
.opts { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 22px; }
.seg { display: flex; border: 3px solid var(--navy); border-radius: 14px; overflow: hidden; flex: none; }
.seg button { border: 0; background: #fff; font-size: 22px; padding: 5px 15px; }
.seg button + button { border-left: 2px solid var(--navy); }
.seg button.on { background: var(--sun); }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 22px; height: 22px; }
.sync { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 18px; color: #6b7190; }
.sync button { width: 30px; height: 30px; border: 2px solid var(--navy); border-radius: 8px; background: #fff; font-size: 20px; line-height: 1; padding: 0; }
.sync b { font: 700 18px var(--word); width: 48px; text-align: center; color: var(--navy); }
.actions { display: flex; gap: 12px; align-items: center; }
.go { background: var(--pink); color: #fff; border: 4px solid var(--navy); border-radius: 20px; font-size: 32px; padding: 8px 34px; box-shadow: 0 5px 0 var(--navy); }
.go small { font-size: 18px; opacity: .85; margin-left: 6px; }
.go:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--navy); }
.go[disabled] { background: #b0b5cc; cursor: default; }
.go.small { font-size: 24px; padding: 6px 20px; box-shadow: 0 3px 0 var(--navy); }
.go.small small { font-size: 15px; }
.ghost { background: #fff; border: 3px solid var(--navy); border-radius: 16px; font-size: 22px; padding: 9px 16px; }
.ghost.off { opacity: .45; }
.ghost small { font-size: 16px; color: #6b7190; }
.actions .ghost:first-of-type { margin-left: auto; }
.note { margin: 0; font-size: 19px; color: #6b7190; }
.note.warn { color: #d9304f; }
.note b { color: var(--navy); font-weight: 400; }

/* 안내·멈춤 */
.overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(20, 28, 70, .62); }
.box { background: var(--paper); border: 4px solid var(--navy); border-radius: 30px; padding: 26px 40px; text-align: center; min-width: 560px; max-width: 1320px; }
.box h2 { margin: 0 0 12px; font-size: 44px; font-weight: 400; }
.box .actions { justify-content: center; margin-top: 18px; }
.box .actions .ghost:first-of-type { margin-left: 0; }
.friends { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0 12px; }
.friend { width: 128px; }
.friend img { width: 104px; height: 104px; object-fit: contain; display: block; margin: 0 auto; }
.friend .ks { display: flex; gap: 3px; justify-content: center; margin-top: 2px; }
.friend .ks i { font: 700 20px/32px var(--word); font-style: normal; width: 32px; height: 32px; border-radius: 8px; background: var(--c); color: #fff; }
.friend small { display: block; margin-top: 3px; font-size: 18px; color: #4d5680; }
.tip { font-size: 26px; margin: 6px 0; }
.ready { font-size: 22px; color: #6b7190; margin: 6px 0 0; }
.ready b { font-family: var(--word); color: var(--navy); }
#pauseBtns[hidden] + * { display: none; }

/* 결과 */
#result { display: grid; grid-template-columns: 560px 1fr; gap: 22px; padding: 26px 30px; background: rgba(20, 28, 70, .72); }
.r-card { background: var(--paper); border: 4px solid var(--navy); border-radius: 28px; padding: 18px 26px; min-width: 0; }
.r-card h2 { margin: 0; font-size: 34px; font-weight: 400; }
.r-card h2 small { display: block; font-size: 21px; color: #6b7190; }
.r-stars { font-size: 76px; line-height: 1.05; color: #d9dce9; letter-spacing: 4px; }
.r-stars span.on { color: #f5a800; animation: pop .4s; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.r-score { font: 700 60px/1.1 var(--word); color: #e0457b; }
.r-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.r-stats div { background: #f2f4fb; border-radius: 14px; padding: 6px 4px; text-align: center; font-size: 19px; color: #6b7190; }
.r-stats b { display: block; font: 700 30px var(--word); color: var(--navy); }
.r-weak { margin-top: 12px; font-size: 23px; line-height: 1.35; }
.r-weak b { font-family: var(--word); }
.r-card:first-child { display: flex; flex-direction: column; }
.r-band { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-items: flex-end; }
.r-band img { height: 92px; max-width: 92px; object-fit: contain; }
.r-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mini-kbd { position: relative; height: 212px; margin-top: 8px; }
.mini-kbd .mk { position: absolute; width: 62px; height: 62px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font: 700 24px var(--word); background: #e6e8f2; color: #b0b5cc; }
.mini-kbd .mk.good { background: #51cf66; color: #fff; }
.mini-kbd .mk.so { background: #ffb347; color: #fff; }
.mini-kbd .mk.weak { background: #ff6b6b; color: #fff; }
.legend { font-size: 18px; color: #6b7190; display: flex; gap: 14px; }
.legend i { display: inline-block; width: 15px; height: 15px; border-radius: 4px; margin-right: 4px; vertical-align: -1px; }
.reg { background: #fff8e1; border: 3px solid #f2c94c; border-radius: 18px; padding: 12px 18px; }
.reg-q { font-size: 27px; }
.reg-q small { font-size: 19px; color: #8b7a3a; margin-left: 8px; }
.reg-q .rank { font-size: 24px; color: #e0457b; margin-left: 8px; }
.reg-q b.me { font-family: var(--word); font-weight: 700; }
.reg-row { display: flex; gap: 10px; margin-top: 8px; align-items: stretch; }
.nick { flex: 1; min-width: 0; background: #fff; border: 3px solid var(--navy); border-radius: 14px; padding: 4px 14px; font: 700 28px/40px var(--word); display: flex; align-items: center; overflow: hidden; }
.nick em { display: none; font-style: normal; font-family: var(--ui); font-weight: 400; font-size: 24px; color: #a3a9c2; margin-left: 6px; }
.nick.empty em { display: inline; }
.caret { display: inline-block; width: 3px; height: 32px; background: var(--navy); margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.reg .note { margin-top: 8px; }
.reg .ghost { font-size: 20px; padding: 6px 12px; }
.link { border: 0; background: none; color: #2f6fdd; text-decoration: underline; font-size: inherit; padding: 0; }
ol.mini { list-style: none; margin: 8px 0 0; padding: 0; font-size: 20px; }
ol.mini li { display: flex; gap: 10px; font-family: var(--word); line-height: 28px; }
ol.mini span { margin-left: auto; color: #e0457b; font-weight: 700; }
ol.mini li.me { background: #fff2b8; border-radius: 8px; }
.r-btns { display: flex; gap: 12px; margin-top: auto; }
.r-btns .go { flex: 1; }

#toast { position: absolute; left: 50%; bottom: 30px; transform: translate(-50%, 30px); background: var(--navy); color: #fff; border-radius: 18px; padding: 10px 24px; font-size: 25px; opacity: 0; transition: .2s; pointer-events: none; z-index: 9; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
