/* قضية — «إكس أو ورد» أونلاين */
:root {
    --qxo-bg: #2a1b3d;
    --qxo-bg2: #3d2457;
    --qxo-card: #fff7ec;
    --qxo-ink: #3a2a1f;
    --qxo-muted: #8a7563;
    --qxo-pink: #e87fa3;
    --qxo-blue: #4f7fd8;
    --qxo-yellow: #f2c811;
    --qxo-line: #e8d6bf;
}

html.qxo-html, body.qxo-body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at 50% 0%, var(--qxo-bg2), var(--qxo-bg) 70%) fixed;
    color: var(--qxo-ink);
    font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
}

.qxo { min-height: 100vh; min-height: 100dvh; display: flex; justify-content: center; padding: 16px; box-sizing: border-box; }
.qxo .qgame-close { z-index: 5; }
.qxo-stage { width: 100%; max-width: 440px; display: flex; flex-direction: column; justify-content: center; }

.qxo-loader { color: #f4e6ff; text-align: center; display: grid; gap: 14px; justify-items: center; }
.qxo-loader__ring {
    width: 56px; height: 56px; border-radius: 50%;
    border: 9px solid var(--qxo-yellow); border-top-color: transparent;
    animation: qxo-spin 1s linear infinite;
}

.qxo-card {
    background: var(--qxo-card);
    border-radius: 26px;
    padding: 20px 18px 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35), inset 0 0 0 3px var(--qxo-line);
    display: grid;
    gap: 14px;
    text-align: center;
}

.qxo-title { margin: 0; font-size: 28px; font-weight: 900; }
.qxo-title span { color: var(--qxo-pink); }
.qxo-note { margin: 0; font-size: 13px; color: var(--qxo-muted); }

/* ورد وكلامها */
.qxo-ward { display: flex; align-items: center; gap: 10px; text-align: start; }
.qxo-ward__pic { width: 64px; height: 76px; object-fit: contain; flex: none; transform-origin: 50% 100%; animation: qxo-breathe 3.2s ease-in-out infinite; }
.qxo-ward__say {
    margin: 0; flex: 1; position: relative;
    background: #fff; border: 2px solid var(--qxo-line); border-radius: 16px;
    padding: 10px 12px; font-size: 15px; font-weight: 700; line-height: 1.5;
}
.qxo-ward.is-cheer .qxo-ward__pic { animation: qxo-hop .5s ease-in-out 3; }
.qxo-ward.is-sad .qxo-ward__pic { filter: saturate(.6); transform: rotate(-6deg); animation: none; }
.qxo-ward.is-casting .qxo-ward__say { color: var(--qxo-muted); }

/* الأطوار */
.qxo-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qxo-mode {
    border: 2px solid var(--qxo-line); background: #fff; border-radius: 16px; padding: 10px 8px;
    display: grid; gap: 4px; cursor: pointer; font: inherit; color: inherit;
}
.qxo-mode b { font-size: 15px; }
.qxo-mode small { font-size: 12px; color: var(--qxo-muted); line-height: 1.4; }
.qxo-mode.is-on { border-color: var(--qxo-pink); background: #fff0f5; box-shadow: 0 0 0 3px rgba(232, 127, 163, .25); }

/* الأزرار */
.qxo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qxo-btn {
    font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
    border: 0; border-radius: 14px; padding: 12px 10px;
    background: #fff; color: var(--qxo-ink); box-shadow: inset 0 0 0 2px var(--qxo-line), 0 3px 0 var(--qxo-line);
    transition: transform .1s;
}
.qxo-btn:active { transform: translateY(2px); }
.qxo-btn:disabled { opacity: .6; cursor: default; }
.qxo-btn--main { background: var(--qxo-pink); color: #fff; box-shadow: 0 3px 0 #c45f84; }
.qxo-btn--ghost { background: transparent; box-shadow: none; color: var(--qxo-muted); text-decoration: underline; }
.qxo-btn--small { padding: 10px 16px; }

.qxo-join { display: flex; gap: 8px; }
.qxo-input {
    flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 800; letter-spacing: 2px; text-align: center;
    border: 2px solid var(--qxo-line); border-radius: 14px; padding: 10px; background: #fff; color: var(--qxo-ink);
}

/* الانتظار والغرفة */
.qxo-spin { display: flex; justify-content: center; }
.qxo-spin .qxo-piece { width: 84px; height: 84px; animation: qxo-spin 1.6s linear infinite; }
.qxo-code { font-size: 34px; font-weight: 900; letter-spacing: 6px; color: var(--qxo-pink); }
.qxo-qr { display: flex; justify-content: center; }
.qxo-qr img, .qxo-qr canvas { background: #fff; padding: 8px; border-radius: 12px; }

/* اللعبة */
.qxo-game { display: grid; gap: 12px; }
.qxo-game .qxo-ward__say { background: var(--qxo-card); }
.qxo-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.qxo-side {
    background: rgba(255, 255, 255, .1); border-radius: 18px; padding: 8px; color: #f4e6ff;
    display: grid; justify-items: center; gap: 2px; border: 2px solid transparent; transition: border-color .2s, background .2s;
}
.qxo-side .qxo-piece { width: 34px; height: 34px; }
.qxo-side__name { font-size: 13px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qxo-side__pts { font-size: 24px; line-height: 1; }
.qxo-side.is-turn { border-color: var(--qxo-yellow); background: rgba(242, 200, 17, .16); }
.qxo-score__mid { color: #f4e6ff; display: grid; justify-items: center; gap: 2px; font-size: 14px; }
.qxo-score__mid small { opacity: .75; }
.qxo-dots { display: flex; gap: 3px; min-height: 8px; }
.qxo-dot { width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.qxo-dot.is-me { background: #7ee08a; }
.qxo-dot.is-them { background: var(--qxo-pink); }

.qxo-clock { height: 6px; background: rgba(255, 255, 255, .12); border-radius: 6px; overflow: hidden; }
.qxo-clock span { display: block; height: 100%; width: 0; background: #b9a6d0; border-radius: 6px; transition: width .2s linear; }
.qxo-clock span.is-mine { background: var(--qxo-yellow); }
.qxo-clock span.is-low { background: #ff6b6b; }

.qxo-board {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    background: var(--qxo-card); border-radius: 26px; padding: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35), inset 0 0 0 3px var(--qxo-line);
}
.qxo-cell {
    position: relative; aspect-ratio: 1; border: 0; border-radius: 18px; padding: 10%;
    background: #f3e4cf; box-shadow: inset 0 3px 0 rgba(0, 0, 0, .06);
    display: flex; align-items: center; justify-content: center; cursor: default;
}
.qxo-cell.is-open { cursor: pointer; background: #fbf0e0; }
.qxo-cell.is-open:hover { background: #fff; box-shadow: inset 0 0 0 3px var(--qxo-yellow); }
.qxo-cell .qxo-piece { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.qxo-cell.is-new .qxo-piece:not(.is-gone) { animation: qxo-pop .45s cubic-bezier(.3, .7, .4, 1.4); }
.qxo-cell.is-fading .qxo-piece { opacity: .4; filter: grayscale(.5); }
.qxo-cell .qxo-piece.is-gone { position: absolute; inset: 10%; width: 80%; height: 80%; animation: qxo-gone .6s forwards; }
.qxo-cell.is-line { background: #fff3b8; box-shadow: inset 0 0 0 3px var(--qxo-yellow); }
.qxo-cell.is-line .qxo-piece { animation: qxo-hop .5s ease-in-out 2; }

.qxo-quit { justify-self: center; color: #cdbbe0; }
.qxo-end { display: grid; gap: 8px; background: var(--qxo-card); border-radius: 20px; padding: 14px; }

@keyframes qxo-spin { to { transform: rotate(360deg); } }
@keyframes qxo-breathe { 50% { transform: scale(1.03, .98); } }
@keyframes qxo-hop { 50% { transform: translateY(-8px); } }
@keyframes qxo-pop { from { transform: scale(.2) rotate(-120deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes qxo-gone { to { transform: scale(.3) rotate(90deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .qxo *, .qxo *::before { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) {
    .qxo-actions, .qxo-modes { grid-template-columns: 1fr; }
}
