:root {
  --bg: #0b0f1a;
  --glass: rgba(13, 17, 30, 0.74);
  --glass-2: rgba(24, 30, 50, 0.85);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #eef1f8;
  --muted: #98a2b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f43f5e;
  --r: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
input, select, textarea, button { font-family: inherit; }
input, textarea { user-select: text; }

html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; touch-action: none; }
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; direction: ltr; }
.labels > * { left: 0; top: 0; direction: rtl; }
#fade { position: fixed; inset: 0; background: #0b0f1a; opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 90; }
#fade.on { opacity: 1; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ---------- mode visibility ---------- */
.hud-map, .hud-room, #login { display: none !important; }
body.mode-login #login { display: grid !important; }
body.mode-map .hud-map { display: flex !important; }
body.mode-room .hud-room { display: flex !important; }
body.mode-map #labels-room, body.mode-room #labels-map, body.mode-login #labels-map, body.mode-boot #labels-map { display: none; }
body.mode-room #sidepanel, body.mode-room #buybar { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .18s, transform .18s, border-color .18s, opacity .18s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px); }
.btn i { font-size: 18px; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 48px; font-size: 16px; font-weight: 700; border-radius: 12px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b8cff); border: none; box-shadow: 0 8px 24px rgba(124, 92, 255, .35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.accent { background: linear-gradient(135deg, #ff9a3d, #ff5f6d); border: none; }
.btn.accent.on { background: linear-gradient(135deg, var(--ok), #10b981); }
.btn.danger { background: rgba(244, 63, 94, .15); border-color: rgba(244, 63, 94, .35); color: #ffc1cc; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.badge { font-style: normal; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); display: inline-grid; place-items: center; padding: 0 4px; position: relative; top: -8px; margin-inline-start: -10px; }
.badge:empty, .badge.zero { display: none; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; letter-spacing: .5px; direction: ltr; }
.brand b { font-size: 18px; background: linear-gradient(90deg, #fff, #c6b8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand.big b { font-size: 34px; }
.logo-mark { display: grid; grid-template-columns: repeat(2, 9px); gap: 2px; }
.logo-mark i { width: 9px; height: 9px; border-radius: 2px; display: block; }
.logo-mark i:nth-child(1) { background: #7c5cff; }
.logo-mark i:nth-child(2) { background: #22d3ee; }
.logo-mark i:nth-child(3) { background: #ff9a3d; }
.logo-mark i:nth-child(4) { background: #34d399; }
.brand.big .logo-mark { grid-template-columns: repeat(2, 15px); gap: 3px; }
.brand.big .logo-mark i { width: 15px; height: 15px; border-radius: 3px; }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; z-index: 50; place-items: center; background: radial-gradient(ellipse at center, rgba(11, 15, 26, .25), rgba(11, 15, 26, .75)); padding: 16px; }
.login-card { width: min(440px, 100%); padding: 30px 28px 22px; display: flex; flex-direction: column; gap: 18px; animation: rise .6s cubic-bezier(.2, .8, .2, 1); }
.login-card .brand { justify-content: center; }
.tagline { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.9; }
.fld { display: flex; flex-direction: column; gap: 8px; }
.fld > span { font-size: 13px; color: var(--muted); }
.fld input, .inp, select, textarea {
  height: 42px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.05);
  color: var(--text); padding: 0 12px; font-size: 14px; outline: none; transition: border-color .2s, background .2s;
}
textarea { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
.fld input:focus, .inp:focus, select:focus, textarea:focus { border-color: var(--accent); background: rgba(124, 92, 255, .08); }
select { cursor: pointer; }
select option { background: #151a2b; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .15); transition: transform .15s; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .2); }
.swatches.sq .swatch { border-radius: 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { height: 54px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .04); color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; }
.seg button i { font-size: 20px; }
.seg button.on { color: #fff; border-color: var(--accent); background: rgba(124, 92, 255, .15); }
.note { font-size: 12px; color: var(--muted); line-height: 1.9; display: flex; gap: 6px; background: rgba(34, 211, 238, .06); border: 1px dashed rgba(34, 211, 238, .25); padding: 10px 12px; border-radius: 10px; }
.note i { color: var(--accent-2); font-size: 16px; margin-top: 2px; }

/* ---------- topbar ---------- */
#topbar { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20; align-items: center; gap: 8px; padding: 7px 10px; max-width: calc(100vw - 24px); }
.sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 2px; }
.coord-search { display: flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 0 4px 0 8px; height: 38px; }
.coord-search i { color: var(--muted); }
.coord-search input { width: 62px; height: 30px; border: none; background: transparent; color: var(--text); text-align: center; outline: none; font-size: 13px; direction: ltr; }
.coord-search input::-webkit-inner-spin-button { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; background: rgba(255, 255, 255, .06); font-size: 14px; font-weight: 700; }
.chip.coins i { color: #fbbf24; font-size: 18px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-inline-start: 4px; font-size: 14px; font-weight: 500; }
.av { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.av.sm { width: 24px; height: 24px; font-size: 11px; }
.av.lg { width: 40px; height: 40px; font-size: 16px; }

/* ---------- online panel ---------- */
#online { position: fixed; top: 76px; right: 14px; width: 270px; z-index: 18; flex-direction: column; overflow: hidden; max-height: calc(100vh - 170px); }
body.mode-room #online { top: 84px; }
.online-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: transparent; border: none; color: var(--text); cursor: pointer; font-size: 14px; }
.online-head em { font-style: normal; background: rgba(52, 211, 153, .15); color: var(--ok); font-size: 12px; padding: 1px 8px; border-radius: 9px; }
.online-head i { margin-inline-start: auto; transition: transform .2s; color: var(--muted); }
#online.collapsed .online-head i { transform: rotate(90deg); }
#online.collapsed .online-list { display: none; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 1.8s infinite; }
.online-list { overflow-y: auto; padding: 0 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.orow { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; transition: background .15s; }
.orow:hover { background: rgba(255, 255, 255, .06); }
.orow .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.orow .meta b { font-size: 13px; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.orow .meta small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-bot { font-size: 9px; font-weight: 500; color: #c4b5fd; background: rgba(124, 92, 255, .18); padding: 0 6px; border-radius: 6px; }
.tag-me { font-size: 9px; color: #a5f3fc; background: rgba(34, 211, 238, .15); padding: 0 6px; border-radius: 6px; }
.vstate { font-size: 17px; color: var(--muted); width: 22px; text-align: center; }
.vstate.live { color: var(--ok); animation: blink .6s infinite alternate; }
.vstate.blocked { color: var(--warn); }
.vstate.off { opacity: .45; }
.orow .vlabel { font-size: 10px; color: var(--muted); }
.kick-btn { color: #fda4af; opacity: .7; }
.kick-btn:hover { opacity: 1; background: rgba(244, 63, 94, .15) !important; }

/* ---------- owner: visitor stats ---------- */
.vis-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.vis-chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; height: 130px; align-items: end; }
.vis-chart .col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.vis-chart .col i { width: 100%; max-width: 22px; min-height: 2px; border-radius: 4px 4px 1px 1px; background: var(--accent-2); }
.vis-chart .col:last-child i { background: var(--accent); }
.vis-chart .n { font-size: 10px; color: var(--muted); }
.vis-chart small { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.vis-rank { width: 20px; text-align: center; color: var(--muted); font-size: 12px; flex: none; }
.vis-log { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.vis-log .row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.vis-log .row b { font-weight: 500; }
.vis-log .row small { color: var(--muted); font-size: 11px; white-space: nowrap; }
@media (max-width: 760px) {
  .vis-kpis { grid-template-columns: repeat(2, 1fr); }
  .vis-chart small { display: none; }
  .vis-log .row { flex-direction: column; gap: 2px; }
}

/* ---------- view bar ---------- */
#viewbar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 18; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; }
.view-mode { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; min-width: 128px; }
.view-mode i { font-size: 18px; color: var(--accent-2); }
.zoom-track { width: 120px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; direction: ltr; }
#zoomFill { height: 100%; width: 30%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 3px; transition: width .1s; }
.coords { font-size: 12px; color: var(--muted); min-width: 110px; text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.hint { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); font-size: 12px; color: rgba(255, 255, 255, .8); background: rgba(0, 0, 0, .35); padding: 5px 14px; border-radius: 20px; z-index: 17; pointer-events: none; white-space: nowrap; transition: opacity .5s; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.hint.gone { opacity: 0; }
body.buying #mapHint::after { content: ' — حالت خرید: روی زمین آزاد بکش تا انتخاب کنی'; color: #ffd27a; }

/* ---------- side panel ---------- */
#sidepanel { position: fixed; top: 76px; left: 14px; bottom: 16px; width: 380px; z-index: 25; overflow: hidden; display: flex; flex-direction: column; transform: translateX(calc(-100% - 30px)); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
#sidepanel.open { transform: none; }
.sp-scroll { overflow-y: auto; flex: 1; padding: 0 18px 18px; }
.sp-cover { height: 150px; margin: 0 -18px 0; position: relative; background: var(--c, #333); display: grid; place-items: center; font-size: 64px; overflow: hidden; }
.sp-cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.sp-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 40%, rgba(13, 17, 30, .95)); }
.sp-close { position: absolute; top: 10px; left: 10px; z-index: 2; background: rgba(0, 0, 0, .4) !important; }
.sp-badge { position: absolute; top: 12px; right: 12px; z-index: 2; font-size: 12px; padding: 3px 10px; border-radius: 10px; background: rgba(0, 0, 0, .45); display: flex; gap: 5px; align-items: center; }
.sp-title { font-size: 21px; font-weight: 900; margin-top: -26px; position: relative; z-index: 2; line-height: 1.5; }
.sp-owner { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.stat small { color: var(--muted); font-size: 11px; }
.stat b { font-size: 15px; display: flex; gap: 4px; align-items: center; }
.stat b i { color: var(--accent-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.actions .btn { flex: 1; }
.sec-title { font-size: 13px; color: var(--muted); margin: 18px 0 10px; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs .th { aspect-ratio: 4/3; border-radius: 8px; background-size: cover; background-position: center; cursor: pointer; position: relative; overflow: hidden; border: 1px solid var(--line); }
.thumbs .th:hover { outline: 2px solid var(--accent); }
.people-row { display: flex; gap: 4px; flex-wrap: wrap; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pitem { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.pitem .em { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 22px; background: rgba(255, 255, 255, .06); background-size: cover; background-position: center; flex: none; }
.pitem .nm { flex: 1; font-size: 13px; display: flex; flex-direction: column; min-width: 0; }
.pitem .nm small { color: var(--muted); }
.pitem input { height: 32px; font-size: 13px; }
.locked { display: flex; gap: 8px; align-items: center; color: var(--warn); background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .25); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* builder */
.bhead { padding: 16px 18px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.bhead h3 { font-size: 17px; flex: 1; }
.size-chip { font-size: 12px; color: #a5f3fc; background: rgba(34, 211, 238, .12); padding: 3px 10px; border-radius: 10px; }
.types { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tcard { border: 1px solid var(--line-2); border-radius: 12px; padding: 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, .03); transition: border-color .15s, background .15s; position: relative; }
.tcard .em { font-size: 26px; }
.tcard b { font-size: 13px; display: block; }
.tcard small { font-size: 10.5px; color: var(--muted); line-height: 1.6; display: block; }
.tcard:hover { background: rgba(255, 255, 255, .06); }
.tcard.on { border-color: var(--accent); background: rgba(124, 92, 255, .14); }
.tcard.lock { opacity: .45; cursor: not-allowed; filter: grayscale(.7); }
.tcard.lock::after { content: '\1F512'; position: absolute; top: 6px; left: 8px; font-size: 11px; }
.row2 { display: flex; gap: 8px; align-items: center; }
.row2 > * { flex: 1; }
.capacity { font-size: 12px; color: var(--muted); margin-top: 8px; }
.upl { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: 13px; transition: border-color .2s; display: flex; gap: 8px; align-items: center; justify-content: center; }
.upl:hover { border-color: var(--accent); color: var(--text); }
.th .x { position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .6); border: none; color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 12px; opacity: 0; transition: opacity .15s; }
.th:hover .x { opacity: 1; }
.emoji-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.emoji-pick button { height: 36px; font-size: 20px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); cursor: pointer; }
.emoji-pick button.on { border-color: var(--accent); background: rgba(124, 92, 255, .2); }
.bfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.bfoot .btn { flex: 1; }

/* ---------- buy bar ---------- */
#buybar { position: fixed; bottom: 76px; left: 50%; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 22; padding: 12px 14px; display: flex; gap: 14px; align-items: center; transition: all .3s cubic-bezier(.2, .8, .2, 1); max-width: calc(100vw - 24px); }
#buybar.open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#buybar { flex-wrap: wrap; justify-content: center; width: max-content; }
.bb-info { display: flex; flex-direction: column; gap: 3px; min-width: 230px; white-space: nowrap; }
.bb-unlocks { flex-wrap: wrap; }
.bb-info b { font-size: 15px; }
.bb-info small { font-size: 12px; color: var(--muted); }
.bb-info .bad { color: #ff9fb0; }
.bb-unlocks { display: flex; gap: 4px; font-size: 20px; }
.bb-unlocks span { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgba(255, 255, 255, .06); }
.bb-unlocks span.no { opacity: .25; filter: grayscale(1); }

/* ---------- room HUD ---------- */
#roomTop { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20; align-items: center; gap: 10px; padding: 7px 10px; }
.room-title { display: flex; flex-direction: column; align-items: center; min-width: 200px; padding: 0 10px; }
.room-title b { font-size: 16px; }
.room-title span { font-size: 12px; color: var(--muted); }
#roomLikeBtn.liked i { color: #ff4d6d; }
#roomBar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20; align-items: center; gap: 8px; padding: 7px 8px; max-width: calc(100vw - 24px); }
.btn.mic { background: rgba(244, 63, 94, .14); border-color: rgba(244, 63, 94, .3); min-width: 150px; }
.btn.mic.on { background: rgba(52, 211, 153, .16); border-color: rgba(52, 211, 153, .4); }
.meter { width: 46px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; direction: ltr; }
#micMeter { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s; }
#roomBar select { height: 38px; font-size: 13px; max-width: 220px; }
.chat-input { display: flex; align-items: center; background: rgba(255, 255, 255, .05); border-radius: 10px; padding-inline-start: 10px; }
.chat-input input { width: 220px; height: 38px; border: none; background: transparent; color: var(--text); outline: none; font-size: 13px; }
#chatbox { position: fixed; bottom: 76px; left: 14px; width: 330px; max-height: 40vh; z-index: 15; flex-direction: column; justify-content: flex-end; pointer-events: none; }
#chatLog { display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.cmsg { background: rgba(10, 13, 24, .6); backdrop-filter: blur(8px); padding: 6px 10px; border-radius: 10px; font-size: 13px; line-height: 1.7; animation: rise .3s ease; align-self: flex-start; max-width: 100%; }
.cmsg b { margin-inline-end: 6px; }
.cmsg.sys { color: var(--muted); font-size: 12px; }
#roomHint { bottom: auto; top: 74px; }

/* ---------- 3D labels ---------- */
.plabel { display: flex; flex-direction: column; align-items: center; gap: 3px; transform: translateY(-6px); pointer-events: none; }
.plabel .t { font-size: 12px; font-weight: 700; color: #fff; background: rgba(13, 17, 30, .72); padding: 2px 10px; border-radius: 8px; white-space: nowrap; border: 1px solid rgba(255, 255, 255, .12); }
.plabel .t.mine { background: rgba(124, 92, 255, .85); }
.plabel .pc { font-size: 11px; font-weight: 700; color: #052e1f; background: var(--ok); padding: 1px 8px; border-radius: 8px; display: flex; gap: 3px; align-items: center; box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 1.8s infinite; }
.plabel .pc:empty, .plabel .t:empty { display: none; }
.alabel { display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.alabel .tag { display: flex; align-items: center; gap: 4px; background: rgba(13, 17, 30, .72); padding: 2px 9px 2px 7px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid rgba(255, 255, 255, .1); }
.alabel.me .tag { background: rgba(34, 211, 238, .35); }
.alabel .mic { font-size: 13px; color: var(--muted); }
.alabel[data-voice="idle"] .mic { color: #cbd5e1; }
.alabel[data-voice="live"] .tag { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .3); }
.alabel[data-voice="live"] .mic { color: var(--ok); }
.alabel[data-voice="blocked"] .mic { color: var(--warn); }
.alabel[data-voice="blocked"] .tag { border-color: rgba(251, 191, 36, .5); }
.alabel .badge-i { font-size: 13px; color: #fbbf24; }
.alabel.admin .badge-i { color: #60a5fa; }
.alabel.owner .tag { background: linear-gradient(135deg, rgba(180, 120, 0, .85), rgba(245, 179, 1, .85)); border-color: rgba(255, 220, 120, .7); color: #fff; }
.alabel.guest .tag { background: rgba(60, 65, 80, .55); border-style: dashed; color: #d6dbe6; font-weight: 500; }
.alabel .role { font-size: 9.5px; padding: 0 7px; border-radius: 6px; background: rgba(0, 0, 0, .45); color: #e5e7eb; margin-top: -2px; }
.alabel.owner .role { color: #fde68a; }
.alabel .bubble { background: #fff; color: #111; font-size: 13px; padding: 6px 12px; border-radius: 12px; max-width: 220px; white-space: normal; text-align: center; line-height: 1.6; opacity: 0; transform: translateY(6px) scale(.9); transition: all .25s; position: relative; }
.alabel .bubble::after { content: ''; position: absolute; bottom: -5px; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff; border-bottom: 0; }
.alabel .bubble.show { opacity: 1; transform: none; }

/* ---------- tooltip ---------- */
#tooltip { position: fixed; z-index: 60; pointer-events: none; background: rgba(10, 13, 24, .88); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; font-size: 13px; display: none; max-width: 260px; backdrop-filter: blur(8px); }
#tooltip .tt-row { display: flex; gap: 8px; align-items: center; }
#tooltip small { color: var(--muted); display: block; font-size: 11px; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(5, 7, 14, .55); backdrop-filter: blur(4px); animation: fadein .2s ease; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: hidden; display: flex; flex-direction: column; animation: rise .3s cubic-bezier(.2, .8, .2, 1); background: var(--glass-2); }
.modal.wide { width: min(920px, 100%); }
.m-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.m-head h3 { flex: 1; font-size: 16px; }
.m-body { padding: 16px; overflow-y: auto; }
.viewer { display: grid; grid-template-columns: 1.5fr 1fr; min-height: 420px; }
.viewer .img { background: #000; display: grid; place-items: center; position: relative; }
.viewer .img img { max-width: 100%; max-height: 70vh; display: block; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, .5) !important; }
.viewer .nav.prev { right: 10px; }
.viewer .nav.next { left: 10px; }
.viewer .side { display: flex; flex-direction: column; border-inline-start: 1px solid var(--line); min-height: 0; }
.viewer .cap { padding: 14px 16px; font-size: 15px; line-height: 1.8; border-bottom: 1px solid var(--line); }
.viewer .cap small { display: block; color: var(--muted); font-size: 12px; }
.viewer .cmts { flex: 1; overflow-y: auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; max-height: 300px; }
.cmt { font-size: 13px; line-height: 1.7; background: rgba(255, 255, 255, .04); border-radius: 10px; padding: 7px 10px; }
.cmt b { color: #c4b5fd; margin-inline-end: 4px; }
.viewer .act { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.viewer .act input { flex: 1; }
.btn.liked i { color: #ff4d6d; }
.prod { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
.prod .pic { aspect-ratio: 1; border-radius: 16px; display: grid; place-items: center; font-size: 110px; background-size: cover; background-position: center; }
.prod h2 { font-size: 22px; margin-bottom: 4px; }
.prod .price { font-size: 20px; font-weight: 900; color: var(--ok); margin: 10px 0 16px; }
.qty { display: inline-flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 3px; }
.qty b { min-width: 30px; text-align: center; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); }
.menu-item .em { font-size: 28px; }
.menu-item .nm { flex: 1; }
.menu-item .pr { color: var(--ok); font-weight: 700; font-size: 14px; }
.total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; padding: 14px 4px 4px; border-top: 1px solid var(--line); margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }
.empty i { font-size: 40px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 95; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(13, 17, 30, .92); border: 1px solid var(--line-2); padding: 9px 16px; border-radius: 12px; font-size: 14px; display: flex; gap: 8px; align-items: center; animation: rise .3s ease; box-shadow: var(--shadow); }
.toast.ok i { color: var(--ok); }
.toast.warn i { color: var(--warn); }
.toast.err i { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
@keyframes blink { from { opacity: .55; } to { opacity: 1; } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }

/* ---------- touch joystick & mobile-only bits (hidden on desktop) ---------- */
.mobile-only, #joy, #chatClose { display: none !important; }
#joy { position: fixed; z-index: 21; width: 120px; height: 120px; border-radius: 50%; left: 18px; bottom: calc(86px + env(safe-area-inset-bottom)); background: rgba(13, 17, 30, .35); border: 2px solid rgba(255, 255, 255, .18); backdrop-filter: blur(6px); touch-action: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: transform .12s; }
#joy.active i { transition: none; background: #fff; }
#joy.run { border-color: var(--accent-2); }

@media (pointer: coarse) {
  body.mode-room #joy { display: block !important; }
  #roomHint { display: none !important; }
}

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .coord-search { display: none !important; }
  #topbar .sep { display: none; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  :root { --r: 16px; }
  .hide-sm, #mapHint, #roomHint, #topbar .brand b, #meName, .coords { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .btn { height: 40px; }
  .btn.icon { width: 40px; }

  /* top bar → full-width compact strip */
  #topbar { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; transform: none; max-width: none; padding: 5px 6px; gap: 4px; justify-content: space-between; border-radius: 14px; }
  #topbar .brand { padding: 0 4px; }
  #buyBtn { padding: 0 12px; }
  #buyBtn span { font-size: 13px; }
  .chip { height: 32px; padding: 0 10px; font-size: 13px; }
  .user-chip { gap: 2px; padding: 0; }
  .user-chip .av { width: 28px; height: 28px; }

  /* online list → floating pill + dropdown */
  #online { top: calc(66px + env(safe-area-inset-top)) !important; right: 8px; width: min(300px, calc(100vw - 16px)); max-height: 46vh; border-radius: 14px; }
  #online.collapsed { width: auto; }
  #online.collapsed .online-head { padding: 8px 12px; }
  #online.collapsed .online-head b { display: none; }
  .orow { padding: 8px 6px; }

  /* zoom bar */
  #viewbar { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); transform: none; justify-content: space-between; padding: 5px 6px 5px 12px; }
  .view-mode { min-width: 0; font-size: 12px; }
  .zoom-track { flex: 1; width: auto; }

  /* side panel → bottom sheet */
  #sidepanel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: min(78vh, 78dvh); border-radius: 22px 22px 0 0; border-bottom: none; transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom); }
  #sidepanel.open { transform: none; }
  #sidepanel::before { content: ''; position: absolute; top: 7px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: rgba(255, 255, 255, .35); z-index: 3; }
  .sp-cover { height: 120px; font-size: 52px; }
  .sp-title { font-size: 19px; }
  .stat { padding: 8px; }
  .stat b { font-size: 14px; }
  .actions .btn { min-width: 0; }
  .bhead { padding: 18px 14px 10px; }
  .bhead h3 { font-size: 15px; }
  .sp-scroll { padding: 0 14px 14px; }
  .types { gap: 6px; }
  .tcard { padding: 8px; gap: 8px; }
  .tcard .em { font-size: 22px; }
  .bfoot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .thumbs { grid-template-columns: repeat(3, 1fr); }
  .emoji-pick { grid-template-columns: repeat(6, 1fr); }

  /* buy bar */
  #buybar { left: 8px; right: 8px; width: auto; bottom: calc(64px + env(safe-area-inset-bottom)); transform: translateY(30px); gap: 10px; padding: 10px; }
  #buybar.open { transform: none; }
  .bb-info { min-width: 0; flex: 1 1 100%; white-space: normal; text-align: center; }
  .bb-unlocks { flex: 1 1 100%; justify-content: center; font-size: 17px; }
  .bb-unlocks span { width: 30px; height: 30px; }
  #buybar .btn { flex: 1; }

  /* modals → bottom sheets */
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: sheet .3s cubic-bezier(.2, .8, .2, 1); padding-bottom: env(safe-area-inset-bottom); }
  .viewer { grid-template-columns: 1fr; min-height: 0; }
  .viewer .img img { max-height: 42vh; }
  .viewer .side { border-inline-start: none; border-top: 1px solid var(--line); }
  .viewer .cmts { max-height: 22vh; }
  .prod { grid-template-columns: 1fr; gap: 12px; }
  .prod .pic { aspect-ratio: auto; height: 180px; font-size: 90px; }
  #toasts { top: calc(64px + env(safe-area-inset-top)); width: calc(100vw - 24px); }
  .toast { font-size: 13px; text-align: center; }

  /* room HUD */
  #roomTop { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; transform: none; padding: 5px 6px; gap: 4px; }
  #roomTop #exitBtn { padding: 0 10px; }
  .room-title { min-width: 0; flex: 1; padding: 0 4px; }
  .room-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .room-title span { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #roomEditBtn span, #roomEditBtn { padding: 0 8px; }
  #roomBar { left: auto; right: 8px; transform: none; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 5px; gap: 5px; border-radius: 16px; }
  #roomBar .sep, #roomBar select, .meter { display: none !important; }
  .btn.mic { min-width: 0; width: 46px; height: 46px; padding: 0; border-radius: 14px; }
  .btn.mic span { display: none; }
  .btn.mic i { font-size: 22px; }
  #roomBar .btn.icon { width: 46px; height: 46px; border-radius: 14px; }
  #roomBar .btn.icon i { font-size: 21px; }
  .chat-input { display: none; }
  body.mode-room.chat-open .chat-input { display: flex; position: fixed; left: 8px; right: 8px; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--glass-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 4px 10px 4px 4px; z-index: 30; }
  body.mode-room.chat-open .chat-input input { flex: 1; width: auto; font-size: 16px; }
  body.chat-open #joy { opacity: .25; pointer-events: none; }
  #chatbox { left: 8px; right: 8px; width: auto; top: calc(66px + env(safe-area-inset-top)); bottom: auto; max-height: 26vh; padding-right: 78px; }
  #chatLog { justify-content: flex-start; }
  .cmsg { font-size: 12px; padding: 4px 9px; }
  #chatLog .cmsg:nth-last-child(n+5) { display: none; }
  body.mode-room #online { top: calc(66px + env(safe-area-inset-top)) !important; }

  .plabel .t { font-size: 10px; padding: 1px 7px; }
  .plabel .pc { font-size: 10px; }
  .alabel .tag { font-size: 11px; }
  .alabel .bubble { font-size: 12px; max-width: 160px; }
  .login-card { padding: 24px 18px 18px; gap: 14px; }
  .brand.big b { font-size: 28px; }
  .seg button { height: 50px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

/* ---------- character portraits ---------- */
.av.pic { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--c, #7c5cff) 55%, #fff), var(--c, #7c5cff)); overflow: hidden; padding: 0; }
.av.pic img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.15) translateY(4%); display: block; pointer-events: none; }

/* ---------- character designer ---------- */
.modal.cc-modal { width: min(940px, 100%); }
.modal.cc-modal .m-body { padding: 0; overflow: hidden; }
.cc { display: grid; grid-template-columns: 1fr 1.1fr; min-height: min(560px, 80vh); }
.cc-stage { position: relative; background: radial-gradient(ellipse at 50% 30%, #3b3f78 0%, #1b2038 60%, #11152a 100%); min-height: 320px; }
.cc-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.cc-stage canvas:active { cursor: grabbing; }
.cc-stage.nogl::after { content: 'پیش‌نمایش سه‌بعدی در این مرورگر در دسترس نیست'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.cc-tools { position: absolute; top: 12px; inset-inline: 12px; display: flex; gap: 6px; justify-content: flex-end; }
.cc-tools .btn { backdrop-filter: blur(6px); background: rgba(13, 17, 30, .55); }
.cc-tools .btn.on { color: #fff; border-color: var(--accent); background: rgba(124, 92, 255, .35); }
.cc-hint { position: absolute; bottom: 12px; inset-inline: 0; text-align: center; color: rgba(255, 255, 255, .55); font-size: 12px; display: flex; gap: 4px; justify-content: center; align-items: center; pointer-events: none; }
.cc-panel { display: flex; flex-direction: column; min-height: 0; padding: 18px; gap: 14px; }
.cc-intro { display: flex; flex-direction: column; gap: 2px; }
.cc-intro b { font-size: 18px; }
.cc-intro span { color: var(--muted); font-size: 13px; }
.cc-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: rgba(255, 255, 255, .04); padding: 4px; border-radius: 12px; }
.cc-tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 4px; border-radius: 9px; cursor: pointer; display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 13px; }
.cc-tabs button i { font-size: 17px; }
.cc-tabs button.on { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, .35); }
.cc-opts { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-inline-end: 4px; min-height: 0; }
.cc-row { display: flex; flex-direction: column; gap: 8px; }
.cc-row > span { font-size: 13px; color: var(--muted); }
.cc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-chips button { border: 1px solid var(--line-2); background: rgba(255, 255, 255, .04); color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.cc-chips button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(255, 255, 255, .3); }
.cc-chips button.on { background: rgba(124, 92, 255, .22); border-color: var(--accent); color: #fff; }
.cc-chips button:disabled { opacity: .35; cursor: not-allowed; }
.cc-sw .swatch { width: 28px; height: 28px; }
.cc-custom { position: relative; overflow: hidden; display: inline-block; }
.cc-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.cc-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); }
.cc-foot .btn.primary { flex: 1; max-width: 260px; }
@media (max-width: 760px) {
  .cc { grid-template-columns: 1fr; grid-template-rows: 42vh auto; min-height: 0; }
  .cc-stage { min-height: 0; }
  .cc-panel { padding: 14px 16px; max-height: 50dvh; }
  .cc-tabs button { flex-direction: column; gap: 2px; font-size: 12px; }
}
