/* ألعاب أونلاين — قضية */
:root {
    --qonline-bg: #0b1020;
    --qonline-surface: rgba(255,255,255,.06);
    --qonline-border: rgba(148,163,184,.2);
    --qonline-text: #e7ecf5;
    --qonline-muted: #94a3b8;
    --qonline-gold: #fbbf24;
    --qonline-sky: #38bdf8;
}

.qonline-body, .qsv-online-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(160deg, #0b1020, #111c33);
    color: var(--qonline-text);
    font-family: 'Tajawal', system-ui, sans-serif;
}

.qonline, .qsv-online {
    max-width: 720px;
    margin: 0 auto;
    padding: max(60px, env(safe-area-inset-top)) 16px 40px;
}

.qonline__head, .qsv-online-panel { text-align: center; }
.qonline__icon { font-size: 48px; }
.qonline__title { margin: 8px 0; font-size: 1.6rem; }
.qonline__sub, .qsv-online-desc { color: var(--qonline-muted); line-height: 1.6; }

.qonline__grid { display: grid; gap: 14px; margin-top: 20px; }
.qonline-card {
    display: block;
    padding: 20px;
    border-radius: 16px;
    background: var(--qonline-surface);
    border: 1px solid var(--qonline-border);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .12s;
}
.qonline-card:hover { border-color: rgba(56,189,248,.45); transform: translateY(-2px); }
.qonline-card__icon { font-size: 36px; }
.qonline-card__title { margin: 8px 0 6px; font-size: 1.15rem; }
.qonline-card__desc { margin: 0; color: var(--qonline-muted); font-size: .92rem; }
.qonline-card__cta { display: inline-block; margin-top: 12px; color: var(--qonline-sky); font-weight: 700; }

.qonline-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 42px; padding: 0 16px; border-radius: 999px;
    border: 1px solid var(--qonline-border); background: rgba(255,255,255,.05);
    color: var(--qonline-text); font-family: inherit; font-weight: 700; cursor: pointer;
}
.qonline-btn--primary { background: rgba(56,189,248,.15); border-color: rgba(56,189,248,.35); color: #bae6fd; }
.qonline-btn--ghost { background: transparent; }
.qonline-input {
    flex: 1; min-height: 42px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--qonline-border); background: rgba(0,0,0,.25);
    color: var(--qonline-text); font-family: inherit;
    box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%;
    text-overflow: ellipsis;
}

.qsv-online-modes { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0; }
.qsv-online-row { display: flex; gap: 8px; margin-top: 10px; }
.qsv-online-friend-box { margin-top: 18px; text-align: right; }
.qsv-online-wait { margin-top: 20px; }
.qsv-online-spinner {
    width: 36px; height: 36px; margin: 0 auto 10px;
    border: 3px solid rgba(255,255,255,.15); border-top-color: var(--qonline-sky);
    border-radius: 50%; animation: qsv-spin .8s linear infinite;
}
@keyframes qsv-spin { to { transform: rotate(360deg); } }

.qsv-friends-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.qsv-friend-chip {
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--qonline-border);
    background: rgba(255,255,255,.04); color: var(--qonline-text); cursor: pointer; font-family: inherit;
}
.qsv-online-muted { color: var(--qonline-muted); font-size: .9rem; }
.qsv-online-code { font-size: 1.1rem; }
.qsv-online-players { list-style: none; padding: 0; text-align: right; }
.qsv-online-players li { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); }

.qsv-online-turn {
    text-align: center; padding: 10px; margin-bottom: 12px; border-radius: 12px;
    background: rgba(255,255,255,.04); color: var(--qonline-muted);
}
/* تفاصيل الدور في sevens-online.css */
.qsv-online-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: .9rem; color: var(--qonline-muted); }
.qsv-online-questions { list-style: none; padding: 0; margin: 0 0 16px; }
.qsv-online-q {
    padding: 10px 12px; margin-bottom: 8px; border-radius: 12px;
    border: 1px solid var(--qonline-border); cursor: pointer; text-align: right;
}
.qsv-online-q:not(.revealed):not(.used-opponent):hover { border-color: rgba(56,189,248,.4); }
.qsv-online-q.revealed {
    cursor: default;
    border-color: rgba(56,189,248,.5);
    background: rgba(56,189,248,.08);
}
.qsv-online-q.revealed .qsv-online-q__num {
    background: #38bdf8;
    color: #04263a;
}
.qsv-online-q.used-opponent {
    cursor: not-allowed;
    pointer-events: none;
    border-color: rgba(248,113,113,.55);
    background: rgba(248,113,113,.1);
    opacity: .95;
}
.qsv-online-q.used-opponent .qsv-online-q__num {
    background: #f87171;
    border-color: #f87171;
    color: #450a0a;
}
.qsv-online-q__tag {
    margin-top: 6px;
    font-size: .82rem;
    color: #fca5a5;
    font-weight: 600;
}
.qsv-online-q__num {
    display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(56,189,248,.15); font-size: .8rem; margin-left: 8px;
}
.qsv-online-q__ans { margin-top: 8px; color: #bae6fd; font-size: .92rem; }
.qsv-online-result { margin-top: 16px; padding: 16px; border-radius: 14px; text-align: center; }
.qsv-online-result.win { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); }
.qsv-online-result.lose { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.25); }
.qsv-online-answer { font-size: 1.3rem; font-weight: 700; margin: 10px 0; }
.qsv-online-img { max-width: 100%; border-radius: 12px; margin: 10px 0; }
.qsv-online-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: rgba(15,23,42,.92); color: #fff; padding: 10px 18px; border-radius: 999px;
    opacity: 0; transition: opacity .2s, transform .2s; z-index: 9999; pointer-events: none;
}
.qsv-online-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.qgame-close {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 10000;
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.12);
    color: #fff; font-size: 18px; display: flex; align-items: center; justify-content: center;
    text-decoration: none;
}

/* ============================================================
   لوبي موحّد — مكوّن الإعداد المشترك (QOnline.Setup)
   وغرفة الانتظار المشتركة (QOnline.renderWaitingRoom)
   ============================================================ */
.qonline-setup { width: 100%; max-width: 480px; margin: 0 auto; text-align: right; }
.qonline-setup__head { text-align: center; margin-bottom: 8px; }
.qonline-setup__icon { font-size: 46px; line-height: 1; }
.qonline-setup__title { margin: 8px 0 6px; font-size: 1.5rem; }
.qonline-setup__desc { color: var(--qonline-muted); line-height: 1.7; font-size: .95rem; margin: 0; }

.qonline-setup, .qonline-setup *,
.qonline-wait-room, .qonline-wait-room * { box-sizing: border-box; }
.qonline-section {
    margin-top: 16px; padding: 16px;
    background: var(--qonline-surface);
    border: 1px solid var(--qonline-border);
    border-radius: 16px;
    overflow: hidden;
}
.qonline-section__title { margin: 0 0 12px; font-size: 1.05rem; font-weight: 800; }

.qonline-modes { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 0; }

.qonline-wait { margin-top: 14px; text-align: center; }
.qonline-spinner {
    width: 36px; height: 36px; margin: 0 auto 10px;
    border: 3px solid rgba(255,255,255,.15); border-top-color: var(--qonline-sky);
    border-radius: 50%; animation: qonline-spin .8s linear infinite;
}
@keyframes qonline-spin { to { transform: rotate(360deg); } }

/* صفوف الإدخال + الأزرار */
.qonline-row { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.qonline-row .qonline-input { flex: 1 1 auto; min-width: 0; }
.qonline-row .qonline-btn { flex: 0 0 auto; white-space: nowrap; }
.qonline-row--stack { flex-direction: column; gap: 10px; }
.qonline-row--stack .qonline-input,
.qonline-row--stack .qonline-btn { width: 100%; }
.qonline-row--stack .qonline-btn { justify-content: center; }
.qonline-input--code { text-align: center; letter-spacing: 3px; font-weight: 800; text-transform: uppercase; }
.qonline-btn--block { width: 100%; margin-top: 10px; }
.qonline-section .qonline-btn--block:first-child { margin-top: 0; }

/* حقول خيارات اللعبة */
.qonline-field { margin-bottom: 12px; }
.qonline-field__label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .9rem; color: #cbd5e1; }
.qonline-fieldhint { margin: 6px 0 0; color: var(--qonline-muted); font-size: .82rem; line-height: 1.6; }
.qonline-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: .92rem; }
.qonline-toggle input { width: 18px; height: 18px; accent-color: var(--qonline-sky); }

/* الأصدقاء */
.qonline-friends-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.qonline-friend-chip {
    padding: 7px 13px; border-radius: 999px; border: 1px solid var(--qonline-border);
    background: rgba(255,255,255,.05); color: var(--qonline-text); cursor: pointer;
    font-family: inherit; font-size: .9rem;
}
.qonline-friend-chip:hover { border-color: rgba(56,189,248,.45); }
.qonline-friend-req {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
    border-radius: 999px; background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.3);
    font-size: .88rem;
}
.qonline-friend-req button {
    border: none; cursor: pointer; border-radius: 50%; width: 24px; height: 24px;
    font-weight: 800; background: rgba(255,255,255,.1); color: var(--qonline-text);
}

/* الدعوات المعلّقة */
.qonline-pending { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.qonline-pending__item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04);
    border: 1px solid var(--qonline-border); font-size: .9rem;
}
.qonline-pending__item small { color: var(--qonline-muted); }
.qonline-pending__join { flex: 0 0 auto; min-height: 36px; padding: 0 14px; }

.qonline-muted { color: var(--qonline-muted); font-size: .9rem; }

/* غرفة الانتظار المشتركة */
.qonline-wait-room {
    width: 100%; max-width: 480px; margin: 0 auto; text-align: center;
    padding: 20px; border-radius: 18px;
    background: var(--qonline-surface); border: 1px solid var(--qonline-border);
}
.qonline-wait-room h2 { margin: 0 0 8px; font-size: 1.4rem; }
.qonline-wait-room__code { font-size: 1.05rem; margin: 0 0 12px; }
.qonline-wait-room__code b { letter-spacing: 2px; color: var(--qonline-gold); }
.qonline-wait-room__players { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.qonline-wait-room__players li {
    padding: 9px 12px; border-radius: 10px; font-weight: 600;
    background: rgba(255,255,255,.06); border: 1px solid var(--qonline-border);
}
.qonline-tag { font-size: .72rem; background: rgba(56,189,248,.18); color: #bae6fd; padding: 2px 8px; border-radius: 999px; margin-right: 6px; }
.qonline-host-tools { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.qonline-qr-wrap {
    display: flex; justify-content: center; margin: 14px auto 6px;
    background: #fff; width: max-content; padding: 10px; border-radius: 14px;
}
.qonline-qr-wrap canvas, .qonline-qr-wrap img { display: block; }
.qonline-qr-hint { color: var(--qonline-muted); font-size: .85rem; margin: 4px 0 12px; }

/* بطاقة «أضِف من حولك للعب» البارزة أعلى اللوبي */
/* رمز QR شخصي «أضِفني صديقًا» داخل قسم الأصدقاء */
.qonline-myqr {
    margin-top: 14px; padding-top: 12px; text-align: center;
    border-top: 1px dashed rgba(148,163,184,.3);
}
.qonline-myqr__hint { color: var(--qonline-muted); font-size: .85rem; margin: 0 0 8px; }
.qonline-create-hint { color: var(--qonline-muted); margin-top: 8px; }

/* بطاقة «العب فورًا» أعلى غرفة الانتظار (رمز انضمام بارز) */
.qonline-play-now {
    text-align: center; padding: 16px; border-radius: 16px; margin-bottom: 14px;
    background: linear-gradient(180deg, rgba(56,189,248,.12), rgba(56,189,248,.03));
    border: 1px solid rgba(56,189,248,.28);
}
.qonline-play-now h2 { margin: 0 0 6px; font-size: 1.4rem; }
.qonline-play-now .qonline-wait-room__code { margin: 10px 0 0; }

/* اسم اللاعب المؤقّت داخل غرفة الانتظار */
.qonline-myname {
    margin: 12px 0; padding: 14px; border-radius: 14px;
    border: 1px solid var(--qonline-border); background: var(--qonline-surface);
}
.qonline-myname__label { display: block; font-weight: 800; margin-bottom: 8px; font-size: .95rem; }

/* أكورديون (إعدادات/أصدقاء داخل غرفة الانتظار) */
.qonline-accordion {
    margin-top: 12px; border: 1px solid var(--qonline-border);
    border-radius: 14px; background: var(--qonline-surface); overflow: hidden;
}
.qonline-accordion > summary {
    cursor: pointer; padding: 14px 16px; font-weight: 700; list-style: none;
    display: flex; align-items: center; justify-content: space-between;
}
.qonline-accordion > summary::-webkit-details-marker { display: none; }
.qonline-accordion > summary::after { content: '▾'; opacity: .6; }
.qonline-accordion[open] > summary::after { content: '▴'; }
.qonline-accordion__body { padding: 0 16px 16px; }

/* تنبيه موحّد */
.qonline-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: rgba(15,23,42,.95); color: #fff; padding: 10px 18px; border-radius: 999px;
    opacity: 0; transition: opacity .2s, transform .2s; z-index: 99999; pointer-events: none;
    border: 1px solid rgba(255,255,255,.12); font-size: .92rem; max-width: 90vw; text-align: center;
}
.qonline-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
