@font-face {
            font-family: 'AAGalaxy';
            src: url('../../fonts/AA-GALAXY.otf') format('opentype');
            /* تطبيق الخط على الحروف فقط واستثناء الأرقام الإنجليزية والعربية */
            unicode-range: U+0000-002F, U+003A-065F, U+066A-06EF, U+06FA-FFFF;
        }

        /* ========================================= */
        /* 1. التنسيقات العامة */
        /* ========================================= */
        * {
            box-sizing: border-box;
            user-select: none;
        }

        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            overflow: hidden;
            background-color: #111; /* لون داكن للاستوديو */
        }

        .app-container {
            display: flex;
            width: 100%;
            height: 100%;
        }

        /* ========================================= */
        /* 2. الشريط الجانبي الأيمن (Sidebar) */
        /* ========================================= */
        .sidebar {
            width: 32%; 
            min-width: 280px; 
            height: 100%;
            background-color: #6d4596; 
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 40px 20px;
            position: relative;
            z-index: 10;
            box-shadow: -10px 0 30px rgba(0,0,0,0.5);
        }

        .menu-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 45px;
            height: 45px;
            background-color: #fff;
            border-radius: 10px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 6px;
            cursor: pointer;
            box-shadow: 0 4px 10px rgba(0,0,0,0.2);
            transition: transform 0.2s;
            z-index: 50;
        }
        .menu-btn:hover { transform: scale(1.05); }
        .menu-btn span {
            width: 25px;
            height: 4px;
            background-color: #6d4596;
            border-radius: 5px;
        }

        .round-title-container {
            margin-top: 60px; 
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px; 
            transform: rotate(-5deg); 
        }

        .round-word {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 6.3rem; 
            line-height: 0.9; 
            text-align: center;
        }

        .word-aljawla {
            color: #e94f4a;
            text-shadow: 
                1px 1px 0 #4a0e0e, 2px 2px 0 #4a0e0e, 3px 3px 0 #4a0e0e,
                4px 4px 0 #4a0e0e, 5px 5px 0 #4a0e0e, 6px 6px 0 #4a0e0e,
                7px 7px 0 #4a0e0e, 8px 8px 0 #4a0e0e, 9px 9px 0 #4a0e0e,
                10px 10px 15px rgba(0,0,0,0.5);
        }

        .word-number {
            color: #ffdd00;
            text-shadow: 
                1px 1px 0 #8b6b00, 2px 2px 0 #8b6b00, 3px 3px 0 #8b6b00,
                4px 4px 0 #8b6b00, 5px 5px 0 #8b6b00, 6px 6px 0 #8b6b00,
                7px 7px 0 #8b6b00, 8px 8px 0 #8b6b00, 9px 9px 0 #8b6b00,
                10px 10px 15px rgba(0,0,0,0.5);
            transform: translateX(-40px); /* إزاحة الكلمة إلى اليسار قليلاً */
        }

        /* ========================================= */
        /* مربع عرض السؤال (ثابت) */
        /* ========================================= */
        .question-display-container {
            margin: auto 0; 
            background: rgba(0, 0, 0, 0.4);
            border: 2px solid rgba(255, 255, 255, 0.15);
            border-radius: 16px;
            padding: 10px 20px; 
            text-align: center;
            box-shadow: inset 0 0 30px rgba(0,0,0,0.6), 0 8px 20px rgba(0,0,0,0.3);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            
            /* تحديد أبعاد ثابتة لتجنب التمدد المزعج */
            height: 170px; 
            max-width: 800px;
            width: 100%; 
            position: relative;
            z-index: 5;
            overflow: hidden; /* Prevent text spilling out */
            container-type: inline-size;
        }

        /* عندما لا يكون هناك سؤال معروض، نحافظ على نفس المساحة لكي لا تقفز العناصر */
        .question-placeholder-space {
            height: 170px; 
            margin: auto 0;
            display: block;
            width: 100%;
        }

        body.host-mode .question-display-container,
        body.host-mode .question-placeholder-space {
            display: none !important;
        }

        .question-label {
            color: #ffdd00;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 1.1rem;
            margin-bottom: 10px;
            opacity: 0.9;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }

        .question-text {
            color: #ffffff;
            font-family: 'Tajawal', sans-serif;
            font-size: min(1.6rem, 5cqw);
            font-weight: 700;
            line-height: 1.4;
            text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 100%;
            margin-bottom: 5px;
        }

        /* أنيميشن دخول السؤال */
        .question-animate-enter {
            animation: questionEnter 0.5s cubic-bezier(0.34,1.4,0.64,1) both;
        }

        @keyframes questionEnter {
            from { opacity: 0; transform: scale(0.9) translateY(-10px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        .answer-box {
            flex: 1;
            background: rgba(255, 255, 255, 0.05);
            border: 1px dashed rgba(255, 255, 255, 0.3);
            border-radius: 8px;
            padding: 8px 15px;
            cursor: pointer;
            font-family: 'Tajawal', sans-serif;
            font-size: 1.2rem;
            color: #ccc;
            transition: all 0.2s;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 45px;
        }
        .answer-box:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #fff;
        }
        .answer-box.revealed {
            border-color: #43b047;
            background: rgba(67, 176, 71, 0.1);
            cursor: default;
            color: #43b047;
        }
        .icon-only-btn {
            background: transparent;
            border: none;
            padding: 0;
            margin: 0;
            font-size: 1.8rem;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-shrink: 0;
            transition: transform 0.2s, filter 0.2s;
            outline: none;
        }
        .icon-only-btn:hover {
            transform: scale(1.1) rotate(15deg);
            filter: brightness(1.2);
        }
        .icon-only-btn:active {
            transform: scale(0.9);
        }

        .scores-container {
            margin-top: 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 16px; 
            padding-bottom: 30px;
        }

        .score-pill {
            border-radius: 16px;
            height: 100px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            padding: 0 18px;
            gap: 16px;
            position: relative;
            overflow: hidden;
        }

        .score-pill.green-pill {
            background: linear-gradient(135deg, #2e7d32 0%, #43a047 60%, #4caf50 100%);
            border: 2px solid rgba(130, 195, 65, 0.7);
            box-shadow: 0 8px 32px rgba(67,176,71,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
        }

        .score-pill.orange-pill {
            background: linear-gradient(135deg, #d84315 0%, #e64a19 60%, #f4511e 100%);
            border: 2px solid rgba(244, 123, 32, 0.7);
            box-shadow: 0 8px 32px rgba(244,123,32,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
        }

        /* خط ضوئي علوي */
        .score-pill::before {
            content: '';
            position: absolute;
            top: 0; left: 10%; right: 10%;
            height: 1px;
            border-radius: 50%;
        }
        .score-pill.green-pill::before {
            background: linear-gradient(90deg, transparent, rgba(130,195,65,0.6), transparent);
        }
        .score-pill.orange-pill::before {
            background: linear-gradient(90deg, transparent, rgba(244,123,32,0.6), transparent);
        }

        /* توهج خلفي */
        .score-pill::after {
            content: '';
            position: absolute;
            bottom: -30px; right: 20px;
            width: 80px; height: 80px;
            border-radius: 50%;
            filter: blur(25px);
            opacity: 0.25;
            pointer-events: none;
        }
        .score-pill.green-pill::after { background: #82c341; }
        .score-pill.orange-pill::after { background: #f47b20; }

        /* السداسي الجديد - على اليسار */
        .score-hex-wrap {
            position: relative;
            width: 72px;
            height: 72px;
            flex-shrink: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .score-hex-svg {
            width: 72px;
            height: 72px;
            filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
        }

        .score-hex-value {
            position: absolute;
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 2rem;
            color: #ffffff;
            line-height: 1;
            padding-top: 3px;
            text-shadow: 0 1px 4px rgba(0,0,0,0.5);
        }

        /* معلومات الفريق */
        .team-info {
            display: flex;
            flex-direction: column;
            justify-content: center;
            gap: 4px;
            flex: 1;
        }

        .team-label {
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 0.8rem;
            font-weight: 700;
            letter-spacing: 0.15em;
            opacity: 0.85;
        }
        .green-pill .team-label { color: #a8e063; }
        .orange-pill .team-label { color: #ffaa55; }

        .team-name {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 2.8rem;
            font-weight: normal;
            line-height: 1;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
        }
        .team-name.green-text { 
            color: #ffffff; 
            text-shadow: 0 0 12px #4caf50, 0 0 24px #4caf50, 2px 2px 4px rgba(0,0,0,0.5);
        }
        .team-name.orange-text { 
            color: #ffffff; 
            text-shadow: 0 0 12px #f4511e, 0 0 24px #f4511e, 2px 2px 4px rgba(0,0,0,0.5);
        }

        /* شريط النقاط السفلي */
        .score-bar-track {
            position: absolute;
            bottom: 0; left: 0; right: 0;
            height: 6px;
            background: rgba(0,0,0,0.4);
            border-radius: 0 0 16px 16px;
            overflow: hidden;
            box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
        }
        .score-bar-fill {
            height: 100%;
            width: 0%;
            border-radius: 0 0 16px 16px;
            transition: width 0.5s ease;
            box-shadow: 0 0 10px rgba(255,255,255,0.4);
        }
        .green-pill .score-bar-fill { background: linear-gradient(90deg, #43b047, #a8e063); }
        .orange-pill .score-bar-fill { background: linear-gradient(90deg, #f47b20, #ffdd55); }

        /* ========================================= */
        /* 3. منطقة اللعب اليسرى (Game Area) */
        /* ========================================= */
        .game-area {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
            /* نقلنا الخلفية المتقاطعة هنا لتملأ المساحة بالكامل بدون أي مربع أسود */
            background: conic-gradient(from 315deg,
                #43b047 0deg 90deg,     
                #f47b20 90deg 180deg,   
                #43b047 180deg 270deg,  
                #f47b20 270deg 360deg   
            );
            background-position: center;
            overflow: hidden;
            padding: 20px;
        }

        .svg-board-wrapper {
            transform: scale(0.92); 
            transition: transform 0.3s ease-out;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
        }

        /* مؤشرات الاتجاه على حواف اللوحة */
        .direction-hint {
            position: absolute;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 0.85rem;
            font-weight: 900;
            letter-spacing: 0.05em;
            padding: 4px 10px;
            border-radius: 20px;
            pointer-events: none;
            z-index: 5;
            opacity: 0.9;
        }
        .green-hint {
            background: rgba(67,176,71,0.2);
            color: #a8e063;
            border: 1px solid rgba(130,195,65,0.4);
        }
        .orange-hint {
            background: rgba(244,123,32,0.2);
            color: #ffaa55;
            border: 1px solid rgba(244,123,32,0.4);
        }
        .top-hint    { top: 6px;    left: 50%; transform: translateX(-50%); }
        .bottom-hint { bottom: 6px; left: 50%; transform: translateX(-50%); }
        .right-hint  { right: 6px;  top: 50%;  transform: translateY(-50%) rotate(90deg); }
        .left-hint   { left: 6px;   top: 50%;  transform: translateY(-50%) rotate(90deg); }

        /* ========================================= */
        /* 4. تصميم الشكل السداسي (SVG) */
        /* ========================================= */
        .hex-group {
            cursor: pointer;
        }

        .hex-polygon, .hex-text {
            transform-origin: 0px 0px;
            /* الإخفاء الافتراضي حتى لا تظهر الخلية قبل بدء الأنيميشن */
            opacity: 0;
            transition: fill 0.2s, opacity 0.3s; /* إضافة opacity للـ transition ليظهر النص بسلاسة */
        }

        /* عندما لا تكون هناك حركة دخول ولا خروج، اجعل الشفافية 1 بقوة */
        .hex-group.visible-hex .hex-polygon,
        .hex-group.visible-hex .hex-text,
        body.host-mode .hex-group .hex-polygon,
        body.host-mode .hex-group .hex-text,
        .hex-text {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }

        .hex-animate-enter .hex-polygon,
        .hex-animate-enter .hex-text {
            animation: hexEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay, 0s) both;
            opacity: 1 !important; /* تأكيد إظهارها مع الأنيميشن */
        }

        .hex-animate-flip .hex-polygon,
        .hex-animate-flip .hex-text {
            animation: hexFlip 0.5s ease-in-out var(--delay, 0s) both;
        }

        @keyframes hexEnter {
            from { opacity: 0; transform: scale(0) rotate(-30deg); }
            to { opacity: 1; transform: scale(1) rotate(0deg); }
        }

        @keyframes hexFlip {
            0% { transform: scale(1) rotateY(0deg); }
            50% { transform: scale(0.8) rotateY(90deg); opacity: 0.5; }
            100% { transform: scale(1) rotateY(0deg); opacity: 1; }
        }

        .hex-polygon {
            fill: #ffffff;
            stroke: #6d4596;
            stroke-width: 4px; 
            stroke-linejoin: round; 
            /* أزلنا transition: all 0.2s من هنا، وضعنا transition: fill 0.2s في الكلاس الأعلى */
        }

        .hex-text {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 38px;
            fill: #6d4596;
            text-anchor: middle;
            dominant-baseline: central;
            pointer-events: none; 
            /* أزلنا transition: all 0.2s من هنا */
        }

        .hex-group:hover .hex-polygon {
            filter: brightness(0.9);
        }

        /* الحفاظ على لون الإطار وتغيير الخلفية فقط */
        /* أنيميشن الوميض للخلية الصفراء */
        @keyframes pulse-yellow {
            0% { filter: drop-shadow(0 0 5px rgba(255,221,0,0.5)) brightness(1); }
            50% { filter: drop-shadow(0 0 25px rgba(255,221,0,1)) brightness(1.2); }
            100% { filter: drop-shadow(0 0 5px rgba(255,221,0,0.5)) brightness(1); }
        }

        .hex-group.state-selected .hex-polygon {
            fill: #ffdd00 !important;
            animation: pulse-yellow 1.5s infinite; /* تشغيل تأثير الوميض باستمرار */
        }
        .hex-group.state-selected .hex-text {
            fill: #4a148c !important;
        }
        .hex-group.state-green .hex-polygon { fill: #43b047; }
        .hex-group.state-green .hex-text { fill: #ffffff; }
        .hex-group.state-orange .hex-polygon { fill: #f47b20; }
        .hex-group.state-orange .hex-text { fill: #ffffff; }

        /* حقول تغيير اسم الفريق */
        .team-name-input {
            width: 100%;
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.15);
            border-radius: 8px;
            padding: 10px 12px;
            color: #fff;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 1rem;
            font-weight: 700;
            outline: none;
            transition: border-color 0.2s, background 0.2s;
            text-align: right;
        }
        .team-name-input:focus {
            border-color: rgba(255,255,255,0.4);
            background: rgba(255,255,255,0.12);
        }
        .team-name-input.green-input { border-left: 3px solid #82c341; }
        .team-name-input.orange-input { border-left: 3px solid #f47b20; }
        .input-label {
            font-size: 0.8rem;
            color: #aaa;
            margin-bottom: 5px;
            display: block;
        }
        .admin-panel {
            position: fixed;
            top: 0;
            left: -350px; 
            width: 320px;
            height: 100vh;
            background: rgba(25, 25, 35, 0.95);
            backdrop-filter: blur(15px);
            z-index: 200;
            box-shadow: 10px 0 30px rgba(0,0,0,0.6);
            transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            color: #fff;
            overflow-y: auto;
        }
        .admin-panel.active { left: 0; }
        .admin-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 20px; background: rgba(0,0,0,0.2); border-bottom: 1px solid rgba(255,255,255,0.05);
        }
        .admin-header h2 { margin: 0; font-size: 1.4rem; color: #ffdd00; display: flex; align-items: center; gap: 8px;}
        .close-admin-btn { background: transparent; border: none; color: #aaa; font-size: 2rem; cursor: pointer; transition: 0.2s; line-height: 1;}
        .close-admin-btn:hover { color: #fff; transform: scale(1.1); }
        .admin-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
        .admin-card { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 15px;}
        .admin-card h3 { margin: 0 0 15px 0; font-size: 1rem; color: #ccc; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px; display: flex; justify-content: space-between;}
        .btn-group { display: flex; gap: 8px; }
        .btn-group-col { display: flex; flex-direction: column; gap: 8px; }
        .btn-sm { flex: 1; padding: 10px; border-radius: 8px; border: none; font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 5px; color: #fff;}
        .btn-sm:hover { filter: brightness(1.2); transform: translateY(-1px); }
        .btn-sm:active { transform: translateY(1px); }
        .btn-dark { background: #3a3b40; }
        .btn-green { background: #43b047; }
        .btn-orange { background: #f47b20; }
        .btn-purple { background: #6d4596; }
        .btn-outline { background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #eee; }
        .btn-outline:hover { background: rgba(255,255,255,0.1); }
        .score-ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
        .team-ctrl-label { display: block; font-size: 0.9rem; margin-bottom: 8px; font-weight: bold; }

        /* ========================================= */
        /* 6. شاشة الفوز - أشعة دوارة تلفزيونية    */
        /* ========================================= */
        .celebration-overlay {
            display: none;
            position: fixed; inset: 0; z-index: 300;
            justify-content: center; align-items: center;
            overflow: hidden;
        }

        /* المحتوى فوق الـ Canvas */
        .win-content {
            position: relative; z-index: 2;
            display: flex; flex-direction: column; align-items: center;
            gap: 8px;
            text-align: center;
        }

        /* الكأس */
        .win-trophy {
            filter: drop-shadow(0 0 30px rgba(255,214,0,0.9));
            animation: trophyPop 0.7s cubic-bezier(0.34,1.56,0.64,1) both,
                       trophyFloat 2.5s ease-in-out 0.7s infinite;
        }
        @keyframes trophyPop {
            from { opacity:0; transform: scale(0) rotate(-15deg); }
            to   { opacity:1; transform: scale(1) rotate(0deg); }
        }
        @keyframes trophyFloat {
            0%,100% { transform: translateY(0); }
            50%      { transform: translateY(-10px); }
        }

        /* تسمية "الفائز" - بخط Lalezar مع تصميم أجمل */
        .win-label {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 1.6rem;
            letter-spacing: 0.25em;
            color: #ffdd00;
            text-shadow:
                2px 2px 0 #8b6b00,
                3px 3px 0 #8b6b00,
                4px 4px 12px rgba(0,0,0,0.5);
            animation: fadeSlideUp 0.5s 0.5s both;
        }

        /* اسم الفريق - نفس أسلوب "الجولة" ثلاثي الأبعاد */
        .win-name-3d {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: clamp(3.5rem, 9vw, 6.5rem);
            line-height: 1;
            animation: nameReveal 0.6s cubic-bezier(0.34,1.4,0.64,1) 0.7s both;
        }
        @keyframes nameReveal {
            from { opacity:0; transform: scale(0.5) translateY(30px); }
            to   { opacity:1; transform: scale(1) translateY(0); }
        }

        /* عدد الخلايا */
        .win-score-line {
            display: flex; align-items: baseline; gap: 10px;
            animation: fadeSlideUp 0.5s 1s both;
        }
        .win-score-line span:first-child,
        .win-score-unit {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 2.6rem;
            color: #ffdd00;
            text-shadow:
                2px 2px 0 #8b6b00,
                3px 3px 0 #8b6b00,
                4px 4px 10px rgba(0,0,0,0.5);
        }

        /* صف الأزرار */
        .win-btns {
            display: flex; gap: 12px; margin-top: 20px;
            animation: fadeSlideUp 0.5s 1.2s both;
        }
        .win-btn {
            padding: 13px 28px;
            border-radius: 50px;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 1rem;
            font-weight: 900;
            letter-spacing: 0.06em;
            cursor: pointer;
            transition: all 0.2s;
        }
        .win-btn-primary {
            border: 2px solid rgba(255,255,255,0.35);
            background: rgba(255,255,255,0.1);
            color: #fff;
        }
        .win-btn-primary:hover {
            background: rgba(255,255,255,0.2);
            border-color: rgba(255,255,255,0.6);
            transform: scale(1.05);
        }
        .win-btn-secondary {
            border: 2px solid rgba(255,221,0,0.5);
            background: rgba(255,221,0,0.12);
            color: #ffdd00;
        }
        .win-btn-secondary:hover {
            background: rgba(255,221,0,0.25);
            border-color: #ffdd00;
            transform: scale(1.05);
        }

        @keyframes fadeSlideUp {
            from { opacity:0; transform: translateY(20px); }
            to   { opacity:1; transform: translateY(0); }
        }
        .confetti { position: absolute; width: 15px; height: 15px; animation: confetti-fall 3s linear infinite; }
        @keyframes confetti-fall {
            0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
            100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
        }

        /* ========================================= */
        /* 7. Landscape على الجوال                   */
        /* ========================================= */

        /* ── Landscape على الجوال (ارتفاع < 500px) ── */
        @media screen and (max-height: 500px) and (orientation: landscape) {

            .sidebar {
                width: 200px;
                min-width: 200px;
                padding: 6px 8px;
                gap: 0;
                justify-content: space-between; /* توزيع المساحة بالتساوي */
            }

            .menu-btn {
                width: 32px; height: 32px;
                top: 6px; right: 6px;
                gap: 3px;
            }
            .menu-btn span { width: 16px; height: 3px; }

            .round-title-container {
                margin-top: 40px;
                transform: rotate(-5deg);
                gap: 0;
                flex: 0 0 auto;
            }
            .round-word { font-size: 3.2rem; line-height: 0.9; }

            .scores-container {
                margin-top: 0;       /* إلغاء margin-top: auto */
                gap: 5px;
                padding-bottom: 4px;
                flex: 0 0 auto;
            }
            .score-pill {
                height: 52px;
                padding: 0 7px;
                gap: 7px;
                border-radius: 9px;
            }

            .score-hex-wrap { width: 38px; height: 38px; }
            .score-hex-svg  { width: 38px; height: 38px; }
            .score-hex-value { font-size: 1.1rem; }
            .team-name { font-size: 1.15rem; }
            .game-area { padding: 3px; }
        }

        /* ========================================= */
        /* 8. تنبيه تدوير الشاشة                    */
        /* ========================================= */
        .rotate-hint {
            display: none;
            position: fixed; inset: 0; z-index: 9999;
            background: #111;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 16px;
        }
        .rotate-icon { animation: rotatePhone 2s ease-in-out infinite; }
        @keyframes rotatePhone {
            0%,30% { transform: rotate(0deg); }
            60%,100% { transform: rotate(90deg); }
        }
        .rotate-text {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            font-size: 2.2rem;
            color: #ffdd00;
            text-shadow: 2px 2px 0 #8b6b00, 3px 3px 0 #8b6b00;
        }
        .rotate-sub {
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: 1rem;
            font-weight: 700;
            color: rgba(255,255,255,0.5);
        }

        /* يظهر فقط في portrait على الجوال - بدون تدوير html */
        @media screen and (orientation: portrait) and (max-width: 900px) {
            body:not(.host-mode) .rotate-hint  { display: flex !important; }
            body:not(.host-mode) .app-container { display: none !important; }
            body:not(.host-mode) .admin-panel   { display: none !important; }
        }
        /* ========================================= */
        /* 9. الشاشة الرئيسية                        */
        /* ========================================= */
        .home-screen {
            position: fixed; inset: 0; z-index: 500;
            background: url('../../images/BACKHROF.webp') center center / cover no-repeat;
            background-color: #5c2d91; /* fallback */
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }

        /* سداسيات الخلفية */
        .home-bg-hexes {
            position: absolute; inset: 0;
            pointer-events: none;
        }
        .home-bg-hex {
            position: absolute;
            opacity: 0.12;
        }
        .home-bg-hex polygon {
            fill: rgba(255,255,255,0.9);
            stroke: rgba(255,255,255,0.4);
            stroke-width: 3;
        }
        .home-bg-hex .hex-letter {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            fill: rgba(255,255,255,0.7);
            text-anchor: middle;
            dominant-baseline: central;
        }

        /* المحتوى */
        .home-content {
            position: relative; z-index: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 48px;
        }

        /* الشعار */
        .home-logo {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0;
            transform: rotate(-4deg);
            filter: drop-shadow(6px 6px 0 rgba(0,0,0,0.3));
        }
        .logo-word {
            font-family: 'AAGalaxy', 'Lalezar', cursive;
            line-height: 0.88;
            text-align: center;
        }
        .logo-row-maa-abqar {
            display: flex;
            align-items: baseline;
            justify-content: center;
            gap: 15px;
            margin-top: -10px;
        }
        .logo-abqar {
            font-size: clamp(4.5rem, 13vw, 8rem);
            color: #ffdd00;
            text-shadow:
                2px 2px 0 #8b6b00, 3px 3px 0 #8b6b00, 4px 4px 0 #8b6b00,
                5px 5px 0 #8b6b00, 6px 6px 0 #8b6b00, 7px 7px 8px rgba(0,0,0,0.4);
            z-index: 1;
        }
        .logo-maa {
            font-size: clamp(2.5rem, 8vw, 4.5rem);
            color: #d500f9; /* لون بنفسجي مشرق */
            text-shadow:
                2px 2px 0 #4a148c, 3px 3px 0 #4a148c, 4px 4px 0 #4a148c,
                5px 5px 6px rgba(0,0,0,0.5);
            margin: 0; /* تم إزالة الهوامش السابقة */
            z-index: 2;
        }
        .logo-horoof {
            font-size: clamp(4rem, 13vw, 8.5rem);
            color: #e94f4a;
            text-shadow:
                2px 2px 0 #4a0e0e, 3px 3px 0 #4a0e0e, 4px 4px 0 #4a0e0e,
                5px 5px 0 #4a0e0e, 6px 6px 0 #4a0e0e, 7px 7px 8px rgba(0,0,0,0.4);
            z-index: 3;
        }

        /* الأزرار */
        .home-buttons {
            display: flex;
            flex-direction: column;
            gap: 16px;
            width: clamp(280px, 40vw, 420px);
        }
        .home-btn {
            width: 100%;
            padding: 20px 32px;
            border: none;
            border-radius: 16px;
            font-family: 'AAGalaxy', 'Tajawal', sans-serif;
            font-size: clamp(1.2rem, 3vw, 1.6rem);
            font-weight: 900;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            letter-spacing: 0.04em;
            transition: transform 0.15s, filter 0.15s;
            position: relative;
            overflow: hidden;
        }
        .home-btn::after {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0;
            height: 50%;
            background: rgba(255,255,255,0.12);
            border-radius: 16px 16px 0 0;
            pointer-events: none;
        }
        .home-btn:hover  { transform: translateY(-3px) scale(1.02) !important; filter: brightness(1.1); }
        .home-btn:active { transform: translateY(1px)  scale(0.98) !important; }
        .home-btn-icon { font-size: 1rem; opacity: 0.85; }

        .home-btn-start {
            background: #ffdd00;
            color: #3a2000;
            box-shadow: 0 6px 0 #b89a00, 0 10px 20px rgba(0,0,0,0.3);
            animation: btnEnter 0.6s cubic-bezier(0.34,1.4,0.64,1) 0.4s both;
        }
        .home-btn-start:hover  { box-shadow: 0 8px 0 #b89a00, 0 14px 24px rgba(0,0,0,0.35); }
        .home-btn-start:active { box-shadow: 0 2px 0 #b89a00, 0 4px 10px rgba(0,0,0,0.2); }

        .home-btn-exit {
            background: #e53935;
            color: #fff;
            box-shadow: 0 6px 0 #8b1a1a, 0 10px 20px rgba(0,0,0,0.3);
            animation: btnEnter 0.6s cubic-bezier(0.34,1.4,0.64,1) 0.55s both;
        }
        .home-btn-exit:hover  { box-shadow: 0 8px 0 #8b1a1a, 0 14px 24px rgba(0,0,0,0.35); }
        .home-btn-exit:active { box-shadow: 0 2px 0 #8b1a1a, 0 4px 10px rgba(0,0,0,0.2); }

        /* انيميشن ظهور الشاشة */
        .home-content { animation: homeIn 0.8s cubic-bezier(0.34,1.4,0.64,1) both; }
        @keyframes homeIn {
            from { opacity:0; transform: scale(0.85) translateY(30px); }
            to   { opacity:1; transform: scale(1)    translateY(0); }
        }
        @keyframes btnEnter {
            from { opacity:0; transform: translateY(30px) scale(0.9); }
            to   { opacity:1; transform: translateY(0) scale(1); }
        }

        /* ========================================= */
        /* 10. وضع المقدم (Host Mode)                */
        /* ========================================= */
        body.host-mode {
            overflow-y: auto !important;
            height: auto !important;
            min-height: 100vh !important;
            background: #111 !important; /* خلفية داكنة نظيفة بدلاً من الشعار */
            display: block !important;
        }
        
        /* إخفاء الشاشة الرئيسية بشكل قاطع للمقدم */
        body.host-mode .home-screen {
            display: none !important;
        }

        body.host-mode .app-container {
            display: flex !important;
            flex-direction: column !important;
            height: auto !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* إخفاء الشريط البنفسجي تماماً للمقدم */
        body.host-mode .sidebar {
            display: none !important;
        }

        /* جعل لوحة التحكم ظاهرة دائماً وتتصرف كريموت */
        body.host-mode .admin-panel {
            position: relative !important;
            left: 0 !important;
            width: 100% !important;
            max-width: 100% !important;
            height: auto !important;
            box-shadow: none !important;
            background: transparent !important;
            padding: 0 10px 10px 10px !important; /* تقليل البادنج من الأعلى */
            display: flex !important;
            flex-direction: column !important;
            gap: 10px !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* إخفاء ترويسة الإعدادات للمقدم لأنها ستكون أزرار مباشرة */
        body.host-mode .admin-header {
            display: none !important;
        }
        
        body.host-mode .admin-panel .admin-card {
            background: #222 !important;
            border-color: #333 !important;
            opacity: 1 !important;
            visibility: visible !important;
        }

        body.host-mode .admin-body {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* زر الإعدادات الترس (جديد) */
        .host-settings-gear {
            display: none;
            position: fixed;
            top: 15px;
            right: 15px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            width: 45px;
            height: 45px;
            border-radius: 50%;
            font-size: 1.5rem;
            z-index: 1000;
            cursor: pointer;
            box-shadow: 0 4px 15px rgba(0,0,0,0.5);
            align-items: center;
            justify-content: center;
            transition: transform 0.2s, background 0.2s;
        }
        .host-settings-gear:active { transform: scale(0.9) rotate(45deg); }
        
        body.host-mode .host-settings-gear {
            display: flex !important;
        }

        /* إخفاء الإعدادات الافتراضية للمقدم ما لم يضغط على الترس */
        body.host-mode .admin-card:not(#hostRandomQuestionsSection):not(#hostBuzzerSection) {
            display: block !important;
            margin-bottom: 10px;
        }
        
        /* إظهار قسم الأسئلة العشوائية والجرس للمقدم فقط */
        body.host-mode #hostRandomQuestionsSection,
        body.host-mode #hostBuzzerSection {
            display: flex !important;
            flex-direction: column;
            margin-top: 0 !important; /* تقليل المساحة الضائعة */
        }
        
        /* أزرار الحروف المصغرة للمقدم */
        .host-mini-letter {
            width: 38px;
            height: 38px;
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.1); /* داكن بدلا من الأبيض */
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            font-family: 'AAGalaxy', sans-serif;
            font-size: 1.2rem;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 4px 6px rgba(0,0,0,0.2);
        }
        .host-mini-letter:active {
            transform: scale(0.9);
        }
        .host-mini-letter.active-letter {
            background: linear-gradient(135deg, #6d4596 0%, #4a148c 100%);
            color: #ffdd00;
            border-color: #ffdd00;
            transform: scale(1.1);
            box-shadow: 0 4px 10px rgba(255, 221, 0, 0.4);
        }

        body.host-mode .menu-btn {
            display: none !important;
        }

        body.host-mode .game-area {
            width: 100% !important;
            height: auto !important;
            min-height: 50vw !important;
            padding: 0 !important;
            flex: none !important;
            margin-top: 30px !important; /* مساحة علوية لتجنب شريط المتصفح */
            margin-bottom: 5px !important;
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            justify-content: center !important;
            align-items: flex-start !important;
        }
        
        body.host-mode .svg-board-wrapper {
            transform: scale(0.85) !important; /* تكبير اللوحة لتناسب الجوال بشكل أفضل */
            transform-origin: center top !important;
            margin: 0 auto 0 auto !important; /* إرجاع المارجن للصفر */
        }

        /* إظهار الخلايا للمقدم حتى لو لم يتم الضغط على ابدأ اللعبة */
        body.host-mode .hex-polygon, 
        body.host-mode .hex-text {
            opacity: 1 !important;
        }

        body.host-mode #fullscreenBtn,
        body.host-mode #show-qr-btn,
        body.host-mode #show-buzzer-qr-btn {
            display: none !important;
        }
        
        body.host-mode .btn-sm {
            padding: 15px;
            font-size: 1.1rem;
        }

        .qr-modal {
            display: none;
            position: fixed; inset: 0; z-index: 9999;
            background: rgba(0,0,0,0.85);
            justify-content: center; align-items: center;
        }
        .qr-content {
            background: #222; padding: 30px; border-radius: 16px;
            text-align: center; color: #fff; border: 2px solid #6d4596;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        }
        .qr-content h2 { margin-top: 0; color: #ffdd00; font-family: 'AAGalaxy', 'Tajawal', sans-serif; }
        .qr-code-container { margin: 20px auto; display: flex; justify-content: center; background: #fff; padding: 15px; border-radius: 10px; width: fit-content; }
        .qr-close-btn {
            margin-top: 20px; padding: 10px 30px;
            background: #e53935; color: #fff; border: none; border-radius: 8px;
            cursor: pointer; font-family: 'Tajawal', sans-serif; font-size: 1.1rem; font-weight: bold;
        }

        /* landscape جوال */
        @media screen and (max-height: 500px) and (orientation: landscape) {
            .home-content { gap: 16px; }
            .home-logo { transform: none; gap: 0; }
            .logo-row-maa-abqar { gap: 8px; margin-top: -5px; }
            .logo-abqar  { font-size: 3.2rem; }
            .logo-maa    { font-size: 1.8rem; margin: 0; }
            .logo-horoof { font-size: 3rem;   }
            .home-buttons { gap: 10px; width: clamp(220px, 45vw, 360px); }
            .home-btn { padding: 13px 24px; font-size: 1.1rem; border-radius: 12px; }
        }

        /* ========================================= */
        /* 10. إشعار الفائز بالجرس (Toast) للشاشة   */
        /* ========================================= */
        .screen-buzzer-toast {
            position: fixed;
            top: -100px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(135deg, #1a1a2e, #4a148c);
            border: 2px solid #ffdd00;
            box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 20px rgba(255,221,0,0.4);
            border-radius: 100px;
            padding: 12px 30px;
            display: flex;
            align-items: center;
            gap: 15px;
            z-index: 10000;
            opacity: 0;
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            pointer-events: none;
        }
        
        .screen-buzzer-toast.show {
            top: 40px;
            opacity: 1;
        }
        
        .sbt-icon {
            font-size: 2.5rem;
            animation: buzzerIconPulse 0.5s alternate infinite;
        }
        
        @keyframes buzzerIconPulse {
            0% { transform: scale(1); filter: drop-shadow(0 0 5px #ffdd00); }
            100% { transform: scale(1.2); filter: drop-shadow(0 0 15px #ffdd00); }
        }
        
        .sbt-text {
            display: flex;
            flex-direction: column;
            text-align: center;
        }
        
        .sbt-title {
            color: #ffdd00;
            font-size: 1rem;
            font-weight: 700;
            margin-bottom: 2px;
            letter-spacing: 1px;
        }
        
        .sbt-name {
            color: #fff;
            font-size: 1.8rem;
            font-weight: 900;
            text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
        }