:root {
  --bg: #050505;
  --bg2: #0d0b09;
  --card: rgba(18, 18, 18, 0.90);
  --card2: rgba(28, 20, 15, 0.88);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f6f3eb;
  --muted: #b7afa1;
  --red: #c51f2d;
  --red2: #7d101a;
  --gold: #d7aa38;
  --gold2: #f2d06b;
  --silver: #d8d8d8;
  --good: #53e0a4;
  --bad: #ff6868;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(197, 31, 45, 0.24), transparent 31rem),
    radial-gradient(circle at bottom right, rgba(215, 170, 56, 0.18), transparent 35rem),
    linear-gradient(135deg, var(--bg), #110b08 52%, #050505);
  color: var(--text);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.04) 25%, transparent 25%);
  background-size: 22px 22px;
  mix-blend-mode: screen;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; position: relative; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-card {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid rgba(215, 170, 56, 0.28);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(18,18,18,.93), rgba(31,17,14,.90));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(18px);
}
.brand-badge {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-weight: 1000;
  letter-spacing: 1px;
  color: #110b08;
  background: linear-gradient(135deg, var(--gold2), var(--gold) 48%, #8d6215);
  box-shadow: 0 14px 32px rgba(215, 170, 56, 0.25), 0 0 0 2px rgba(197,31,45,.28);
}
.brand-badge.small { width: 44px; height: 44px; border-radius: 15px; font-size: 0.9rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 6vw, 3.45rem); line-height: .95; margin: 20px 0 12px; letter-spacing: -1px; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 0.95rem; margin: 0; color: #fff3c8; }
.muted { color: var(--muted); line-height: 1.5; }
.form-stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #eee3c9; font-weight: 800; font-size: 0.92rem; }
input, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(215, 170, 56, 0.78); box-shadow: 0 0 0 4px rgba(215, 170, 56, 0.12); }
textarea { resize: none; max-height: 160px; line-height: 1.35; }
.primary-btn, .ghost-btn, .icon-btn, .tiny-btn, .file-btn, .game-btn, .quick-chip {
  border: 0;
  border-radius: 15px;
  padding: 12px 16px;
  color: var(--text);
  font-weight: 900;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.primary-btn {
  color: #120b07;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  box-shadow: 0 12px 24px rgba(215, 170, 56, 0.16), inset 0 -2px 0 rgba(0,0,0,.16);
}
.primary-btn:hover, .ghost-btn:hover, .icon-btn:hover, .tiny-btn:hover, .file-btn:hover, .game-btn:hover, .quick-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0,0,0,.22);
}
.primary-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.ghost-btn, .icon-btn, .tiny-btn, .file-btn, .game-btn, .quick-chip {
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line);
}
.icon-btn { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; }
.tiny-btn { padding: 7px 10px; font-size: 0.78rem; }
.danger { color: #ffd8d8; border-color: rgba(255,104,104,.28); }
.error-text { min-height: 1.2rem; color: var(--bad); font-weight: 900; }
.status-text { min-height: 1.2rem; color: var(--good); font-weight: 800; }
.bad-status { color: var(--bad) !important; }
.login-note { margin-top: 18px; color: var(--muted); font-size: 0.88rem; line-height: 1.45; border-top: 1px solid var(--line); padding-top: 16px; }
.streetwise-credit { display: inline-block; margin-top: 14px; color: var(--gold2); text-decoration: none; font-weight: 900; font-size: .86rem; }
.streetwise-credit:hover { text-decoration: underline; }
.streetwise-credit.inline { margin-top: 12px; }

.chat-screen { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(215,170,56,.22);
  background: rgba(8, 8, 8, 0.90);
  backdrop-filter: blur(18px);
}
.top-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.backend-status { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions .ghost-btn { padding: 10px 12px; font-size: 0.86rem; }

.room-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 305px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}
.side-panel { display: grid; align-content: start; gap: 14px; min-height: 0; }
.panel-card {
  background: linear-gradient(145deg, rgba(16,16,16,.91), rgba(32,21,17,.78));
  border: 1px solid rgba(255,255,255,.11);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 16px 34px rgba(0,0,0,.30), inset 0 0 0 1px rgba(215,170,56,.035);
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pill, .mini-badge { display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 8px; border-radius: 999px; background: rgba(83, 224, 164, 0.16); color: var(--good); font-weight: 1000; font-size: .78rem; }
.mini-badge { background: rgba(215,170,56,.15); color: var(--gold2); }
.online-list, .login-board { display: grid; gap: 9px; max-height: 42vh; overflow: auto; padding-right: 4px; }
.online-user, .login-item {
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.055);
  border-radius: 14px;
  padding: 10px;
}
.online-user { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 16px rgba(83,224,164,.72); }
.login-item strong { display: block; font-size: .92rem; }
.login-item span { color: var(--muted); font-size: .78rem; }
.empty { color: var(--muted); font-size: .9rem; }
.announcement-card p, .helper-card p { color: #e9e1d0; line-height: 1.45; margin-bottom: 0; white-space: pre-wrap; }
.now-playing { display: grid; gap: 4px; line-height: 1.35; }
.now-playing strong { color: var(--gold2); overflow-wrap: anywhere; }
.now-playing span { color: var(--muted); font-size: .82rem; }

.chat-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: rgba(7, 7, 7, 0.82);
  border: 1px solid rgba(215,170,56,.18);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.messages { overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 420px; }
.date-divider {
  align-self: center;
  margin: 10px 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(215,170,56,.10);
  border: 1px solid rgba(215,170,56,.18);
  color: #f0d99c;
  font-size: .78rem;
  font-weight: 900;
}
.message {
  max-width: min(76%, 720px);
  padding: 12px 13px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.066);
}
.message.mine { align-self: flex-end; background: linear-gradient(135deg, rgba(197,31,45,.34), rgba(215,170,56,.18)); border-color: rgba(215,170,56,.22); }
.message.system { align-self: center; max-width: 88%; text-align: center; color: var(--muted); background: rgba(215,170,56,.075); border-color: rgba(215,170,56,.18); font-size: .9rem; }
.message-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.message-user { color: #fff8dc; font-weight: 1000; }
.message-time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.message-body { line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.message-media { margin-top: 10px; display: grid; gap: 8px; }
.message-media audio, .message-media video, .message-media img { width: 100%; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: #050505; }
.message-media video { max-height: 360px; }
.media-link { color: var(--gold2); font-weight: 900; text-decoration: none; overflow-wrap: anywhere; }
.media-link:hover { text-decoration: underline; }

.composer { border-top: 1px solid rgba(215,170,56,.18); padding: 12px; background: rgba(8, 8, 8, 0.94); }
.quick-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }
.quick-chip { min-width: 38px; padding: 7px 10px; }
.composer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 9px; align-items: end; }
.file-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 48px; }
.file-btn input { display: none; }
.send-btn { min-height: 48px; }
.attachment-preview {
  margin-bottom: 10px;
  border: 1px solid rgba(215,170,56,.24);
  background: rgba(215,170,56,.08);
  color: #fff0c0;
  border-radius: 14px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.attachment-preview button { border: 0; background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; padding: 6px 8px; }

.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.game-btn { min-height: 44px; padding: 10px 9px; background: linear-gradient(145deg, rgba(197,31,45,.22), rgba(215,170,56,.10)); }
.game-status { color: var(--muted); font-size: .84rem; line-height: 1.35; margin: 12px 0 0; }

.modal { border: 0; padding: 0; background: transparent; color: var(--text); width: min(640px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(0, 0, 0, 0.70); backdrop-filter: blur(8px); }
.modal-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: linear-gradient(145deg, #111, #201410);
  border: 1px solid rgba(215,170,56,.22);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.small-modal { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 1120px) {
  .room-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .right-panel { grid-column: 1 / -1; grid-template-columns: 1fr 1fr 1fr; }
  .login-board, .online-list { max-height: 260px; }
}
@media (max-width: 860px) {
  .right-panel { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: stretch; }
  .top-actions .ghost-btn, .top-actions .icon-btn { flex: 1; }
  .room-layout { display: flex; flex-direction: column; padding: 10px; }
  .left-panel, .right-panel { display: grid; grid-template-columns: 1fr; }
  .chat-panel { min-height: 68vh; border-radius: 20px; }
  .messages { min-height: 52vh; padding: 12px; }
  .message { max-width: 92%; }
  .composer-row { grid-template-columns: 1fr; }
  .file-btn, .send-btn { width: 100%; justify-content: center; }
  .login-card { padding: 24px; }
  h1 { font-size: 2.3rem; }
  .backend-status { max-width: 92vw; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .login-screen { padding: 16px; }
  .top-actions { gap: 7px; }
  .top-actions .ghost-btn { font-size: .78rem; padding: 9px 8px; }
  .panel-card { padding: 13px; border-radius: 18px; }
  .modal-card { padding: 16px; }
  .game-grid { grid-template-columns: 1fr; }
}
