:root { --bg:#0f1b2d; --panel:#172a45; --line:#2b4266; --text:#eef3fa; --mute:#9db0cc; --gold:#e3b341; --red:#d9534f; --green:#3fb37f; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button:hover { border-color: var(--gold); }
button.primary { background: var(--gold); color: #1b1300; border-color: var(--gold); font-weight: 600; }
button.danger { background: var(--red); border-color: var(--red); }
button.on { border-color: var(--gold); color: var(--gold); }
button.small { padding: 6px 10px; font-size: 14px; }
input { width: 100%; font: inherit; padding: 11px 12px; margin-top: 6px; border-radius: 10px; border: 1px solid var(--line); background: #0c1626; color: var(--text); }
input:focus { outline: 2px solid var(--gold); }

#lobby { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.card h1 { margin: 0 0 4px; color: var(--gold); font-size: 26px; }
.sub { color: var(--mute); margin: 4px 0 12px; font-size: 14px; }
label, .lbl { display: block; margin: 14px 0 0; font-size: 14px; color: var(--mute); }
.rooms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }
.rooms button { text-align: left; }
.rooms button small { display: block; color: var(--mute); }
.rooms button.day { opacity: .5; }
#btnVao { width: 100%; margin-top: 18px; padding: 13px; }
.err { color: #ff9a96; min-height: 1.4em; margin: 10px 0 0; }

#room { height: 100%; display: grid; grid-template-rows: auto auto 1fr auto; grid-template-columns: 1fr auto; }
#room header { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pill { font-size: 13px; color: var(--mute); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }
.banner { grid-column: 1 / -1; background: #3a2e0a; color: #ffe08a; padding: 8px 14px; font-size: 14px; }
#stage { min-height: 0; padding: 10px; overflow: auto; }
#grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-content: start; }
#grid.co-man-hinh { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile { position: relative; background: #0a1322; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.tile.noi { border-color: var(--green); }
.tile.man-hinh { grid-column: 1 / -1; aspect-ratio: auto; max-height: 68vh; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.man-hinh video { object-fit: contain; max-height: 68vh; }
.tile.toi video.cam { transform: scaleX(-1); }
.tile .chu { width: 72px; height: 72px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-size: 28px; color: var(--gold); }
.tile .nhan { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 8px; font-size: 13px; max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tay { position: absolute; right: 8px; top: 8px; background: var(--gold); color: #1b1300; padding: 2px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; }
#side { width: 320px; border-left: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr; min-height: 0; background: var(--panel); }
.tabs { display: flex; gap: 6px; padding: 8px; }
.tabs button { padding: 6px 10px; font-size: 14px; }
.tab { min-height: 0; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
#dsNguoi { list-style: none; margin: 0; padding: 0; }
#dsNguoi li { display: flex; align-items: center; gap: 6px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
#dsNguoi li span.t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dsNguoi li em { color: var(--mute); font-style: normal; font-size: 12px; }
#tin { flex: 1; overflow: auto; font-size: 14px; }
#tin p { margin: 0 0 8px; overflow-wrap: anywhere; }
#tin b { color: var(--gold); }
#fChat { display: flex; gap: 6px; }
#fChat input { margin: 0; }
#room footer { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 10px; border-top: 1px solid var(--line); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.float { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 5; padding: 16px 22px; }
@media (max-width: 760px) {
  #side { position: fixed; inset: 0; width: auto; z-index: 4; }
  #grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  #room footer button { padding: 9px 10px; font-size: 14px; }
}
