:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1f232c;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #8b92a3;
  --accent: #ff4d5e;
  --accent2: #ff6b7a;
  --ok: #3ccf8e;
  --warn: #f5b942;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: var(--text); }

.btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #3a4150; background: #262b36; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }

input[type=text], input:not([type]) {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; min-width: 0;
}
input:not([type]):focus { border-color: #4a5263; }

/* 입장 */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.lobby-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.lobby h1 { margin: 0 0 4px; font-size: 26px; }
.sub { margin: 0 0 22px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field span { color: var(--muted); font-size: 12px; }
.field input { width: 100%; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 16px 0; font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.invite-note { margin: 0 0 12px; color: var(--muted); }
.invite-note b { color: var(--text); letter-spacing: 2px; }
.error { color: var(--accent2); min-height: 1em; margin: 12px 0 0; font-size: 13px; }

/* 방 */
.room { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; }
.room-info { display: flex; align-items: center; gap: 8px; }
.code-chip { font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; background: var(--bg); border: 1px solid var(--line); padding: 4px 9px; border-radius: 8px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status.ok i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.bad i { background: var(--accent); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 340px; }
.stage { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow: auto; }
.url-bar { display: flex; gap: 8px; }
.url-bar input { flex: 1; }

.player-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 230px); background: #000; border-radius: var(--radius); overflow: hidden; }
.player-wrap:fullscreen { max-height: none; border-radius: 0; aspect-ratio: auto; }
.player-wrap #player, .player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.click-shield { position: absolute; inset: 0; z-index: 2; }
.empty { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; text-align: center; color: var(--muted); background: #0b0c0f; }
.empty div { font-size: 44px; }
.wait-banner { position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 7px 14px; border-radius: 99px; font-size: 13px; }
.tap-to-play { position: absolute; z-index: 5; inset: 0; margin: auto; width: 220px; height: 56px; border-radius: 99px; border: 0; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.react-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.react-layer span { position: absolute; bottom: 10px; font-size: 38px; animation: floatUp 2.4s ease-out forwards; }
.react-layer span small { display: block; font-size: 11px; text-align: center; color: #fff; text-shadow: 0 1px 3px #000; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 12% { opacity: 1; transform: translateY(-20px) scale(1.1); } 100% { transform: translateY(-260px) scale(1); opacity: 0; } }
.toast { position: absolute; z-index: 7; left: 14px; bottom: 14px; background: rgba(0,0,0,.78); padding: 7px 12px; border-radius: 9px; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }

.controls { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.icon-btn { background: none; border: 0; width: 34px; height: 34px; border-radius: 8px; font-size: 16px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--panel2); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
.seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
.vol { width: 80px; accent-color: var(--text); }
.sync-badge { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); padding: 3px 7px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sync-badge.good { color: var(--ok); }
.sync-badge.fix { color: var(--warn); }

.reactions { display: flex; align-items: center; gap: 4px; }
.reactions button { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; width: 38px; height: 34px; font-size: 17px; }
.reactions button:hover { transform: translateY(-2px); }
.now-title { margin-left: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 사이드 */
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 12px 6px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 99px; margin-left: 3px; }
.count { color: var(--muted); font-weight: 400; font-size: 12px; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { background: var(--panel2); padding: 7px 11px; border-radius: 12px; word-break: break-word; line-height: 1.45; }
.msg.me { align-self: flex-end; }
.msg.me .who { text-align: right; }
.msg.me .bubble { background: #3a1e25; }
.msg.sys { align-self: center; color: var(--muted); font-size: 12px; text-align: center; max-width: 100%; }
.ts-link { color: #7fb4ff; text-decoration: underline; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }
.chat-form .icon-btn { width: 36px; height: 38px; }
.chat-form .icon-btn.off { opacity: .45; }

.queue-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.auto { color: var(--muted); display: flex; gap: 5px; align-items: center; cursor: pointer; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 24px 12px; line-height: 1.6; }
.queue { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.queue li { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 10px; }
.queue li:hover { background: var(--panel2); }
.queue li.current { background: #2c1a1f; outline: 1px solid #5a2a33; }
.queue img { width: 80px; height: 45px; object-fit: cover; border-radius: 6px; flex: none; background: #000; cursor: pointer; }
.queue .meta { flex: 1; min-width: 0; cursor: pointer; }
.queue .t { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.35; }
.queue .by { font-size: 11px; color: var(--muted); margin-top: 2px; }
.queue .acts { display: flex; flex-direction: column; gap: 2px; opacity: .35; }
.queue li:hover .acts { opacity: 1; }
.queue .acts button { background: none; border: 0; padding: 1px 5px; border-radius: 5px; font-size: 12px; color: var(--muted); }
.queue .acts button:hover { background: var(--line); color: var(--text); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .stage { overflow: visible; padding: 10px; }
  .side { border-left: 0; border-top: 1px solid var(--line); min-height: 380px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .vol, #resyncBtn, .now-title { display: none; }
  .url-bar .btn { padding: 9px 10px; }
  .player-wrap { max-height: none; }
}
