:root {
  --ink: #26305c;
  --soft: #5d6585;
  --paper: #fffdf8;
  --bg1: #2b1d5c;
  --bg2: #10173a;
  --l0: #ff6b8b;
  --l1: #ffc94a;
  --l2: #4cc9f0;
  --good: #7bdc65;
  --miss: #9aa0b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Jua", "Malgun Gothic", sans-serif;
  color: #fff;
  background: radial-gradient(ellipse at 50% 0%, var(--bg1), var(--bg2) 70%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.en { font-family: "Lexend", "Segoe UI", sans-serif; font-weight: 700; }
.hide { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 18px; color: var(--ink); background: #fff; padding: 10px 20px; font-size: 22px; box-shadow: 0 5px 0 rgba(0,0,0,.3); }
button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
button:disabled { opacity: .45; cursor: default; }
button.main { background: var(--l1); }
button.go { background: var(--good); }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--paper); color: var(--ink); border-radius: 28px; padding: 22px 26px; box-shadow: 0 10px 0 rgba(0,0,0,.3); }
h1 { margin: 0; font-weight: 400; }
.title { font-size: clamp(40px, 7vw, 84px); letter-spacing: 2px; text-shadow: 0 6px 0 rgba(0,0,0,.35); text-align: center; }
.title b { color: var(--l1); font-weight: 400; }
.sub { color: #c9cdf0; font-size: clamp(18px, 2.2vw, 26px); text-align: center; margin: 6px 0 20px; }

/* ───── TV 대기실 ───── */
.lobby { display: grid; grid-template-columns: minmax(280px, 34vw) 1fr; gap: 22px; width: 100%; height: 100%; padding: 22px; }
.joinbox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.joinbox canvas { width: min(30vw, 56vh) !important; height: auto !important; aspect-ratio: 1; border-radius: 22px; background: #fff; border: 6px solid #fff; }
.joinbox .code { font-size: clamp(54px, 7vw, 96px); line-height: 1; color: var(--l1); }
.joinbox .url { font-size: clamp(18px, 1.8vw, 26px); color: #dfe2ff; text-align: center; word-break: break-all; }
.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.side .card { padding: 16px 20px; }
.side h2 { margin: 0 0 10px; font-weight: 400; font-size: 26px; }
.songs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; max-height: 30vh; overflow: auto; }
.songs button { font-size: 18px; padding: 8px 10px; text-align: left; background: #f1efff; box-shadow: 0 3px 0 rgba(0,0,0,.18); border-radius: 14px; }
.songs button small { display: block; color: var(--soft); font-size: 14px; }
.songs button.on, .levels button.on { background: var(--l1); }
.levels { display: flex; gap: 10px; flex-wrap: wrap; }
.levels button { font-size: 20px; background: #f1efff; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.levels button small { color: var(--soft); font-size: 15px; margin-left: 4px; }
.kids { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; align-content: flex-start; flex: 1; overflow: auto; }
.kid { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #e6e8f5; color: var(--ink); position: relative; transition: transform .08s, background .15s; }
.kid.on { background: var(--l2); color: #fff; }
.kid.cal::after { content: "🥁"; position: absolute; right: -6px; bottom: -6px; font-size: 18px; }
.kid.off { opacity: .35; }
.kid.p2 { background: var(--l1); color: var(--ink); transform: scale(1.18); }
.kid.p1 { background: var(--good); color: #fff; transform: scale(1.08); }
.kid.p0 { background: #5a5f78; color: #fff; }
.empty { color: var(--soft); font-size: 20px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.actions button { font-size: 26px; padding: 14px 26px; }
.tip { color: var(--soft); font-size: 17px; margin-top: 8px; }

/* ───── TV 판 ───── */
#tvPlay canvas, #pPlay canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 26px; pointer-events: none; }
.hud .song { font-size: clamp(22px, 2.4vw, 32px); }
.hud .song small { display: block; color: #c9cdf0; font-size: .7em; }
.combo { text-align: center; }
.combo .num { font-size: clamp(70px, 11vw, 150px); line-height: .9; color: var(--l1); text-shadow: 0 6px 0 rgba(0,0,0,.35); transition: transform .1s; }
.combo .lab { font-size: clamp(20px, 2vw, 28px); color: #dfe2ff; }
.gauge { width: clamp(220px, 24vw, 360px); }
.gauge .bar { height: 26px; background: rgba(255,255,255,.18); border-radius: 13px; overflow: hidden; }
.gauge .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--l0), var(--l1), var(--good)); transition: width .3s; }
.gauge .lab { font-size: 22px; margin-bottom: 4px; text-align: right; }
.tvkids { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0 20px; pointer-events: none; }
.tvkids .kid { width: 46px; height: 46px; font-size: 19px; }
.stopbtn { position: absolute; left: 22px; top: 96px; font-size: 16px; padding: 6px 14px; opacity: .55; }
.count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(120px, 22vw, 300px); color: #fff; text-shadow: 0 10px 0 rgba(0,0,0,.35); pointer-events: none; }

/* ───── 박자 맞추기 ───── */
.calib .big { font-size: clamp(30px, 4vw, 56px); text-align: center; margin-bottom: 10px; }
.beats { display: flex; gap: 14px; margin: 26px 0; }
.beats i { width: clamp(34px, 5vw, 70px); aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.18); transition: transform .08s, background .08s; }
.beats i.listen { border: 4px dashed rgba(255,255,255,.4); }
.beats i.now { background: var(--l1); transform: scale(1.25); }

/* ───── 결과 ───── */
.result { text-align: center; min-width: min(640px, 92vw); }
.result .stars { font-size: clamp(60px, 9vw, 120px); letter-spacing: 6px; }
.result .stars span { opacity: .2; filter: grayscale(1); }
.result .stars span.on { opacity: 1; filter: none; }
.result .msg { font-size: clamp(28px, 3.4vw, 44px); margin: 4px 0 14px; }
.stats { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.stats div { background: #f1efff; border-radius: 18px; padding: 10px 18px; min-width: 150px; }
.stats b { display: block; font-size: clamp(30px, 3.4vw, 46px); font-weight: 400; }
.stats small { color: var(--soft); font-size: 17px; }

/* ───── 태블릿 ───── */
.nums { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: min(560px, 94vw); }
.nums button { font-size: 24px; padding: 12px 0; border-radius: 14px; }
.nums button.taken { background: #c9cdf0; color: #7a80a0; }
.codein { display: flex; gap: 10px; }
.codein input { font: inherit; font-size: 40px; width: 180px; text-align: center; border-radius: 16px; border: 0; padding: 8px; color: var(--ink); }
.me { font-size: clamp(60px, 14vw, 120px); color: var(--l1); line-height: 1; }
.pad { width: min(78vw, 56vh); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffe08a, var(--l1) 60%, #e09a1a); color: var(--ink); font-size: clamp(30px, 6vw, 48px); display: flex; align-items: center; justify-content: center; box-shadow: 0 12px 0 rgba(0,0,0,.35); touch-action: none; }
.pad.hit { transform: scale(.95); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.err { color: #ffb0c0; font-size: 20px; margin-top: 10px; text-align: center; }
.small { color: #c9cdf0; font-size: 22px; text-align: center; margin-top: 10px; }
#pWait .sub { font-size: clamp(24px, 4vw, 34px); }
.phud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; padding: 10px 16px; font-size: 20px; pointer-events: none; }
.phud b { color: var(--l1); font-weight: 400; }
#pPlay { touch-action: none; }
