:root { --bg:#0b0e16; --panel:#121826; --line:#243049; --gold:#e6c97a; --text:#e8ebf2; --dim:#8d97ad; --red:#e0685a; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); font-family:"Malgun Gothic","Noto Sans KR",system-ui,sans-serif; overflow:hidden; overscroll-behavior:none; }
#app { display:flex; flex-direction:column; height:100dvh; }

/* 화면 위가 아니라 화면 바깥 띠에 메뉴를 둔다: 공식 플레이어를 가리지 않기 위해 */
#bar { flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:6px 10px; background:var(--panel); border-bottom:1px solid var(--line); min-height:40px; overflow-x:auto; white-space:nowrap; }
#bar .title { color:var(--gold); font-size:15px; }
.chip { font-size:12px; padding:3px 8px; border-radius:999px; background:#1a2338; color:var(--text); }
.chip.dim { color:var(--dim); background:transparent; padding-left:0; }
.chip.grow { max-width:34vw; overflow:hidden; text-overflow:ellipsis; }
.sp { flex:1 1 auto; }
button { font:inherit; font-size:12px; color:var(--text); background:#1d2840; border:1px solid var(--line); border-radius:6px; padding:5px 10px; cursor:pointer; }
button:hover:not(:disabled) { background:#27345a; }
button:disabled { opacity:.55; cursor:default; }
button.on { background:#3b4f86; border-color:#6f86c8; }
.devbox select { font-size:12px; max-width:200px; background:#1d2840; color:var(--text); border:1px solid var(--line); border-radius:6px; padding:4px; }
.narrow-only { display:none; }

#main { flex:1 1 auto; display:flex; min-height:0; }

/* 방송 고르기 투표 띠 */
#voteBar { flex:0 0 auto; display:flex; align-items:center; gap:10px; padding:6px 10px; background:#151d31; border-bottom:1px solid var(--line); font-size:13px; flex-wrap:wrap; }
#voteBar.open { background:#2a2312; border-bottom-color:#7a6326; }
#voteBar .vmsg { color:var(--dim); white-space:nowrap; }
#voteBar.open .vmsg { color:var(--gold); font-weight:700; }
#voteBar .vopts { display:flex; gap:6px; flex-wrap:wrap; min-width:0; }
#voteBar .vopt { max-width:340px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left; }
#voteBar .vopt .n { display:inline-block; min-width:2.2em; margin-left:6px; padding:0 6px; border-radius:999px; background:rgba(255,255,255,.12); text-align:center; }
#voteBar .vopt.mine { background:#6b5418; border-color:var(--gold); }
#voteBar .vopt.keep::before { content:'계속 보기 · '; color:var(--gold); }
#stage { position:relative; flex:1 1 auto; min-width:0; overflow:hidden; background:#000; touch-action:none; user-select:none; -webkit-user-select:none; }
#gl { position:absolute; inset:0; width:100%; height:100%; display:block; }
#bubbles { position:absolute; inset:0; pointer-events:none; overflow:hidden; }   /* 공식 플레이어 층(#css3d) 아래 */
#css3d { position:absolute; inset:0; overflow:hidden; pointer-events:none; }
#css3d iframe { pointer-events:none; }
#conn { position:absolute; left:50%; top:10px; transform:translateX(-50%); padding:6px 12px; border-radius:8px; background:rgba(60,20,20,.85); font-size:13px; z-index:5; }

/* 아바타 이름표·투명 말풍선 (바람의나라식: 반투명 바탕 + 또렷한 글씨) */
.pl { position:absolute; left:0; top:0; display:flex; flex-direction:column; align-items:center; gap:3px; will-change:transform; }
.tag { font-size:11px; padding:1px 6px; border-radius:4px; background:rgba(0,0,0,.35); color:#dfe5f3; text-shadow:0 1px 1px #000; white-space:nowrap; }
.tag.me { color:#ffe8a0; }
.bubble { max-width:210px; padding:5px 9px; border-radius:7px; background:rgba(8,12,24,.52); border:1px solid rgba(255,255,255,.28); color:#fff; font-size:14px; font-weight:600; line-height:1.3; text-align:center; word-break:break-all; text-shadow:0 1px 2px #000, 0 0 3px #000; animation:pop .15s ease-out; }
@keyframes pop { from { transform:scale(.85); opacity:0; } to { transform:none; opacity:1; } }

/* 채팅은 PC·휴대폰 모두 3D 화면 아래 띠에 둔다 (공식 플레이어 위에 아무것도 겹치지 않게) */
#main { flex-direction:column; }
#dock { flex:0 0 auto; display:flex; width:100%; height:clamp(170px, 28dvh, 300px); border-top:1px solid var(--line); }
#pad { display:none; width:150px; flex:0 0 auto; align-items:center; justify-content:center; background:var(--panel); border-right:1px solid var(--line); }
#joy { position:relative; width:112px; height:112px; border-radius:50%; background:rgba(255,255,255,.08); border:2px solid rgba(255,255,255,.22); touch-action:none; }
#knob { position:absolute; left:50%; top:50%; width:46px; height:46px; margin:-23px 0 0 -23px; border-radius:50%; background:rgba(230,201,122,.75); pointer-events:none; }

#side { position:relative; flex:1 1 auto; min-width:0; display:flex; flex-direction:column; background:var(--panel); min-height:0; }
body:not(.side-open) #side { display:none; }
#log { flex:1 1 auto; overflow-y:auto; padding:6px 12px; font-size:13px; line-height:1.45; }
.line { margin-bottom:3px; word-break:break-all; }
.line.sys { color:var(--dim); font-size:12px; }
.line .more { padding:0 6px; margin-left:4px; font-size:13px; line-height:1.2; opacity:.6; background:transparent; border-color:transparent; }
.line:hover .more { opacity:1; }
.err { margin:0 12px 4px; font-size:12px; color:var(--red); }
#chatForm { display:flex; gap:6px; padding:4px 12px 0; }
#chatIn { flex:1 1 auto; min-width:0; font:inherit; font-size:14px; padding:8px; border-radius:6px; border:1px solid var(--line); background:#0e1422; color:var(--text); }
#chatBtn { min-width:56px; }
.foot { display:flex; justify-content:space-between; padding:2px 12px 0; font-size:11px; color:var(--dim); }
.nick { padding:2px 12px 6px; font-size:11px; color:var(--dim); }
.nick b { color:var(--gold); }
.menu { position:absolute; right:12px; bottom:70px; width:260px; padding:10px; border-radius:8px; background:#1a2338; border:1px solid #3a4a72; box-shadow:0 8px 24px rgba(0,0,0,.5); display:flex; flex-direction:column; gap:6px; z-index:10; font-size:12px; }
.menu .mt { font-weight:700; color:var(--gold); }
.menu select { width:100%; margin-top:3px; font-size:12px; padding:4px; background:#0e1422; color:var(--text); border:1px solid var(--line); border-radius:6px; }
.menu .hint { margin:0; color:var(--dim); font-size:11px; }
.menu .ghost { background:transparent; }

dialog { max-width:520px; width:92vw; background:#151c2e; color:var(--text); border:1px solid #3a4a72; border-radius:10px; }
dialog::backdrop { background:rgba(0,0,0,.75); }
dialog#help li { margin-bottom:8px; font-size:13px; line-height:1.5; }
dialog#help a { color:#9ec1ff; }
#nameDlg { max-width:380px; }
#nameDlg h2, #bannedDlg h2 { margin:4px 0 8px; font-size:18px; color:var(--gold); }
#nameDlg .hint { margin:0 0 12px; font-size:13px; line-height:1.5; color:#c8cfdd; }
#nameIn { width:100%; font:inherit; font-size:16px; padding:10px; border-radius:8px; border:1px solid var(--line); background:#0e1422; color:var(--text); }
#nameDlg .err { margin:8px 0 0; }
#nameOk { width:100%; margin-top:12px; padding:10px; font-size:15px; background:#3b4f86; border-color:#6f86c8; }

/* 좁은 화면(휴대폰): 머리띠 줄이기, 조이스틱은 채팅 왼쪽 */
@media (max-width: 820px), (pointer: coarse) and (max-width: 1100px) {
  .narrow-only { display:inline-block; }
  #pad { display:flex; width:132px; }
  #joy { width:104px; height:104px; }
  #dock { height:clamp(160px, 34dvh, 280px); }
  body:not(.side-open) #dock { height:140px; }
  body:not(.side-open) #pad { width:100%; border-right:0; }
  #bar { gap:5px; padding:5px 6px; }
  #bar .title, #syncInfo, #lagInfo { display:none; }
  #bar button { padding:4px 7px; font-size:11px; }
  .chip { font-size:11px; padding:2px 6px; }
  .chip.grow { max-width:34vw; }
  .devbox select { max-width:96px; }
  .menu { right:8px; bottom:64px; width:min(260px, 70vw); }
}
@media (pointer: coarse) { #pad { display:flex; } }

/* 가로로 눕힌 휴대폰: 채팅은 그대로 아래, 높이만 줄인다 */
@media (max-height: 520px) and (orientation: landscape) {
  #bar { min-height:34px; padding:3px 8px; }
  #dock { height:40dvh; min-height:0; }
  #pad { width:120px; }
  #joy { width:92px; height:92px; }
  #log { padding:4px 10px; }
  .menu { bottom:40px; }
}
