:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #ef4444;
  --border: rgba(255,255,255,0.08);
  --room-bg: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
button, input { font: inherit; }
button {
  background: var(--accent);
  color: #082f49;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}
input {
  width: 100%;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  padding: 12px;
}
label span { display:block; margin-bottom:6px; color: var(--muted); font-size: 14px; }
.stack { display:flex; flex-direction:column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.top-gap { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #fca5a5; min-height: 20px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.demo-box {
  margin-top: 14px;
  font-size: 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 14px;
  padding: 14px;
}
.sidebar, .center-panel {
  min-height: calc(100vh - 28px);
}
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  overflow: auto;
}
.center-panel {
  display:flex;
  flex-direction:column;
  gap: 12px;
}
.topbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  gap: 12px;
}
.topbar-actions { display:flex; gap: 10px; flex-wrap: wrap; }
.panel-section {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel-title { font-weight: 700; margin-bottom: 8px; }
.profile-box { display:flex; align-items:center; gap: 12px; }
.avatar-large {
  width: 60px;
  height: 57px;
  position: relative;
  overflow: visible;
  background: transparent;
  border-radius: 0;
  display: block;
  flex: 0 0 60px;
  cursor: pointer;
}

.avatar-large img {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 57px;
  display: block;
  pointer-events: none;
}
.profile-name { font-size: 18px; font-weight: 700; }
.room-name { font-weight: 700; font-size: 16px; }
.room-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px;
  min-height: 560px;
}
.room-canvas {
  position: relative;

  width: min(100%, 1000px);
  aspect-ratio: 500 / 350;

  border-radius: 14px;
  overflow: hidden;

  background: var(--room-bg);
  border: 1px solid rgba(0,0,0,0.08);
}
.room-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}
.room-item,
.user-avatar,
.room-exit {
  position: absolute;
}

.room-item,
.room-exit {
  transform: translate(-50%, -50%);
}
.user-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 28px;
  color: #111827;
  border: 3px solid rgba(255,255,255,0.8);
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.user-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(15,23,42,0.85);
  color: white;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}
.room-item {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  display:grid;
  place-items:center;
  font-size: 24px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  cursor: pointer;
}
.room-item-image {
  position: absolute;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  width: auto;
  height: auto;
  display: block;
}
.room-exit {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(17,24,39,0.82);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}
.chat-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 560px;
  height: 100%;
}

.chat-log {
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 10px;
  flex: 1;
  min-height: 450px;
  max-height: none;
  overflow-y: auto;
}
.chat-line { margin-bottom: 8px; line-height: 1.4; }
.chat-line strong { color: #f8fafc; }
.chat-line.private {
  background: rgba(251, 191, 36, 0.14);
  border-left: 4px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.chat-line.private strong {
  color: #fbbf24;
}
.chat-form {
  display:grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.user-list, .inventory-list, .exit-list {
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.inventory-item, .exit-chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.user-chip {
  padding:4px 0;
  border:none;
  background:none;
  cursor:pointer;
}
.inventory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  width: fit-content;
}

.inventory-item img {
  width: 32px;
  height: 32px;
  display: block;
}

.inventory-count {
  font-size: 12px;
  opacity: 0.8;
  min-width: 20px;
}
.inventory-actions { display:flex; gap: 8px; }
.inventory-actions button { padding: 8px 10px; }
.empty-state { color: var(--muted); font-size: 14px; }

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      'center'
      'left'
      'right';
  }
  .left-panel { grid-area: left; min-height: auto; }
  .center-panel { grid-area: center; min-height: auto; }
  .right-panel { grid-area: right; min-height: auto; }
}

@media (max-width: 700px) {
  .app-shell { padding: 8px; gap: 8px; }
  .sidebar, .topbar, .room-container, .chat-section { border-radius: 14px; }
  .room-container { padding: 6px; }
  .room-canvas { min-height: 420px; }
  .topbar { align-items:flex-start; flex-direction:column; }
  .chat-form { grid-template-columns: 1fr; }
  button { min-height: 44px; }
}

.avatar-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 99999;
  align-items: center;
  justify-content: center;
}

.avatar-modal-content {
  background: #1f2937;
  color: white;
  width: 900px;
  max-width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.avatar-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.avatar-tabs button {
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.avatar-tabs button.active {
  font-weight: bold;
}

.avatar-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 200px;
}

.avatar-select-item {
  width: 64px;
  height: 64px;
  object-fit: contain;
  cursor: pointer;
  border-radius: 10px;
  padding: 6px;
  background: rgba(255,255,255,0.05);
}

.avatar-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.chat-line.private {
  background: rgba(251, 191, 36, 0.12);
  border-left: 4px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.chat-line.private strong {
  color: #fbbf24;
}