/* ============================================
   التصميم العام - دعم RTL كامل
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, "Cairo", sans-serif;
  direction: rtl;
  background: #1a1a2e;
  color: #eaeaea;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.hidden {
  display: none !important;
}

/* ---- الرأس ---- */
header {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 22px;
  font-weight: 600;
}

.score-badge {
  background: #2d2d44;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
}

#score-value {
  font-weight: bold;
  color: #ffd700;
}

/* ---- اختيار المستوى ---- */
#level-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 480px;
}

.level-card {
  background: #2d2d44;
  border: none;
  border-radius: 12px;
  padding: 20px;
  color: #eaeaea;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.level-card:hover:not(.locked) {
  background: #3a3a5c;
  transform: translateY(-2px);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-number {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.level-progress {
  font-size: 13px;
  color: #b0b0c0;
}

/* ---- شاشة اللغز ---- */
#puzzle-screen {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.puzzle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}

#puzzle-level-label {
  font-size: 14px;
  color: #b0b0c0;
}

#puzzle-objective {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.icon-btn {
  background: #2d2d44;
  border: none;
  border-radius: 8px;
  color: #eaeaea;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.icon-btn:hover {
  background: #3a3a5c;
}

/* ---- الرقعة ---- */
#chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  border: 3px solid #44446a;
  border-radius: 8px;
  overflow: hidden;
  direction: ltr; /* الرقعة نفسها تبقى LTR لأن الشطرنج عالمي */
}

.square {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 7vw, 36px);
  cursor: pointer;
  user-select: none;
}

.square.light {
  background: #eeedf6;
  color: #1a1a2e;
}

.square.dark {
  background: #7a77b8;
  color: #1a1a2e;
}

.square.selected {
  background: #ffd700 !important;
}

/* ---- رسائل الحالة ---- */
.status-message {
  min-height: 24px;
  margin-top: 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.status-message.success {
  color: #4ade80;
}

.status-message.error {
  color: #f87171;
}

/* ---- زر اللغز التالي ---- */
#next-puzzle-btn {
  margin-top: 16px;
  background: #4ade80;
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

#next-puzzle-btn:hover {
  background: #3ec76e;
}

/* ---- مؤشر التحميل ---- */
#loading-indicator {
  text-align: center;
  padding: 40px;
  color: #b0b0c0;
}

.puzzle-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
