/* «ورد ضد الغيلان»: a knitted blanket of a page, a board of crocheted squares, yarn X's and Ward's yellow ring. */
:root {
  --bg: #f6efe3; --bg2: #efe3cf; --ink: #3b2a4a; --muted: #7a6a80; --card: #fffaf2; --line: #e2d3bb;
  --accent: #e8772e; --ward: #f2c21b; --good: #2f9c5a; --bad: #d9434b; --bar: #3b2a4a; --bar-ink: #fbefd9;
  --cell: #fff6e6; --cell-stitch: #f0e2c8; --shadow: 0 6px 18px rgba(59, 42, 74, .14);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #221a2b; --bg2: #2b2135; --ink: #f7ecdc; --muted: #c2b3c8; --card: #2f2539; --line: #4a3b55;
    --cell: #3a2e45; --cell-stitch: #463852; --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #221a2b; --bg2: #2b2135; --ink: #f7ecdc; --muted: #c2b3c8; --card: #2f2539; --line: #4a3b55;
  --cell: #3a2e45; --cell-stitch: #463852; --shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

html, body.qdiw-xo-page { margin: 0 !important; padding: 0 !important; min-height: 100%; background: var(--bg); color: var(--ink); }
body.qdiw-xo-page { font-family: 'Tajawal', 'Segoe UI', system-ui, sans-serif; -webkit-tap-highlight-color: transparent;
  background-image: repeating-linear-gradient(45deg, transparent 0 10px, rgba(0, 0, 0, .025) 10px 11px), repeating-linear-gradient(-45deg, transparent 0 10px, rgba(0, 0, 0, .025) 10px 11px); }
#wpadminbar, #qadiyah-wanees, #qosocial-root, #qadiyah-social-root, .qdn-fab, .qdn-panel { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
button { font: inherit; color: inherit; }

.xo-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.xo-bar { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--bar); color: var(--bar-ink); border-bottom: 3px dashed var(--ward); }
.xo-brand { display: flex; flex-direction: column; margin-inline-end: auto; line-height: 1.25; }
.xo-brand strong { font-size: 19px; color: #ffd36a; }
.xo-brand small { font-size: 12px; opacity: .8; }
.xo-back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid #ffd36a66; border-radius: 12px; color: var(--bar-ink) !important; text-decoration: none !important; }
.xo-back:hover, .xo-back:focus-visible { background: #ffd36a22; }
.xo-preview { padding: 3px 10px; border-radius: 999px; background: #7a2f2f; color: #fff; font-size: 12px; white-space: nowrap; }
@media (max-width: 768px) { .xo-bar { padding-inline-start: 64px; } .xo-back-long { display: none; } } /* the theme's menu button sits top-right */

.xo-app { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 16px; }
.xo-loading, .xo-noscript { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- Buttons ---- */
.xo-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.xo-btn { min-height: 46px; padding: 0 22px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; font-weight: 700; font-size: 16px; }
.xo-btn:hover:not(:disabled), .xo-btn:focus-visible { border-color: var(--accent); }
.xo-btn-main { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 0 #b9561a; }
.xo-btn-main:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #b9561a; }
.xo-btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.xo-link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 14px; min-height: 44px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Ward and her speech ---- */
.xo-bubble { position: relative; margin: 0; padding: 12px 16px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); font-size: 16px; line-height: 1.6; min-height: 52px; }
.xo-bubble.is-pop { animation: xo-pop .35s ease-out; }
.xo-ward-img { display: block; width: 100%; max-width: 190px; height: auto; margin: 0 auto; transform-origin: 50% 100%; filter: drop-shadow(0 8px 10px rgba(59, 42, 74, .2)); }
.xo-ward-img.is-happy { animation: xo-hop .7s ease-in-out 2; }
.xo-ward-img.is-sad { animation: xo-droop 1.2s ease-in-out forwards; }
.xo-ward-img.is-think { animation: xo-sway 1.4s ease-in-out infinite; }
.xo-ward-img.is-surprised { animation: xo-shake .5s ease-in-out; }
.xo-ward-img.is-wink { animation: xo-tilt 1.1s ease-in-out; }
@keyframes xo-pop { from { transform: scale(.92); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes xo-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-18px) rotate(-3deg); } 70% { transform: translateY(0) scaleY(.95); } }
@keyframes xo-droop { to { transform: rotate(6deg) translateY(6px) scale(.97); filter: grayscale(.25) drop-shadow(0 8px 10px rgba(59, 42, 74, .2)); } }
@keyframes xo-sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes xo-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes xo-tilt { 0%, 100% { transform: none; } 50% { transform: rotate(-8deg) translateY(-6px); } }

/* ---- Screen 1: the ghouls ---- */
.xo-intro { display: grid; gap: 18px; }
.xo-intro-ward { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: end; }
.xo-intro-ward .xo-ward-img { max-width: 120px; }
.xo-rules h1 { margin: 0 0 6px; font-size: 30px; font-weight: 800; }
.xo-rules p { margin: 0 0 8px; line-height: 1.7; color: var(--muted); }
.xo-rules b { color: var(--ink); }
.xo-x-mark { color: var(--accent); } .xo-o-mark { color: #c79a00; }
.xo-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.xo-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 12px; border: 3px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; text-align: center; transition: transform .15s, border-color .15s; }
.xo-pick img { width: 100%; max-width: 110px; aspect-ratio: 1; object-fit: contain; }
.xo-pick strong { font-size: 15px; }
.xo-pick span { font-size: 13px; color: var(--muted); }
.xo-pick:hover { transform: translateY(-2px); }
.xo-pick.is-on { border-color: var(--g); background: color-mix(in srgb, var(--g) 12%, var(--card)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g) 30%, transparent); }
.xo-pick-n { position: absolute; top: 8px; inset-inline-start: 8px; width: 28px; height: 28px; border-radius: 50%; background: var(--g); color: #fff; font-style: normal; font-weight: 800; display: grid; place-items: center; }

/* ---- Screen 2: the match ---- */
.xo-match { display: grid; gap: 14px; }
.xo-score { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); font-weight: 700; }
.xo-score b { font-size: 24px; margin-inline-start: 4px; }
.xo-score-you b { color: var(--accent); } .xo-score-ward b { color: #c79a00; }
.xo-score-round { color: var(--muted); font-size: 14px; }
.xo-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: center; }
.xo-side-ward { display: grid; grid-template-columns: 84px 1fr; grid-template-areas: "img bubble" "tag bubble"; gap: 4px 12px; align-items: center; }
.xo-side-ward .xo-bubble { grid-area: bubble; }
.xo-side-ward .xo-ward-img { grid-area: img; max-width: 84px; }
.xo-tag { grid-area: tag; justify-self: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.xo-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 380px; margin: 0 auto; padding: 10px; background: var(--bg2); border-radius: 22px; border: 3px dashed var(--line); }
.xo-cell { position: relative; aspect-ratio: 1; border: 0; border-radius: 16px; cursor: pointer; padding: 0;
  background: var(--cell); background-image: repeating-linear-gradient(90deg, transparent 0 6px, var(--cell-stitch) 6px 7px), repeating-linear-gradient(0deg, transparent 0 6px, var(--cell-stitch) 6px 7px);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .06); transition: transform .12s; }
.xo-cell:not(:disabled):hover { transform: scale(1.03); box-shadow: inset 0 0 0 3px var(--accent); }
.xo-cell:disabled { cursor: default; }
.xo-cell.is-chosen { box-shadow: inset 0 0 0 4px var(--accent); animation: xo-pulse 1s ease-in-out infinite; }
.xo-cell.is-line { background-color: color-mix(in srgb, var(--ward) 35%, var(--cell)); }
@keyframes xo-pulse { 50% { transform: scale(.96); } }
/* X: two crossed strands of yarn in the colour of the ghoul who gave it. */
.xo-x { position: absolute; inset: 18%; }
.xo-x::before, .xo-x::after { content: ""; position: absolute; top: 50%; inset-inline: 0; height: 22%; margin-top: -11%; border-radius: 999px;
  background: var(--g, var(--accent)); background-image: repeating-linear-gradient(60deg, rgba(255, 255, 255, .28) 0 3px, transparent 3px 7px); box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.xo-x::before { transform: rotate(45deg); } .xo-x::after { transform: rotate(-45deg); }
/* O: Ward's own ring, rebuilt from her picture (img/ring.webp). */
.xo-o { position: absolute; inset: 10%; background: url("img/ring.webp") center / contain no-repeat; filter: drop-shadow(0 0 8px rgba(242, 194, 27, .45)); }
.xo-cell.is-new .xo-x, .xo-cell.is-new .xo-o { animation: xo-drop .35s ease-out; }
@keyframes xo-drop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.xo-hint { margin: 0; text-align: center; color: var(--muted); min-height: 24px; }
.xo-ghouls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.xo-chip { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 700; }
.xo-chip img { width: 38px; height: 38px; object-fit: contain; }
.xo-chip em { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--g); color: #fff; }
.xo-chip:not(.is-next) em { display: none; }
.xo-chip.is-next { border-color: var(--g); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g) 25%, transparent); }
@media (max-width: 480px) {
  .xo-ghouls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .xo-chip { flex-direction: column; gap: 2px; padding: 8px 4px 6px; border-radius: 16px; font-size: 12px; text-align: center; }
  .xo-chip img { width: 34px; height: 34px; }
  .xo-chip em { position: absolute; top: -9px; inset-inline-start: 50%; transform: translateX(50%); }
}

@media (min-width: 760px) {
  .xo-intro { grid-template-columns: 1fr 1.25fr; align-items: start; }
  .xo-intro-ward { grid-column: 1; grid-template-columns: 150px 1fr; }
  .xo-intro-ward .xo-ward-img { max-width: 150px; }
  .xo-rules { grid-column: 1; }
  .xo-picks { grid-column: 2; grid-row: 1 / span 3; }
  .xo-intro > .xo-actions { grid-column: 1; justify-content: flex-start; }
  .xo-stage { grid-template-columns: 240px minmax(0, 1fr); }
  .xo-side-ward { grid-template-columns: 1fr; grid-template-areas: "bubble" "img" "tag"; }
  .xo-side-ward .xo-ward-img { max-width: 190px; }
  .xo-board { max-width: 420px; }
}

/* ---- The ghoul's question, and the end panels ---- */
.xo-modal { position: fixed; inset: 0; z-index: 100000; display: grid; place-items: center; padding: 16px; background: rgba(34, 26, 43, .55); animation: xo-fade .2s ease-out; overflow-y: auto; }
@keyframes xo-fade { from { opacity: 0; } }
.xo-card { width: 100%; max-width: 520px; padding: 18px; background: var(--card); border-radius: 22px; border: 3px solid var(--g, var(--line)); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); font-family: 'Tajawal', 'Segoe UI', system-ui, sans-serif; color: var(--ink); animation: xo-pop .25s ease-out; }
.xo-q-head { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 2px dashed var(--line); }
.xo-q-head img { width: 84px; height: 84px; object-fit: contain; }
.xo-q-head strong { display: block; font-size: 19px; }
.xo-q-head span { font-size: 13px; color: var(--g); font-weight: 700; }
.xo-q-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.xo-q-body { padding-top: 14px; }
.xo-q-prompt { font-size: 19px; line-height: 1.7; font-weight: 700; margin: 0 0 14px; }
.xo-q-hint { margin: -6px 0 12px; color: var(--muted); font-size: 14px; }
.xo-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.xo-choice { min-height: 52px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); cursor: pointer; font-size: 17px; font-weight: 700; line-height: 1.4; }
.xo-choice:hover:not(:disabled), .xo-choice:focus-visible { border-color: var(--g, var(--accent)); }
.xo-choice:disabled { cursor: default; }
.xo-choice.is-right { border-color: var(--good); background: color-mix(in srgb, var(--good) 18%, var(--card)); }
.xo-choice.is-wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, var(--card)); }
@media (max-width: 380px) { .xo-choices:not(.xo-choices-2) { grid-template-columns: 1fr; } }
.xo-free { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.xo-input { flex: 1; min-width: 160px; min-height: 50px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); font: inherit; font-size: 18px; }
.xo-input:focus { border-color: var(--g, var(--accent)); outline: none; }
.xo-unit { color: var(--muted); }
.xo-verdict { margin-top: 14px; padding: 12px 14px; border-radius: 14px; border: 2px solid; }
.xo-verdict.is-right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--card)); }
.xo-verdict.is-wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.xo-verdict strong { font-size: 18px; }
.xo-verdict p { margin: 6px 0 0; line-height: 1.6; }
.xo-explain { color: var(--muted); }
.xo-error { color: var(--bad); font-weight: 700; }
.xo-balls { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; transition: opacity .2s; }
.xo-ball { width: 44px; height: 44px; border-radius: 50%; background: var(--c); background-image: repeating-linear-gradient(35deg, rgba(255, 255, 255, .22) 0 3px, transparent 3px 7px); box-shadow: inset -4px -6px 0 rgba(0, 0, 0, .15); }
.xo-balls.is-hidden .xo-ball { background: var(--line); background-image: none; }
.xo-timer { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.xo-timer span { display: block; height: 100%; background: var(--g, var(--accent)); transform-origin: right; animation: xo-timer linear forwards; }
@keyframes xo-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.xo-card-end { text-align: center; border-color: var(--ward); }
.xo-card-end h2 { margin: 0 0 8px; font-size: 26px; }
.xo-card-end p { margin: 0; line-height: 1.7; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
