:root {
  --bg: #0b0710;
  --panel: #160d1f;
  --panel-2: #1d1230;
  --line: #2a1b3d;
  --txt: #ece6f5;
  --muted: #9a8bb0;
  --soag: #b06bff;
  --soag-2: #6b4bff;
  --green: #43d17a;
  --red: #ff5a7a;
  --gold: #ffd166;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #2a124d 0%, var(--bg) 55%);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: var(--soag); }

/* ---------- gate ---------- */
#gate {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 500px at 50% 0%, #34145e 0%, #0b0710 60%);
  padding: 24px;
}
.gate-card {
  width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 30px 26px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.gate-card h1 { margin: 8px 0 4px; font-size: 26px; letter-spacing: .2px; }
.gate-card .trap { font-size: 34px; }
.gate-card p { color: var(--muted); margin: 6px 0 18px; }
.btn {
  width: 100%; border: none; border-radius: 12px; padding: 13px 16px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--soag), var(--soag-2)); margin-top: 6px;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.gate-msg { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--gold); }
.gate-demo { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.gate-demo small { color: var(--muted); }

/* ---------- app shell ---------- */
#app { display: none; height: 100%; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: rgba(22,13,31,.7); backdrop-filter: blur(6px);
}
header .logo { font-weight: 800; font-size: 17px; }
header .logo b { color: var(--soag); }
header .spacer { flex: 1; }
.pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }
.pill b { color: var(--txt); }

.layout { flex: 1; display: flex; min-height: 0; }

/* sidebar */
aside {
  width: 250px; border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
aside h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 16px 14px 8px; }
.rooms { padding: 0 12px; }
.room-input { display: flex; gap: 6px; margin-bottom: 8px; }
.room-input input { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); border-radius: 9px; padding: 9px 10px; }
.room-row { display: flex; gap: 6px; }
.room-row .btn { margin: 0; font-size: 13px; padding: 9px; }
.btn.join { background: linear-gradient(135deg,#6b4bff,#9a5bff); }
.btn.create { background: linear-gradient(135deg,#2f9e5a,#43d17a); }
.lobby { margin-top: 6px; overflow-y: auto; }
.lobby .lroom { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.lobby .lroom:hover { background: var(--panel-2); }
.lobby .lroom.active { background: var(--panel-2); outline: 1px solid var(--soag); }
.lobby .lroom .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby .lroom .ct { font-size: 12px; color: var(--muted); }
.users { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 12px; overflow-y: auto; max-height: 42%; }
.user { display: flex; align-items: center; gap: 8px; padding: 5px 4px; font-size: 14px; }
.user .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.user.voice .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.user .me { color: var(--soag); font-size: 11px; }

/* main */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: none; background: transparent; color: var(--muted); padding: 9px 14px; border-radius: 10px 10px 0 0; font-weight: 600; white-space: nowrap; }
.tab.active { color: var(--txt); background: var(--panel-2); }
.tab:hover { color: var(--txt); }
.panel { flex: 1; min-height: 0; display: none; flex-direction: column; }
.panel.active { display: flex; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.empty .big { font-size: 40px; }

/* chat */
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.msg { max-width: 80%; }
.msg .who { font-size: 12px; color: var(--soag); margin-bottom: 2px; }
.msg .bubble { background: var(--panel-2); border: 1px solid var(--line); padding: 8px 12px; border-radius: 12px; word-wrap: break-word; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .bubble { background: linear-gradient(135deg,#3a1d6e,#2a1b5d); }
.msg.sys { align-self: center; font-size: 12px; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.composer input { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); border-radius: 11px; padding: 12px 14px; }
.composer .btn { width: auto; margin: 0; padding: 12px 18px; }

/* voice */
.voicebar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.voicebar .btn { width: auto; margin: 0; }
.btn.mute { background: linear-gradient(135deg,#7a2740,#ff5a7a); }
.btn.leave-v { background: transparent; border: 1px solid var(--line); color: var(--txt); }
.voicegrid { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 14px; align-content: start; }
.vtile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 10px; text-align: center; transition: box-shadow .12s, border-color .12s; }
.vtile.speaking { border-color: var(--green); box-shadow: 0 0 0 2px var(--green) inset; }
.vtile .av { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 8px; background: linear-gradient(135deg,var(--soag),var(--soag-2)); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.vtile .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtile .st { font-size: 11px; color: var(--muted); margin-top: 2px; }
.vtile.me .nm { color: var(--soag); }

/* watch + games */
.watchbar { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.watchbar input { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); border-radius: 10px; padding: 10px 12px; }
.watchbar .btn { width: auto; margin: 0; padding: 10px 16px; }
.player { flex: 1; min-height: 0; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; }
.games { padding: 18px; display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 14px; align-content: start; overflow-y: auto; }
.gcard { display: block; text-decoration: none; color: var(--txt); background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; transition: transform .1s, border-color .1s; }
.gcard:hover { transform: translateY(-2px); border-color: var(--soag); }
.gcard .ico { font-size: 30px; }
.gcard .gt { font-weight: 700; margin: 8px 0 3px; }
.gcard .gd { font-size: 13px; color: var(--muted); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2a1b3d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 80; }
.toast.show { opacity: 1; }

@media (max-width: 720px) {
  aside { position: fixed; z-index: 30; height: calc(100% - 49px); top: 49px; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 60px rgba(0,0,0,.7); }
  aside.open { transform: none; }
  .menu-btn { display: inline-flex !important; }
  .msg { max-width: 92%; }
}
.menu-btn { display: none; background: transparent; border: 1px solid var(--line); color: var(--txt); border-radius: 9px; padding: 6px 10px; }
