/* ══════════════════════════════════════════════════════════
   إكس أو — لوحة الألوان: حبر صنوبري داكن + زعفران (X) + بنفسج (O)
   الإطار حول اللوح "حيّ": لونه = صاحب الدور، وتوهّجه = من يتكلم الآن.
   ══════════════════════════════════════════════════════════ */

@property --glow { syntax: '<number>'; initial-value: 0; inherits: true; }

:root{
  --ink:      #0E1A18;
  --ink-2:    #142623;
  --ink-3:    #1E3630;
  --hair:     #27453E;
  --bone:     #E9F0EC;
  --bone-dim: #7E958E;

  --x-rgb: 242 179 61;
  --o-rgb: 138 123 247;

  --turn-rgb: var(--x-rgb);
  --turn: rgb(var(--turn-rgb));
  --glow: 0;

  --display: 'Reem Kufi', system-ui, sans-serif;
  --body: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 26px;
}

*, *::before, *::after { box-sizing: border-box; }

/* لا بد أن تسبق قواعد العرض: عناصر كثيرة هنا display:flex/grid
   وكانت تتجاهل خاصية hidden لولا هذا السطر. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body{
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.veil{
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(70% 50% at 50% -10%, rgb(var(--turn-rgb) / .13), transparent 70%),
    radial-gradient(90% 60% at 50% 115%, rgb(var(--o-rgb) / .07), transparent 70%);
  transition: background .6s ease;
}

.view{
  position: relative; z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

button, input { font: inherit; color: inherit; }

:focus-visible{
  outline: 2px solid var(--turn);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ─────────────── الأزرار ─────────────── */

.btn{
  border: 1px solid var(--hair);
  background: var(--ink-2);
  color: var(--bone);
  border-radius: var(--r-md);
  padding: 13px 20px;
  cursor: pointer;
  font-weight: 500;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}
.btn:hover:not(:disabled){ background: var(--ink-3); }
.btn:active:not(:disabled){ transform: translateY(1px); }
.btn:disabled{ opacity: .42; cursor: not-allowed; }

.btn-primary{
  background: var(--turn);
  border-color: transparent;
  color: #0B1513;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled){ background: rgb(var(--turn-rgb) / .88); }

.btn-ghost{ background: transparent; }

.btn-wa{
  background: #1EA855;
  border-color: transparent;
  color: #04240F;
  font-weight: 600;
}
.btn-wa:hover{ background: #24bd60; }

/* ─────────────── الصفحة الأولى ─────────────── */

#view-home{ justify-content: center; gap: 34px; }

.home{ display: grid; gap: 30px; }

.home-art{ display: grid; place-items: center; }

.demo-svg{ width: min(58vw, 210px); height: auto; }

.eyebrow{
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--bone-dim);
  text-transform: uppercase;
}

.title{
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(48px, 15vw, 76px);
  line-height: .95;
  margin: 0 0 14px;
  letter-spacing: -.01em;
}
.title .tt-o{ color: var(--peri, rgb(var(--o-rgb))); }

.lede{
  margin: 0 0 26px;
  color: var(--bone-dim);
  font-weight: 300;
  max-width: 34ch;
}

.actions{ display: grid; gap: 12px; }

.btn-primary#btn-new{ padding: 16px; font-size: 17px; }

.join{ display: flex; gap: 10px; }

.code-input{
  flex: 1;
  min-width: 0;
  background: var(--ink-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: .34em;
  text-align: center;
  text-transform: uppercase;
  direction: ltr;
}
.code-input::placeholder{
  font-family: var(--body);
  font-size: 15px;
  letter-spacing: 0;
  color: var(--bone-dim);
}

.note{
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
  font-size: 12.5px;
  font-weight: 300;
  color: var(--bone-dim);
}

/* ─────────────── شريط علوي ─────────────── */

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand{
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .02em;
}

.topbar-right{ display: flex; align-items: center; gap: 8px; }

.chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--hair);
  background: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: default;
  font-size: 12px;
  color: var(--bone-dim);
}
.chip-code{ cursor: pointer; }
.chip-code:hover{ background: var(--ink-3); }
.chip-code b{
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: .18em;
  color: var(--bone);
  direction: ltr;
}
.chip-quiet[data-q="good"]{ color: #62D2A2; border-color: #23503F; }
.chip-quiet[data-q="fair"]{ color: #F2B33D; border-color: #4A3A19; }
.chip-quiet[data-q="poor"]{ color: #EC6A5E; border-color: #4E2723; }

/* ─────────────── بطاقات اللاعبين ─────────────── */

.seats{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seat{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  background: var(--ink-2);
  transition: border-color .3s ease, background .3s ease;
  min-width: 0;
}
.seat[data-seat="X"]{ --c: var(--x-rgb); }
.seat[data-seat="O"]{ --c: var(--o-rgb); }
.seat.active{
  border-color: rgb(var(--c) / .6);
  background: rgb(var(--c) / .08);
}
.seat.offline{ opacity: .48; }

.seat-glyph{
  font-size: 17px;
  color: rgb(var(--c));
  flex: none;
}

.seat-meta{ display: grid; min-width: 0; flex: 1; }
.seat-name{
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-sub{ font-size: 11px; color: var(--bone-dim); }
.seat-sub.live{ color: #62D2A2; }

.seat-score{
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  flex: none;
}

.turn-line{
  text-align: center;
  margin: 18px 0 12px;
  font-size: 14px;
  color: var(--bone-dim);
  min-height: 1.6em;
}
.turn-line b{ color: var(--turn); font-weight: 600; }

/* ─────────────── اللوح والإطار الحي ─────────────── */

.board-wrap{
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1px solid rgb(var(--turn-rgb) / .35);
  background:
    radial-gradient(130% 110% at 50% 0%, rgb(var(--turn-rgb) / .10), transparent 62%),
    var(--ink-2);
  box-shadow:
    0 0 calc(14px + var(--glow) * 44px) rgb(var(--turn-rgb) / calc(.12 + var(--glow) * .42)),
    inset 0 1px 0 rgb(255 255 255 / .04);
  transition: border-color .45s ease, background .45s ease;
  align-self: center;
  width: 100%;
  max-width: 380px;
}

.board{
  position: relative;
  direction: ltr;      /* الإحداثيات يسار→يمين حتى في RTL */
  aspect-ratio: 1;
}

.board-svg{ width: 100%; height: 100%; display: block; }

.grid line{
  stroke: var(--hair);
  stroke-width: 3;
  stroke-linecap: round;
}

.cells{
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n, 3), 1fr);
  grid-template-rows: repeat(var(--n, 3), 1fr);
}
.cells button{
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background .18s ease;
}
.cells button:disabled{ cursor: default; }
.cells button:not(:disabled):hover{ background: rgb(var(--turn-rgb) / .09); }

.mark{
  fill: none;
  /* لوح ٤×٤ خاناته أصغر، فسماكة ثابتة كانت تطغى على الشبكة */
  stroke-width: var(--mark-w, 11);
  stroke-linecap: round;
  animation: draw .32s cubic-bezier(.4,.9,.3,1) forwards;
}
.mark.x{ stroke: rgb(var(--x-rgb)); }
.mark.o{ stroke: rgb(var(--o-rgb)); }
.mark:nth-child(even){ animation-delay: .07s; }

@keyframes draw{
  from{ stroke-dasharray: 1; stroke-dashoffset: 1; }
  to  { stroke-dasharray: 1; stroke-dashoffset: 0; }
}

.winline{
  fill: none;
  stroke: var(--turn);
  stroke-width: calc(var(--mark-w, 11) * .68);
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgb(var(--turn-rgb) / .7));
  animation: draw .55s .1s cubic-bezier(.4,.9,.3,1) backwards;
}

.board-wrap.settled{ animation: settle .5s ease; }
@keyframes settle{
  0%{ transform: scale(1); }
  35%{ transform: scale(1.024) rotate(-.4deg); }
  100%{ transform: scale(1); }
}

/* ─── لحظة الفوز: نبضة في لون الفائز تتلاشى، لا احتفال صاخب ─── */
.board-wrap.won{ animation: settle .5s ease, victory 1.5s ease .12s; }
@keyframes victory{
  0%   { box-shadow: 0 0 0 0 rgb(var(--turn-rgb) / .55); }
  55%  { box-shadow: 0 0 0 22px rgb(var(--turn-rgb) / 0); }
  100% { box-shadow: 0 0 0 0 rgb(var(--turn-rgb) / 0); }
}
.board-wrap.lost{ animation: settle .5s ease; opacity: .82; }

.seat.bump{ animation: bump .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes bump{
  0%{ transform: scale(1); }
  40%{ transform: scale(1.07); }
  100%{ transform: scale(1); }
}

/* ─────────────── أدوات التحكم ─────────────── */

.controls{
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0 8px;
}

.btn-voice{ display: inline-flex; align-items: center; gap: 9px; }
.btn-voice .dot{
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bone-dim);
  transition: background .3s ease, box-shadow .3s ease;
}
.btn-voice.on .dot{
  background: #62D2A2;
  box-shadow: 0 0 0 4px rgb(98 210 162 / .18);
}
.btn-voice.connecting .dot{ background: var(--x-rgb); animation: pulse 1s infinite; }
@keyframes pulse{ 50%{ opacity: .3; } }

/* ─────────────── الدردشة ─────────────── */

.chat{
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}

.chat-head{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  padding: 6px 2px;
  cursor: pointer;
  font-size: 14px;
  color: var(--bone-dim);
}
.chat-head::after{ content: '⌃'; transform: rotate(180deg); transition: transform .25s ease; }
.chat-head[aria-expanded="true"]::after{ transform: rotate(0deg); }

.chat-badge{
  background: var(--turn);
  color: #0B1513;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-inline-start: auto;
  margin-inline-end: 10px;
}

.chat-log{
  max-height: 34vh;
  overflow-y: auto;
  display: grid;
  gap: 7px;
  padding: 10px 0;
  scrollbar-width: thin;
}
.msg{
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--ink-2);
  font-size: 14px;
  max-width: 82%;
  word-break: break-word;
}
.msg.mine{ justify-self: start; background: rgb(var(--turn-rgb) / .16); }
.msg.theirs{ justify-self: end; }
.msg.system{
  justify-self: center;
  background: none;
  color: var(--bone-dim);
  font-size: 12px;
  padding: 2px;
}
.msg-who{ display: block; font-size: 11px; color: var(--bone-dim); margin-bottom: 1px; }

.chat-form{ display: flex; gap: 8px; padding-top: 4px; }
.chat-form input{
  flex: 1;
  min-width: 0;
  background: var(--ink-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 11px 14px;
}

/* ─────────────── ورقة المشاركة ─────────────── */

.sheet{
  position: fixed; inset: 0; z-index: 20;
  background: rgb(6 12 11 / .74);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: end center;
  animation: fade .2s ease;
}
@keyframes fade{ from{ opacity: 0; } }

.sheet-card{
  width: min(100%, 460px);
  background: var(--ink-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 26px 20px calc(26px + env(safe-area-inset-bottom));
  animation: rise .28s cubic-bezier(.3,1,.4,1);
}
@keyframes rise{ from{ transform: translateY(24px); opacity: 0; } }

.sheet-title{ font-family: var(--display); font-size: 21px; margin: 0 0 14px; }
.sheet-code{
  font-family: var(--mono);
  font-size: 40px;
  letter-spacing: .28em;
  text-align: center;
  direction: ltr;
  margin: 0;
  color: var(--turn);
}
.sheet-url{
  text-align: center;
  direction: ltr;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--bone-dim);
  word-break: break-all;
  margin: 4px 0 20px;
}
.sheet-actions{ display: grid; gap: 10px; }

/* ─────────────── تنبيه عائم ─────────────── */

.toast{
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: var(--ink-3);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 30;
}
.toast.show{ opacity: 1; transform: translate(-50%, 0); }

/* ─────────────── شاشات أوسع ─────────────── */

@media (min-width: 900px){
  #view-game{
    max-width: 1000px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 288px;
    grid-template-areas:
      "top    top"
      "seats  chat"
      "series chat"
      "turn   chat"
      "timer  chat"
      "board  chat"
      "ctrl   chat"
      "react  chat";
    align-content: start;
    column-gap: 26px;
  }
  .series{ grid-area: series; }
  .timer{ grid-area: timer; }
  .reacts{ grid-area: react; }
  .board-wrap{ max-width: 460px; margin-inline: auto; width: 100%; }
  .topbar{ grid-area: top; }
  .seats{ grid-area: seats; }
  .turn-line{ grid-area: turn; }
  .board-wrap{ grid-area: board; }
  .controls{ grid-area: ctrl; }
  .chat{
    grid-area: chat;
    margin-top: 0;
    border: 1px solid var(--hair);
    border-radius: var(--r-lg);
    background: var(--ink-2);
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 440px;
  }
  .chat-head{ display: none; }
  .chat-body{ display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .chat-log{ flex: 1; max-height: none; align-content: start; }

  #view-home .home{ grid-template-columns: 280px 1fr; align-items: center; gap: 50px; }
  #view-home{ max-width: 860px; }
  .demo-svg{ width: 260px; }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ═══════════════════════════════════════════════════════════
   الإضافات: الوضع النهاري، إعدادات الغرفة، السلسلة،
   مؤقّت الدور، التفاعلات، رمز المسح
   ═══════════════════════════════════════════════════════════ */

/* ─────────────── الوضع النهاري ───────────────
   ورق فاتح دافئ بدل الأبيض الناصع: أقل إجهاداً للعين تحت الشمس،
   ويبقي الزعفران والبنفسج واضحَين. */

:root[data-theme="light"]{
  --ink:      #F3EFE6;
  --ink-2:    #FBF8F2;
  --ink-3:    #EAE3D5;
  --hair:     #D6CCB8;
  --bone:     #1B2B27;
  --bone-dim: #6B7A73;

  --x-rgb: 198 124 12;     /* زعفران أغمق ليبقى مقروءاً على الفاتح */
  --o-rgb: 88  70  214;
}

:root[data-theme="light"] .veil{
  background:
    radial-gradient(70% 50% at 50% -10%, rgb(var(--turn-rgb) / .16), transparent 70%),
    radial-gradient(90% 60% at 50% 115%, rgb(var(--o-rgb) / .08), transparent 70%);
}

:root[data-theme="light"] .btn-primary{ color: #FFF8EA; }
:root[data-theme="light"] .chip-quiet[data-q="good"]{ color: #17795A; border-color: #A9D8C4; }
:root[data-theme="light"] .chip-quiet[data-q="fair"]{ color: #9A6A08; border-color: #E0C88A; }
:root[data-theme="light"] .chip-quiet[data-q="poor"]{ color: #B33127; border-color: #E7B0AA; }
:root[data-theme="light"] .seat-sub.live{ color: #17795A; }

.chip-icon{
  cursor: pointer;
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
}
.chip-icon:hover{ background: var(--ink-3); }

/* ─────────────── إعدادات الغرفة ─────────────── */

.setup{
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px 14px;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  background: rgb(var(--o-rgb) / .04);
}

/* التسمية فوق والخيارات تحتها بعرض كامل: يقرأ أوضح ولا يزدحم
   على الشاشات الضيقة، وهو الوضع الغالب في لعبة تُفتح من واتساب. */
.opt{ display: grid; gap: 7px; }

.opt-label{
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--bone-dim);
}

.seg{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--hair);
}
.seg button{
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--bone-dim);
  font-family: var(--body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
  white-space: nowrap;
}
.seg button:hover{ color: var(--bone); background: var(--ink-3); }
.seg button:focus-visible{ outline: 2px solid var(--turn); outline-offset: 2px; }
.seg button.on{
  background: rgb(var(--turn-rgb) / .18);
  color: var(--turn);
  font-weight: 600;
}

/* ─────────────── شريط السلسلة ─────────────── */

.series{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.series-text{
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--bone-dim);
  white-space: nowrap;
}

.series-pips{ display: flex; gap: 5px; }
.series-pips[data-seat="X"]{ --c: var(--x-rgb); flex-direction: row-reverse; }
.series-pips[data-seat="O"]{ --c: var(--o-rgb); }

.series-pips i{
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgb(var(--c) / .38);
  transition: background .3s ease, transform .3s ease;
}
.series-pips i.won{
  background: rgb(var(--c));
  border-color: rgb(var(--c));
  transform: scale(1.14);
}

/* ─────────────── مؤقّت الدور ─────────────── */

.timer{
  height: 3px;
  margin: 0 auto 14px;
  width: min(92vw, 340px);
  border-radius: 999px;
  background: var(--hair);
  overflow: hidden;
}
.timer i{
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--turn);
  transform-origin: right center;   /* الاتجاه من اليمين لليسار مع RTL */
  transition: background .3s ease;
}
:root[dir="ltr"] .timer i{ transform-origin: left center; }
.timer.urgent i{ background: #EC6A5E; }
.timer.urgent{ animation: pulse-timer .7s ease-in-out infinite; }
@keyframes pulse-timer{ 50%{ opacity: .5; } }

/* ─────────────── التفاعلات السريعة ─────────────── */

.reacts{
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.react-btn{
  border: 1px solid var(--hair);
  background: var(--ink-2);
  border-radius: 999px;
  font-size: 19px;
  line-height: 1;
  padding: 7px 11px;
  cursor: pointer;
  transition: transform .14s ease, background .18s ease;
}
.react-btn:hover{ background: var(--ink-3); transform: translateY(-2px); }
.react-btn:active{ transform: scale(.9); }

.reacts-layer{
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.float-react{
  position: absolute;
  bottom: 4%;
  font-size: 30px;
  line-height: 1;
  animation: rise 1.9s cubic-bezier(.3,.7,.4,1) forwards;
}
@keyframes rise{
  0%   { opacity: 0; transform: translate(0, 12px) scale(.6); }
  14%  { opacity: 1; transform: translate(0, 0) scale(1.12); }
  30%  { transform: translate(calc(var(--drift) * .4), -34%) scale(1); }
  100% { opacity: 0; transform: translate(var(--drift), -128%) scale(.86); }
}

/* ─────────────── رمز المسح ─────────────── */

.qr{
  width: min(56vw, 190px);
  margin: 4px auto 8px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--ink-2);
  border: 1px solid var(--hair);
  color: var(--bone);          /* رمز QR يرث هذا اللون عبر currentColor */
  line-height: 0;
}
.qr svg{ width: 100%; height: auto; shape-rendering: crispEdges; }

.sheet-hint{
  margin: 0 0 12px;
  font-size: 11px;
  text-align: center;
  color: var(--bone-dim);
}

/* ─────────────── احترام تقليل الحركة ─────────────── */

@media (prefers-reduced-motion: reduce){
  .board-wrap.settled,
  .board-wrap.won,
  .seat.bump,
  .timer.urgent{ animation: none !important; }
  .float-react{ animation-duration: .9s; }
}

/* ─────────────── الشاشات الضيقة ─────────────── */

@media (max-width: 380px){
  .seg button{ font-size: 12.5px; padding: 8px 4px; }
  .react-btn{ font-size: 17px; padding: 6px 9px; }
}


/* ═══════════ لحظة الفوز: انفجار أشعة من مركز اللوح ═══════════ */

.burst{
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
}

.burst i{
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--turn);
  opacity: 0;
}
.burst.go i{ animation: shard .9s cubic-bezier(.2,.7,.35,1) forwards; }

@keyframes shard{
  0%   { opacity: 1; transform: rotate(var(--a)) translateY(0) scaleY(1); }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(var(--d)) scaleY(3.4); }
}

.win-word{
  position: absolute;
  font-family: var(--display);
  font-size: clamp(30px, 9vw, 58px);
  font-weight: 700;
  color: var(--turn);
  text-shadow: 0 0 26px rgb(var(--turn-rgb) / .55);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.burst.go .win-word{ animation: word 1.7s cubic-bezier(.2,.8,.3,1) forwards; }

@keyframes word{
  0%   { opacity: 0; transform: scale(.55); }
  18%  { opacity: 1; transform: scale(1.14); }
  32%  { transform: scale(1); }
  74%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06); }
}

/* ═══════════ إحصائيات الصفحة الأولى ═══════════ */

.stats{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px 0 4px;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
}

.stat{ text-align: center; }

.stat b{
  display: block;
  font-family: var(--mono);
  font-size: clamp(20px, 6vw, 27px);
  font-weight: 600;
  line-height: 1.15;
  color: var(--turn);
  font-variant-numeric: tabular-nums;
}
.stat span{
  display: block;
  font-size: 11px;
  color: var(--bone-dim);
  margin-top: 2px;
}
.stat.hot b{ color: rgb(var(--o-rgb)); }

.live-dot{
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #35D08A;
  margin-inline-end: 5px;
  vertical-align: 1px;
  animation: breathe 1.9s ease-in-out infinite;
}
@keyframes breathe{ 50%{ opacity: .3; } }

@media (prefers-reduced-motion: reduce){
  .burst.go i, .live-dot{ animation: none !important; }
  .burst.go .win-word{ animation-duration: .4s; }
}

/* نبضة تلفت النظر لزر الصوت حين يشغّله الطرف الآخر */
.btn-voice.nudge{
  border-color: rgb(var(--turn-rgb) / .8);
  animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge{
  0%, 100%{ box-shadow: 0 0 0 0 rgb(var(--turn-rgb) / .45); }
  60%     { box-shadow: 0 0 0 12px rgb(var(--turn-rgb) / 0); }
}
@media (prefers-reduced-motion: reduce){ .btn-voice.nudge{ animation: none; } }


/* ═══════════ اللعب ضد الجهاز ═══════════ */

.solo{
  display: grid;
  gap: 8px;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--hair);
}

.solo-label{
  font-size: 12px;
  color: var(--bone-dim);
  text-align: center;
}

.solo-row{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-solo{
  padding: 11px 6px;
  font-size: 14px;
  border-color: var(--hair);
}
.btn-solo.hard{
  border-color: rgb(var(--o-rgb) / .55);
  color: rgb(var(--o-rgb));
}
.btn-solo.hard:hover:not(:disabled){ background: rgb(var(--o-rgb) / .12); }

/* أمام الجهاز لا صوت ولا دردشة ولا دعوة */
body.solo-mode .chat,
body.solo-mode #btn-voice,
body.solo-mode #btn-mute,
body.solo-mode #btn-share,
body.solo-mode #net-chip{ display: none !important; }

body.solo-mode #view-game{
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "seats" "series" "turn" "timer" "board" "ctrl" "react";
  max-width: 520px;
}
