/* ═════════════ الثيمات ═════════════
   لإضافة ثيم جديد: انسخ أي كتلة [data-theme="..."] وغيّر الألوان،
   ثم أضف اسمه في قائمة THEMES داخل js/app.js */
:root,
[data-theme="night"] {
  --bg: #0f172a; --surface: #1e293b; --surface2: #273449; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --primary: #6366f1; --primary-text: #fff;
  --bubble: #1e293b; --bubble-me: #4f46e5; --bubble-me-text: #fff; --danger: #ef4444;
  --admin: #fbbf24; --mod: #34d399;
}
[data-theme="light"] {
  --bg: #f1f5f9; --surface: #ffffff; --surface2: #e2e8f0; --border: #cbd5e1;
  --text: #0f172a; --muted: #64748b; --primary: #2563eb; --primary-text: #fff;
  --bubble: #ffffff; --bubble-me: #2563eb; --bubble-me-text: #fff; --danger: #dc2626;
  --admin: #b45309; --mod: #047857;
}
[data-theme="ocean"] {
  --bg: #042f3a; --surface: #0b4352; --surface2: #115565; --border: #17697b;
  --text: #e0f7fa; --muted: #8cc7d1; --primary: #06b6d4; --primary-text: #022c33;
  --bubble: #0b4352; --bubble-me: #0891b2; --bubble-me-text: #fff; --danger: #f87171;
  --admin: #fcd34d; --mod: #6ee7b7;
}
[data-theme="sunset"] {
  --bg: #2a1215; --surface: #3d1a1f; --surface2: #52232a; --border: #6b2e36;
  --text: #fde8e4; --muted: #d4a5a0; --primary: #f97316; --primary-text: #fff;
  --bubble: #3d1a1f; --bubble-me: #ea580c; --bubble-me-text: #fff; --danger: #f43f5e;
  --admin: #fde047; --mod: #86efac;
}
[data-theme="forest"] {
  --bg: #0c1f14; --surface: #14301f; --surface2: #1b3f29; --border: #255436;
  --text: #e3f5e8; --muted: #9dc5a8; --primary: #22c55e; --primary-text: #052e12;
  --bubble: #14301f; --bubble-me: #16a34a; --bubble-me-text: #fff; --danger: #f87171;
  --admin: #fcd34d; --mod: #5eead4;
}
[data-theme="purple"] {
  --bg: #1a0f2e; --surface: #2a1a47; --surface2: #36225a; --border: #4a2f78;
  --text: #f1e9ff; --muted: #b9a6dc; --primary: #c026d3; --primary-text: #fff;
  --bubble: #2a1a47; --bubble-me: #a21caf; --bubble-me-text: #fff; --danger: #fb7185;
  --admin: #fde047; --mod: #6ee7b7;
}
[data-theme="rose"] {
  --bg: #fff1f4; --surface: #ffffff; --surface2: #ffe4ea; --border: #fbc6d2;
  --text: #4a1020; --muted: #9f5b6c; --primary: #e11d48; --primary-text: #fff;
  --bubble: #ffffff; --bubble-me: #e11d48; --bubble-me-text: #fff; --danger: #b91c1c;
  --admin: #b45309; --mod: #047857;
}

/* ═════════════ الأساسيات ═════════════ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif; font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; font-size: 14px; }
.grow { flex: 1; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface2); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; direction: rtl; }
textarea.code { direction: ltr; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 600; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 6px; }
.icon-btn {
  min-width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; cursor: pointer; font-size: 18px; display: inline-flex;
  align-items: center; justify-content: center; gap: 4px; padding: 0 8px;
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn.pill { font-size: 14px; background: var(--surface2); }

/* ═════════════ الهيكل ═════════════ */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.views { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; }

.ad { text-align: center; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--border); }
#adBottom { border-bottom: 0; border-top: 1px solid var(--border); }
.ad:empty { display: none; }
.ad img { max-width: 100%; height: auto; display: block; margin: 0 auto; }

.bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.bar .title strong, .bar .title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .actions { display: flex; gap: 2px; }

/* ═════════════ صفحة الدخول ═════════════ */
#viewLogin { overflow-y: auto; }
.landing {
  position: relative; flex: 1 0 auto; display: flex; justify-content: center; align-items: center;
  padding: 32px 16px 76px; isolation: isolate;
}
/* خلفية: دوائر ملوّنة ضبابية تتحرك ببطء، بألوان الثيم المختار */
.landing-bg { position: absolute; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.landing-bg span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .32; animation: drift 20s ease-in-out infinite; }
.landing-bg span:nth-child(1) { width: 360px; height: 360px; background: var(--primary); top: -90px; inset-inline-start: -80px; }
.landing-bg span:nth-child(2) { width: 300px; height: 300px; background: var(--bubble-me); bottom: 6%; inset-inline-end: -90px; animation-delay: -7s; }
.landing-bg span:nth-child(3) { width: 240px; height: 240px; background: var(--mod); top: 42%; inset-inline-start: 32%; opacity: .16; animation-delay: -14s; }
@keyframes drift { 50% { transform: translate(34px, -44px) scale(1.1); } }

.landing-inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 18px; text-align: center; }
.logo-bubble {
  width: 78px; height: 78px; margin: 0 auto; border-radius: 26px; display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(135deg, var(--primary), var(--bubble-me));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 45%, transparent);
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.hero h1 { margin: 10px 0 4px; font-size: clamp(28px, 7vw, 40px); font-weight: 700; }
.tagline { margin: 0; color: var(--muted); font-size: 16px; }

.live-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.stat {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border); font-size: 13px;
}
.stat b { font-size: 15px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; animation: ping 1.8s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .6); } 70%, 100% { box-shadow: 0 0 0 9px rgb(34 197 94 / 0); } }

.join-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 10px; text-align: start; box-shadow: 0 22px 50px rgb(0 0 0 / .22);
}
.join-card label { font-weight: 700; font-size: 15px; }
.nick-row { display: flex; gap: 8px; }
.nick-row input { font-size: 17px; padding: 13px 14px; }
.dice {
  flex: 0 0 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2);
  font-size: 22px; cursor: pointer; transition: transform .3s;
}
.dice:hover { transform: rotate(-20deg) scale(1.06); }
.dice.roll { animation: roll .45s ease-out; }
@keyframes roll { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.join-btn {
  padding: 14px; font-size: 17px; border-radius: 14px; transition: transform .15s, filter .15s;
  background: linear-gradient(135deg, var(--primary), var(--bubble-me));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 38%, transparent);
}
.join-btn:hover { transform: translateY(-1px); }
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.join-card .error { margin: 0; text-align: center; }
.join-card .error:empty { display: none; }

/* زر دخول الإدارة: صغير وهادئ في الزاوية السفلية */
.staff-btn {
  position: absolute; bottom: 16px; inset-inline-start: 16px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12px; cursor: pointer; opacity: .85; transition: opacity .15s, color .15s;
}
.staff-btn:hover { opacity: 1; color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .landing-bg span, .logo-bubble, .pulse { animation: none; }
}

/* ═════════════ الغرف ═════════════ */
.lobby-body { flex: 1; overflow-y: auto; padding: 14px; max-width: 1000px; width: 100%; margin: 0 auto; }
.search { margin-bottom: 14px; }
.cat h2 { font-size: 16px; margin: 18px 4px 10px; color: var(--muted); }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.room-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.room-card.closed { opacity: .6; }
.room-main {
  width: 100%; text-align: right; background: none; border: 0; padding: 14px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
}
.room-main:hover { background: var(--surface2); }
.room-name { font-weight: 700; font-size: 16px; }
.room-main small { grid-column: 1 / -1; }
.count { font-size: 13px; color: var(--muted); }
.room-card details { border-top: 1px solid var(--border); }
.room-card summary { padding: 8px 14px; cursor: pointer; color: var(--primary); font-size: 14px; }
.sub-list { display: flex; flex-direction: column; padding: 0 8px 8px; }
.sub-room {
  display: flex; justify-content: space-between; background: none; border: 0;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: right;
}
.sub-room:hover { background: var(--surface2); }

/* ═════════════ الدردشة ═════════════ */
.chat-body { flex: 1; min-height: 0; display: flex; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: min(78%, 560px); background: var(--bubble); border: 1px solid var(--border);
  padding: 6px 12px 8px; border-radius: 14px; border-top-right-radius: 4px; align-self: flex-start;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.me {
  align-self: flex-end; background: var(--bubble-me); color: var(--bubble-me-text);
  border-color: transparent; border-top-right-radius: 14px; border-top-left-radius: 4px;
}
.msg.me .meta, .msg.me .meta time { color: inherit; opacity: .85; }
.msg.system {
  align-self: center; background: transparent; border: 0; color: var(--muted);
  font-size: 13px; padding: 0; max-width: 90%; text-align: center;
}
.msg.welcome { background: var(--surface2); padding: 8px 14px; border-radius: 10px; color: var(--text); }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 2px; }
.nick { font-weight: 700; }
.role-admin .nick { color: var(--admin); }
.role-moderator .nick { color: var(--mod); }
.msg.me .nick { color: inherit; }
.meta time { color: var(--muted); margin-inline-start: auto; }
.del:hover { opacity: 1; color: var(--danger); }
.voice { display: flex; align-items: center; gap: 8px; }
.voice audio { height: 36px; max-width: 240px; }
.voice span { font-size: 12px; opacity: .8; }

.side-panel {
  width: 230px; flex-shrink: 0; background: var(--surface);
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column;
}
.users-panel { border-inline-start: 1px solid var(--border); }
.rooms-panel { width: 250px; border-inline-end: 1px solid var(--border); }
.side-panel h3 { font-size: 14px; color: var(--muted); margin: 4px 6px 10px; }

/* قائمة الغرف الجانبية */
.side-cat { font-size: 12px; color: var(--muted); margin: 12px 8px 4px; font-weight: 700; }
.side-room {
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; text-align: right;
}
.side-room:hover { background: var(--surface2); }
.side-room.active { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.side-room.active .count { color: inherit; }
.side-room .count { margin-inline-start: auto; }
.side-room.closed { opacity: .55; }
.side-room.sub { padding-inline-start: 26px; font-size: 14px; }
.side-room .toggle { width: 18px; font-size: 11px; color: var(--muted); }
.side-room.active .toggle { color: inherit; }

/* الإطارات الإعلانية الجانبية */
.ad-side { margin-top: auto; padding-top: 12px; background: none; border: 0; }

/* إطار "أعلن هنا" عندما تكون المساحة فارغة */
.ad-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px dashed var(--border); border-radius: 10px; color: var(--muted);
  min-height: 70px; max-width: 728px; margin: 6px auto; padding: 8px; font-weight: 600; font-size: 14px;
}
.ad-placeholder small { font-weight: 400; font-size: 12px; opacity: .8; }
.ad-side .ad-placeholder { min-height: 250px; margin: 0; }
.users-panel ul { list-style: none; margin: 0; padding: 0; }
.users-panel li {
  padding: 7px 10px; border-radius: 8px; display: flex; gap: 6px; align-items: center; cursor: default;
}
.users-panel li.away { opacity: .55; }
.users-panel li.clickable { cursor: pointer; }
.users-panel li.clickable:hover { background: var(--surface2); }
.users-panel li.role-admin { color: var(--admin); font-weight: 700; }
.users-panel li.role-moderator { color: var(--mod); font-weight: 600; }
.users-panel li.self::after { content: '(أنت)'; color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.chat-body.hide-users .users-panel { display: none; }
.chat-body.hide-rooms .rooms-panel { display: none; }
@media (max-width: 1100px) and (min-width: 761px) {
  .rooms-panel { width: 210px; }
  .users-panel { width: 190px; }
}

.composer {
  display: flex; gap: 8px; padding: 10px; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.rec-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface2); border-top: 1px solid var(--border);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
#micBtn.recording { background: var(--danger); }

/* ═════════════ النافذة المنبثقة ═════════════ */
.modal {
  position: fixed; inset: 0; background: rgb(0 0 0 / .55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  width: 100%; max-width: 440px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
  animation: pop .18s ease-out;
}
.modal-box.wide { max-width: 900px; height: 92vh; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; margin: 0; font-size: 17px; }
.modal-body { padding: 14px; overflow-y: auto; flex: 1; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.theme-grid, .game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.theme-opt, .game-opt {
  border: 2px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer;
  background: var(--surface2); text-align: center;
}
.theme-opt.active { border-color: var(--primary); }
.swatch { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.swatch i { flex: 1; }
.game-opt { font-size: 15px; font-weight: 600; }
.game-opt b { display: block; font-size: 34px; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ═════════════ لوحة التحكم ═════════════ */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: none; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.panel { background: var(--surface2); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.panel h4 { margin: 0 0 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 140px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.check input { width: auto; }
.list-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface); margin-bottom: 6px; flex-wrap: wrap;
}
.list-item .grow { min-width: 120px; }
.list-item.sub { margin-inline-start: 26px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tag.off { background: var(--danger); color: #fff; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 10px; max-height: 220px; overflow-y: auto; }

/* ═════════════ التفاعلات والإشارات والرسائل المؤقتة ═════════════ */
.nick { cursor: pointer; }
.act, .del { background: none; border: 0; color: inherit; opacity: .35; cursor: pointer; padding: 0 3px; font-size: 13px; }
.msg:hover .act, .msg:hover .del { opacity: .9; }
.act:hover { opacity: 1; }
@media (hover: none) { .act, .del { opacity: .7; } }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reactions:not(:empty) { margin-top: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 999px;
  padding: 1px 9px; font-size: 13px; cursor: pointer;
}
.chip.mine { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 25%, var(--surface2)); }
.picker {
  display: flex; gap: 2px; margin-top: 6px; padding: 4px; border-radius: 999px; width: max-content; max-width: 100%;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
}
.picker button { background: none; border: 0; font-size: 20px; cursor: pointer; padding: 2px 5px; border-radius: 8px; }
.picker button:hover { background: var(--surface); }

.mention { color: var(--primary); font-weight: 700; background: color-mix(in srgb, var(--primary) 16%, transparent); border-radius: 4px; padding: 0 3px; }
.msg.me .mention { color: inherit; background: rgb(255 255 255 / .22); }
.mention.me { background: var(--admin); color: #000; }
.msg.mentioned { border-color: var(--admin); box-shadow: 0 0 0 1px var(--admin); }

.msg.ephemeral { border-style: dashed; }
.eph-note { font-size: 12px; opacity: .8; margin-top: 4px; }

.composer .input-wrap { flex: 1; position: relative; min-width: 0; }
.mention-box {
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 0; min-width: 180px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 24px rgb(0 0 0 / .35); z-index: 8;
}
.mention-opt { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 9px 14px; cursor: pointer; }
.mention-opt:hover { background: var(--surface2); }
#ttlBtn.active { background: var(--primary); color: var(--primary-text); font-size: 13px; font-weight: 700; }

/* ═════════════ لوحة الإيموجي ═════════════ */
.composer { position: relative; }
#emojiBtn.active { background: var(--surface2); }
.emoji-panel {
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 10px; z-index: 9;
  width: min(352px, calc(100vw - 20px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 28px rgb(0 0 0 / .4);
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-tabs button {
  flex: 1 0 auto; min-width: 44px; padding: 8px 6px; font-size: 18px; background: none; border: 0;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.emoji-tabs button.active { border-bottom-color: var(--primary); background: var(--surface2); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; height: 224px; overflow-y: auto; align-content: start; }
.emoji-grid button { font-size: 22px; line-height: 1.2; padding: 4px 0; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--surface2); }

/* ═════════════ عدادات فتح وإغلاق الغرف ═════════════ */
.cd { font-size: 11px; font-weight: 700; }
.cd-open { color: var(--mod); }
.cd-closed { color: var(--muted); }
.cd-soon { color: var(--danger); }
.side-room.active .cd, .side-room.active .cd-soon { color: inherit; }
.rname { display: flex; flex-direction: column; line-height: 1.3; }
.sched-box { border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin: 4px 0 10px; }

/* ═════════════ تحميل التطبيق ═════════════ */
.dl-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 10px;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface2);
}
.dl-card.mine { border-color: var(--primary); }
.dl-icon { font-size: 32px; }
.dl-card a.btn { text-decoration: none; display: inline-block; }

/* ═════════════ الأصوات ═════════════ */
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.snd-opt {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 6px; background: var(--surface2);
  color: var(--text); cursor: pointer; font-weight: 600;
}
.snd-opt:hover { filter: brightness(1.12); }
.snd-opt.active { border-color: var(--primary); }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--primary); margin-top: 6px; }

/* ═════════════ طلبات الزوار ═════════════ */
.side-req { margin-top: 14px; display: flex; flex-direction: column; gap: 0; font-weight: 600; }
.side-req small { font-weight: 400; font-size: 11px; color: var(--muted); }
.req-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.req-type {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 6px; background: var(--surface2);
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.req-type b { display: block; font-size: 24px; }
.req-type.active { border-color: var(--primary); }
.req-item { background: var(--surface2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.req-body { margin: 6px 0; white-space: pre-wrap; font-size: 14px; }
.req-reply { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border-inline-start: 3px solid var(--primary); white-space: pre-wrap; }
.status { font-size: 12px; padding: 2px 10px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.st-new { background: #3b82f6; color: #fff; }
.st-progress { background: #f59e0b; color: #000; }
.st-done { background: #22c55e; color: #fff; }
.st-rejected { background: #ef4444; color: #fff; }
.adminBtn, .repBtn { position: relative; }
.adminBtn[data-badge]::after, .repBtn[data-badge]::after {
  content: attr(data-badge); position: absolute; top: 0; inset-inline-end: 0;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ═════════════ الألعاب ═════════════ */
.game { text-align: center; }
.game .status { font-size: 17px; font-weight: 700; margin: 8px 0 12px; min-height: 1.5em; }
.xo { display: grid; grid-template-columns: repeat(3, 80px); gap: 6px; justify-content: center; direction: ltr; }
.xo button { height: 80px; font-size: 38px; font-weight: 700; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; }
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 340px; margin: 0 auto; }
.memory button { aspect-ratio: 1; font-size: 30px; border-radius: 12px; border: 0; background: var(--primary); cursor: pointer; transition: .2s; }
.memory button.open, .memory button.done { background: var(--surface2); }
.memory button.done { opacity: .5; }
.rps { display: flex; gap: 10px; justify-content: center; }
.rps button { font-size: 40px; width: 84px; height: 84px; border-radius: 16px; border: 0; background: var(--surface2); cursor: pointer; }
.rps button:hover { transform: translateY(-2px); }
.game-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; }

/* ═════════════ الهاتف ═════════════ */
@media (max-width: 760px) {
  .side-panel {
    position: absolute; inset-block: 0; width: 78%; max-width: 290px;
    z-index: 5; box-shadow: 0 0 30px rgb(0 0 0 / .4); display: none;
  }
  .users-panel { inset-inline-end: 0; }
  .rooms-panel { inset-inline-start: 0; }
  .chat-body.show-users .users-panel,
  .chat-body.show-rooms .rooms-panel { display: flex; }
  .chat-body.hide-users .users-panel { display: none; }
  .ad-placeholder { min-height: 50px; }
  .ad-side .ad-placeholder { min-height: 160px; }
  #roomsBtn { font-size: 13px; }
  .msg { max-width: 88%; }
  .bar .actions .icon-btn { min-width: 34px; padding: 0 6px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.wide { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-box.wide { height: 94vh; }
  .xo { grid-template-columns: repeat(3, 72px); }
  .xo button { height: 72px; }
}
