/* =========================================================
   جرس أثَر | تنسيقات شاشة المقدّم وصفحة المشارك
   الهوية المشتركة في ../assets/athar.css
   ========================================================= */

/* ---------- أساسيات ---------- */
*{box-sizing:border-box; margin:0; padding:0;}
html{-webkit-text-size-adjust:100%; background:var(--bg);}
body{
  --ok:#1FA971; --bad:#E8554E; --warn:#E59A1C;
  min-height:100vh; min-height:100dvh;
  background:var(--bg-paint); background-attachment:fixed;
  color:var(--text);
  font-family:"Thmanyah Sans","IBM Plex Sans Arabic",system-ui,sans-serif;
  font-weight:500; font-size:16px; line-height:1.7;
  display:flex; flex-direction:column; overflow-x:hidden;
}
h1,h2,h3,h4,strong,b{font-weight:700;}
button,input{font:inherit; color:inherit;}
button{cursor:pointer; -webkit-tap-highlight-color:transparent; touch-action:manipulation;}
ul,ol{list-style:none;}
[hidden]{display:none !important;}
:focus-visible{outline:3px solid var(--hl); outline-offset:2px;}
.muted{color:var(--text-2); font-size:.86rem;}

/* ---------- الشريط العلوي ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px clamp(12px,3vw,28px); border-bottom:1px solid var(--line);
}
.brand{display:flex; align-items:center; gap:10px; min-width:0; text-decoration:none; color:inherit;}
.brand .logo{height:48px; width:auto; flex:none;}
.brand-text{display:flex; flex-direction:column; min-width:0; line-height:1.35;}
.brand-text strong{font-size:1.1rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.brand-text small{color:var(--text-2); font-size:.8rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.top-tools{display:flex; align-items:center; gap:8px; flex:none;}

.icon-btn{
  width:42px; height:42px; border-radius:50%;
  display:grid; place-items:center;
  background:var(--surface); border:1px solid var(--line);
  transition:transform .15s ease, background .2s ease;
}
.icon-btn:hover{background:var(--surface-2);}
.icon-btn:active{transform:scale(.92);}
.icon-btn svg{width:22px; height:22px; fill:var(--text);}
.icon-btn .wave{stroke:var(--text);}
.icon-btn .ico-off{display:none;}
.icon-btn[aria-pressed="false"] .ico-on{display:none;}
.icon-btn[aria-pressed="false"] .ico-off{display:block; opacity:.6;}

/* حالة الاتصال */
.net{
  display:flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:999px;
  background:var(--surface); border:1px solid var(--line);
  font-size:.78rem; white-space:nowrap;
}
.net i{width:9px; height:9px; border-radius:50%; background:var(--bad); flex:none;}
.net[data-on="true"] i{background:var(--ok); box-shadow:0 0 0 3px rgba(31,169,113,.25);}
.net b{font-weight:500;}

/* ---------- الأزرار ---------- */
.btn{
  min-height:48px; padding:10px 20px;
  border-radius:14px; border:1px solid var(--line);
  background:var(--surface); color:var(--text);
  font-weight:700; font-size:1rem;
  transition:transform .15s ease, background .2s ease, filter .2s ease, opacity .2s;
}
.btn:hover{background:var(--surface-2); transform:translateY(-2px);}
.btn:active{transform:translateY(0) scale(.97);}
.btn:disabled{opacity:.45; cursor:not-allowed; transform:none;}
.btn-primary{background:var(--accent); color:var(--on-accent); border-color:transparent; box-shadow:0 8px 22px rgba(30,111,224,.28);}
.btn-primary:hover{background:var(--accent-hover);}
.btn-danger{background:var(--bad); color:#fff; box-shadow:0 8px 22px rgba(232,85,78,.3);}
.btn-danger:hover{background:var(--bad); filter:brightness(1.08);}
.btn-big{width:100%; min-height:58px; font-size:1.15rem; border-radius:18px;}
.btn-small{min-height:40px; padding:6px 14px; font-size:.9rem; border-radius:12px;}
.btn-ghost{background:transparent; border-color:transparent; color:var(--text-2);}

/* ---------- الشاشات ---------- */
main{flex:1; padding:clamp(12px,3vw,26px); display:flex; flex-direction:column;}
.screen{display:none;}
.screen.active{display:block; animation:screenIn .45s ease both;}
@keyframes screenIn{from{opacity:0; transform:translateY(14px);} to{opacity:1; transform:none;}}

/* ---------- البداية والدخول ---------- */
.setup{max-width:620px; margin:0 auto;}
.setup-hero{text-align:center; margin-bottom:18px;}
.hero-logo{width:clamp(104px,20vw,150px); height:auto; margin:0 auto; animation:floaty 5s ease-in-out infinite;}
@keyframes floaty{50%{transform:translateY(-8px);}}
.setup-hero h1{font-size:clamp(2rem,7.5vw,3rem); line-height:1.35;}
.lead{color:var(--text-2); font-size:clamp(1rem,2.4vw,1.12rem); max-width:44ch; margin:4px auto 0;}

.card{
  background:var(--surface); border:1px solid var(--line); border-radius:20px;
  padding:18px; margin-bottom:14px; box-shadow:var(--shadow);
}
.card-head{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px;}
.card-head h2{font-size:1.15rem;}

.resume{display:flex; align-items:center; justify-content:space-between; gap:12px; border-color:var(--hl);}
.resume .btn{flex:none;}
.code-inline{font-size:1.1rem; letter-spacing:.12em; direction:ltr; unicode-bidi:isolate; color:var(--text);}

/* طريقة الجرس */
.modes{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.mode{
  text-align:start; padding:12px 14px; border-radius:16px;
  background:var(--solid); border:2px solid var(--line);
  display:flex; flex-direction:column; gap:2px;
  transition:transform .15s ease, border-color .2s, background .2s;
}
.mode:hover{transform:translateY(-2px);}
.mode strong{font-size:1.02rem;}
.mode span{color:var(--text-2); font-size:.84rem; line-height:1.6;}
.mode[aria-pressed="true"]{border-color:var(--accent); background:var(--surface-2);}
.mode[aria-pressed="true"] strong::before{
  content:""; display:inline-block; width:.62em; height:.62em; border-radius:50%;
  background:var(--accent); margin-inline-end:.45em;
}
.modes.compact .mode{padding:9px 12px; text-align:center; align-items:center; border-radius:14px;}
.modes.compact .mode strong{font-size:.94rem;}

.rules summary{font-weight:700; cursor:pointer; list-style-position:inside;}
.rules ul{margin-top:10px; padding-inline-start:20px; color:var(--text-2); font-size:.95rem; list-style:disc;}
.rules li{margin-bottom:6px;}
.rules strong{color:var(--text);}

.home-link{display:block; width:max-content; max-width:100%; margin:10px auto 0; color:var(--text-2); font-weight:700; text-decoration:none; padding:6px 10px; border-radius:10px;}
.home-link:hover{background:var(--surface);}

.field{display:block; margin-bottom:12px;}
.field:last-of-type{margin-bottom:0;}
.field span{display:block; font-size:.88rem; color:var(--text-2); margin-bottom:4px;}
input[type="text"]{
  width:100%; height:52px; padding:0 14px;
  border-radius:14px; border:1px solid var(--line);
  background:var(--solid); color:var(--text); font-weight:700; font-size:1.05rem;
}
input[type="text"]::placeholder{color:var(--text-2); opacity:.55; font-weight:500;}
.code-input{
  height:68px !important; text-align:center; font-size:2rem !important;
  letter-spacing:.35em; font-variant-numeric:tabular-nums;
}
.error{margin-top:10px; color:var(--bad); font-weight:700; font-size:.95rem;}
[data-theme="blue"] .error{color:#fff; background:rgba(232,85,78,.85); padding:6px 12px; border-radius:10px;}

/* =========================================================
   شاشة المقدّم: الغرفة
   ========================================================= */
.room{max-width:1240px; margin:0 auto; display:flex; flex-direction:column; gap:14px;}

.joinbar{
  display:flex; align-items:center; gap:clamp(12px,2.4vw,24px);
  background:var(--surface); border:1px solid var(--line); border-radius:22px;
  padding:14px clamp(14px,2.4vw,22px); box-shadow:var(--shadow);
}
.qr{
  flex:none; width:clamp(92px,13vw,136px); aspect-ratio:1;
  background:#fff; border-radius:14px; padding:6px; display:grid; place-items:center;
}
.qr svg{width:100%; height:100%; display:block;}
.join-info{flex:1; min-width:0; display:flex; flex-direction:column; line-height:1.5;}
.join-url{font-size:clamp(.95rem,1.9vw,1.3rem); overflow-wrap:anywhere; word-break:break-all; text-align:right;}
.code{
  font-size:clamp(2.4rem,7vw,4.4rem); font-weight:700; line-height:1.15;
  letter-spacing:.16em; font-variant-numeric:tabular-nums;
  color:var(--accent); text-align:right;
}
.join-actions{flex:none; display:flex; flex-direction:column; gap:6px;}

.room-grid{display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:14px; align-items:start;}
.stage-col{display:flex; flex-direction:column; gap:12px; min-width:0;}

/* ---------- المسرح ---------- */
.stage{
  position:relative; overflow:hidden;
  min-height:clamp(300px,44vh,460px);
  background:var(--surface); border:1px solid var(--line); border-radius:26px;
  padding:16px clamp(14px,2.4vw,24px) 20px; box-shadow:var(--shadow);
  display:flex; flex-direction:column;
  transition:border-color .3s ease, box-shadow .3s ease;
}
.stage[data-state="buzzed"]{border-color:var(--ok); box-shadow:0 0 0 4px rgba(31,169,113,.18), var(--shadow);}
.stage[data-state="closed"]{border-style:dashed;}
.stage-head{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px;}
.pill{
  padding:3px 13px; border-radius:999px; white-space:nowrap;
  background:var(--surface-2); border:1px solid var(--line); font-size:.86rem; font-weight:700;
}

.waiting{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:10px 0;}
.waiting h2{font-size:clamp(1.5rem,3.6vw,2.3rem); line-height:1.5;}
.waiting .muted{font-size:1rem;}
.pulse{
  position:relative; width:clamp(84px,11vw,120px); aspect-ratio:1; border-radius:50%;
  display:grid; place-items:center; background:var(--accent); margin-bottom:14px;
}
.pulse svg{width:52%; height:52%; fill:var(--on-accent);}
.pulse::before,.pulse::after{
  content:""; position:absolute; inset:0; border-radius:50%;
  border:3px solid var(--accent); opacity:0; animation:ring 2.2s ease-out infinite;
}
.pulse::after{animation-delay:1.1s;}
@keyframes ring{0%{transform:scale(1); opacity:.7;} 100%{transform:scale(1.9); opacity:0;}}
.stage[data-state="closed"] .pulse{background:var(--cell);}
.stage[data-state="closed"] .pulse svg{fill:var(--text-2);}
.stage[data-state="closed"] .pulse::before,.stage[data-state="closed"] .pulse::after{animation:none;}

.winner{text-align:center; padding:6px 0 14px; animation:pop .5s cubic-bezier(.3,1.6,.5,1) both;}
@keyframes pop{from{opacity:0; transform:scale(.7);} to{opacity:1; transform:none;}}
.kicker{
  display:inline-block; padding:3px 16px; border-radius:999px;
  background:var(--ok); color:#fff; font-weight:700; font-size:clamp(.9rem,1.6vw,1.1rem);
}
.winner h2{
  font-size:clamp(2.4rem,8vw,5.4rem); line-height:1.35; overflow-wrap:anywhere;
}
.win-time{color:var(--text-2); font-size:clamp(1rem,2vw,1.3rem); font-variant-numeric:tabular-nums;}
.win-time b{color:var(--text);}

.queue{display:flex; flex-direction:column; gap:8px;}
.q-row{
  display:flex; align-items:center; gap:12px;
  background:var(--solid); border:1px solid var(--line); border-radius:16px;
  padding:8px 14px; border-inline-start:6px solid var(--c);
  transition:opacity .3s ease, transform .3s ease, box-shadow .3s ease;
}
.q-row.in{animation:rowIn .4s cubic-bezier(.3,1.4,.5,1) both;}
@keyframes rowIn{from{opacity:0; transform:translateX(-26px);} to{opacity:1; transform:none;}}
.q-rank{
  flex:none; width:40px; height:40px; border-radius:12px;
  display:grid; place-items:center; background:var(--cell); font-weight:700; font-size:1.15rem;
}
.q-name{flex:1; min-width:0; font-weight:700; font-size:clamp(1.05rem,2vw,1.35rem); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.q-time{flex:none; color:var(--text-2); font-variant-numeric:tabular-nums; font-size:clamp(.92rem,1.6vw,1.1rem); direction:rtl;}
.q-row.now{box-shadow:0 0 0 3px var(--ok);}
.q-row.now .q-rank{background:var(--ok); color:#fff;}
.q-row.done{opacity:.45;}
.q-row.done .q-name{text-decoration:line-through;}

/* ---------- أزرار المقدّم ---------- */
.controls{display:grid; grid-template-columns:1.25fr 1fr 1fr; gap:10px;}
.btn-ctl{
  display:flex; align-items:center; gap:10px; text-align:start;
  min-height:68px; padding:10px 16px; border-radius:18px;
}
.btn-ctl svg{flex:none; width:28px; height:28px; stroke:currentColor; fill:none;}
.btn-ctl svg rect{fill:currentColor; stroke:none;}
.btn-ctl span{display:flex; flex-direction:column; line-height:1.4; font-size:1.05rem; min-width:0;}
.btn-ctl small{font-weight:500; font-size:.78rem; opacity:.8;}
.btn-wrong{border-color:var(--bad);}
.btn-wrong svg{stroke:var(--bad);}
[data-theme="blue"] .btn-wrong svg{stroke:#fff;}
#armBtn[aria-pressed="false"]{background:var(--warn); color:#fff; border-color:transparent;}
#armBtn[aria-pressed="false"] .shackle{transform:translate(-3px,-2px) rotate(-18deg); transform-origin:16px 11px;}

/* ---------- المشاركون ---------- */
.people{
  background:var(--surface); border:1px solid var(--line); border-radius:22px;
  padding:16px; box-shadow:var(--shadow);
}
.people .empty{font-size:.95rem; padding:6px 2px;}
.people-list{display:flex; flex-direction:column; gap:8px; max-height:62vh; overflow-y:auto;}
.person{
  display:flex; align-items:center; gap:10px;
  background:var(--solid); border:1px solid var(--line); border-radius:14px; padding:7px 10px;
}
.person.in{animation:screenIn .3s ease both;}
.avatar{
  position:relative; flex:none; width:38px; height:38px; border-radius:12px;
  display:grid; place-items:center; background:var(--c); color:#fff; font-weight:700;
}
.avatar::after{
  content:""; position:absolute; inset-block-end:-3px; inset-inline-end:-3px;
  width:12px; height:12px; border-radius:50%; background:var(--ok); border:2px solid var(--solid);
}
.person.off .avatar::after{background:var(--cell-label);}
.person.off .p-name{opacity:.6;}
.p-text{flex:1; min-width:0; line-height:1.35;}
.p-name{display:block; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.p-note{display:block; font-size:.76rem; color:var(--text-2);}
.person.blocked{border-color:var(--bad); background:var(--surface);}
.person.blocked .p-note{color:var(--bad); font-weight:700;}
[data-theme="blue"] .person.blocked .p-note{color:#fff;}
.p-btn{
  flex:none; min-height:36px; padding:4px 11px; border-radius:10px;
  background:var(--surface); border:1px solid var(--line); font-size:.82rem; font-weight:700;
  transition:background .2s, transform .15s;
}
.p-btn:hover{background:var(--surface-2);}
.p-btn:active{transform:scale(.94);}
.p-btn.on{background:var(--bad); color:#fff; border-color:transparent;}
.p-btn.x{width:36px; padding:0; display:grid; place-items:center;}
.p-btn.x svg{width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:2.6; stroke-linecap:round;}

/* =========================================================
   صفحة المشارك: الجرس
   ========================================================= */
body.play main{padding-bottom:max(14px,env(safe-area-inset-bottom));}
body.play .net b{display:none;}
body.play .net{padding:8px;}
#screen-bell.active{flex:1; display:flex;}
.bell-wrap{
  flex:1; width:100%; max-width:560px; margin:0 auto;
  display:flex; flex-direction:column; align-items:center; justify-content:space-between; gap:14px;
  text-align:center; user-select:none; -webkit-user-select:none;
}
.bell-status{min-height:6.2rem; display:flex; flex-direction:column; justify-content:center;}
.bell-status h1{font-size:clamp(1.7rem,7.4vw,2.6rem); line-height:1.4;}
.bell-status p{color:var(--text-2); font-size:1.05rem; font-variant-numeric:tabular-nums;}

/* الزر الكبير */
.bell{
  --face:var(--accent); --ink:var(--on-accent); --edge:rgba(10,36,99,.38);
  position:relative; flex:none;
  width:min(76vw,46vh,380px); aspect-ratio:1; border-radius:50%;
  background:none; border:0; touch-action:none;
}
.bell-face{
  position:absolute; inset:0; border-radius:50%;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px;
  background:
    radial-gradient(circle at 34% 26%, rgba(255,255,255,.38), transparent 46%),
    var(--face);
  color:var(--ink);
  box-shadow:0 14px 0 var(--edge), 0 30px 44px rgba(10,36,99,.28), inset 0 -10px 22px rgba(0,0,0,.14);
  transform:translateY(-8px);
  transition:transform .09s ease, box-shadow .09s ease, background-color .25s ease;
}
.bell-ico svg{width:clamp(64px,22vw,110px); height:auto; fill:currentColor; display:block;}
.bell-label{font-weight:700; font-size:clamp(1.6rem,8vw,2.6rem); line-height:1.3;}
.bell-ring{
  position:absolute; inset:-4px; border-radius:50%;
  border:4px solid var(--face); opacity:0; pointer-events:none;
}
.bell:active .bell-face,.bell.down .bell-face{
  transform:translateY(4px);
  box-shadow:0 2px 0 var(--edge), 0 10px 18px rgba(10,36,99,.25), inset 0 -6px 16px rgba(0,0,0,.18);
}
[data-theme="navy"] .bell{--edge:rgba(92,194,245,.4);}
[data-theme="blue"] .bell{--edge:rgba(10,36,99,.42);}

/* جاهز: نبض يدعو للضغط */
[data-state="ready"] .bell-ring{animation:ring 1.8s ease-out infinite;}
[data-state="ready"] .bell-ico{animation:swing 2.4s ease-in-out infinite; transform-origin:50% 12%;}
@keyframes swing{0%,60%,100%{transform:rotate(0);} 68%{transform:rotate(11deg);} 76%{transform:rotate(-9deg);} 84%{transform:rotate(6deg);} 92%{transform:rotate(-3deg);}}

/* أنت الأول / دورك */
[data-state="first"] .bell{--face:var(--ok); --ink:#fff; --edge:#147a52;}
[data-state="first"] .bell-ring{animation:ring 1.2s ease-out infinite;}
[data-state="first"] .bell-status h1{color:var(--ok);}
[data-theme="blue"] [data-state="first"] .bell-status h1{color:#fff;}

/* في الطابور */
[data-state="rank"] .bell{--face:var(--warn); --ink:#fff; --edge:#a96d0c;}

/* مقفول أو بانتظار */
[data-state="wait"] .bell,[data-state="locked"] .bell,[data-state="done"] .bell{
  --face:var(--cell); --ink:var(--text-2); --edge:var(--line);
}
[data-state="wait"] .bell-face,[data-state="locked"] .bell-face,[data-state="done"] .bell-face,
[data-state="blocked"] .bell-face,[data-state="rank"] .bell-face,[data-state="first"] .bell-face{
  transform:translateY(2px);
  box-shadow:0 4px 0 var(--edge), 0 12px 22px rgba(10,36,99,.16), inset 0 -6px 16px rgba(0,0,0,.1);
}
[data-theme="light"] [data-state="wait"] .bell-face,
[data-theme="light"] [data-state="locked"] .bell-face,
[data-theme="light"] [data-state="done"] .bell-face{background:#DFEBFB;}

/* ممنوع */
[data-state="blocked"] .bell{--face:var(--bad); --ink:#fff; --edge:#a8322c;}
[data-state="blocked"] .bell-face{opacity:.8;}

.bell.shake{animation:shake .35s ease;}
@keyframes shake{20%{transform:translateX(7px);} 40%{transform:translateX(-7px);} 60%{transform:translateX(4px);} 80%{transform:translateX(-3px);}}

/* ترتيب مختصر تحت الزر */
.mini-queue{width:100%; display:flex; flex-direction:column; gap:6px; min-height:3rem;}
.mini-queue li{
  display:flex; align-items:center; gap:10px;
  background:var(--surface); border:1px solid var(--line); border-radius:13px; padding:5px 12px;
  font-size:.95rem; animation:rowIn .35s ease both;
}
.mini-queue .q-rank{width:30px; height:30px; border-radius:9px; font-size:.95rem;}
.mini-queue .q-name{font-size:1rem; text-align:start;}
.mini-queue .q-time{font-size:.86rem;}
.mini-queue li.me{border-color:var(--accent); background:var(--surface-2);}
.mini-queue li.now .q-rank{background:var(--ok); color:#fff;}
.mini-queue li.done{opacity:.45;}
.mini-queue li.more{justify-content:center; color:var(--text-2); font-size:.85rem; border-style:dashed;}
.leave{flex:none;}

/* ---------- النوافذ والتنبيه ---------- */
.modal{
  position:fixed; inset:0; z-index:50; display:grid; place-items:center; padding:18px;
  background:var(--scrim); backdrop-filter:blur(4px);
}
.modal-card{
  width:min(100%,420px); text-align:center;
  background:var(--solid); border:1px solid var(--line); border-radius:24px; padding:24px 20px 20px;
  box-shadow:0 30px 60px rgba(0,0,0,.3);
  animation:modalIn .35s cubic-bezier(.3,1.5,.5,1) both;
}
@keyframes modalIn{from{opacity:0; transform:scale(.85) translateY(20px);}}
.modal-card h3{font-size:1.35rem; line-height:1.5; margin-bottom:6px;}
.modal-card p{color:var(--text-2); margin-bottom:18px;}
.modal-actions{display:grid; grid-template-columns:1fr 1fr; gap:10px;}

.toast{
  position:fixed; inset-block-end:max(18px,env(safe-area-inset-bottom)); inset-inline:0; z-index:60;
  width:max-content; max-width:calc(100% - 28px); margin-inline:auto;
  background:var(--text); color:var(--bg); font-weight:700;
  padding:9px 18px; border-radius:999px; box-shadow:0 12px 30px rgba(0,0,0,.25);
}
.toast.in{animation:toastIn .3s ease both;}
@keyframes toastIn{from{opacity:0; transform:translateY(14px);}}

/* =========================================================
   هوية «جرس أثَر» الخاصة: أجواء استوديو مسابقات فوق ألوان أثَر
   ذهبي للأسرع والسرعة، وأحمر لقفل الجرس، وأزرار مجسّمة
   ========================================================= */
:root,[data-theme="light"]{
  --gold:#F59E0B; --gold-2:#FCD34D; --gold-ink:#0A2463; --gold-text:#B45309;
  --red:#EF4444; --red-deep:#B91C1C;
  --slate:#475569; --slate-deep:#1E293B;
  --edge:#C6D8F1; --edge-accent:#0F4FB0;
  --spot:rgba(92,194,245,.42); --pattern:.05; --bezel:#E4EFFD;
}
[data-theme="navy"]{
  --gold-text:#F59E0B; --edge:rgba(0,0,0,.38); --edge-accent:#4C9FD8;
  --spot:rgba(143,208,250,.28); --pattern:.06; --bezel:#0F2F7A;
}
[data-theme="blue"]{
  --gold-text:#FFFFFF; --edge:rgba(10,36,99,.3); --edge-accent:#9CCBF3;
  --spot:rgba(255,255,255,.32); --pattern:.07; --bezel:rgba(255,255,255,.22);
}

/* ---------- إضاءة المسرح والنقش المائي ---------- */
html{
  background:radial-gradient(75% 52% at 50% -14%, var(--spot), transparent 72%), var(--bg-paint);
  background-attachment:fixed; background-color:var(--bg);
}
body{background:transparent;}
body::before{
  content:""; position:fixed; inset:0; z-index:0; pointer-events:none;
  background:var(--text); opacity:var(--pattern);
  -webkit-mask:url("img/pattern.svg") 0 0 / 260px 260px repeat;
          mask:url("img/pattern.svg") 0 0 / 260px 260px repeat;
}
/* حزمتا ضوء خفيفتان من أعلى المسرح */
body::after{
  content:""; position:fixed; inset:0 0 auto 0; height:70vh; z-index:0; pointer-events:none;
  background:
    conic-gradient(from 160deg at 18% -10%, transparent 0 8deg, var(--spot) 14deg, transparent 22deg),
    conic-gradient(from 178deg at 82% -10%, transparent 0 8deg, var(--spot) 14deg, transparent 22deg);
  opacity:.45; -webkit-mask:linear-gradient(#000, transparent); mask:linear-gradient(#000, transparent);
}
.topbar, main{position:relative; z-index:1;}
/* حلقات النبض والتوهج ما تسبب تمرير أفقي */
html,body{overflow-x:clip;}
.bell-wrap{overflow-x:clip; overflow-y:visible; padding-inline:4px;}

/* ---------- صورة الزر فوق العنوان ---------- */
.hero-buzzer{
  position:relative; width:clamp(150px,30vw,210px); aspect-ratio:200/160; margin:0 auto 2px;
  display:grid; place-items:center;
}
.hero-buzzer svg{position:relative; width:100%; height:100%; overflow:visible;}
.hero-buzzer .ring{
  position:absolute; inset-inline:24%; top:22%; aspect-ratio:1; border-radius:50%;
  border:2px solid var(--hl); opacity:0; animation:heroRing 3s ease-out infinite;
}
.hero-buzzer .ring:nth-child(2){animation-delay:1s;}
.hero-buzzer .ring:nth-child(3){animation-delay:2s;}
@keyframes heroRing{0%{transform:scale(.7); opacity:.75;} 100%{transform:scale(1.9); opacity:0;}}
.hero-buzzer .shadow{fill:var(--text); opacity:.14;}
.hero-buzzer .base{stroke:rgba(255,255,255,.28); stroke-width:1.5;}
.hero-buzzer .bolt{fill:var(--gold);}
.hero-buzzer .spark path{fill:none; stroke:var(--gold); stroke-width:6; stroke-linecap:round; animation:spark 1.8s ease-in-out infinite;}
.hero-buzzer .dome{transform-origin:100px 111px; animation:press 3s ease-in-out infinite;}
@keyframes press{0%,78%,100%{transform:none;} 84%{transform:scaleY(.86);} 90%{transform:none;}}
@keyframes spark{0%,76%,100%{opacity:0;} 84%,92%{opacity:1;}}
.setup-hero h1{margin-top:-2px;}

/* ---------- أزرار مجسّمة تنزل عند الضغط ---------- */
.btn{box-shadow:0 4px 0 var(--edge);}
.btn:hover{transform:translateY(-1px);}
.btn:active{transform:translateY(4px); box-shadow:0 0 0 var(--edge);}
.btn-primary{box-shadow:0 5px 0 var(--edge-accent), 0 14px 26px rgba(10,36,99,.22);}
.btn-primary:active{transform:translateY(5px); box-shadow:0 0 0 var(--edge-accent), 0 4px 10px rgba(10,36,99,.2);}
.btn-ghost{box-shadow:none;}
.btn-ghost:active{transform:scale(.97); box-shadow:none;}
.btn-danger{box-shadow:0 5px 0 var(--red-deep);}
.btn:disabled,.btn:disabled:active{transform:none; box-shadow:0 2px 0 var(--edge);}
.btn-wrong{box-shadow:0 4px 0 var(--red-deep); border-color:var(--red);}
.btn-wrong svg{stroke:var(--red);}
.btn-wrong:active{box-shadow:0 0 0 var(--red-deep);}
#armBtn[aria-pressed="false"]{background:var(--red); box-shadow:0 4px 0 var(--red-deep);}

.mode{box-shadow:0 5px 0 var(--edge); transition:transform .12s ease, box-shadow .12s ease, border-color .2s, background .2s;}
.mode:hover{transform:translateY(-1px);}
.mode:active{transform:translateY(5px); box-shadow:0 0 0 var(--edge);}
.mode[aria-pressed="true"]{box-shadow:0 5px 0 var(--edge-accent);}
.mode[aria-pressed="true"]:active{box-shadow:0 0 0 var(--edge-accent);}
.p-btn{box-shadow:0 3px 0 var(--edge);}
.p-btn:active{transform:translateY(3px); box-shadow:none;}
.p-btn.on{background:var(--red); box-shadow:0 3px 0 var(--red-deep);}

/* ---------- شارة البث المباشر ---------- */
.net{gap:7px; font-weight:700;}
.net i{position:relative; background:var(--cell-label);}
.net b{font-weight:700;}
.net[data-on="true"]{border-color:rgba(239,68,68,.45);}
.net[data-on="true"] i{background:var(--red); box-shadow:none;}
.net[data-on="true"] i::after{
  content:""; position:absolute; inset:0; border-radius:50%; background:var(--red);
  animation:live 1.5s ease-out infinite;
}
@keyframes live{0%{transform:scale(1); opacity:.8;} 100%{transform:scale(2.8); opacity:0;}}
[data-theme="blue"] .net[data-on="true"]{border-color:rgba(255,255,255,.5);}

/* ---------- أشرطة الصوت المتمايلة ---------- */
.snd .bars{display:flex; align-items:center; gap:3px; height:20px;}
.snd .bars i{width:3.5px; height:100%; border-radius:3px; background:var(--text); transform-origin:50% 100%; transform:scaleY(.35);}
.snd[aria-pressed="true"] .bars i{animation:eq 1s ease-in-out infinite;}
.snd[aria-pressed="true"] .bars i:nth-child(2){animation-delay:-.35s; animation-duration:.8s;}
.snd[aria-pressed="true"] .bars i:nth-child(3){animation-delay:-.6s; animation-duration:1.15s;}
.snd[aria-pressed="true"] .bars i:nth-child(4){animation-delay:-.2s; animation-duration:.9s;}
@keyframes eq{0%,100%{transform:scaleY(.3);} 50%{transform:scaleY(1);}}
.snd[aria-pressed="false"] .bars{position:relative; opacity:.5;}
.snd[aria-pressed="false"] .bars i{transform:scaleY(.22);}
.snd[aria-pressed="false"] .bars::after{
  content:""; position:absolute; left:-3px; right:-3px; top:50%; height:2.5px; border-radius:2px;
  background:var(--text); transform:rotate(-38deg);
}

/* ---------- شاشة المقدّم: الذهبي للأسرع والأحمر للقفل ---------- */
.kicker{background:var(--gold); color:var(--gold-ink); box-shadow:0 4px 0 #B45309;}
.stage[data-state="buzzed"]{border-color:var(--gold); box-shadow:0 0 0 4px rgba(245,158,11,.22), 0 0 60px rgba(245,158,11,.18), var(--shadow);}
.stage.flash{animation:stageFlash .7s ease;}
@keyframes stageFlash{0%,40%{background:rgba(245,158,11,.28);} 100%{background:var(--surface);}}
.winner h2{text-shadow:0 4px 0 rgba(245,158,11,.25);}
.q-row.now{box-shadow:0 0 0 3px var(--gold);}
.q-row.now .q-rank{background:var(--gold); color:var(--gold-ink);}
.q-time{direction:rtl;}

.pulse .i-lock,.pulse .i-bolt{display:none;}
.pulse svg{fill:var(--on-accent); color:var(--on-accent);}
.stage[data-state="closed"] .pulse{background:var(--red);}
.stage[data-state="closed"] .pulse .i-bell{display:none;}
.stage[data-state="closed"] .pulse .i-lock{display:block; fill:#fff; color:#fff;}
.stage[data-state="closed"]{border-color:rgba(239,68,68,.55);}

/* ---------- جرس المتسابق ---------- */
.bell{--glow:transparent;}
.bell::before{
  content:""; position:absolute; inset:-12px; border-radius:50%;
  background:var(--bezel); border:1px solid var(--line);
  box-shadow:inset 0 6px 14px rgba(10,36,99,.14), 0 0 70px var(--glow);
  transition:box-shadow .3s ease;
}
.bell-face{
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.55), transparent 42%),
    radial-gradient(circle at 50% 120%, rgba(0,0,0,.22), transparent 55%),
    var(--face);
}
.bell-ico{display:grid; place-items:center;}
.bell-ico svg{display:none; color:var(--ink);}
.bell-ico .i-bell{display:block;}
.bell-sub{font-weight:700; font-size:clamp(1rem,4.6vw,1.35rem); line-height:1.2; direction:rtl; opacity:.95;}
.bell-sub:empty{display:none;}

/* جاهز: سماوي متوهج بنبض هادئ */
[data-state="ready"] .bell{--face:#2EA8F2; --ink:#fff; --edge:#0F4FB0; --glow:rgba(92,194,245,.55);}
[data-state="ready"] .bell::before{animation:glow 2s ease-in-out infinite;}
@keyframes glow{50%{box-shadow:inset 0 6px 14px rgba(10,36,99,.14), 0 0 100px var(--glow);}}
[data-theme="blue"] [data-state="ready"] .bell{--face:#5CC2F5; --ink:#0A2463; --edge:#0A2463;}

/* الأسرع: ذهبي ببرق ووميض */
[data-state="first"] .bell{--face:var(--gold); --ink:var(--gold-ink); --edge:#B45309; --glow:rgba(245,158,11,.7);}
[data-state="first"] .bell-ring{border-color:var(--gold);}
[data-state="first"] .bell-ico .i-bell{display:none;}
[data-state="first"] .bell-ico .i-bolt{display:block;}
[data-state="first"] .bell-face{animation:flash .9s ease-out 1;}
@keyframes flash{0%,30%,60%{filter:brightness(1.5) saturate(1.2);} 15%,45%,100%{filter:none;}}
[data-state="first"] .bell-status h1{color:var(--gold-text);}

/* متأخر في الطابور: رمادي داكن بفارق التوقيت */
[data-state="rank"] .bell{--face:var(--slate); --ink:#fff; --edge:var(--slate-deep); --glow:transparent;}
[data-state="rank"] .bell-ico{display:none;}
[data-state="rank"] .bell-label{font-size:clamp(3rem,18vw,5rem); line-height:1;}

/* مقفل: أحمر باهت بقفل */
[data-state="locked"] .bell{--face:#F08A8A; --ink:#fff; --edge:var(--red-deep);}
[data-state="locked"] .bell-face{opacity:.85;}
[data-state="blocked"] .bell{--face:var(--red); --ink:#fff; --edge:var(--red-deep);}
[data-state="locked"] .bell-ico .i-bell,[data-state="blocked"] .bell-ico .i-bell,
[data-state="wait"] .bell-ico .i-bell,[data-state="done"] .bell-ico .i-bell{display:none;}
[data-state="locked"] .bell-ico .i-lock,[data-state="blocked"] .bell-ico .i-lock,
[data-state="wait"] .bell-ico .i-lock,[data-state="done"] .bell-ico .i-lock{display:block;}
[data-state="wait"] .bell,[data-state="done"] .bell{--face:#7A8AA3; --ink:#fff; --edge:#3D4B63;}
[data-theme="light"] [data-state="wait"] .bell-face,
[data-theme="light"] [data-state="locked"] .bell-face,
[data-theme="light"] [data-state="done"] .bell-face{background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.5), transparent 42%),
    radial-gradient(circle at 50% 120%, rgba(0,0,0,.2), transparent 55%), var(--face);}
.mini-queue li.now .q-rank{background:var(--gold); color:var(--gold-ink);}

/* قصاصات الفوز */
.confetti{position:fixed; inset:0; width:100%; height:100%; pointer-events:none; z-index:40;}

/* ---------- التجاوب ---------- */
@media (max-width:980px){
  .room-grid{grid-template-columns:1fr;}
  .people-list{max-height:none;}
}
@media (max-width:640px){
  .topbar{padding:8px 12px;}
  .brand .logo{height:40px;}
  .host .net b{display:none;}
  .host .net{padding:8px;}
  .theme-dot{width:26px; height:26px;}
  .joinbar{flex-wrap:wrap;}
  .join-actions{flex-direction:row; width:100%;}
  .join-actions .btn{flex:1;}
  .controls{grid-template-columns:1fr 1fr;}
  .controls #resetBtn{grid-column:1 / -1;}
  .join-url{font-size:.86rem; line-height:1.45;}
  .code{letter-spacing:.1em;}
  .modes{grid-template-columns:1fr;}
  .modes.compact{grid-template-columns:1fr 1fr;}
  .resume{flex-direction:column; align-items:stretch; text-align:center;}
}
@media (max-height:620px) and (orientation:landscape){
  .bell-wrap{flex-direction:row; flex-wrap:wrap; justify-content:center;}
  .bell{width:min(52vh,300px);}
  .mini-queue{display:none;}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important;}
}

/* سؤال ديوان فوق المسرح */
.bq{margin-bottom:14px; padding:16px; border-radius:20px; background:var(--surface); border:1px solid var(--line); box-shadow:var(--shadow);}
.bq-head{display:flex; align-items:center; justify-content:space-between; gap:8px;}
.bq-cat{font-size:.8rem; color:var(--text-2); background:var(--surface-2); border-radius:999px; padding:1px 10px;}
.bq-text{font-size:clamp(1.25rem,3.4vw,1.9rem); line-height:1.6; margin:6px 0 12px; overflow-wrap:anywhere;}
.bq .aq-opt{cursor:default;}
.bq-reveal{margin-top:12px;}
