/* style.css */

/* تعريفات الخطوط مع تحسين الأداء */
@font-face {
  font-family: 'ltBukraBold';
  src: url('fonts/29ltbukrabold.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'AlHurraBold';
  src: url('fonts/AlHurraFontBold.ttf') format('truetype');
  font-display: swap;
}

/* الخلفية العامة */
body {
  background: url('img/bb.png') no-repeat center center fixed;
  background-size: cover;
  image-rendering: auto;
  margin: 0;
  padding: 10px;
  padding-top: 10px;
  text-align: center;
  font-family: ltBukraBold, sans-serif;
  box-sizing: border-box;
  padding-bottom: 30px;
}

/* اللوقو */
#logo {
  top: 10px;
  left: 50%;
  width: clamp(250px, 95vw, 1200px);
  height: auto;
  z-index: 1000;
}

/* إخفاء العناصر */
.hidden {
  display: none;
}

/* جدول الإعدادات */
.settingsTable {
  width: 95%;
  max-width: 600px;
  margin: 0 auto 20px;
  overflow-x: auto;
  border-collapse: separate;
  border: 2px solid #000;
  border-radius: 8px;
  padding: 2px;
}
.settingsTable td {
  padding: 8px 1px;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  white-space: nowrap;
}
.settingsTable .title {
  white-space: nowrap;
}
.settingsTable .mySelect {
  min-width: 50px;
  background: #3f617e8e;
  font-weight: bold;
  text-align: center;
}
.settingsTable .startBtn {
  background: #28a745;
  color: #fff;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: 8px;
  text-align: center;
  white-space: nowrap;
  font-size: inherit;
}

#settings {
  padding-bottom: 90%;
}

/* شبكة البطاقات */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  margin: 20px auto;
  padding: 0 10px;
  box-sizing: border-box;
}

/* خلية البطاقة */
.cell {
  position: relative;
  width: 100%;
  padding-top: 100%;
  overflow: hidden;
  cursor: pointer;
  perspective: 1000px;
}
.cell .card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease-in-out;
  transform-origin: center center;
}
.cell .card .front,
.cell .card .back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.cell .card .front {
  transform: rotateY(0deg);
  z-index: 2;
  background-size: cover;
  background-position: center;
}
.cell .card .front .number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cell .card .back {
  transform: rotateY(180deg);
  z-index: 1;
  background-color: #fff;
  border-radius: 10px;
}
.cell .card .back .card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.cell .card.flipped {
  transform: rotateY(180deg);
}

/* الفرق والنقاط */
.teams {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
  padding: 0 10px;
  box-sizing: border-box;
  overflow-x: auto;
  padding-top: 20px;
}
.team-box {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.team-box .name,
.team-box .score {
  padding: 2px 4px;
  font-size: clamp(0.8rem, 2vw, 1rem);
  box-sizing: border-box;
}
.team-box .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.5rem, 1.5vw, 1rem);
}
.team-box.current .name,
.team-box.current .score {
  background: #3f617e9d;
  color: #fff;
}
.team-box.current {
  background: #3f617e9d;
  color: #fff;
  border-radius: 6px;
  overflow: hidden;
}

/* رابط المشاهدة */
#watchLink {
  flex: 0 0 auto;
  margin: 0 3px;
  display: inline-block;
  max-width: 180px;
  width: 90%;
  font-size: 0.7rem;
  padding: 2px 5px;
  color: #fff;
  background: none;
  border: 1px solid #105c8849;
  border-radius: 4px;
  text-align: center;
}

/* الفوتر */
.footer {
  color: #fff;
  padding: 8px 16px;
  font-size: 10px;
  font-family: ltBukraBold, sans-serif;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
.footer .balloon {
  margin-left: 4px;
  font-size: 20px;
}

/* عناصر التحكم */
.controls {
  width: 99% !important;
  margin: 0 auto;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 0 10px !important;
  box-sizing: border-box;
  overflow-x: hidden !important;
}
.controls .skip-btn,
.controls .update-btn,
.controls #watchLink {
  box-shadow: none !important;
  outline: none !important;
}
.controls .skip-btn,
.controls .update-btn {
  flex: 0 0 auto;
  background: yellow;
  border: none;
  padding: 4px 7px;
  min-width: clamp(40px, 15vw, 80px);
  font-size: clamp(0.7rem, 1.5vw, 1rem);
  cursor: pointer;
  font-weight: bold;
  border-radius: 4px;
  box-shadow: none !important;
}

/* صندوق المحتوى */
*,
*::before,
*::after {
  box-sizing: inherit;
}

/* توزيع عناصر التحكم حسب الدور */
.controls.creator {
  justify-content: space-between;
}
.controls.spectator {
  justify-content: center;
}

.front {
  direction: ltr;
}