/* =====================================================================
   snake.css — أنماط ألعاب الثعبان الثلاث (ثعبان اليوم · الحروف · الألغاز)
   ---------------------------------------------------------------------
   ملفٌّ واحد للثلاثة: الهيكل واحد (لوحة + لوحة مفاتيح اتجاه + أدوات)
   وإن اختلفت القواعد. وما يخصّ لعبةً بعينها مُعلَّمٌ باسمها.

   واللوحة القماشية اتجاهها ثابتٌ في اللغتين (`direction: ltr` على
   حاويتها): الحركة رسمٌ لا نصّ، وقلبُها في العربية يقلب اليمين شمالاً
   في عين اللاعب وهو يضغط.
   ===================================================================== */

.sn-stage {
  background: var(--bg-soft); border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg); padding: 16px 12px 18px; margin: 14px 0;
}

/* ------------------------------------------------------- السرعات */
.sn-speeds { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.sn-sp {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  padding: 9px 16px; min-height: 40px; border-radius: 999px;
  background: var(--tile-bg); border: 1px solid var(--tile-border); color: var(--text-muted);
  transition: background .15s, border-color .15s, color .15s;
}
.sn-sp.on { background: var(--accent-teal-dim); border-color: var(--accent-teal); color: var(--accent-teal); }

/* ------------------------------------------------------- الشريط */
.sn-head { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 10px; }
.sn-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 12.5px; color: var(--text-muted);
  background: var(--tile-bg); border: 1px solid var(--tile-border);
  border-radius: 999px; padding: 6px 13px;
}
.sn-chip b { font-family: var(--font-mono); font-size: 15px; color: var(--text-primary); }
.sn-chip.best b { color: var(--accent-amber); }
.sn-chip.day  { color: var(--accent-violet); border-color: var(--accent-violet); background: var(--accent-violet-dim); }

.sn-ask { text-align: center; font-size: 15px; font-weight: 800; color: var(--text-primary); margin: 0 0 10px; line-height: 1.7; }
.sn-word {
  text-align: center; margin: 0 0 10px; font-family: var(--font-mono);
  font-size: 30px; font-weight: 800; letter-spacing: 6px; color: var(--text-muted);
  direction: rtl;
}
.sn-word .got { color: var(--accent-teal); }
.sn-word .next { color: var(--accent-amber); text-decoration: underline; text-underline-offset: 7px; }

/* ------------------------------------------------------- اللوحة */
.sn-wrap { direction: ltr; display: flex; justify-content: center; padding: 2px 0; }
.sn-board {
  touch-action: none;              /* السحب لنا لا للمتصفّح */
  user-select: none; -webkit-user-select: none;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--panel-border), 0 10px 30px rgba(0, 0, 0, .35);
}

.sn-say { text-align: center; font-size: 13px; color: var(--text-muted); min-height: 20px; margin-top: 8px; line-height: 1.7; }
.sn-say.warn { color: var(--accent-amber); font-weight: 700; }

/* ------------------------------------------------------- أزرار الاتجاه
   تظهر في كل المقاسات: ليست للجوّال وحده — من يلعب بالفأرة يحتاجها
   أيضاً، ولوحةُ المفاتيح تعمل معها لا بدلاً منها. */
.sn-pad {
  direction: ltr;
  display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px);
  gap: 8px; justify-content: center; margin: 14px auto 2px;
}
.sn-pad button {
  font: inherit; font-size: 24px; cursor: pointer;
  border-radius: 16px; border: 1px solid var(--tile-border); background: var(--tile-bg);
  color: var(--accent-teal); display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.sn-pad button:active { background: var(--accent-teal-dim); border-color: var(--accent-teal); transform: scale(.94); }
.sn-pad .up    { grid-area: 1 / 2; }
.sn-pad .left  { grid-area: 2 / 1; }
.sn-pad .right { grid-area: 2 / 3; }
.sn-pad .down  { grid-area: 3 / 2; }
.sn-pad .mid   { grid-area: 2 / 2; border: 0; background: none; color: var(--text-muted); font-size: 11px; cursor: default; }

/* على الشاشات العريضة: صفٌّ واحد أفقيّ بدل المربّع.
   ⚠️ ليس تجميلاً: المربّع يأكل ١٩٠ بكسلاً من الارتفاع، ونافذةُ الحاسوب
   قد لا يزيد ارتفاعها على ٦٠٠ — فإمّا لوحةٌ صغيرة وإمّا أزرارٌ تحت
   الطيّة. والصفُّ يُعيد ١٣٠ بكسلاً إلى اللوحة. ولوحةُ المفاتيح هي
   الأصل على الحاسوب، فهذه الأزرار لمن يلعب بالفأرة. */
@media (min-width: 820px) {
  .sn-pad { grid-template-columns: repeat(4, 56px); grid-template-rows: 56px; margin: 10px auto 2px; }
  .sn-pad .left  { grid-area: 1 / 1; }
  .sn-pad .up    { grid-area: 1 / 2; }
  .sn-pad .down  { grid-area: 1 / 3; }
  .sn-pad .right { grid-area: 1 / 4; }
  .sn-pad .mid   { display: none; }
}

/* ------------------------------------------------------- الأدوات */
.sn-tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.sn-tools button {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  background: var(--tile-bg); border: 1px solid var(--tile-border); color: var(--text-primary);
}
.sn-tools button:hover:not(:disabled) { border-color: var(--accent-teal); }
.sn-tools .primary { background: var(--accent-teal-dim); border-color: var(--accent-teal); color: var(--accent-teal); }

/* ------------------------------------------------------- نهاية الجولة */
.sn-over {
  margin-top: 14px; text-align: center; padding: 18px 14px;
  background: linear-gradient(180deg, rgba(87, 232, 201, .12), var(--tile-bg));
  border: 1px solid var(--accent-teal); border-radius: var(--radius-lg);
}
.sn-over.lost { background: linear-gradient(180deg, rgba(255, 122, 138, .12), var(--tile-bg)); border-color: var(--accent-coral); }
.sn-over h3 { margin: 0 0 8px; font-size: 19px; color: var(--text-primary); }
.sn-over .score { font-size: 40px; font-weight: 800; font-family: var(--font-mono); color: var(--accent-teal); line-height: 1.1; }
.sn-over.lost .score { color: var(--accent-coral); }
.sn-over .tally { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.sn-over .extra { font-size: 13px; color: var(--accent-violet); margin-top: 6px; min-height: 18px; }
.sn-over .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.sn-over button {
  font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
  min-height: var(--touch-min); padding: 12px 24px; border-radius: 999px; border: 0;
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-violet)); color: var(--bg);
}
.sn-over button.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--tile-border); font-weight: 700; }

/* شارة «ابدأ» فوق اللوحة قبل أوّل حركة */
.sn-startcue {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; font-size: 17px; font-weight: 800; color: var(--text-primary);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .8);
}
.sn-boardbox { position: relative; display: inline-block; }

@media (max-width: 420px) {
  .sn-ask { font-size: 14px; }
  .sn-tools button { padding: 10px 12px; font-size: 12.5px; }
  .sn-chip { padding: 5px 11px; }
  .sn-pad { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); }
}
