/* Owlzo Lobbies — theme matches owlzo.com community page */
:root {
  --cm-bg: #131318;
  --cm-surface: #1b1b22;
  --cm-raised: #23232c;
  --cm-border: #2c2c36;
  --cm-primary: #ff5a1f;
  --cm-primary-2: #e8480f;
  --cm-accent: #6366f1;
  --cm-online: #39ff14;
  --cm-text: #f3f4f6;
  --cm-muted: #9ca3af;
  --cm-dim: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--cm-bg);
  color: var(--cm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--cm-surface);
  border-bottom: 1px solid var(--cm-border);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--cm-text); font-weight: 800; }
.brand-owl { font-size: 1.4rem; }
.brand-text { font-size: 1.1rem; }
.brand-accent { color: var(--cm-primary); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.back-link { color: var(--cm-muted); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { color: var(--cm-text); }
.me { color: var(--cm-primary); font-weight: 600; font-size: 0.9rem; }

/* Layout: lobbies | chat | presence */
.layout { display: grid; grid-template-columns: 240px 1fr 220px; grid-template-rows: minmax(0, 1fr); flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* Lobby list */
.lobbies { background: var(--cm-surface); border-right: 1px solid var(--cm-border); overflow-y: auto; padding: 10px; display: flex; flex-direction: column; }
.lobby-search-wrap { position: sticky; top: 0; background: var(--cm-surface); padding-bottom: 8px; margin-bottom: 2px; z-index: 2; }
.lobby-search { width: 100%; background: var(--cm-raised); border: 1px solid var(--cm-border); color: var(--cm-text); padding: 8px 10px; border-radius: 8px; font-size: 0.85rem; outline: none; box-sizing: border-box; }
.lobby-search:focus { border-color: var(--cm-primary); }
.lobby-empty { color: var(--cm-dim); font-size: 0.85rem; text-align: center; padding: 16px 8px; }
.lobby-count { margin-left: auto; background: var(--cm-primary); color: #fff; font-size: 0.7rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.lobby-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 1px solid transparent; color: var(--cm-text);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  font-size: 0.92rem; margin-bottom: 4px; position: relative; transition: background 0.15s, border-color 0.15s;
}
.lobby-btn:hover { background: var(--cm-raised); }
.lobby-btn.active { background: var(--cm-raised); border-color: var(--cm-primary); }
.lobby-emoji { font-size: 1.15rem; width: 22px; text-align: center; }
.lobby-name { flex: 1; }
.lobby-btn.has-unread::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--cm-primary); position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
}

/* Chat */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; background: var(--cm-bg); }
.chat-header { padding: 12px 18px; border-bottom: 1px solid var(--cm-border); background: var(--cm-surface); flex: 0 0 auto; }
.chat-title { font-weight: 700; font-size: 1.05rem; }
.chat-sub { color: var(--cm-muted); font-size: 0.8rem; margin-top: 2px; }

.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.loading { color: var(--cm-dim); text-align: center; margin: auto; }

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.in { animation: fadeIn 0.18s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--cm-raised); flex: 0 0 auto; object-fit: cover; }
.msg-body { min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.msg-user { color: var(--cm-primary); font-weight: 600; font-size: 0.85rem; text-decoration: none; }
.msg-user:hover { text-decoration: underline; }
.msg.mine .msg-user { color: var(--cm-accent); }
.msg-time { color: var(--cm-dim); font-size: 0.7rem; }
.msg-text { color: var(--cm-text); font-size: 0.92rem; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; }

/* Composer */
.composer { flex: 0 0 auto; border-top: 1px solid var(--cm-border); background: var(--cm-surface); padding: 10px 14px; }
.composer-note { color: var(--cm-primary); font-size: 0.78rem; min-height: 16px; opacity: 0; transition: opacity 0.2s; }
.composer-note.show { opacity: 1; }
#composerForm { display: flex; gap: 8px; }
#input {
  flex: 1; background: var(--cm-raised); border: 1px solid var(--cm-border); color: var(--cm-text);
  padding: 11px 14px; border-radius: 10px; font-size: 0.92rem; outline: none;
}
#input:focus { border-color: var(--cm-primary); }
#sendBtn {
  background: var(--cm-primary); color: #fff; border: none; font-weight: 700;
  padding: 0 20px; border-radius: 10px; cursor: pointer; transition: background 0.15s;
}
#sendBtn:hover:not(:disabled) { background: var(--cm-primary-2); }
#sendBtn:disabled, #input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Guest "log in to chat" bar */
.guest-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.guest-bar-text { color: var(--cm-muted); font-size: 0.85rem; }
.guest-bar-btn { background: var(--cm-primary); color: #fff; text-decoration: none; font-weight: 700; font-size: 0.9rem; padding: 10px 18px; border-radius: 10px; white-space: nowrap; }
.guest-bar-btn:hover { background: var(--cm-primary-2); }

/* Presence */
.presence { background: var(--cm-surface); border-left: 1px solid var(--cm-border); overflow-y: auto; padding: 12px; }
.presence-header { font-weight: 700; font-size: 0.85rem; color: var(--cm-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cm-online); box-shadow: 0 0 6px var(--cm-online); }
.presence-list { list-style: none; margin: 0; padding: 0; }
.presence-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; }
.presence-item:hover { background: var(--cm-raised); }
.pa { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--cm-raised); }
.pn { font-size: 0.85rem; color: var(--cm-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gate */
.gate { position: fixed; inset: 0; background: rgba(9,9,12,0.92); display: flex; align-items: center; justify-content: center; z-index: 50; }
.gate.hidden { display: none; }
.gate-card { background: var(--cm-surface); border: 1px solid var(--cm-border); border-radius: 16px; padding: 40px; text-align: center; max-width: 380px; }
.gate-owl { font-size: 2.6rem; margin-bottom: 8px; }
.gate-card h1 { font-size: 1.4rem; margin: 0 0 10px; }
.gate-card p { color: var(--cm-muted); font-size: 0.9rem; margin: 0 0 22px; }
.gate-btn { display: inline-block; background: var(--cm-primary); color: #fff; text-decoration: none; font-weight: 700; padding: 12px 22px; border-radius: 10px; }
.gate-btn:hover { background: var(--cm-primary-2); }

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 64px 1fr; grid-template-rows: minmax(0, 1fr); }
  .lobby-name { display: none; }
  .lobby-btn { justify-content: center; padding: 12px 0; }
  .lobby-emoji { width: auto; font-size: 1.3rem; }
  .lobby-search-wrap { display: none; }
  .lobby-count { display: none; }
  .presence { display: none; }
}
@media (max-width: 480px) {
  .brand-text { font-size: 0.95rem; }
  .back-link { display: none; }
}
