:root {
  --ink: #06050d;
  --glass: rgba(10, 8, 24, 0.72);
  --glass-2: rgba(16, 13, 36, 0.86);
  --line: rgba(255, 255, 255, 0.13);
  --fg: #f6f4ff;
  --dim: #b3acd0;
  --accent: #ff4fd8;
  --accent-2: #39e6ff;
  --gold: #ffd23a;
  --c: #ff5a5f;
  --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 { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.vignette { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 52%, transparent 58%, rgba(3, 2, 10, 0.6) 100%); }
.hidden { display: none !important; }
kbd { font-family: var(--sans); font-size: 0.86em; font-weight: 700; padding: 3px 9px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); border-bottom-width: 2px; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); display: inline-block; }

/* ---------- 점수판 ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; }
.sb { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; height: 74px;
  border-radius: 18px; overflow: hidden; background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4); }
.sb .team { display: flex; align-items: center; gap: 14px; padding: 0 18px; min-width: 210px; }
.sb .team.a { justify-content: flex-end; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c) 26%, transparent)); }
.sb .team.b { justify-content: flex-start; background: linear-gradient(270deg, transparent, color-mix(in srgb, var(--c) 26%, transparent)); }
.sb .bar { width: 6px; align-self: stretch; margin: 14px 0; border-radius: 3px; background: var(--c); box-shadow: 0 0 14px var(--c); }
.sb .names { font-family: var(--display); font-size: 26px; letter-spacing: 0.02em; color: var(--c); white-space: nowrap; }
.sb .team b { font-family: var(--display); font-weight: 400; font-size: 56px; line-height: 1; min-width: 1.1ch; text-align: center;
  text-shadow: 0 0 22px color-mix(in srgb, var(--c) 55%, transparent); }
.sb .team b.on { animation: bump 0.8s cubic-bezier(.2, 1.6, .4, 1); color: var(--gold); }
.sb .mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 18px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 120px; }
.sb .mode { font-family: var(--display); font-size: 22px; letter-spacing: 0.08em; }
.sb .first { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; color: var(--dim); white-space: nowrap; }
.sb .first.mp { color: var(--gold); animation: blink 0.6s infinite alternate; }
.sb .lv { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--lv, #8fd8ff); white-space: nowrap; }
.sb .lv i { width: 6px; height: 6px; border-radius: 50%; background: var(--lv, #8fd8ff); box-shadow: 0 0 8px var(--lv, #8fd8ff); }
@keyframes bump { 0% { transform: scale(1.7); } 100% { transform: none; } }
@keyframes blink { to { opacity: 0.45; } }

.speed { position: absolute; left: 28px; bottom: 26px; width: 210px; padding: 12px 16px 14px; border-radius: 16px; background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--line); --c: var(--accent-2); }
.spd-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 800; color: var(--dim); letter-spacing: 0.06em; }
.spd-top em { font-style: normal; color: var(--c); opacity: 0; transition: opacity 0.2s; }
.spd-num { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 8px; }
.spd-num b { font-family: var(--display); font-weight: 400; font-size: 46px; line-height: 1; }
.spd-num small { color: var(--dim); font-size: 13px; font-weight: 700; }
.spd-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.spd-track i { display: block; height: 100%; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent-2), var(--accent)); box-shadow: 0 0 12px var(--accent); }
.speed.fast { border-color: var(--c); box-shadow: 0 0 30px color-mix(in srgb, var(--c) 45%, transparent); }
.speed.fast em { opacity: 1; }
.speed.fast .spd-num b { color: var(--c); animation: bump 0.6s cubic-bezier(.2, 1.6, .4, 1); }
.keys { position: absolute; right: 28px; bottom: 22px; font-size: 13px; color: rgba(255, 255, 255, 0.45); font-weight: 600; }
.keys kbd { font-size: 11px; padding: 1px 6px; }
.keys span { color: rgba(255, 255, 255, 0.3); }

.join { position: fixed; top: 18px; right: 24px; width: 132px; padding: 9px; border-radius: 16px; background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--line); display: flex; flex-direction: column;
  gap: 7px; align-items: center; pointer-events: none; }
.join img { width: 112px; height: 112px; border-radius: 10px; background: #fff; padding: 5px; }
.join div { display: flex; align-items: baseline; gap: 8px; }
.join-k { color: var(--dim); font-size: 12px; font-weight: 700; }
.join b { font-family: var(--display); font-weight: 400; letter-spacing: 0.18em; font-size: 20px; }

/* 말렛 이름표 */
.tags { position: fixed; inset: 0; pointer-events: none; }
.tags.off { display: none; }
.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; will-change: transform; }
.tag b { font-family: var(--display); font-weight: 400; font-size: 17px; line-height: 1; padding: 3px 9px 4px; border-radius: 999px;
  background: var(--c); color: #0b0f17; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 14px color-mix(in srgb, var(--c) 50%, transparent); }
.tag.cpu b { background: rgba(20, 16, 40, 0.85); color: var(--c); border: 1.5px solid var(--c); }
.tag span { font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); white-space: nowrap; }
.tag span:empty { display: none; }
.tag.away b { opacity: 0.5; }
.tag::after { content: ""; width: 2px; height: 10px; background: var(--c); opacity: 0.7; border-radius: 1px; }

/* ---------- 판정 글자 ---------- */
.call { position: fixed; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; opacity: 0;
  transform: translateY(14px) scale(0.92); transition: opacity 0.2s, transform 0.32s cubic-bezier(.2, 1.4, .4, 1); --c: #fff; }
.call.on { opacity: 1; transform: none; }
.call-main { font-family: var(--display); font-weight: 400; font-size: 150px; line-height: 1; letter-spacing: 0.02em;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.55); }
.call-sub { margin-top: 12px; font-size: 30px; font-weight: 900; letter-spacing: -0.02em; text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7); }
.call.goal .call-main { color: #fff; -webkit-text-stroke: 3px var(--c);
  text-shadow: 0 0 30px var(--c), 0 0 80px color-mix(in srgb, var(--c) 60%, transparent), 0 8px 40px rgba(0, 0, 0, 0.5); }
.call.goal .call-sub { color: var(--c); }
.call.win .call-main { font-size: 200px; background: linear-gradient(180deg, #fff6c4 0%, #ffd23a 45%, #ff9d1a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 10px 30px rgba(255, 170, 0, 0.45)); }
.call.win .call-sub { color: var(--c); font-size: 40px; }
.call.count .call-main { font-size: 190px; color: #fff; text-shadow: 0 0 40px var(--accent), 0 8px 40px rgba(0, 0, 0, 0.5); }
.call.count .call-sub { color: var(--accent-2); }
.call.ready .call-main { font-family: var(--sans); font-weight: 900; font-size: 96px; letter-spacing: -0.04em; }
.call.ready .call-sub { font-family: var(--display); font-weight: 400; font-size: 34px; letter-spacing: 0.04em; color: var(--dim); }

.rule { position: fixed; left: 50%; top: 104px; transform: translate(-50%, -8px); padding: 8px 18px; border-radius: 999px;
  background: rgba(255, 210, 58, 0.16); border: 1px solid rgba(255, 210, 58, 0.55); color: var(--gold); font-weight: 900; font-size: 17px;
  opacity: 0; transition: opacity 0.2s, transform 0.3s; pointer-events: none; }
.rule.on { opacity: 1; transform: translate(-50%, 0); }
.note { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 14px); padding: 13px 24px; border-radius: 16px;
  background: var(--glass-2); border: 1px solid var(--line); font-weight: 800; font-size: 17px; opacity: 0;
  transition: opacity 0.25s, transform 0.35s; pointer-events: none; white-space: nowrap; }
.note.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 대기실 ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 40px;
  background: linear-gradient(90deg, rgba(5, 3, 14, 0.94) 0%, rgba(5, 3, 14, 0.7) 54%, rgba(5, 3, 14, 0.3) 100%); }
.lobby { display: flex; align-items: center; gap: 64px; width: min(1220px, 100%); }
/* 위쪽 74px 는 '준비 n/m' 띠(ready.js) 자리. 난이도·연습 칸이 늘어도 720p 화면에 들어가게 제목을 화면 높이에 맞춥니다. */
#lobby { padding-top: 74px; padding-bottom: 24px; }
#lobby .wordmark { font-size: clamp(54px, min(8.5vw, 11.5vh), 124px); }
#lobby .lede { margin: 14px 0 18px; }
.lobby-copy { flex: 1; min-width: 0; }
.eyebrow { font-size: 14px; font-weight: 800; letter-spacing: 0.24em; color: var(--accent-2); margin-bottom: 14px; }
.wordmark { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(60px, 8.5vw, 124px); line-height: 0.92;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 48%, var(--accent) 100%); -webkit-background-clip: text; background-clip: text;
  color: transparent; filter: drop-shadow(0 0 30px rgba(255, 79, 216, 0.25)); }
.wordmark.sm { font-family: var(--sans); font-weight: 900; font-size: 60px; letter-spacing: -0.03em; filter: none; }
.lede { margin: 20px 0 26px; font-size: 19px; color: #ddd8f2; line-height: 1.55; max-width: 60ch; }
.steps { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--line); }
.steps svg { flex: none; width: 40px; height: 40px; fill: none; stroke: var(--accent-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.steps b { display: block; font-size: 16px; margin-bottom: 4px; }
.steps span { font-size: 13.5px; color: var(--dim); line-height: 1.45; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.slot { position: relative; height: 72px; border-radius: 14px; border: 2px dashed rgba(255, 255, 255, 0.2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.4); font-weight: 700; font-size: 15px; transition: all 0.3s; }
.slot b { font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1; }
.slot small { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--c); margin-top: 4px; }
.slot.on { border: 2px solid var(--c); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, transparent), transparent);
  color: var(--fg); animation: pop 0.4s cubic-bezier(.2, 1.6, .4, 1); }
.slot.bot small { color: var(--dim); }
.slot.away { opacity: 0.45; }
.slot.ready { box-shadow: 0 0 0 1px var(--c), 0 0 26px color-mix(in srgb, var(--c) 45%, transparent); }
.slot.ready small { color: #9dffb5; }
.slot.prac small { color: var(--gold); animation: blink 0.7s infinite alternate; }
.slot.away small { color: var(--dim); }
@keyframes pop { from { transform: scale(0.9); } to { transform: none; } }
.set-box { margin: 0 0 14px; max-width: 760px; }
.set-box .pcgs-panel { --pcgs-accent: var(--accent-2); background: var(--glass-2); border-color: var(--line); }
.tut-box { margin: 0 0 14px; max-width: 900px; }
.tut-box:has(.pcgb[hidden]) { display: none; }
.over-set { display: flex; justify-content: center; margin: 0 0 14px; }
.over-set .pcgs-panel { --pcgs-accent: var(--accent-2); background: var(--glass-2); border-color: var(--line); }
.hint b { color: var(--fg); }
.kb-test { display: inline-flex; align-items: center; gap: 8px; }
.pairs { min-height: 22px; margin-bottom: 14px; font-size: 15px; font-weight: 800; color: #cfc8e8; }
.pairs i { font-style: normal; color: var(--dim); margin: 0 6px; font-weight: 600; }
.hint { color: var(--dim); font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qr-card { flex: none; width: 340px; padding: 24px; border-radius: 26px; background: #f7f5ee; color: #0b1220;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.4), 0 0 60px rgba(255, 79, 216, 0.18); text-align: center; }
.qr-card img { width: 100%; aspect-ratio: 1; display: block; border-radius: 10px; background: #eeeae0; }
.qr-code { margin-top: 16px; display: flex; align-items: baseline; justify-content: center; gap: 12px; }
.qr-code span { font-size: 13px; font-weight: 800; color: #5d6a7c; letter-spacing: 0.1em; }
.qr-code b { font-family: var(--display); font-weight: 400; font-size: 54px; letter-spacing: 0.2em; line-height: 1; }
.qr-url { margin-top: 6px; font-size: 13px; color: #5d6a7c; word-break: break-all; }
.qr-warn { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #fff1c7; color: #6a4b00; font-size: 13px; line-height: 1.45; font-weight: 600; }
.msg { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 16px); padding: 14px 24px; border-radius: 16px; background: var(--glass-2);
  border: 1px solid var(--line); font-weight: 700; opacity: 0; transition: opacity 0.25s, transform 0.35s; pointer-events: none; }
.msg.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 결과 ---------- */
#over { padding-top: 74px; padding-bottom: 24px; }
.screen#over { background: radial-gradient(ellipse at center, rgba(5, 3, 14, 0.82) 0%, rgba(5, 3, 14, 0.62) 70%, rgba(5, 3, 14, 0.4) 100%); }
.over { width: min(900px, 100%); text-align: center; }
.over-title { margin: 0; font-family: var(--sans); font-weight: 900; font-size: 60px; letter-spacing: -0.04em; color: var(--c);
  text-shadow: 0 0 40px color-mix(in srgb, var(--c) 50%, transparent); }
.over-score { margin-top: 6px; display: flex; justify-content: center; align-items: baseline; gap: 18px; font-family: var(--display); }
.over-score b { font-weight: 400; font-size: 66px; line-height: 1; }
.over-score i { font-style: normal; font-size: 44px; color: var(--dim); }
.podium { display: flex; flex-direction: column; gap: 9px; margin: 18px 0 18px; }
.podium .r { display: flex; align-items: center; gap: 18px; padding: 10px 24px; border-radius: 18px; background: var(--glass-2);
  border: 1px solid var(--line); text-align: left; animation: rise 0.5s backwards cubic-bezier(.2, 1.2, .4, 1); }
.podium .r.win { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 32%, transparent), var(--glass-2)); border-color: var(--c); }
.podium .rank { font-family: var(--display); font-size: 32px; width: 1.2em; color: var(--dim); }
.podium .r:first-child .rank { color: var(--gold); font-size: 40px; }
.podium .who { font-family: var(--display); font-size: 30px; flex: 1; color: var(--c); }
.podium .res { font-weight: 900; font-size: 20px; padding: 4px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); color: var(--dim); }
.podium .r.win .res { background: var(--c); color: #0b0f17; }
.podium .num { text-align: right; min-width: 92px; }
.podium .num b { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; }
.podium .num span { display: block; color: var(--dim); font-size: 12px; font-weight: 700; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.over .hint { justify-content: center; }

@media (max-width: 1000px) {
  .lobby { flex-direction: column; gap: 26px; }
  .steps { grid-template-columns: 1fr; }
  .qr-card { width: 280px; }
  .sb .team { min-width: 140px; padding: 0 12px; }
  .sb .names { font-size: 18px; }
  .sb .team b { font-size: 42px; }
  .keys { display: none; }
  .call-main { font-size: 100px; }
  .call.win .call-main, .call.count .call-main { font-size: 130px; }
}
