:root {
  --ink: #04040a;
  --glass: rgba(8, 10, 22, 0.66);
  --glass-2: rgba(10, 12, 26, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --fg: #f4f5fb;
  --dim: #a6b0c8;
  --accent: #7fd4ff;
  --pink: #ff4fd8;
  --gold: #ffd23a;
  --sans: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", system-ui, sans-serif;
  --display: Anton, Impact, "Pretendard Variable", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--fg); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
canvas#stage, canvas#lanes { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#lanes { z-index: 2; pointer-events: none; }
.hidden { display: none !important; }
kbd { font-family: var(--sans); font-size: 0.86em; font-weight: 700; padding: 2px 8px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); border-bottom-width: 2px; }
.vig { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 90% 85% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.6) 100%); }
.screen { position: fixed; inset: 0; z-index: 3; }

/* ---------- 고르기(대기실) ---------- */
#select { display: flex; flex-direction: column; padding: 26px 30px 16px; gap: 14px;
  background: linear-gradient(180deg, rgba(4, 4, 10, 0.55), rgba(4, 4, 10, 0.1) 30%, rgba(4, 4, 10, 0.15) 62%, rgba(4, 4, 10, 0.78)); }
.sel { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(250px, 22vw) 1fr minmax(230px, 19vw); gap: 22px; }
.sel-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.eyebrow { font-size: 14px; font-weight: 800; letter-spacing: 0.22em; color: var(--accent); text-transform: uppercase; }
.wordmark { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(54px, 6.4vw, 104px); line-height: 0.9; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff 30%, #c9d6ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px rgba(127, 212, 255, 0.35)); }
.wordmark span { background: linear-gradient(90deg, #ff4fd8, #7fd4ff 55%, #5ef0a0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { margin: 2px 0 0; font-size: clamp(15px, 1.15vw, 19px); line-height: 1.5; color: #d7deee; font-weight: 600; }
.tutbox { margin-top: auto; min-height: 0; }
.tutbox .pcgb-tile { min-width: 0; }
/* 위쪽 가운데의 '준비 n/m' 띠(ready.js)와 겹치지 않게 CD 선반을 조금 내립니다 */
.sel-mid { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding-top: 46px; }
.picker { flex: 1; min-height: 340px; border-radius: 26px; background: radial-gradient(70% 60% at 50% 40%, rgba(40, 50, 90, 0.35), rgba(8, 10, 22, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.08); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); overflow: hidden; }
.picker .dp-title { font-size: clamp(16px, 1.5vw, 22px); }
.picked { position: absolute; left: 50%; top: 98px; transform: translateX(-50%); z-index: 20; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px 7px 8px; border-radius: 999px; background: rgba(8, 12, 24, 0.85); border: 1.5px solid var(--pc, #fff);
  font-size: 15px; font-weight: 800; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); animation: pop 0.45s cubic-bezier(.2, 1.5, .4, 1); white-space: nowrap; }
.picked span { font-weight: 700; color: var(--dim); }
.picked b { font-family: var(--display); font-weight: 400; font-size: 14px; padding: 1px 8px; border-radius: 999px; background: var(--pc, #fff); color: #0b1220; letter-spacing: 0.04em; }
@keyframes pop { from { transform: translateX(-50%) scale(0.7); opacity: 0; } }
.sel-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 16px 14px; border-radius: 22px; background: var(--glass-2);
  border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); }
.qr-card img { width: min(100%, 210px); aspect-ratio: 1; border-radius: 12px; background: #fff; padding: 6px; }
.qr-code { display: flex; align-items: baseline; gap: 10px; }
.qr-code span { font-size: 13px; font-weight: 800; color: var(--dim); letter-spacing: 0.08em; }
.qr-code b { font-family: var(--display); font-weight: 400; font-size: 40px; letter-spacing: 0.12em; line-height: 1; }
.qr-url { font-size: 12px; color: var(--dim); word-break: break-all; text-align: center; }
.qr-warn { font-size: 12px; color: #ffcf8a; text-align: center; line-height: 1.4; }
.howto { margin: 0; padding: 14px 16px 14px 34px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.55; color: #dfe6f3; display: flex; flex-direction: column; gap: 6px; }
.howto b { color: #fff; }
.howto li::marker { font-family: var(--display); color: var(--accent); }

/* 아래 사람 카드 */
.roster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pc { position: relative; display: grid; grid-template-columns: 58px 1fr auto; gap: 4px 14px; align-items: center; min-height: 112px; padding: 14px 16px;
  border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 24%, rgba(8, 10, 22, 0.9)), rgba(8, 10, 22, 0.9) 70%);
  border: 1.5px solid color-mix(in srgb, var(--c) 65%, transparent); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4); overflow: hidden; transition: transform 0.25s, border-color 0.25s; }
.pc.empty { background: rgba(8, 10, 22, 0.42); border: 1.5px dashed rgba(255, 255, 255, 0.18); box-shadow: none; grid-template-columns: 58px 1fr; }
.pc.empty .pc-sub { grid-row: 1 / span 3; align-self: center; white-space: normal; }
.pc.empty .pc-badge { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.35); }
.pc.away { opacity: 0.55; filter: saturate(0.4); }
.pc.ready { border-color: #5ef0a0; box-shadow: 0 0 0 2px rgba(94, 240, 160, 0.25), 0 14px 40px rgba(0, 0, 0, 0.4); }
.pc-badge { grid-row: 1 / span 3; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 16px; background: var(--c); color: #0b1220;
  font-family: var(--display); font-size: 26px; letter-spacing: 0.02em; }
.pc-mode { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 900; letter-spacing: -0.02em; white-space: nowrap; min-width: 0; }
.pc-mode svg { width: 22px; height: 22px; flex: none; }
.pc-diff { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: #cfd8ea; white-space: nowrap; }
.pc-diff .stars { color: var(--gold); font-family: var(--display); font-size: 15px; letter-spacing: 0.04em; }
.pc-diff .stars em { font-style: normal; color: rgba(255, 255, 255, 0.18); }
.pc-sub { font-size: 13px; font-weight: 700; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pc-state { grid-column: 3; grid-row: 1 / span 3; align-self: center; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pc-chip { padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; background: rgba(255, 255, 255, 0.08); color: #dfe6f3; }
.pc-chip.ok { background: #5ef0a0; color: #062012; }
.pc-chip.tut { background: rgba(255, 210, 58, 0.18); color: var(--gold); }
.pc-chip.off { background: rgba(255, 90, 95, 0.18); color: #ffb3b5; }
.pc-arrows { display: flex; gap: 3px; }
.pc-arrows i { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: rgba(255, 255, 255, 0.07); font-style: normal;
  font-size: 13px; font-weight: 900; color: rgba(255, 255, 255, 0.45); transition: background 0.35s, color 0.35s, transform 0.35s; }
.pc-arrows i.on { background: var(--c); color: #0b1220; transform: scale(1.18); transition: none; }
.foot { display: flex; justify-content: center; gap: 22px; font-size: 13px; font-weight: 700; color: var(--dim); flex-wrap: wrap; }
.foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 경기 중 ---------- */
.songbar { position: fixed; z-index: 4; left: 50%; top: 14px; transform: translateX(-50%); display: grid; grid-template-columns: 46px auto 260px auto; align-items: center; gap: 12px;
  padding: 7px 16px 7px 7px; border-radius: 16px; background: rgba(6, 8, 18, 0.78); border: 1px solid var(--line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.songbar img { width: 46px; height: 46px; border-radius: 9px; }
.sb-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 34vw; }
.sb-txt b { font-size: 17px; font-weight: 900; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-txt span { font-size: 12px; color: var(--dim); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-prog { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.sb-prog i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #7fd4ff, #ff4fd8); }
.sb-time { font-family: var(--display); font-size: 18px; letter-spacing: 0.06em; color: #dfe6f3; min-width: 44px; text-align: right; }
.join { position: fixed; z-index: 4; right: 14px; top: 10px; display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 7px; border-radius: 14px;
  background: rgba(6, 8, 18, 0.72); border: 1px solid var(--line); opacity: 0.8; }
.join img { width: 58px; height: 58px; border-radius: 6px; background: #fff; padding: 3px; }
.join span { display: block; font-size: 11px; font-weight: 800; color: var(--dim); letter-spacing: 0.1em; }
.join b { font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: 0.1em; }
.count { position: fixed; z-index: 6; left: 50%; top: 46%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none;
  font-family: var(--display); font-size: clamp(110px, 24vh, 280px); line-height: 1; color: #fff; letter-spacing: 0.04em;
  text-shadow: 0 0 40px rgba(127, 212, 255, 0.9), 0 0 100px rgba(255, 79, 216, 0.5), 0 10px 40px rgba(0, 0, 0, 0.6); transition: opacity 0.25s; }
.count.on { opacity: 1; }
.count.pop { animation: countpop 0.5s cubic-bezier(.2, 1.4, .4, 1); }
.count.go { color: #fff6c2; text-shadow: 0 0 40px rgba(255, 210, 90, 0.95), 0 0 110px rgba(255, 140, 60, 0.55), 0 10px 40px rgba(0, 0, 0, 0.6); }
@keyframes countpop { from { transform: translate(-50%, -50%) scale(1.7); } to { transform: translate(-50%, -50%) scale(1); } }
.banner { position: fixed; left: 0; right: 0; top: 64%; z-index: 6; text-align: center; pointer-events: none; opacity: 0; transform: translateY(12px); transition: opacity 0.35s, transform 0.45s; }
.banner.on { opacity: 1; transform: none; }
.banner b { display: block; font-size: clamp(36px, 5.4vh, 64px); font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; text-shadow: 0 6px 40px rgba(0, 0, 0, 0.7); }
.banner span { display: block; margin-top: 8px; font-size: clamp(15px, 2vh, 22px); font-weight: 700; color: #d7deee; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8); }
.hold { position: fixed; z-index: 7; left: 50%; top: 58%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 26px; border-radius: 20px; background: rgba(8, 10, 22, 0.9); border: 1.5px solid var(--gold); box-shadow: 0 0 40px rgba(255, 210, 58, 0.25);
  animation: holdglow 1.2s ease-in-out infinite alternate; }
.hold b { font-size: 24px; font-weight: 900; }
.hold span { font-size: 15px; font-weight: 700; color: var(--dim); }
@keyframes holdglow { to { box-shadow: 0 0 70px rgba(255, 210, 58, 0.45); } }

/* ---------- 결과 ---------- */
#over { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, rgba(10, 10, 30, 0.35), rgba(4, 4, 10, 0.82)); }
.over { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(1500px, 94vw); }
.ov-title { margin: 0; font-size: clamp(30px, 4.2vh, 46px); font-weight: 900; letter-spacing: -0.03em; text-align: center; }
.ranks { display: flex; justify-content: center; gap: 18px; width: 100%; margin-top: 8px; }
.rk { position: relative; flex: 1 1 0; max-width: 340px; padding: 18px 18px 16px; border-radius: 24px;
  background: linear-gradient(170deg, color-mix(in srgb, var(--c) 30%, rgba(8, 10, 22, 0.94)), rgba(8, 10, 22, 0.94) 62%);
  border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; align-items: center; gap: 6px; animation: rkin 0.6s cubic-bezier(.2, 1.3, .4, 1) both; }
.rk.first { transform: translateY(-14px); box-shadow: 0 0 0 2px var(--gold), 0 24px 70px rgba(255, 210, 58, 0.25); }
@keyframes rkin { from { opacity: 0; transform: translateY(40px) scale(0.92); } }
.rk-top { display: flex; align-items: center; gap: 10px; width: 100%; }
.rk-rank { font-family: var(--display); font-size: 30px; line-height: 1; color: #fff; }
.rk-rank small { font-size: 16px; color: var(--dim); margin-left: 2px; }
.rk-badge { margin-left: auto; padding: 3px 12px; border-radius: 999px; background: var(--c); color: #0b1220; font-family: var(--display); font-size: 20px; letter-spacing: 0.04em; }
.rk-grade { font-family: var(--display); font-size: clamp(110px, 17vh, 170px); line-height: 0.95; margin: 4px 0 0;
  background: linear-gradient(180deg, #fff 20%, var(--gc, #7fd4ff)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px color-mix(in srgb, var(--gc, #7fd4ff) 55%, transparent)); }
.rk-tags { display: flex; gap: 6px; min-height: 26px; flex-wrap: wrap; justify-content: center; }
.rk-tags span { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; letter-spacing: 0.06em; }
.rk-tags .fc { background: linear-gradient(90deg, #ffd23a, #ff9d2e); color: #241400; }
.rk-tags .pfc { background: linear-gradient(90deg, #fff6c2, #7fd4ff, #ff4fd8); color: #120a24; }
.rk-tags .fail { background: rgba(255, 90, 110, 0.2); color: #ff9aa8; }
.rk-tags .mode { background: rgba(255, 255, 255, 0.1); color: #dfe6f3; }
.rk-score { font-family: var(--display); font-size: 40px; letter-spacing: 0.04em; line-height: 1; }
.rk-acc { font-size: 14px; font-weight: 800; color: var(--dim); }
.rk-acc b { color: #fff; font-size: 16px; }
.rk-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 100%; margin-top: 6px; }
.rk-counts div { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.rk-counts span { font-family: var(--display); font-size: 11px; letter-spacing: 0.08em; }
.rk-counts b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.rk-counts .p span { color: #ffd23a; } .rk-counts .g span { color: #5ef0a0; } .rk-counts .o span { color: #7cc8ff; } .rk-counts .m span { color: #9aa3b5; }
.ov-hint { margin-top: 10px; font-size: 16px; font-weight: 700; color: var(--dim); text-align: center; }
.toast { position: fixed; z-index: 8; left: 50%; top: 52%; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 12px 22px; border-radius: 999px;
  background: rgba(8, 10, 22, 0.9); border: 1.5px solid var(--pc, rgba(255, 255, 255, 0.3)); font-size: 18px; font-weight: 800; transition: opacity 0.3s, transform 0.4s; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast b { font-family: var(--display); font-weight: 400; padding: 1px 9px; margin-right: 6px; border-radius: 999px; background: var(--pc, #fff); color: #0b1220; }

@media (max-width: 1180px) {
  .sel { grid-template-columns: minmax(210px, 24vw) 1fr minmax(200px, 22vw); gap: 14px; }
  .howto { display: none; }
  .pc { grid-template-columns: 48px 1fr auto; padding: 12px; }
  .pc-badge { width: 48px; height: 48px; font-size: 22px; }
}
@media (max-height: 760px) {
  #select { padding: 16px 22px 10px; gap: 10px; }
  .pc { min-height: 92px; }
  .qr-card img { width: min(100%, 160px); }
}

/* 결과 화면에서는 '모두 준비하면 시작' 띠를 숨깁니다(폰의 '다음 곡 고르기'로 노래 고르기로 돌아감) */
body[data-phase="over"] #readyBar { display: none !important; }
