:root { color-scheme: dark; }
#gate[hidden], #app[hidden] { display: none; }
* { box-sizing: border-box; font-family: system-ui, sans-serif; }
body { margin:0; background:#0f1118; color:#e8eaf4; min-height:100vh; }
#gate { max-width: 460px; margin: 12vh auto 0; padding: 0 16px; }
#gate h1 { font-size: 1.7rem; margin: 0 0 18px; }
#roomlist { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:10px; }
#roomlist li { background:#1a1d28; border:1px solid #2b2f3a; border-radius:10px; padding:14px; display:flex; align-items:center; gap:12px; cursor:pointer; }
#roomlist li:hover { border-color:#4f46e5; }
#roomlist li.empty { cursor: default; justify-content:center; color:#8b90a6; font-style:italic; }
#roomlist li.empty:hover { border-color:#2b2f3a; }
#roomlist .name { flex:1; font-weight:600; }
#roomlist .badge { font-size:.7rem; padding:3px 10px; border-radius:999px; text-transform:uppercase; letter-spacing:.05em; }
#roomlist .badge.open { background:rgba(34,197,94,.18); color:#4ade80; border:1px solid rgba(34,197,94,.4); }
#roomlist .badge.closed { background:rgba(248,113,113,.14); color:#f87171; border:1px solid rgba(248,113,113,.35); }
#roomlist .meta { color:#8b90a6; font-size:.8rem; min-width:70px; text-align:right; }
#new-room { margin-top:14px; width:100%; background:transparent; color:#8b90a6; border:1px dashed #2b2f3a; border-radius:10px; padding:12px; cursor:pointer; }
#new-room:hover { color:#e8eaf4; border-color:#4f46e5; }
#msg { color:#f87171; min-height:1.2em; margin:10px 0 0; }
input, select, button { padding:11px; border-radius:9px; border:1px solid #2b2f3a; background:#1a1d28; color:#e8eaf4; font-size:1rem; }
button { cursor:pointer; }
#modal { position:fixed; inset:0; background:rgba(0,0,0,.62); display:flex; align-items:center; justify-content:center; padding:16px; z-index:10; }
#modal[hidden] { display:none; }
#modal .box { background:#171a24; border:1px solid #2b2f3a; border-radius:14px; padding:22px; width:min(92vw,360px); display:flex; flex-direction:column; gap:12px; }
#modal h2 { margin:0; font-size:1.05rem; }
#modal input { width:100%; }
#modal button.ghost { background:transparent; color:#8b90a6; border:1px solid #2b2f3a; }
#modal button.ghost:hover { color:#e8eaf4; border-color:#4f46e5; }
#modal #confirm { background:#4f46e5; border:none; font-weight:600; padding:13px; }
#modal label { font-size:.75rem; color:#8b90a6; text-transform:uppercase; letter-spacing:.05em; }
#app { display:grid; grid-template-columns: 220px 1fr 330px; height:100vh; }
#members { border-right:1px solid #2b2f3a; padding:14px; overflow-y:auto; }
#members h2 { margin:0 0 10px; font-size:.75rem; color:#8b90a6; text-transform:uppercase; letter-spacing:.05em; font-weight:600; }
#memberlist { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:6px; }
#memberlist li { display:flex; align-items:center; gap:10px; background:#1a1d28; border:1px solid #2b2f3a; border-radius:9px; padding:9px 10px; cursor:pointer; font-size:.92rem; }
#memberlist li:hover { border-color:#4f46e5; }
#memberlist li.selected { border-color:#4f46e5; background:rgba(79,70,229,.16); }
#memberlist .dot { width:9px; height:9px; border-radius:50%; background:#6b7280; flex-shrink:0; }
#memberlist .name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#stage { position:relative; background:#000; display:flex; align-items:center; justify-content:center; padding:14px; min-width:0; }
#tile-wrap { width:100%; min-height:0; display:flex; align-items:center; justify-content:center; }
#stage-video { max-width:100%; max-height:100%; border-radius:12px; background:#0a0c12; width:100%; height:100%; }
#stage-empty { position:absolute; color:#8b90a6; text-align:center; font-size:1rem; }
#gear { position:absolute; top:14px; right:14px; background:rgba(20,22,32,.72); border:1px solid #2b2f3a; font-size:1.15rem; padding:8px 10px; border-radius:9px; z-index:2; }
#panel { position:absolute; top:56px; right:14px; z-index:2; background:rgba(23,26,36,.96); border:1px solid #2b2f3a; border-radius:11px; padding:14px; display:flex; flex-direction:column; gap:10px; width:230px; }
#panel[hidden] { display:none; }
#panel label { font-size:.72rem; color:#8b90a6; text-transform:uppercase; letter-spacing:.05em; }
#panel select { width:100%; }
#panel .primary { background:#4f46e5; border:none; font-weight:600; padding:12px; }
#delete-room { background:transparent; color:#f87171; border:1px solid rgba(248,113,113,.4); padding:10px; border-radius:9px; }
#delete-room:hover { background:rgba(248,113,113,.12); }
#chat { border-left:1px solid #2b2f3a; display:flex; flex-direction:column; min-height:0; }
#messages { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.msg { background:#1a1d28; border-radius:9px; padding:7px 10px; max-width:95%; align-self:flex-start; }
.msg .who { font-size:.7rem; color:#8b90a6; display:block; text-transform:uppercase; letter-spacing:.04em; }
#chatform { display:flex; gap:8px; padding:10px; border-top:1px solid #2b2f3a; }
#chatform input { flex:1; }
#chatform button { background:#4f46e5; border:none; font-weight:600; }
@media (max-width:1000px) {
  #app { grid-template-columns:1fr; grid-template-rows:auto auto 1fr; }
  #members { border-right:none; border-bottom:1px solid #2b2f3a; display:flex; gap:6px; overflow-x:auto; padding:8px; }
  #memberlist { flex-direction:row; }
  #members h2 { display:none; }
  #chat { border-left:none; border-top:1px solid #2b2f3a; max-height:34vh; }
}
#memberlist .thumb { width:56px; height:34px; object-fit:cover; border-radius:6px; background:#0a0c12; flex-shrink:0; }
