/* سباق — نظام التصميم */
@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@500;700;800&family=Tajawal:wght@400;500;700;900&display=swap');

:root {
  --bg1: #141034;
  --bg2: #2a1e5c;
  --gold: #fbbf24;
  --gold2: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --card: rgba(255, 255, 255, 0.07);
  --card2: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f5f3ff;
  --muted: #b8b3d7;
  --radius: 18px;
  --font-head: 'Baloo Bhaijaan 2', 'Tajawal', sans-serif;
  --font-body: 'Tajawal', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(1200px 800px at 85% -10%, #4c1d95cc 0%, transparent 55%),
              radial-gradient(1000px 700px at -10% 110%, #0e7490aa 0%, transparent 55%),
              linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3, .head { font-family: var(--font-head); }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }

/* ———— مكونات عامة ———— */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-size: 1.05rem; font-weight: 700;
  color: #1c1917; background: linear-gradient(180deg, var(--gold), var(--gold2));
  border: none; border-radius: 14px; padding: 12px 22px; cursor: pointer;
  box-shadow: 0 4px 14px #f59e0b55, inset 0 1px 0 #fff6;
  transition: transform .12s, box-shadow .12s, filter .12s;
  min-height: 44px;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--card2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.red { background: linear-gradient(180deg, #f87171, #dc2626); color: #fff; box-shadow: 0 4px 14px #dc262655; }
.btn.green { background: linear-gradient(180deg, #4ade80, #16a34a); color: #052e16; box-shadow: 0 4px 14px #16a34a55; }
.btn.blue { background: linear-gradient(180deg, #60a5fa, #2563eb); color: #fff; box-shadow: 0 4px 14px #2563eb55; }
.btn.sm { padding: 7px 14px; font-size: .92rem; min-height: 36px; border-radius: 10px; }
.btn.big { font-size: 1.3rem; padding: 16px 34px; border-radius: 18px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

input, select, textarea {
  font-family: var(--font-body); font-size: 1rem; color: var(--text);
  background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #fbbf2433; }
select option { background: #241d4e; color: var(--text); }
label { font-size: .9rem; color: var(--muted); display: block; margin-bottom: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; font-weight: 500; user-select: none;
  transition: all .15s;
}
.chip.on { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1c1917; font-weight: 700; border-color: transparent; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); font-size: .95rem; }
th { color: var(--gold); font-family: var(--font-head); white-space: nowrap; }
tr:hover td { background: rgba(255,255,255,.03); }

.grid { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.center { text-align: center; }

/* ———— شعار ———— */
.logo {
  font-family: var(--font-head); font-weight: 800;
  background: linear-gradient(90deg, #fbbf24, #fde68a, #fbbf24);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 4s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }

/* ———— أنيميشن ———— */
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 24px 4px var(--glow, #fbbf2488); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.pop { animation: pop .45s cubic-bezier(.2,1.4,.4,1) both; }
.fade-up { animation: fadeUp .4s ease both; }

/* ———— مودال ———— */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,8,30,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: #241d4e; border: 1px solid var(--border); border-radius: 20px; padding: 22px; }

/* ———— توست ———— */
#toast {
  position: fixed; bottom: 24px; right: 50%; transform: translateX(50%);
  background: #241d4e; border: 1px solid var(--gold); color: var(--text);
  border-radius: 14px; padding: 12px 22px; z-index: 99; font-weight: 700;
  box-shadow: 0 8px 30px #0008; display: none;
}

/* ———— تبويبات الإدارة ———— */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab {
  font-family: var(--font-head); font-weight: 700; cursor: pointer;
  padding: 10px 20px; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
}
.tab.on { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1c1917; border-color: transparent; }

/* ———— شاشة التلفزيون ———— */
.tv-body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
.tv-scores {
  display: flex; align-items: stretch; justify-content: space-between; gap: 16px;
  padding: 14px 22px 4px;
}
.team-card {
  flex: 1; max-width: 330px; display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--border); border-radius: 20px; padding: 10px 18px;
  transition: all .3s;
}
.team-card.turn { border-color: var(--tc, var(--gold)); --glow: var(--tc); animation: pulseGlow 1.6s infinite; }
.team-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 12px var(--tc); flex: none; }
.team-name { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; line-height: 1.2; }
.team-score { font-family: var(--font-head); font-weight: 800; font-size: 2.6rem; margin-inline-start: auto; color: var(--gold); min-width: 70px; text-align: center; }
.tv-mid-title { font-family: var(--font-head); font-size: 1.6rem; text-align: center; align-self: center; color: var(--muted); }

.tv-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px 26px 26px; min-height: 0; }

/* لوحة التحدي */
.jboard { display: grid; gap: 12px; width: 100%; height: 100%; }
.jcol { display: grid; grid-template-rows: auto 1fr 1fr 1fr; gap: 12px; min-height: 0; }
.jhead {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--card2); border-radius: 16px; padding: 8px 6px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; text-align: center;
  border-top: 4px solid var(--cc, var(--gold));
}
.jhead .ic { font-size: 1.7rem; }
.jcell {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--card2), var(--card));
  border: 1px solid var(--border); border-radius: 16px;
  font-family: var(--font-head); font-weight: 800; font-size: 2.4rem; color: var(--gold);
  transition: all .25s; min-height: 0;
}
.jcell.done { opacity: .22; filter: grayscale(.8); font-size: 1.6rem; }
.jcell.won0 { border-color: var(--red); color: var(--red); }
.jcell.won1 { border-color: var(--green); color: var(--green); }

/* خلية الحروف */
.hive-wrap { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.hex-letter { font-family: var(--font-head); font-weight: 800; }

/* بطاقة السؤال */
.qcard {
  width: min(1050px, 94%); text-align: center; position: relative;
  background: linear-gradient(170deg, rgba(255,255,255,.1), rgba(255,255,255,.04));
  border: 1px solid var(--border); border-radius: 28px; padding: 40px 44px 34px;
  box-shadow: 0 20px 60px #0006;
}
.qmeta { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.qchip { background: var(--card2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 18px; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; }
.qpts { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #1c1917; }
.qtext { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.8rem, 4vw, 3.2rem); line-height: 1.5; }
.qanswer {
  margin-top: 26px; font-family: var(--font-head); font-weight: 800;
  font-size: clamp(1.6rem, 3.4vw, 2.8rem); color: var(--gold);
  border-top: 2px dashed var(--border); padding-top: 22px;
}
.timer-ring { position: absolute; top: -34px; right: 50%; transform: translateX(50%); }

/* شاشة الانتظار والفوز */
.tv-idle { text-align: center; }
.tv-idle .logo { font-size: clamp(4rem, 12vw, 9rem); }
.tv-idle .sub { font-size: 1.6rem; color: var(--muted); margin-top: 8px; }
.winner-stage { text-align: center; }
.winner-stage .crown { font-size: 6rem; animation: wiggle 1.2s infinite; display: inline-block; }
.winner-stage .wname { font-family: var(--font-head); font-size: clamp(3rem, 8vw, 6rem); font-weight: 800; }
.winner-stage .wscore { font-size: 2rem; color: var(--muted); margin-top: 10px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

/* ———— شاشة المقدم ———— */
.host-sticky { position: sticky; top: 0; z-index: 10; background: linear-gradient(180deg, #141034f2, #141034cc); backdrop-filter: blur(8px); padding: 10px 0; margin-bottom: 14px; }
.hteam { flex: 1; border-radius: 14px; padding: 10px 12px; border: 2px solid var(--border); background: var(--card); }
.hteam.turn { border-color: var(--tc); }
.hteam .nm { font-weight: 700; font-size: .95rem; }
.hteam .sc { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; color: var(--gold); }
.mini-board { display: grid; gap: 6px; }
.mini-cell {
  display: flex; align-items: center; justify-content: center; border-radius: 10px;
  background: var(--card2); border: 1px solid var(--border); cursor: pointer;
  font-family: var(--font-head); font-weight: 700; padding: 10px 4px; font-size: 1rem;
  transition: all .15s; min-height: 48px;
}
.mini-cell:hover { border-color: var(--gold); }
.mini-cell.done { opacity: .25; pointer-events: none; }
.mini-cell.owned0 { background: #ef444433; border-color: var(--red); }
.mini-cell.owned1 { background: #22c55e33; border-color: var(--green); }

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

@media (max-width: 640px) {
  .qcard { padding: 26px 18px; }
  .team-name { font-size: 1.1rem; }
  .team-score { font-size: 1.9rem; }
}
