:root {
  --bg: #0a0516;
  --bg2: #120a28;
  --panel: #1a1033;
  --panel2: #241647;
  --line: #3a2766;
  --txt: #f1ecff;
  --mut: #a396c9;
  --purple: #8b5cf6;
  --purple2: #6d28d9;
  --neon: #22d3ee;
  --gold: #fbbf24;
  --gold2: #f59e0b;
  --ok: #22c55e;
  --bad: #ef4444;
  --font: 'Inter', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 🟢 إعدادات الصفحات العامة (التمرير يعمل هنا) */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden; /* منع التمرير الأفقي فقط */
  font-family: var(--font);
}

body {
  background: radial-gradient(1100px 560px at 50% -10%, #2b1262 0, transparent 62%), var(--bg);
  color: var(--txt);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }
a { color: var(--neon); text-decoration: none; transition: 0.2s; }
a:hover { filter: brightness(1.2); }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.5px; }

.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 60px; }
.center { text-align: center; }
.mut { color: var(--mut); }
.gold { color: var(--gold); }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ==========================================
   أزرار ومدخلات
   ========================================== */
button, input, select, textarea { font-family: var(--font); font-size: 16px; }
button { cursor: pointer; border: 0; color: inherit; }

.btn {
  display: inline-block; text-align: center; text-decoration: none;
  padding: 14px 18px; border-radius: 14px; font-weight: 700;
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  transition: transform 0.1s, filter 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #2a1700; border: 0; box-shadow: 0 6px 22px rgba(251, 191, 36, 0.28); }
.btn-purple { background: linear-gradient(135deg, var(--purple), var(--purple2)); border: 0; box-shadow: 0 6px 22px rgba(139, 92, 246, 0.35); }
.btn-bad { background: #7f1d1d; border-color: #b91c1c; }
.btn-ok { background: #14532d; border-color: #16a34a; }
.btn-big { width: 100%; padding: 18px; font-size: 20px; border-radius: 16px; }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }

.input, select.input, textarea.input {
  width: 100%; padding: 15px; border-radius: 14px; border: 1px solid var(--line);
  background: #0f0824; color: var(--txt); outline: 0; transition: border-color 0.2s;
}
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
.input.code { text-align: center; letter-spacing: 6px; font-size: 24px; font-weight: 800; text-transform: uppercase; }
label.lbl { display: block; margin: 0 0 6px; color: var(--mut); font-size: 14px; font-weight: 600; }
.err { color: #fca5a5; text-align: center; min-height: 22px; font-size: 14px; }

/* ==========================================
   بطاقات عامة
   ========================================== */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.card h2 { font-size: 16px; color: var(--gold); margin-bottom: 10px; font-weight: 700; letter-spacing: 0.5px; }

.hero { padding-top: 8vh; text-align: center; }
.logo { font-size: 60px; filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.8)); }
.title {
  font-size: clamp(32px, 5vw, 44px); font-weight: 900; margin: 10px 0;
  background: linear-gradient(90deg, var(--gold), var(--neon), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { color: var(--mut); margin: 0 0 28px; font-size: 16px; }

dialog { background: var(--panel); color: var(--txt); border: 1px solid var(--line); border-radius: 18px; max-width: 440px; width: 92%; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
dialog::backdrop { background: rgba(5, 2, 15, 0.85); backdrop-filter: blur(4px); }
dialog ol { padding-left: 20px; line-height: 1.8; margin: 10px 0 16px; font-size: 15px; }

/* ==========================================
   واجهة اللاعب (الهاتف)
   ========================================== */
.hud {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 85%, transparent);
  padding: 10px 0 15px;
}
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hud .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48%; font-size: 18px; }
.hud .sc { color: var(--gold); font-weight: 900; font-size: 20px; }
.hearts { font-size: 22px; letter-spacing: 2px; margin-top: 6px; min-height: 30px; }
.streak { color: var(--neon); font-size: 13px; font-weight: 700; margin-top: 4px; }

.tbar { height: 12px; border-radius: 99px; background: #1b1138; border: 1px solid var(--line); overflow: hidden; margin-top: 8px; }
.tbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--neon), var(--purple)); transform-origin: left; will-change: width; transition: width 0.3s linear; }
.tbar.low i { background: linear-gradient(90deg, #f97316, var(--bad)); }

.qno { text-align: center; color: var(--mut); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-top: 10px; }
.qtext { font-size: 22px; font-weight: 800; text-align: center; line-height: 1.5; padding: 15px 5px; }

.opts { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.opt {
  min-height: 65px; padding: 15px 16px; border-radius: 16px;
  font-size: 18px; font-weight: 700; color: #fff; border: 2px solid transparent;
  text-align: left; display: flex; align-items: center; gap: 14px;
  transition: transform 0.1s, filter 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.opt b { display: inline-grid; place-items: center; min-width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,0.25); font-size: 16px; }
.opt:nth-child(1) { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.opt:nth-child(2) { background: linear-gradient(135deg, #0891b2, #155e75); }
.opt:nth-child(3) { background: linear-gradient(135deg, #d97706, #92400e); }
.opt:active:not(:disabled) { transform: scale(0.97); }
.opt:disabled { filter: saturate(0.3) brightness(0.6); cursor: default; }
.opt.correct { background: linear-gradient(135deg, #16a34a, #15803d) !important; border-color: #86efac; box-shadow: 0 0 20px rgba(34, 197, 94, 0.5); }
.opt.wrong { background: linear-gradient(135deg, #dc2626, #991b1b) !important; border-color: #fca5a5; box-shadow: 0 0 20px rgba(239, 68, 68, 0.5); }
.opt.picked { outline: 3px solid var(--gold); }

.msg { text-align: center; min-height: 50px; font-size: 17px; font-weight: 700; margin-top: 15px; }
.msg small { display: block; color: var(--mut); font-weight: 400; font-size: 14px; margin-top: 4px; }
.explain { background: #0f0824; border: 1px dashed var(--line); border-radius: 14px; padding: 12px; color: var(--mut); font-size: 15px; margin-top: 10px; line-height: 1.5; }
.banner { background: #2b1262; border: 1px solid var(--purple); border-radius: 12px; padding: 12px; text-align: center; font-weight: 700; color: var(--neon); margin-bottom: 15px; }

/* شبكة الشخصيات */
.chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.char { position: relative; padding: 0; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; overflow: hidden; aspect-ratio: 1 / 1; transition: 0.2s; }
.char img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.char span { position: absolute; inset: auto 0 0 0; padding: 6px 4px; background: linear-gradient(transparent, rgba(5,2,15,0.95)); font-weight: 700; font-size: 11px; text-align: center; }
.char.taken { filter: grayscale(1) brightness(0.4); pointer-events: none; }
.char.taken::after { content: "Taken"; position: absolute; top: 8px; right: 8px; background: #000a; padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: bold; }
.char.mine { border-color: var(--gold); box-shadow: 0 0 15px rgba(251, 191, 36, 0.4); }

.avatar { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; object-position: top; border: 3px solid var(--gold); box-shadow: 0 0 20px rgba(251,191,36,0.3); margin: 0 auto; display: block; }
.chip img, .lb img, .tavatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: top; border: 2px solid var(--purple); }

.spin { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--purple); animation: sp 1s linear infinite; margin: 0 auto; }
@keyframes sp { to { transform: rotate(360deg); } }

/* القوائم والترتيب */
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb li { display: flex; align-items: center; gap: 10px; background: #0f0824; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.lb .n { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lb .l { font-size: 13px; color: var(--mut); }
.lb .s { color: var(--gold); font-weight: 900; font-size: 15px; }
.lb li.out { opacity: 0.4; }

/* التأثيرات الصوتية والبصرية */
.shake { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-5px); } }
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle, transparent 30%, rgba(239, 68, 68, 0.45)); opacity: 0; z-index: 99; }
#flash.on { animation: flash 0.6s; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.pop { animation: pop 0.4s; }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 60% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
#conn { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #3a1a1e; color: #fecaca; border: 1px solid #7f1d1d; padding: 10px 16px; border-radius: 99px; font-size: 13px; z-index: 100; font-weight: bold; }
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--purple); padding: 12px 20px; border-radius: 99px; z-index: 100; font-weight: 700; box-shadow: 0 4px 15px rgba(0,0,0,0.4); }

/* ==========================================
   شاشة العرض (Projector) - الفصل التام
   ========================================== */
.arena-body {
  background: linear-gradient(rgba(10, 5, 22, 0.65), rgba(10, 5, 22, 0.85)), url(../images/backgrounds/arena_bg.jpg) center/cover fixed, var(--bg);
  min-height: 100vh;
  overflow-y: auto; /* 🟢 السماح بالتمرير في صفحة النتائج */
}

/* 🟢 كلاس جديد مخصص فقط لشاشة العرض لمنع التمرير وتثبيت الشاشة */
/* 🟢 كلاس جديد مخصص فقط لشاشة العرض لمنع التمرير */
.screen-fixed {
  height: 100vh !important;
  width: 100vw !important;
  overflow: hidden !important;
  position: fixed;
  top: 0; left: 0;
}

.lobby-screen {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 10px; text-align: center; overflow: hidden;
}
.room-code { font-size: clamp(60px, 10vw, 130px); font-weight: 900; letter-spacing: 0.1em; color: var(--gold); text-shadow: 0 0 30px rgba(251, 191, 36, 0.4); line-height: 1; }
.join-url { font-size: clamp(16px, 2vw, 28px); color: var(--neon); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 1200px; }
.chip { display: flex; align-items: center; gap: 10px; background: rgba(26,16,51,0.9); border: 1px solid var(--line); border-radius: 99px; padding: 6px 16px 6px 8px; font-weight: 700; animation: pop 0.3s; }

.arena {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 20px; padding: 20px 30px; height: 100vh;
  box-sizing: border-box; overflow: hidden;
}

.side { display: flex; flex-direction: column; gap: 15px; height: 100%; overflow: hidden; }
.side .card { background: rgba(26, 16, 51, 0.85); backdrop-filter: blur(8px); border-radius: 16px; padding: 15px; }

.main { display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 100%; width: 100%; overflow: hidden; padding-bottom: 10px; }

.sq-head { display: flex; justify-content: space-between; width: 100%; max-width: 1000px; font-size: 18px; color: var(--mut); font-weight: 600; flex-shrink: 0; margin-bottom: 5px; }

/* السؤال */
.sq-text {
  font-size: clamp(20px, 2.2vw, 36px); 
  font-weight: 800; text-align: center; line-height: 1.4;
  max-width: 1100px; text-shadow: 0 4px 15px rgba(0,0,0,0.5);
  padding: 15px; width: 100%; box-sizing: border-box;
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; 
}
.sq-text::-webkit-scrollbar { width: 6px; }
.sq-text::-webkit-scrollbar-track { background: transparent; }
.sq-text::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 10px; }

.ring { position: relative; width: clamp(90px, 10vw, 130px); aspect-ratio: 1; flex-shrink: 0; margin: 5px 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: #2a1a52; }
.ring .fg { stroke: var(--neon); stroke-linecap: round; stroke-dasharray: 339.292; stroke-dashoffset: 0; filter: drop-shadow(0 0 10px var(--neon)); }
.ring.low .fg { stroke: var(--bad); filter: drop-shadow(0 0 10px var(--bad)); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(30px, 3.5vw, 50px); font-weight: 900; }
.ring.low .num { color: var(--bad); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

.sopts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; width: 100%; max-width: 1100px; flex-shrink: 0; margin-top: 10px; }
.sopt {
  padding: 18px 15px; border-radius: 16px;
  font-size: clamp(16px, 1.8vw, 26px); 
  font-weight: 800; text-align: center; border: 3px solid transparent; transition: all 0.3s;
}
.sopt:nth-child(1) { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.sopt:nth-child(2) { background: linear-gradient(135deg, #0891b2, #155e75); }
.sopt:nth-child(3) { background: linear-gradient(135deg, #d97706, #92400e); }
.sopt.dim { opacity: 0.3; filter: grayscale(0.6); }
.sopt.correct { background: linear-gradient(135deg, #16a34a, #15803d) !important; border-color: #86efac; box-shadow: 0 0 30px rgba(34, 197, 94, 0.6); transform: scale(1.02); }

.s-explain { font-size: clamp(14px, 1.5vw, 20px); color: #d9ccff; background: rgba(15, 8, 36, 0.9); border-radius: 12px; padding: 10px 20px; max-width: 900px; text-align: center; flex-shrink: 0; margin-bottom: 5px; }

.feed { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; }
.feed::-webkit-scrollbar { display: none; }
.feed div { background: #3a1a1e; border: 1px solid #7f1d1d; color: #fecaca; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 14px; animation: slidein 0.4s; }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.alive { font-size: 16px; color: var(--mut); font-weight: 600; margin-top: 5px; }
.alive b { color: var(--ok); }

/* ==========================================
   المنصة (Podium) والنتائج
   ========================================== */
.podium-wrap { max-width: 900px; margin: 0 auto; padding: 20px 14px 60px; }
.podium { 
  display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 15px; align-items: end; margin: 20px 0; width: 100%; max-width: 800px; margin-left: auto; margin-right: auto;
}
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0; animation: rise 0.9s forwards; }
.pod .av { width: clamp(60px, 10vw, 100px); aspect-ratio: 3/4; border-radius: 16px; object-fit: cover; object-position: top; border: 3px solid var(--purple); background: var(--panel); }
.pod .nm { font-weight: 900; font-size: clamp(16px, 2vw, 22px); text-align: center; overflow-wrap: anywhere; }
.pod .pt { color: var(--gold); font-weight: 900; font-size: 18px; }
.pod .base { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: clamp(30px, 5vw, 50px); font-weight: 900; color: #1a0f00; }
.pod.p1 .base { height: 120px; background: linear-gradient(var(--gold), var(--gold2)); }
.pod.p1 .av { border-color: var(--gold); box-shadow: 0 0 40px rgba(251, 191, 36, 0.6); }
.pod.p2 .base { height: 90px; background: linear-gradient(#e5e7eb, #9ca3af); }
.pod.p3 .base { height: 60px; background: linear-gradient(#d6935a, #92562c); }
.pod.p3 { animation-delay: 0.3s; }
.pod.p2 { animation-delay: 1.2s; }
.pod.p1 { animation-delay: 2.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(50px) scale(0.9); } to { opacity: 1; transform: none; } }

.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 40; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.rank-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.rank-table td, .rank-table th { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 15px; }
.rank-table th { color: var(--mut); font-weight: 600; font-size: 14px; }
.rank-table tr.me { background: rgba(251, 191, 36, 0.15); }

.rev { border: 1px solid var(--line); border-radius: 14px; padding: 15px; margin-bottom: 15px; background: var(--panel); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.rev h3 { font-size: 16px; margin-bottom: 10px; font-weight: 700; line-height: 1.4; }
.rev .o { padding: 8px 12px; border-radius: 10px; margin: 6px 0; background: #0f0824; font-size: 15px; }
.rev .o.ok { background: rgba(20, 83, 45, 0.5); border: 1px solid #16a34a; }
.rev .o.mine-bad { background: rgba(127, 29, 29, 0.5); border: 1px solid #b91c1c; }
.rev .ex { color: var(--neon); font-size: 14px; margin-top: 8px; font-style: italic; }

/* ==========================================
   لوحة التحكم (Admin)
   ========================================== */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 20px 14px 60px; }
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.admin-nav a { padding: 10px 16px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; color: var(--mut); transition: 0.2s; }
.admin-nav a:hover { filter: brightness(1.2); }
.admin-nav a.on { background: var(--purple2); color: #fff; border-color: var(--purple); box-shadow: 0 0 15px rgba(109, 40, 217, 0.4); }
.admin-nav a.out { margin-left: auto; color: #fca5a5; border-color: #7f1d1d; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid3, .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 15px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.tile b { display: block; font-size: 24px; color: var(--gold); margin-bottom: 4px; }
.tile span { font-size: 12px; color: var(--mut); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #2a1a52; color: #c4b5fd; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--mut); font-weight: 600; font-size: 13px; text-transform: uppercase; }

@media (max-width: 768px) {
  .arena { grid-template-columns: 1fr; padding: 10px; }
  .side { display: none; }
  .main { order: 1; }
  .sopts { grid-template-columns: 1fr; gap: 10px; }
}