@font-face { font-family: "Plex Arabic"; src: url("fonts/IBMPlexSansArabic_400Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/IBMPlexSansArabic_700Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Kufi"; src: url("fonts/NotoKufiArabic_700Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #12263a; --paper: #f6f4ef; --card: #fffdf8; --muted: #4a5a6a; --line: #d9d3c5;
  --teal: #1f6f62; --teal-soft: #e3efec; --orange: #e07a1f; --orange-soft: #fbeadb;
  --blue: #2f5d8a; --plum: #7a4e8c; --ok: #1f7a4d; --bad: #b8402f;
  --radius: 16px; --shadow: 0 1px 2px rgba(18,38,58,.06), 0 6px 24px rgba(18,38,58,.06);
  --body: "Plex Arabic", Tahoma, "Segoe UI", sans-serif; --head: "Kufi", "Plex Arabic", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--head); line-height: 1.35; margin: 0 0 .4em; }
h1 { font-size: clamp(24px, 5vw, 34px); }
h2 { font-size: clamp(20px, 4vw, 26px); }
p { margin: 0 0 .8em; }
.en { font-family: var(--body); unicode-bidi: isolate; direction: ltr; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* ------------------------------------------------ layout */
.topbar { background: var(--ink); color: #fff; padding: 14px 16px; }
.topbar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.brand { font-family: var(--head); font-size: 15px; line-height: 1.4; }
.brand small { display: block; font-family: var(--body); font-weight: 400; color: #c9d6df; font-size: 13px; }
.pill { display: inline-block; text-decoration: none; background: rgba(255,255,255,.12); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; border: 1px solid #ece6d8; }
.accent { border-right: 6px solid var(--teal); }
.accent.orange { border-right-color: var(--orange); }

/* ------------------------------------------------ forms */
label { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type=text], input[type=password] { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; font-size: 18px; border: 0; border-radius: 12px; padding: 13px 22px; cursor: pointer; background: var(--teal); color: #fff; text-decoration: none; transition: transform .08s ease, filter .15s ease; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.orange { background: var(--orange); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.sm { font-size: 14px; padding: 7px 12px; border-radius: 9px; }
.error { background: #fbe4df; color: #7a2418; border-radius: 10px; padding: 10px 14px; margin-top: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg button { font: inherit; font-weight: 700; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.seg button[aria-pressed=true] { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }
.seg button[disabled] { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------ intro */
.rules { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; background: var(--paper); border-radius: 12px; padding: 12px 14px; }
.rules b.n { font-family: var(--head); color: var(--orange); font-size: 20px; min-width: 28px; }

/* ------------------------------------------------ question */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 15px; }
.progress { height: 8px; background: #e7e1d3; border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.progress > i { display: block; height: 100%; background: var(--teal); width: 0; transition: width .3s ease; }
.timer { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.timer .bar { flex: 1; height: 12px; background: #e7e1d3; border-radius: 99px; overflow: hidden; }
.timer .bar > i { display: block; height: 100%; width: 100%; background: var(--orange); }
.timer .bar.low > i { background: var(--bad); }
.timer .sec { font-family: var(--head); font-size: 22px; min-width: 40px; text-align: center; }
.qtext { font-size: clamp(19px, 4.4vw, 24px); font-weight: 700; line-height: 1.55; margin: 6px 0 18px; }
.unit { display: inline-block; font-size: 13px; color: var(--teal); background: var(--teal-soft); border-radius: 99px; padding: 2px 10px; }
.opts { display: grid; gap: 12px; }
@media (min-width: 700px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { display: flex; align-items: center; gap: 14px; text-align: right; font: inherit; font-size: 18px; font-weight: 700; color: #fff; border: 0; border-radius: 14px; padding: 16px 16px; min-height: 76px; cursor: pointer; transition: transform .08s ease, opacity .2s ease, filter .2s; }
.opt:hover { filter: brightness(1.07); }
.opt:active { transform: scale(.98); }
.opt .sh { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-family: var(--head); font-size: 18px; }
.opt .tx { flex: 1; line-height: 1.5; }
.opt.c0 { background: var(--teal); } .opt.c1 { background: var(--orange); } .opt.c2 { background: var(--blue); } .opt.c3 { background: var(--plum); }
.opts.locked .opt { cursor: default; }
.opts.locked .opt:not(.picked) { opacity: .35; }
.opt.picked { outline: 4px solid var(--ink); outline-offset: 2px; }
.flash { margin-top: 16px; border-radius: 12px; padding: 14px 16px; font-weight: 700; font-size: 18px; }
.flash.ok { background: #dff1e7; color: var(--ok); }
.flash.bad { background: #fbe4df; color: var(--bad); }
.flash.neutral { background: var(--teal-soft); color: var(--teal); }
.flash .sub { display: block; font-weight: 400; font-size: 15px; color: var(--ink); margin-top: 4px; }

/* ------------------------------------------------ result */
.score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
.score div { background: var(--paper); border-radius: 12px; padding: 12px 8px; text-align: center; }
.score b { display: block; font-family: var(--head); font-size: clamp(22px, 6vw, 30px); color: var(--teal); }
.score span { font-size: 14px; color: var(--muted); }
.big { font-family: var(--head); font-size: clamp(48px, 14vw, 76px); color: var(--orange); line-height: 1.1; text-align: center; margin: 4px 0; }
.compare { display: grid; gap: 8px; margin: 10px 0; }
.compare .row { display: grid; grid-template-columns: 90px 1fr 60px; align-items: center; gap: 10px; font-size: 15px; }
.track { height: 16px; background: #ebe5d7; border-radius: 99px; overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 99px; background: var(--teal); width: 0; transition: width .8s ease; }
.track.o > i { background: var(--orange); }
.review { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.review li { border-radius: 12px; padding: 12px 14px; background: var(--paper); border-right: 5px solid var(--ok); }
.review li.no { border-right-color: var(--bad); }
.review .a { font-size: 15px; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ------------------------------------------------ board (projector) */
body.board { background: var(--ink); color: #fff; min-height: 100vh; }
.bwrap { max-width: 1400px; margin: 0 auto; padding: 24px 24px 40px; }
.bhead { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.bhead h1 { font-size: clamp(26px, 3.2vw, 44px); margin: 0; }
.bhead .sub { color: #c9d6df; font-size: clamp(15px, 1.4vw, 20px); }
.join { display: flex; gap: 16px; align-items: center; background: #fff; color: var(--ink); border-radius: 18px; padding: 12px 16px; }
.join img { width: 132px; height: 132px; image-rendering: pixelated; display: block; }
.join .u { font-family: var(--body); font-weight: 700; font-size: clamp(16px, 1.6vw, 22px); direction: ltr; unicode-bidi: isolate; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs button { font: inherit; font-weight: 700; font-size: 17px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,.25); background: transparent; color: #fff; cursor: pointer; }
.tabs button[aria-pressed=true] { background: var(--orange); border-color: var(--orange); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stats div { background: rgba(255,255,255,.07); border-radius: 14px; padding: 14px 16px; }
.stats b { display: block; font-family: var(--head); font-size: clamp(24px, 2.6vw, 38px); }
.stats span { color: #c9d6df; font-size: 15px; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 16px; align-items: end; margin-bottom: 18px; }
.pod { background: rgba(255,255,255,.08); border-radius: 18px; padding: 18px 14px; text-align: center; min-height: 170px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; animation: rise .5s ease both; }
.pod.r1 { background: var(--orange); min-height: 220px; }
.pod.r2 { background: rgba(255,255,255,.16); }
.pod .medal { font-family: var(--head); font-size: 44px; line-height: 1; }
.pod .nm { font-weight: 700; font-size: clamp(18px, 2vw, 28px); line-height: 1.35; word-break: break-word; }
.pod .en2 { font-size: 15px; opacity: .85; }
.pod .pts { font-family: var(--head); font-size: clamp(22px, 2.4vw, 34px); }
.list { display: grid; gap: 8px; }
.lrow { display: grid; grid-template-columns: 56px 1fr auto auto; gap: 14px; align-items: center; background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px 16px; font-size: clamp(16px, 1.6vw, 22px); animation: rise .4s ease both; }
.lrow .rk { font-family: var(--head); color: #f4b27a; text-align: center; }
.lrow .nm small { color: #c9d6df; font-size: .75em; margin-inline-start: 8px; }
.lrow .pc { color: #c9d6df; }
.lrow .pt { font-family: var(--head); min-width: 90px; text-align: left; }
.live { display: inline-block; font-size: 13px; background: rgba(224,122,31,.25); color: #f4b27a; border-radius: 99px; padding: 1px 8px; margin-inline-start: 8px; }
.empty { text-align: center; color: #c9d6df; padding: 50px 10px; font-size: 22px; }
.cmp { background: rgba(255,255,255,.06); border-radius: 18px; padding: 18px 20px; margin-bottom: 20px; }
.cmp .row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 14px; align-items: center; font-size: 20px; margin: 8px 0; }
.cmp .track { background: rgba(255,255,255,.12); height: 22px; }
.cmp b { font-family: var(--head); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) {
  .bwrap { padding: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .podium { grid-template-columns: 1fr; }
  .pod, .pod.r1 { min-height: 0; }
  .lrow { grid-template-columns: 40px 1fr auto; }
  .lrow .pc { display: none; }
  .join img { width: 96px; height: 96px; }
  .cmp .row { grid-template-columns: 90px 1fr 60px; font-size: 16px; }
}

/* ------------------------------------------------ admin */
.awrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.phase h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status { font-family: var(--body); font-size: 14px; padding: 3px 10px; border-radius: 99px; background: #eee; }
.status.on { background: #dff1e7; color: var(--ok); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 14px; }
.kv div { background: var(--paper); border-radius: 10px; padding: 8px; text-align: center; }
.kv b { display: block; font-family: var(--head); font-size: 20px; }
.kv span { font-size: 13px; color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid #eee6d6; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 99px; border: 0; background: #cfc8b8; cursor: pointer; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: right .15s ease; }
.switch[aria-checked=true] { background: var(--teal); }
.switch[aria-checked=true]::after { right: 25px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid #eee6d6; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini { display: grid; grid-template-columns: 1fr 48px; gap: 6px; align-items: center; min-width: 140px; }
.mini .track { height: 10px; }
.qrow-weak td:first-child { border-right: 4px solid var(--bad); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.joinbox { display: flex; gap: 14px; align-items: center; }
.joinbox img { width: 92px; height: 92px; image-rendering: pixelated; border-radius: 8px; background: #fff; }
.joinbox .u { direction: ltr; unicode-bidi: isolate; font-weight: 700; word-break: break-all; }
.narrow { max-width: 440px; margin: 30px auto; }
.mt { margin-top: 14px; }

/* ------------------------------------------------ prompts page */
.tabs.light button { color: var(--ink); border-color: var(--line); background: #fff; }
.tabs.light button[aria-pressed=true] { background: var(--teal); border-color: var(--teal); color: #fff; }
#filter { margin: 4px 0 16px; }
.plist { display: grid; gap: 14px; }
.pcard { margin: 0; }
.phead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.phead h3 { margin: 0; font-size: 17px; }
.ptext { white-space: pre-wrap; direction: rtl; text-align: right; font-family: var(--body); font-size: 16px; line-height: 1.8; background: var(--teal-soft); border-radius: 10px; padding: 12px 14px; margin: 0; user-select: all; }
.btn.done { background: var(--ok); }
.offscreen { position: fixed; top: -1000px; opacity: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.empty-light { text-align: center; color: var(--muted); padding: 40px 0; }
